mongodoc

package
v0.0.0-...-2b2b6fc Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidObject = rerror.NewE(i18n.T("invalid object"))
	ErrInvalidDoc    = rerror.NewE(i18n.T("invalid document"))
)

Functions

func FromResourceDocument

func FromResourceDocument(r *ResourceDocument) *workspacesettings.Resource

func FromResources

func FromResources(rd []*ResourceDocument) []*workspacesettings.Resource

func ModelFrom

func ModelFrom(obj Document) (res any, err error)

func NewConsumer

func NewConsumer[T Model[U], U any]() *mongox.SliceFuncConsumer[T, U]

Types

type AndConditionDocument

type AndConditionDocument struct {
	Conditions []FilterDocument
}

type AssetAndFileConsumer

type AssetAndFileConsumer = mongox.SliceConsumer[*AssetAndFileDocument]

type AssetAndFileDocument

type AssetAndFileDocument struct {
	ID        string
	File      *AssetFileDocument
	FlatFiles bool
}

type AssetConsumer

type AssetConsumer = mongox.SliceFuncConsumer[*AssetDocument, *asset.Asset]

func NewAssetConsumer

func NewAssetConsumer() *AssetConsumer

type AssetDocument

type AssetDocument struct {
	ID                      string
	Project                 string
	CreatedAt               time.Time
	User                    *string
	Integration             *string
	FileName                string
	Size                    uint64
	PreviewType             string
	UUID                    string
	Thread                  string
	ArchiveExtractionStatus string
	FlatFiles               bool
}

func NewAsset

func NewAsset(a *asset.Asset) (*AssetDocument, string)

func (*AssetDocument) Model

func (d *AssetDocument) Model() (*asset.Asset, error)

type AssetFileDocument

type AssetFileDocument struct {
	Name        string
	Size        uint64
	ContentType string
	Path        string
	Children    []*AssetFileDocument
}

func NewFile

func NewFile(f *asset.File) *AssetFileDocument

func (*AssetFileDocument) Model

func (f *AssetFileDocument) Model() *asset.File

type AssetFilesConsumer

type AssetFilesConsumer struct {
	// contains filtered or unexported fields
}

func (*AssetFilesConsumer) Consume

func (a *AssetFilesConsumer) Consume(raw bson.Raw) error

func (*AssetFilesConsumer) Result

type AssetFilesDocument

type AssetFilesDocument []*AssetFilesPageDocument

func NewFiles

func NewFiles(assetID id.AssetID, fs []*asset.File) AssetFilesDocument

func (AssetFilesDocument) Model

func (d AssetFilesDocument) Model() []*asset.File

type AssetFilesPageDocument

type AssetFilesPageDocument struct {
	AssetID string
	Page    int
	Files   []*AssetFileDocument
}

type AssetUploadConsumer

type AssetUploadConsumer = mongox.SliceFuncConsumer[*AssetUploadDocument, *asset.Upload]

func NewAssetUploadConsumer

func NewAssetUploadConsumer() *AssetUploadConsumer

type AssetUploadDocument

type AssetUploadDocument struct {
	UUID          string    `bson:"uuid"`
	Project       string    `bson:"project"`
	FileName      string    `bson:"filename"`
	ExpiresAt     time.Time `bson:"expires_at"`
	ContentLength int64     `bson:"content_length"`
}

func NewAssetUpload

func NewAssetUpload(u *asset.Upload) *AssetUploadDocument

func (*AssetUploadDocument) Model

func (d *AssetUploadDocument) Model() (*asset.Upload, error)

type BasicConditionDocument

type BasicConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value any
}

type BoolConditionDocument

type BoolConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value bool
}

type CesiumResourcePropsDocument

type CesiumResourcePropsDocument struct {
	Name                 string
	URL                  string
	Image                string
	CesiumIonAssetID     string
	CesiumIonAccessToken string
}

type ColumnDocument

type ColumnDocument struct {
	Field   FieldSelectorDocument
	Visible bool
}

func NewColumn

func NewColumn(i view.Column) ColumnDocument

func (*ColumnDocument) Model

func (d *ColumnDocument) Model() view.Column

type CommentDocument

