model

package
v0.0.0-...-c455053 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivacyPublic = iota
	PrivacyPrivateImages
	PrivacyPrivateDetail
	PrivacyPrivateDetailImages
	PrivacyPrivateSearch
	PrivacyPrivateSearchImages
	PrivacyPrivateSearchDetail
	PrivacyPrivateSearchDetailImages
)
View Source
const (
	// IntType indicates a field of type int
	IntType fieldType = "Int"
	// StringType indicates a field of type string
	StringType fieldType = "String"
	// ImageType indicates a field of type image.Image
	ImageType fieldType = "Image"
	// LocationType indicates a field of type Location
	LocationType fieldType = "Location"
	// TimeType indicates a field of type time.Time
	TimeType fieldType = "Time"
)
View Source
const (
	AuthGuest = iota
	AuthReader
	AuthContributor
	AuthEditor
	AuthAdmin
)
View Source
const ImageDimensionsSuffix = "__dimensions.json"
View Source
const ImageThumbnailHeight = 0
View Source
const ImageThumbnailQuality = 75
View Source
const ImageThumbnailSuffix = "__thumbnail.jpg"
View Source
const ImageThumbnailWidth = 160

Variables

Functions

func UserAcceptedImagesStatus

func UserAcceptedImagesStatus(status ImagesStatus) bool

UserAcceptedImagesStatus returns true if status can be submitted by a user

func UserAcceptedPostStatus

func UserAcceptedPostStatus(status PostStatus) bool

UserAcceptedPostStatus returns true if status can be submitted by a user

func UserAcceptedRecordsStatus

func UserAcceptedRecordsStatus(status RecordsStatus) bool

UserAcceptedRecordsStatus returns true if status can be submitted by a user

Types

type AuthLevel

type AuthLevel int

func (AuthLevel) String

func (l AuthLevel) String() string

type Category