type CommentDocument struct {
	ID          string
	User        *string
	Integration *string
	Content     string
}

func NewComment

func NewComment(c *thread.Comment) *CommentDocument

func (*CommentDocument) Model

func (c *CommentDocument) Model() *thread.Comment

type Document

type Document struct {
	Type   Type
	Object bson.Raw
}

func NewDocument

func NewDocument(obj any) (doc Document, id string, err error)

type EventConsumer

type EventConsumer = mongox.SliceFuncConsumer[*EventDocument, *event.Event[any]]

func NewEventConsumer

func NewEventConsumer() *EventConsumer

type EventDocument

type EventDocument struct {
	ID          string
	Timestamp   time.Time
	User        *string
	Integration *string
	Machine     bool
	Type        string
	Object      Document
}

func NewEvent

func NewEvent(e *event.Event[any]) (*EventDocument, string, error)

func (*EventDocument) Model

func (d *EventDocument) Model() (*event.Event[any], error)

type FieldDocument

type FieldDocument struct {
	ID           string
	Name         string
	Description  string
	Order        int
	Key          string
	Unique       bool
	Multiple     bool
	Required     bool
	UpdatedAt    time.Time
	DefaultValue *ValueDocument
	TypeProperty TypePropertyDocument
}

type FieldGroupPropertyDocument

type FieldGroupPropertyDocument struct {
	Group string
}

type FieldIntegerPropertyDocument

type FieldIntegerPropertyDocument struct {
	Min *int64
	Max *int64
}

type FieldNumberPropertyDocument

type FieldNumberPropertyDocument struct {
	Min *float64
	Max *float64
}

type FieldReferencePropertyDocument

type FieldReferencePropertyDocument struct {
	Model              string
	Schema             string
	CorrespondingField *string
}

type FieldSelectPropertyDocument

type FieldSelectPropertyDocument struct {
	Values []string
}

type FieldSelectorDocument

type FieldSelectorDocument struct {
	Field *string
	Type  string
}

func (FieldSelectorDocument) Model

type FieldTagPropertyDocument

type FieldTagPropertyDocument struct {
	Tags []FieldTagValueDocument
}

type FieldTagValueDocument

type FieldTagValueDocument struct {
	ID    string
	Name  string
	Color string
}

type FieldTextPropertyDocument

type FieldTextPropertyDocument struct {
	MaxLength *int
}

type FilterDocument

type FilterDocument struct {
	ConditionType     string
	AndCondition      *AndConditionDocument
	OrCondition       *OrConditionDocument
	BasicCondition    *BasicConditionDocument
	NullableCondition *NullableConditionDocument
	MultipleCondition *MultipleConditionDocument
	BoolCondition     *BoolConditionDocument
	StringCondition   *StringConditionDocument
	NumberCondition   *NumberConditionDocument
	TimeCondition     *TimeConditionDocument
}

func NewFilter

func NewFilter(i *view.Condition) *FilterDocument

func (*FilterDocument) Model

func (d *FilterDocument) Model() *view.Condition

type GroupConsumer

type GroupConsumer = mongox.SliceFuncConsumer[*GroupDocument, *group.Group]

func NewGroupConsumer

func NewGroupConsumer() *GroupConsumer

type GroupDocument

type GroupDocument struct {
	ID          string
	Name        string
	Description string
	Key         string
	Project     string
	Schema      string
}

func NewGroup

func NewGroup(group *group.Group) (*GroupDocument, string)

func (*GroupDocument) Model

func (d *GroupDocument) Model() (*group.Group, error)

type IntegrationDocument

type IntegrationDocument struct {
	ID          string
	Name        string
	Description string
	LogoUrl     string
	Type        string
	Token       string
	Developer   string
	Webhook     []WebhookDocument
	UpdatedAt   time.Time
}

func (*IntegrationDocument) Model

type ItemConsumer

type ItemConsumer = mongox.SliceFuncConsumer[*ItemDocument, *item.Item]

func NewItemConsumer

func NewItemConsumer() *ItemConsumer

type ItemDocument

type ItemDocument struct {
	ID                   string
	Project              string
	Schema               string
	Thread               string
	ModelID              string
	Fields               []ItemFieldDocument
	Timestamp            time.Time
	User                 *string
	Integration          *string
	Assets               []string `bson:"assets,omitempty"`
	MetadataItem         *string
	IsMetadata           bool
	OriginalItem         *string
	UpdatedByUser        *string
	UpdatedByIntegration *string
}

func NewItem

func NewItem(i *item.Item) (*ItemDocument, string)

func NewItems

func NewItems(items item.List) ([]*ItemDocument, []string)

func (*ItemDocument) Model

func (d *ItemDocument) Model() (*item.Item, error)

type ItemFieldDocument

type ItemFieldDocument struct {
	F         string        `bson:"f,omitempty"`
	V         ValueDocument `bson:"v,omitempty"`
	Field     string        `bson:"schemafield,omitempty"` // compat
	ValueType string        `bson:"valuetype,omitempty"`   // compat
	Value     any           `bson:"value,omitempty"`       // compat
	ItemGroup *string
}

type Model

type Model[T any] interface {
	Model() (T, error)
}

type ModelConsumer

type ModelConsumer = mongox.SliceFuncConsumer[*ModelDocument, *model.Model]

func NewModelConsumer

func NewModelConsumer() *ModelConsumer

type ModelDocument

type ModelDocument struct {
	ID          string
	Name        string
	Description string
	Key         string
	Public      bool
	Project     string
	Schema      string
	Metadata    *string
	UpdatedAt   time.Time
	Order       int
}

func NewModel

func NewModel(model *model.Model) (*ModelDocument, string)

func NewModels

func NewModels(models model.List) ([]*ModelDocument, []string)

func (*ModelDocument) Model

func (d *ModelDocument) Model() (*model.Model, error)

type MultipleConditionDocument

type MultipleConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value []any
}

type NullableConditionDocument

type NullableConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
}

type NumberConditionDocument

type NumberConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value float64
}

type OrConditionDocument

type OrConditionDocument struct {
	Conditions []FilterDocument
}

type ProjectConsumer

func NewProjectConsumer

func NewProjectConsumer() *ProjectConsumer

type ProjectDocument

type ProjectDocument struct {
	ID           string
	UpdatedAt    time.Time
	Name         string
	Description  string
	Alias        string
	ImageURL     string
	Workspace    string
	Publication  *ProjectPublicationDocument
	RequestRoles []string
}

func NewProject

func NewProject(project *project.Project) (*ProjectDocument, string)

func (*ProjectDocument) Model

func (d *ProjectDocument) Model() (*project.Project, error)

type ProjectPublicationDocument

type ProjectPublicationDocument struct {
	AssetPublic bool
	Scope       string
}

func (*ProjectPublicationDocument) Model

type RequestConsumer

func NewRequestConsumer

func NewRequestConsumer() *RequestConsumer

type RequestDocument

type RequestDocument struct {
	ID          string
	Workspace   string
	Project     string
	Items       []RequestItem
	Title       string
	Description string
	CreatedBy   string
	Reviewers   []string
	State       string
	UpdatedAt   time.Time
	ApprovedAt  *time.Time
	ClosedAt    *time.Time
	Thread      string
}

func NewRequest

func NewRequest(r *request.Request) (*RequestDocument, string)

func NewRequests

func NewRequests(requests request.List) ([]*RequestDocument, []string)

func (*RequestDocument) Model

func (d *RequestDocument) Model() (*request.Request, error)

type RequestItem

type RequestItem struct {
	Item    string
	Version *string
	Ref     *string
}

type ResourceDocument

type ResourceDocument struct {
	ResourceType string
	Tile         *TileResourceDocument
	Terrain      *TerrainResourceDocument
}

func ToResources

func ToResources(rs []*workspacesettings.Resource) []*ResourceDocument

type ResourceListDocument

type ResourceListDocument struct {
	Resources        []*ResourceDocument
	SelectedResource *string
	Enabled          *bool // only in terrains
}

type SchemaConsumer

func NewSchemaConsumer

func NewSchemaConsumer() *SchemaConsumer

type SchemaDocument

type SchemaDocument struct {
	ID         string
	Workspace  string
	Project    string
	Fields     []FieldDocument
	TitleField *string
}

func NewSchema

func NewSchema(s *schema.Schema) (*SchemaDocument, string)

func (*SchemaDocument) Model

func (d *SchemaDocument) Model() (*schema.Schema, error)

type SortDocument

type SortDocument struct {
	Field     FieldSelectorDocument
	Direction string
}

func NewSort

func NewSort(i *view.Sort) *SortDocument

func (*SortDocument) Model

func (d *SortDocument) Model() *view.Sort

type StringConditionDocument

type StringConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value string
}

type TerrainResourceDocument

type TerrainResourceDocument struct {
	ID    string
	Type  string
	Props CesiumResourcePropsDocument
}

type ThreadConsumer

func NewThreadConsumer

func NewThreadConsumer() *ThreadConsumer

type ThreadDocument

type ThreadDocument struct {
	ID        string
	Workspace string
	Comments  []*CommentDocument
}

func NewThread

func NewThread(a *thread.Thread) (*ThreadDocument, string)

func (*ThreadDocument) Model

func (d *ThreadDocument) Model() (*thread.Thread, error)

type TileResourceDocument

type TileResourceDocument struct {
	ID    string
	Type  string
	Props UrlResourcePropsDocument
}

type TimeConditionDocument

type TimeConditionDocument struct {
	Field FieldSelectorDocument
	Op    string
	Value time.Time
}

type Type

type Type string

type TypePropertyDocument

type TypePropertyDocument struct {
	Type      string
	Text      *FieldTextPropertyDocument      `bson:",omitempty"`
	TextArea  *FieldTextPropertyDocument      `bson:",omitempty"`
	RichText  *FieldTextPropertyDocument      `bson:",omitempty"`
	Markdown  *FieldTextPropertyDocument      `bson:",omitempty"`
	Select    *FieldSelectPropertyDocument    `bson:",omitempty"`
	Tag       *FieldTagPropertyDocument       `bson:",omitempty"`
	Number    *FieldNumberPropertyDocument    `bson:",omitempty"`
	Integer   *FieldIntegerPropertyDocument   `bson:",omitempty"`
	Reference *FieldReferencePropertyDocument `bson:",omitempty"`
	Group     *FieldGroupPropertyDocument     `bson:",omitempty"`
}

type UrlResourcePropsDocument

type UrlResourcePropsDocument struct {
	Name  string
	URL   string
	Image string
}

type ValueDocument

type ValueDocument struct {
	T string `bson:"t"`
	V any    `bson:"v"`
}

func NewMultipleValue

func NewMultipleValue(v *value.Multiple) *ValueDocument

func NewOptionalValue

func NewOptionalValue(v *value.Optional) *ValueDocument

func NewValue

func NewValue(v *value.Value) *ValueDocument

func (*ValueDocument) MultipleValue

func (d *ValueDocument) MultipleValue() *value.Multiple

func (*ValueDocument) OptionalValue

func (d *ValueDocument) OptionalValue() *value.Optional

func (*ValueDocument) Value

func (d *ValueDocument) Value() *value.Value

type VersionedItemConsumer

func NewVersionedItemConsumer

func NewVersionedItemConsumer() *VersionedItemConsumer

type ViewConsumer

type ViewConsumer = mongox.SliceFuncConsumer[*ViewDocument, *view.View]

func NewViewConsumer

func NewViewConsumer() *ViewConsumer

type ViewDocument

type ViewDocument struct {
	ID        string
	Name      string
	User      string
	Project   string
	ModelId   string
	Schema    string
	Sort      *SortDocument
	Filter    *FilterDocument
	Columns   []ColumnDocument
	UpdatedAt time.Time
}

func NewView

func NewView(i *view.View) (*ViewDocument, string)

func (*ViewDocument) Model

func (d *ViewDocument) Model() (*view.View, error)

type WebhookDocument

type WebhookDocument struct {
	ID        string
	Name      string
	Url       string
	Active    bool
	Trigger   map[string]bool
	UpdatedAt time.Time
	Secret    string
}

type WorkspaceSettingsDocument

type WorkspaceSettingsDocument struct {
	ID       string
	Tiles    *ResourceListDocument
	Terrains *ResourceListDocument
}

func (*WorkspaceSettingsDocument) Model

Jump to

Keyboard shortcuts

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