type Category struct {
	ID   uint32 `json:"id,omitempty" example:"999" validate:"required,omitempty" dynamodbav:"pk,string"`
	Type string `json:"-" dynamodbav:"sk"`
	CategoryBody
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Category represents a set of collections

func NewCategory

func NewCategory(id uint32, in CategoryIn) Category

NewCategory constructs a Category from an id and body

type CategoryBody

type CategoryBody struct {
	Name string `json:"name" validate:"required" dynamodbav:"altSort"`
}

CategoryBody is the JSON part of the Category object

func (*CategoryBody) Scan

func (cb *CategoryBody) Scan(value interface{}) error

Scan makes CategoryBody implement the sql.Scanner interface.

func (CategoryBody) Value

func (cb CategoryBody) Value() (driver.Value, error)

Value makes CategoryBody implement the driver.Valuer interface.

type CategoryIn

type CategoryIn struct {
	CategoryBody
}

CategoryIn is the payload to create or update a category

func NewCategoryIn

func NewCategoryIn(name string) (CategoryIn, error)

NewCategoryIn constructs a CategoryIn

type CategoryPersister

type CategoryPersister interface {
	SelectCategories(ctx context.Context) ([]Category, error)
	SelectCategoriesByID(ctx context.Context, ids []uint32) ([]Category, error)
	SelectOneCategory(ctx context.Context, id uint32) (*Category, error)
	InsertCategory(ctx context.Context, in CategoryIn) (*Category, error)
	UpdateCategory(ctx context.Context, id uint32, body Category) (*Category, error)
	DeleteCategory(ctx context.Context, id uint32) error
}

CategoryPersister defines methods needed to persist categories

type Collection

type Collection struct {
	ID   uint32 `json:"id,omitempty" example:"999" validate:"required" dynamodbav:"pk,string"`
	Type string `json:"-" dynamodbav:"sk"`
	CollectionIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Collection represents a set of related Records

func NewCollection

func NewCollection(id uint32, ci CollectionIn) Collection

NewCollection constructs a Collection from a CollectionIn

type CollectionBody

type CollectionBody struct {
	Name                        string              `json:"name" validate:"required" dynamodbav:"altSort"`
	Location                    string              `json:"location,omitempty"`
	CollectionType              CollectionType      `json:"type" validate:"required"`
	Fields                      []CollectionField   `json:"fields"`
	Mappings                    []CollectionMapping `json:"mappings"`
	CitationTemplate            string              `json:"citation_template,omitempty"`
	ImagePathHeader             string              `json:"imagePathHeader,omitempty"`
	HouseholdNumberHeader       string              `json:"householdNumberHeader,omitempty"`
	HouseholdRelationshipHeader string              `json:"householdRelationshipHeader,omitempty"`
	GenderHeader                string              `json:"genderHeader,omitempty"`
	PrivacyLevel                PrivacyLevel        `json:"privacyLevel"`
}

CollectionBody is the JSON body of a Collection

func (*CollectionBody) Scan

func (cb *CollectionBody) Scan(value interface{}) error

Scan makes CollectionBody implement the sql.Scanner interface.

func (CollectionBody) Value

func (cb CollectionBody) Value() (driver.Value, error)

Value makes CollectionBody implement the driver.Valuer interface.

type CollectionField

type CollectionField struct {
	Header string `json:"header"`
}

type CollectionIn

type CollectionIn struct {
	CollectionBody
	Categories []uint32 `json:"categories" validate:"required"`
}

CollectionIn is the payload to create or update a Collection

func NewCollectionIn

func NewCollectionIn(name string, categoryIDs []uint32) CollectionIn

NewCollectionIn constructs a CollectionIn

type CollectionMapping

type CollectionMapping struct {
	Header  string `json:"header"`
	DbField string `json:"dbField"`
	IxRole  string `json:"ixRole"`
	IxField string `json:"ixField"`
}

type CollectionPersister

type CollectionPersister interface {
	SelectCollections(ctx context.Context) ([]Collection, error)
	SelectCollectionsByID(ctx context.Context, ids []uint32, enforceContextSocietyMatch bool) ([]Collection, error)
	SelectOneCollection(ctx context.Context, id uint32) (*Collection, error)
	InsertCollection(ctx context.Context, in CollectionIn) (*Collection, error)
	UpdateCollection(ctx context.Context, id uint32, in Collection) (*Collection, error)
	DeleteCollection(ctx context.Context, id uint32) error
}

CollectionPersister defines methods needed to persist categories

type CollectionType

type CollectionType string
const (
	CollectionTypeRecords CollectionType = "Records"
	CollectionTypeCatalog CollectionType = "Catalog"
)

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Params  []string  `json:"params"`
	Message string    `json:"message"`
}

Error represents a single API error

func NewError

func NewError(code ErrorCode, params ...string) *Error

NewError builds an error. If the error code is unknown it is set to ErrOther.

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode string

ErrorCode is one of the valid error codes the API can return

const (
	ErrRequired         ErrorCode = "REQUIRED"
	ErrNotFound         ErrorCode = "NOT_FOUND"
	ErrBadReference     ErrorCode = "BAD_REFERENCE"
	ErrConcurrentUpdate ErrorCode = "CONCURRENT_UPDATE"
	ErrConflict         ErrorCode = "CONFICT"
	ErrOther            ErrorCode = "OTHER"
)

Standard error codes

func (ErrorCode) Matches

func (code ErrorCode) Matches(err error) bool

Matches returns `true` if the passed `error` is a `model.Error` with a matching `ErrorCode`

type EventType

type EventType string
const (
	BirthEvent     EventType = "birth"
	MarriageEvent  EventType = "marriage"
	ResidenceEvent EventType = "residence"
	DeathEvent     EventType = "death"
	OtherEvent     EventType = "other"
)

type FieldDef

type FieldDef struct {
	Name       string    `json:"name"`
	Type       fieldType `json:"type,omitempty" swaggertype:"string" enums:"Int,String,Image,Location,Time"`
	CSVHeading string    `json:"csv_heading,omitempty"`
}

FieldDef defines a name and type of a field

func NewFieldDef

func NewFieldDef(name string, ft fieldType, csvHeading string) (FieldDef, error)

NewFieldDef constructs a FieldDef

type FieldDefSet

type FieldDefSet []FieldDef

FieldDefSet represents a set of field definitions which must have both unigue names and unique CSV header names.

func NewFieldDefSet

func NewFieldDefSet() FieldDefSet

NewFieldDefSet constructs a FieldDefSet

func (*FieldDefSet) Add

func (fds *FieldDefSet) Add(fd FieldDef) bool

Add adds a FieldDef to a FieldDefSet

func (*FieldDefSet) Contains

func (fds *FieldDefSet) Contains(fd FieldDef) bool

Contains indicates whether a FieldDefSet contains a FieldDef

func (*FieldDefSet) UnmarshalJSON

func (fds *FieldDefSet) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON to a FieldDefSet

type FieldTyper

type FieldTyper interface {
	Name() string
	Type() string
}

FieldTyper returns the type of a field

type Gender

type Gender string

supported genders: male (anything that starts with an m), female (anything that starts with f) everything else is handled as other

const (
	GenderMale   Gender = "male"
	GenderFemale Gender = "female"
	GenderOther  Gender = "other"
)

type HouseholdRelToHead

type HouseholdRelToHead string

supported relationships to head: head, father, mother, spouse, husband, wife, child, son, daughter everything else is handled as other

const (
	HeadRelToHead     HouseholdRelToHead = "head"
	FatherRelToHead   HouseholdRelToHead = "father"
	MotherRelToHead   HouseholdRelToHead = "mother"
	SpouseRelToHead   HouseholdRelToHead = "spouse"
	HusbandRelToHead  HouseholdRelToHead = "husband"
	WifeRelToHead     HouseholdRelToHead = "wife"
	ChildRelToHead    HouseholdRelToHead = "child"
	SonRelToHead      HouseholdRelToHead = "son"
	DaughterRelToHead HouseholdRelToHead = "daughter"
	OtherRelToHead    HouseholdRelToHead = "other"
)

type ImageDimensions

type ImageDimensions struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

type ImagesStatus

type ImagesStatus string
const (
	ImagesStatusDefault      ImagesStatus = ""
	ImagesStatusToLoad       ImagesStatus = "Load Requested"
	ImagesStatusLoading      ImagesStatus = "Loading"
	ImagesStatusLoadComplete ImagesStatus = "LoadComplete"
	ImagesStatusLoadError    ImagesStatus = "LoadError"
	ImagesStatusError        ImagesStatus = "Error"
)

type ImagesWriterAction

type ImagesWriterAction string

ImageWriter actions

const (
	ImagesWriterActionUnzip             ImagesWriterAction = "unzip"
	ImagesWriterActionGenerateThumbnail ImagesWriterAction = "thumb"
)

type ImagesWriterMsg

type ImagesWriterMsg struct {
	SocietyID uint32             `json:"societyId"`
	PostID    uint32             `json:"postId"`
	Action    ImagesWriterAction `json:"action"`
	ImagePath string             `json:"imagePath"`
	NewZips   []string           `json:"newZips"`
}

ImagesWriterMsg represents a message to initiate processing of an image upload

type IntField

type IntField struct {
	FieldDef
	// contains filtered or unexported fields
}

IntField represent an int64 field

func (*IntField) AsInt64

func (s *IntField) AsInt64() int64

AsInt64 returns the field value as an int64

func (*IntField) SetInt64

func (s *IntField) SetInt64(value int64)

SetInt64 set the field value from an int64

type Invitation

type Invitation struct {
	ID uint32 `json:"id,omitempty" example:"999" validate:"required,omitempty"`
	//Type string `json:"-" dynamodbav:"sk"`
	InvitationIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Invitation represents an invitation to a society

func NewInvitation

func NewInvitation(id uint32, in InvitationIn) Invitation

NewInvitation constructs a Invitation from an id and body

type InvitationBody

type InvitationBody struct {
	Level AuthLevel `json:"level" validate:"required"`
	Name  string    `json:"name" validate:"required"`
}

InvitationBody is the JSON part of the Invitation object

func (*InvitationBody) Scan

func (cb *InvitationBody) Scan(value interface{}) error

Scan makes InvitationBody implement the sql.Scanner interface.

func (InvitationBody) Value

func (cb InvitationBody) Value() (driver.Value, error)

Value makes InvitationBody implement the driver.Valuer interface.

type InvitationIn

type InvitationIn struct {
	InvitationBody
	Code      string `json:"code" validate:"required"`
	SocietyID uint32 `json:"societyId" validate:"required"`
}

InvitationIn is the payload to create or update a Invitation

func NewInvitationIn

func NewInvitationIn(name, code string, level AuthLevel, societyID uint32) InvitationIn

NewInvitationIn constructs an InvitationIn

type InvitationPersister

type InvitationPersister interface {
	SelectInvitationByCode(ctx context.Context, code string) (*Invitation, error)
	SelectInvitations(ctx context.Context) ([]Invitation, error)
	SelectOneInvitation(ctx context.Context, id uint32) (*Invitation, error)
	InsertInvitation(ctx context.Context, in InvitationIn) (*Invitation, error)
	DeleteInvitation(ctx context.Context, id uint32) error
}

InvitationPersister defines methods needed to persist Invitations

type LocationField

type LocationField struct {
	FieldDef
	// contains filtered or unexported fields
}

LocationField represent a string field

func (*LocationField) AsString

func (s *LocationField) AsString() string

AsString returns the field value as a string

func (*LocationField) SetString

func (s *LocationField) SetString(value string)

SetString set the field value from a string

type NamePersister

type NamePersister interface {
	SelectNameVariants(ctx context.Context, nameType NameType, name string) (*NameVariants, error)
}

NamePersister defines methods needed to persist places

type NameType

type NameType int
const (
	GivenType NameType = iota
	SurnameType
)

type NameVariants

type NameVariants struct {
	Name           string      `json:"name" dynamodbav:"pk"`
	Type           string      `json:"-" dynamodbav:"sk"`
	Variants       StringSlice `json:"variants"`
	InsertTime     time.Time   `json:"insert_time,omitempty"`
	LastUpdateTime time.Time   `json:"last_update_time,omitempty"`
}

NameVariants holds name variants

type Place

type Place struct {
	ID               uint32      `json:"id" dynamodbav:"pk,string"`
	Type             string      `json:"-" dynamodbav:"sk"`
	AltSort          string      `json:"-" dynamodbav:"altSort"`
	Name             string      `json:"name"`
	FullName         string      `json:"fullName"`
	AltNames         StringSlice `json:"altNames"`
	Types            StringSlice `json:"types"`
	LocatedInID      uint32      `json:"locatedInId"`
	AlsoLocatedInIDs Uint32Slice `json:"alsoLocatedInIds"`
	Level            int         `json:"level"`
	CountryID        uint32      `json:"countryId"`
	Latitude         float32     `json:"latitude"`
	Longitude        float32     `json:"longitude"`
	Count            int         `json:"count"`
	InsertTime       time.Time   `json:"insert_time,omitempty"`
	LastUpdateTime   time.Time   `json:"last_update_time,omitempty"`
}

Place holds information about a place

type PlacePersister

type PlacePersister interface {
	SelectPlaceSettings(ctx context.Context) (*PlaceSettings, error)
	SelectPlace(ctx context.Context, id uint32) (*Place, error)
	SelectPlacesByID(ctx context.Context, ids []uint32) ([]Place, error)
	SelectPlacesByFullNamePrefix(ctx context.Context, prefix string, count int) ([]Place, error)
	SelectPlaceWord(ctx context.Context, word string) (*PlaceWord, error)
	SelectPlaceWordsByWord(ctx context.Context, words []string) ([]PlaceWord, error)
}

PlacePersister defines methods needed to persist places

type PlaceSettings

type PlaceSettings struct {
	ID int    `json:"-" dynamodbav:"-"`
	Pk string `json:"-" dynamodbav:"pk"`
	Sk string `json:"-" dynamodbav:"sk"`
	PlaceSettingsIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

PlaceSettings represents global placeSettings

func NewPlaceSettings

func NewPlaceSettings(obj PlaceSettingsIn) PlaceSettings

NewPlaceSettings constructs a PlaceSettings object from a PlaceSettingsIn

type PlaceSettingsBody

type PlaceSettingsBody struct {
	Abbreviations             map[string]string `json:"abbreviations"`
	TypeWords                 []string          `json:"typeWords"`
	NoiseWords                []string          `json:"noiseWords"`
	LargeCountries            []uint32          `json:"largeCountries"`
	MediumCountries           []uint32          `json:"mediumCountries"`
	LargeCountryLevelWeights  []int             `json:"largeCountryLevelWeights"`
	MediumCountryLevelWeights []int             `json:"mediumCountryLevelWeights"`
	SmallCountryLevelWeights  []int             `json:"smallCountryLevelWeights"`
	PrimaryMatchWeight        int               `json:"primaryMatchWeight"`
	USCountryID               uint32            `json:"USCountryId"`
}

PlaceSettingsBody is the JSON body of a PlaceSettings object

func (*PlaceSettingsBody) Scan

func (cb *PlaceSettingsBody) Scan(value interface{}) error

Scan makes PlaceSettingsBody implement the sql.Scanner interface.

func (PlaceSettingsBody) Value

func (cb PlaceSettingsBody) Value() (driver.Value, error)

Value makes PlaceSettingsBody implement the driver.Valuer interface.

type PlaceSettingsIn

type PlaceSettingsIn struct {
	PlaceSettingsBody
}

PlaceSettingsIn is the payload to create or update a PlaceSettings object

func NewPlaceSettingsIn

func NewPlaceSettingsIn(abbreviations map[string]string, typeWords, noiseWords []string, largeCountries, mediumCountries []uint32, largeCountryLevelWeights, mediumCountryLevelWeights, smallCountryLevelWeights []int, primaryMatchWeight int, USCountryID uint32) PlaceSettingsIn

NewPlaceSettingsIn constructs a PlaceSettingsIn

type PlaceWord

type PlaceWord struct {
	Pk             string      `json:"-" dynamodbav:"pk"`
	Type           string      `json:"-" dynamodbav:"sk"`
	Word           string      `json:"word" dynamodbav:"-"`
	IDs            Uint32Slice `json:"ids"`
	InsertTime     time.Time   `json:"insert_time,omitempty"`
	LastUpdateTime time.Time   `json:"last_update_time,omitempty"`
}

PlaceWord holds the IDs of all places that have that word in their name or alt name

type Post

type Post struct {
	ID   uint32 `json:"id,omitempty" example:"999" validate:"required" dynamodbav:"pk,string"`
	Type string `json:"-" dynamodbav:"sk"`
	PostIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Post represents a set of related Records

func NewPost

func NewPost(id uint32, ci PostIn) Post

NewPost constructs a Post from a PostIn

type PostBody

type PostBody struct {
	Name          string                 `json:"name" validate:"required"`
	Metadata      map[string]interface{} `json:"metadata"`
	PostStatus    PostStatus             `json:"postStatus"`
	PostError     string                 `json:"postError"`
	RecordsKey    string                 `json:"recordsKey"`
	RecordsStatus RecordsStatus          `json:"recordsStatus"`
	RecordsError  string                 `json:"recordsError"`
	ImagesKeys    StringSet              `json:"imagesKeys"`
	ImagesStatus  ImagesStatus           `json:"imagesStatus"`
	ImagesError   string                 `json:"imagesError"`
}

PostBody is the JSON body of a Post

func (*PostBody) Scan

func (cb *PostBody) Scan(value interface{}) error

Scan makes PostBody implement the sql.Scanner interface.

func (PostBody) Value

func (cb PostBody) Value() (driver.Value, error)

Value makes PostBody implement the driver.Valuer interface.

type PostIn

type PostIn struct {
	PostBody
	Collection uint32 `json:"collection" example:"999" validate:"required" dynamodbav:"altSort,string"`
}

PostIn is the payload to create or update a Post

func NewPostIn

func NewPostIn(name string, collectionID uint32, recordsKey string) PostIn

NewPostIn constructs a PostIn

type PostPersister

type PostPersister interface {
	SelectPosts(ctx context.Context) ([]Post, error)
	SelectOnePost(ctx context.Context, id uint32) (*Post, error)
	InsertPost(ctx context.Context, in PostIn) (*Post, error)
	UpdatePost(ctx context.Context, id uint32, in Post) (*Post, error)
	DeletePost(ctx context.Context, id uint32) error
}

PostPersister defines methods needed to persist categories

type PostStatus

type PostStatus string
const (
	PostStatusDraft             PostStatus = "Draft"
	PostStatusToPublish         PostStatus = "Publication Requested"
	PostStatusPublishing        PostStatus = "Publishing"
	PostStatusPublishComplete   PostStatus = "PublishComplete"
	PostStatusPublishError      PostStatus = "PublishError"
	PostStatusPublished         PostStatus = "Published"
	PostStatusToUnpublish       PostStatus = "Unpublication Requested"
	PostStatusUnpublishing      PostStatus = "Unpublishing"
	PostStatusUnpublishComplete PostStatus = "UnpublishComplete"
	PostStatusUnpublishError    PostStatus = "UnpublishError"
	PostStatusError             PostStatus = "Error"
)

type PrivacyLevel

type PrivacyLevel int

func (PrivacyLevel) String

func (l PrivacyLevel) String() string

type PublisherAction

type PublisherAction string

Publisher actions

const (
	PublisherActionIndex   PublisherAction = "index"
	PublisherActionUnindex PublisherAction = "unindex"
)

type PublisherMsg

type PublisherMsg struct {
	Action    PublisherAction `json:"action"`
	SocietyID uint32          `json:"societyId"`
	PostID    uint32          `json:"postId"`
}

PublisherMsg represents a message to initiate publishing of a post

type Record

type Record struct {
	ID   uint32 `json:"id,omitempty" example:"999" validate:"required" dynamodbav:"pk,string"`
	Type string `json:"-" dynamodbav:"sk"`
	RecordIn
	IxHash         string    `json:"ix_hash,omitempty"`
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Record represents a set of related Records

func NewRecord

func NewRecord(id uint32, ci RecordIn) Record

NewRecord constructs a Record from a RecordIn

func (Record) GetCitation

func (record Record) GetCitation(tpl string) string

Accept a citation in simple mustache syntax {{ var name can have spaces }} and convert it to go template syntax before applying it to the record data

type RecordBody

type RecordBody struct {
	Data map[string]string `json:"data" validate:"required"`
}

RecordBody is the JSON body of a Record

func (*RecordBody) Scan

func (cb *RecordBody) Scan(value interface{}) error

Scan makes RecordBody implement the sql.Scanner interface.

func (RecordBody) Value

func (cb RecordBody) Value() (driver.Value, error)

Value makes RecordBody implement the driver.Valuer interface.

type RecordHousehold

type RecordHousehold struct {
	RecordHouseholdIn
	Type           string    `json:"-" dynamodbav:"sk"`
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

RecordHousehold holds the record IDs of all records in this household

type RecordHouseholdIn

type RecordHouseholdIn struct {
	Post      uint32      `json:"post" example:"999" validate:"required"  dynamodbav:"pk,string"`
	Household string      `json:"household" example:"999" validate:"required"  dynamodbav:"-"`
	Records   Uint32Slice `json:"records" example:"[1,2,3]" validate:"required"`
}

RecordHouseholdIn is the payload to create a Record Household

type RecordIn

type RecordIn struct {
	RecordBody
	Post uint32 `json:"post" example:"999" validate:"required" dynamodbav:"-"`
}

RecordIn is the payload to create or update a Record

func NewRecordIn

func NewRecordIn(data map[string]string, postID uint32) RecordIn

NewRecordIn constructs a RecordIn

type RecordPersister

type RecordPersister interface {
	SelectRecordsForPost(ctx context.Context, postID uint32, limit int) ([]Record, error)
	SelectRecordsByID(ctx context.Context, ids []uint32, enforceContextSocietyMatch bool) ([]Record, error)
	SelectOneRecord(ctx context.Context, id uint32) (*Record, error)
	InsertRecord(ctx context.Context, in RecordIn) (*Record, error)
	UpdateRecord(ctx context.Context, id uint32, in Record) (*Record, error)
	DeleteRecord(ctx context.Context, id uint32) error
	DeleteRecordsForPost(ctx context.Context, postID uint32) error
	SelectRecordHouseholdsForPost(ctx context.Context, postID uint32) ([]RecordHousehold, error)
	SelectOneRecordHousehold(ctx context.Context, postID uint32, householdID string) (*RecordHousehold, error)
	InsertRecordHousehold(ctx context.Context, in RecordHouseholdIn) (*RecordHousehold, error)
	DeleteRecordHouseholdsForPost(ctx context.Context, postID uint32) error
}

RecordPersister defines methods needed to persist records

type RecordsStatus

type RecordsStatus string
const (
	RecordsStatusDefault      RecordsStatus = ""
	RecordsStatusToLoad       RecordsStatus = "Load Requested"
	RecordsStatusLoading      RecordsStatus = "Loading"
	RecordsStatusLoadComplete RecordsStatus = "LoadComplete"
	RecordsStatusLoadError    RecordsStatus = "LoadError"
	RecordsStatusError        RecordsStatus = "Error"
)

type RecordsWriterMsg

type RecordsWriterMsg struct {
	SocietyID uint32 `json:"societyId"`
	PostID    uint32 `json:"postId"`
}

RecordsWriterMsg represents a message to initiate processing of an uploaded recods CSV

type Relative

type Relative string
const (
	FatherRelative Relative = "father"
	MotherRelative Relative = "mother"
	SpouseRelative Relative = "spouse"
	OtherRelative  Relative = "other"
)

type Role

type Role string
const (
	PrincipalRole   Role = "principal"
	FatherRole      Role = "father"
	MotherRole      Role = "mother"
	SpouseRole      Role = "spouse"
	BrideRole       Role = "bride"
	GroomRole       Role = "groom"
	BrideFatherRole Role = "brideFather"
	BrideMotherRole Role = "brideMother"
	GroomFatherRole Role = "groomFather"
	GroomMotherRole Role = "groomMother"
	OtherRole       Role = "other"
)

type SearchEvent

type SearchEvent struct {
	Type  EventType `json:"type"`
	Date  string    `json:"date,omitempty"`
	Place string    `json:"place,omitempty"`
}

type SearchFacet

type SearchFacet struct {
	ErrorUpperBound int                 `json:"errorUpperBound"`
	OtherDocCount   int                 `json:"otherDocCount"`
	Buckets         []SearchFacetBucket `json:"buckets"`
}

type SearchFacetBucket

type SearchFacetBucket struct {
	Label string `json:"label"`
	Count int    `json:"count"`
}

type SearchHit

type SearchHit struct {
	ID                 string         `json:"id"`
	SocietyID          uint32         `json:"societyId"`
	Private            bool           `json:"private"`
	LoginURL           string         `json:"loginURL,omitempty"`
	Score              float64        `json:"score"`
	Person             SearchPerson   `json:"person,omitempty"`
	Record             SearchRecord   `json:"record,omitempty"` // only returned on search by id
	CollectionID       uint32         `json:"collection"`
	CollectionName     string         `json:"collectionName"`
	CollectionType     CollectionType `json:"collectionType"`
	ImagePath          string         `json:"imagePath,omitempty"`
	PostID             uint32         `json:"post,omitempty"`
	CollectionLocation string         `json:"collectionLocation,omitempty"` // only returned on search by id
	Citation           string         `json:"citation,omitempty"`           // only returned on search by id
	Household          []SearchRecord `json:"household,omitempty"`          // only returned on search by id
}

type SearchLabelValue

type SearchLabelValue struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

type SearchPerson

type SearchPerson struct {
	Name          string               `json:"name"`
	Role          Role                 `json:"role"`
	Events        []SearchEvent        `json:"events,omitempty"`
	Relationships []SearchRelationship `json:"relationships,omitempty"`
}

type SearchRecord

type SearchRecord []SearchLabelValue

type SearchRelationship

type SearchRelationship struct {
	Type Relative `json:"type"`
	Name string   `json:"name,omitempty"`
}

type SearchResult

type SearchResult struct {
	Hits     []SearchHit            `json:"hits"`
	Total    int                    `json:"total"`
	MaxScore float64                `json:"maxScore"`
	Facets   map[string]SearchFacet `json:"facets"`
}

type SettingsPostMetadata

type SettingsPostMetadata struct {
	Name    string `json:"name"  dynamodbav:"altSort"`
	Type    string `json:"type" validate:"eq=string|eq=number|eq=date|eq=boolean"`
	Tooltip string `json:"tooltip"`
}

type Society

type Society struct {
	ID uint32 `json:"id,omitempty" example:"999" validate:"required,omitempty"`
	//Type string `json:"-" dynamodbav:"sk"`
	SocietyIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

Society represents a group of users and data

func NewSociety

func NewSociety(id uint32, in SocietyIn) Society

NewSociety constructs a Society from an id and a SocietyIn

type SocietyBody

type SocietyBody struct {
	Name         string                 `json:"name" validate:"required"`
	SecretKey    string                 `json:"secretKey"`
	LoginURL     string                 `json:"loginURL"`
	PostMetadata []SettingsPostMetadata `json:"postMetadata"`
}

SocietyBody is the JSON part of the Society object

func (*SocietyBody) Scan

func (cb *SocietyBody) Scan(value interface{}) error

Scan makes SocietyBody implement the sql.Scanner interface.

func (SocietyBody) Value

func (cb SocietyBody) Value() (driver.Value, error)

Value makes SocietyBody implement the driver.Valuer interface.

type SocietyIn

type SocietyIn struct {
	SocietyBody
}

SocietyIn is the payload to create or update a Society

func NewSocietyIn

func NewSocietyIn(name, secretKey, loginURL string) SocietyIn

NewSocietyIn constructs a SocietyIn

type SocietyPersister

type SocietyPersister interface {
	SelectSocietySummariesByID(ctx context.Context, ids []uint32) ([]SocietySummary, error)
	SelectSocietySummary(ctx context.Context, id uint32) (*SocietySummary, error)
	SelectSociety(ctx context.Context, id uint32) (*Society, error)
	InsertSociety(ctx context.Context, in SocietyIn) (*Society, error)
	UpdateSociety(ctx context.Context, in Society) (*Society, error)
	DeleteSociety(ctx context.Context) error
}

SocietyPersister defines methods needed to persist societies

type SocietySummary

type SocietySummary struct {
	ID           uint32                 `json:"id" example:"999"`
	Name         string                 `json:"name"`
	PostMetadata []SettingsPostMetadata `json:"postMetadata"`
	InsertTime   time.Time              `json:"insert_time"`
}

SocietySummary represents public info about a society

type SocietyUser

type SocietyUser struct {
	ID uint32 `json:"id,omitempty" example:"999" validate:"required,omitempty"`
	//	Type string `json:"-" dynamodbav:"sk"`
	SocietyUserIn
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

SocietyUser represents an authorization level between a user and a society

func NewSocietyUser

func NewSocietyUser(id uint32, in SocietyUserIn) SocietyUser

NewSocietyUser constructs a SocietyUser from an id and a SocietyUserIn

type SocietyUserBody

type SocietyUserBody struct {
	UserName string    `json:"name"` // override userName from user record
	Level    AuthLevel `json:"level" validate:"required"`
}

SocietyUserBody is the JSON part of the SocietyUser object

func (*SocietyUserBody) Scan

func (cb *SocietyUserBody) Scan(value interface{}) error

Scan makes SocietyUserBody implement the sql.Scanner interface.

func (SocietyUserBody) Value

func (cb SocietyUserBody) Value() (driver.Value, error)

Value makes SocietyUserBody implement the driver.Valuer interface.

type SocietyUserIn

type SocietyUserIn struct {
	SocietyUserBody
	UserID    uint32 `json:"userId" validate:"required"`
	SocietyID uint32 `json:"societyId" validate:"required"`
}

SocietyUserIn is the payload to create or update a SocietyUser

func NewSocietyUserIn

func NewSocietyUserIn(userID uint32, level AuthLevel) SocietyUserIn

NewSocietyUserIn constructs a SocietyUserIn

type SocietyUserPersister

type SocietyUserPersister interface {
	SelectSocietyUsers(ctx context.Context) ([]SocietyUser, error)
	SelectAllSocietyUsersByUser(ctx context.Context, userID uint32) ([]SocietyUser, error)
	SelectOneSocietyUser(ctx context.Context, id uint32) (*SocietyUser, error)
	SelectOneSocietyUserByUser(ctx context.Context, userID uint32) (*SocietyUser, error)
	InsertSocietyUser(ctx context.Context, in SocietyUserIn) (*SocietyUser, error)
	UpdateSocietyUser(ctx context.Context, id uint32, in SocietyUser) (*SocietyUser, error) // can't update userID or societyID
	DeleteSocietyUser(ctx context.Context, id uint32) error
}

SocietyUserPersister defines methods needed to persist SocietyUsers

type StringField

type StringField struct {
	FieldDef
	// contains filtered or unexported fields
}

StringField represent a string field

func (*StringField) AsString

func (s *StringField) AsString() string

AsString returns the field value as a string

func (*StringField) SetString

func (s *StringField) SetString(value string)

SetString set the field value from a string

type StringSet

type StringSet []string

StringSet represents a set of unique strings

func NewStringSet

func NewStringSet() StringSet

NewStringSet constructs a StringSet

func (*StringSet) Add

func (ss *StringSet) Add(s string) bool

Add adds a string to a StringSet

func (*StringSet) Contains

func (ss *StringSet) Contains(s string) bool

Contains indicates whether a StringSet contains a string

func (*StringSet) Equals

func (ss *StringSet) Equals(ss1 *StringSet) bool

Equals compares two StringSets and returns true if they contain the same strings

func (*StringSet) UnmarshalJSON

func (ss *StringSet) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON to a StringSet

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (cb *StringSlice) Scan(value interface{}) error

Scan makes StringSlice implement the sql.Scanner interface.

func (StringSlice) Value

func (cb StringSlice) Value() (driver.Value, error)

Value makes StringSlice implement the driver.Valuer interface.

type TimeField

type TimeField struct {
	FieldDef
	// contains filtered or unexported fields
}

TimeField represent a string field

func (*TimeField) AsTime

func (s *TimeField) AsTime() time.Time

AsTime returns the field value as a time.Time

func (*TimeField) SetTime

func (s *TimeField) SetTime(value time.Time)

SetTime set the field value from a time.Time

type Uint32Slice

type Uint32Slice []uint32

func (*Uint32Slice) Scan

func (cb *Uint32Slice) Scan(value interface{}) error

Scan makes Uint32Slice implement the sql.Scanner interface.

func (Uint32Slice) Value

func (cb Uint32Slice) Value() (driver.Value, error)

Value makes Uint32Slice implement the driver.Valuer interface.

type User

type User struct {
	ID      uint32 `json:"id,omitempty" example:"999" validate:"required,omitempty" dynamodbav:"pk,string"`
	Type    string `json:"-" dynamodbav:"sk"`
	SortKey string `json:"-" dynamodbav:"altSort"`
	UserBody
	InsertTime     time.Time `json:"insert_time,omitempty"`
	LastUpdateTime time.Time `json:"last_update_time,omitempty"`
}

User represents a user, which may belong to multiple societies

func NewUser

func NewUser(id uint32, in UserIn) User

NewUser constructs a User from an id and body

type UserBody

type UserBody struct {
	Name           string `json:"name,omitempty" validate:"required"`
	Email          string `json:"email,omitempty" validate:"required,email"`
	EmailConfirmed bool   `json:"email_confirmed,omitempty"`
	Issuer         string `json:"iss" validate:"required,url" dynamodbav:"-"`
	Subject        string `json:"sub" validate:"required" dynamodbav:"-"`
	Enabled        bool   `json:"enabled"`
}

UserBody is the JSON part of the User object

func (*UserBody) Scan

func (cb *UserBody) Scan(value interface{}) error

Scan makes UserBody implement the sql.Scanner interface.

func (UserBody) Value

func (cb UserBody) Value() (driver.Value, error)

Value makes UserBody implement the driver.Valuer interface.

type UserIn

type UserIn struct {
	UserBody
}

UserIn is the payload to create or update a category

func NewUserIn

func NewUserIn(name string, email string, emailConfirmed bool, issuer string, subject string) (UserIn, error)

NewUserIn constructs a UserIn

type UserPersister

type UserPersister interface {
	RetrieveUser(ctx context.Context, in UserIn) (*User, bool, error)
	SelectUsersByID(ctx context.Context, ids []uint32) ([]User, error)
}

UserPersister defines methods needed to persist categories

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL