// // Copyright © 2020, 2021 Anticrm Platform Contributors. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // import { DOMAIN_BLOB, DOMAIN_CONFIGURATION, DOMAIN_DOC_INDEX_STATE, DOMAIN_MIGRATION, DOMAIN_MODEL, IndexKind, type Account, type AnyAttribute, type ArrOf, type AttachedDoc, type Blob, type Class, type ClassifierKind, type Collection, type Configuration, type ConfigurationElement, type Doc, type DocIndexState, type Domain, type DomainIndexConfiguration, type Enum, type EnumOf, type FieldIndexConfig, type FullTextSearchContext, type IndexingConfiguration, type Interface, type MigrationState, type Mixin, type Obj, type PluginConfiguration, type Ref, type RefTo, type Space, type Timestamp, type Type, type TypeAny, type Version } from '@hcengineering/core' import { Hidden, Index, Mixin as MMixin, Model, Prop, ReadOnly, TypeBoolean, TypeFileSize, TypeIntlString, TypeRecord, TypeRef, TypeString, TypeTimestamp, UX } from '@hcengineering/model' import { getEmbeddedLabel, type IntlString, type Plugin } from '@hcengineering/platform' import core from './component' // C O R E @Model(core.class.Obj, core.class.Obj) export class TObj implements Obj { @Prop(TypeRef(core.class.Class), core.string.ClassLabel) @Index(IndexKind.Indexed) @Hidden() _class!: Ref> } @Model(core.class.Doc, core.class.Obj) @UX(core.string.Object) export class TDoc extends TObj implements Doc { @Prop(TypeRef(core.class.Doc), core.string.Id) @Hidden() // @Index(IndexKind.Indexed) // - automatically indexed by default. _id!: Ref @Prop(TypeRef(core.class.Space), core.string.Space) @Index(IndexKind.Indexed) @Hidden() space!: Ref @Prop(TypeTimestamp(), core.string.ModifiedDate) @Index(IndexKind.Indexed) modifiedOn!: Timestamp @Prop(TypeRef(core.class.Account), core.string.ModifiedBy) @Index(IndexKind.Indexed) modifiedBy!: Ref @Prop(TypeRef(core.class.Account), core.string.CreatedBy) @Index(IndexKind.Indexed) createdBy!: Ref @Prop(TypeTimestamp(), core.string.CreatedDate) @ReadOnly() @Index(IndexKind.IndexedDsc) createdOn!: Timestamp } @Model(core.class.AttachedDoc, core.class.Doc) export class TAttachedDoc extends TDoc implements AttachedDoc { @Prop(TypeRef(core.class.Doc), core.string.AttachedTo) @Index(IndexKind.Indexed) @Hidden() attachedTo!: Ref @Prop(TypeRef(core.class.Class), core.string.AttachedToClass) @Index(IndexKind.Indexed) @Hidden() attachedToClass!: Ref> @Prop(TypeString(), core.string.Collection) @Hidden() collection!: string } @Model(core.class.Blob, core.class.Doc, DOMAIN_BLOB) @UX(core.string.Object) export class TBlob extends TDoc implements Blob { @Prop(TypeString(), core.string.Blob) @ReadOnly() // @Index(IndexKind.Indexed) provider!: string @Prop(TypeString(), core.string.BlobContentType) @ReadOnly() contentType!: string @Prop(TypeString(), core.string.BlobStorageId) @ReadOnly() storageId!: string @Prop(TypeString(), core.string.BlobEtag) @ReadOnly() etag!: string @Prop(TypeString(), core.string.BlobVersion) @ReadOnly() version!: string @Prop(TypeFileSize(), core.string.BlobSize) @ReadOnly() size!: number } @UX(core.string.ClassLabel) @Model(core.class.Class, core.class.Doc, DOMAIN_MODEL) export class TClass extends TDoc implements Class { kind!: ClassifierKind @Prop(TypeIntlString(), core.string.ClassPropertyLabel) label!: IntlString extends!: Ref> domain!: Domain } @Model(core.class.Mixin, core.class.Class) export class TMixin extends TClass implements Mixin {} @Model(core.class.Interface, core.class.Class) export class TInterface extends TDoc implements Interface { kind!: ClassifierKind label!: IntlString extends?: Ref>[] } @UX(core.string.Enum) @Model(core.class.Enum, core.class.Doc, DOMAIN_MODEL) export class TEnum extends TDoc implements Enum { name!: string enumValues!: string[] } @Model(core.class.Attribute, core.class.Doc, DOMAIN_MODEL) export class TAttribute extends TDoc implements AnyAttribute { attributeOf!: Ref> name!: string type!: Type label!: IntlString isCustom?: boolean defaultValue?: any } @Model(core.class.Type, core.class.Obj, DOMAIN_MODEL) export class TType extends TObj implements Type { label!: IntlString } @UX(core.string.String) @Model(core.class.TypeString, core.class.Type) export class TTypeString extends TType {} @UX(core.string.String) @Model(core.class.TypeRecord, core.class.Type) export class TTypeRecord extends TType {} @UX(core.string.String) @Model(core.class.TypeBlob, core.class.Type) export class TTypeBlob extends TType {} @UX(core.string.Hyperlink) @Model(core.class.TypeHyperlink, core.class.Type) export class TTypeHyperlink extends TType {} @UX(core.string.IntlString) @Model(core.class.TypeIntlString, core.class.Type) export class TTypeIntlString extends TType {} @UX(core.string.Number) @Model(core.class.TypeNumber, core.class.Type) export class TTypeNumber extends TType {} @UX(core.string.BlobSize) @Model(core.class.TypeFileSize, core.class.Type) export class TTypeFileSize extends TType {} @UX(core.string.Markup) @Model(core.class.TypeMarkup, core.class.Type) export class TTypeMarkup extends TType {} @UX(core.string.Ref) @Model(core.class.RefTo, core.class.Type) export class TRefTo extends TType implements RefTo { to!: Ref> } @UX(core.string.Collection) @Model(core.class.Collection, core.class.Type) export class TCollection extends TType implements Collection { of!: Ref> } @UX(core.string.Array) @Model(core.class.ArrOf, core.class.Type) export class TArrOf extends TType implements ArrOf { of!: Type } @UX(core.string.Boolean) @Model(core.class.TypeBoolean, core.class.Type) export class TTypeBoolean extends TType {} @UX(core.string.Timestamp) @Model(core.class.TypeTimestamp, core.class.Type) export class TTypeTimestamp extends TType {} @UX(core.string.Ref) @Model(core.class.TypeRelatedDocument, core.class.Type) export class TTypeRelatedDocument extends TType {} @UX(core.string.Date) @Model(core.class.TypeDate, core.class.Type) export class TTypeDate extends TType {} @UX(core.string.Enum) @Model(core.class.EnumOf, core.class.Type) export class TEnumOf extends TType implements EnumOf { of!: Ref } @UX(getEmbeddedLabel('Any')) @Model(core.class.TypeAny, core.class.Type) export class TTypeAny extends TType implements TypeAny { presenter!: any editor!: any } @Model(core.class.Version, core.class.Doc, DOMAIN_MODEL) export class TVersion extends TDoc implements Version { major!: number minor!: number patch!: number } @Model(core.class.MigrationState, core.class.Doc, DOMAIN_MIGRATION) export class TMigrationState extends TDoc implements MigrationState { plugin!: string state!: string } @Model(core.class.PluginConfiguration, core.class.Doc, DOMAIN_MODEL) export class TPluginConfiguration extends TDoc implements PluginConfiguration { pluginId!: Plugin transactions!: Ref[] label!: IntlString enabled!: boolean beta!: boolean } @Model(core.class.DocIndexState, core.class.Doc, DOMAIN_DOC_INDEX_STATE) export class TDocIndexState extends TDoc implements DocIndexState { @Prop(TypeRef(core.class.Class), core.string.Class) @Index(IndexKind.Indexed) @Hidden() objectClass!: Ref> @Prop(TypeRef(core.class.Doc), core.string.AttachedTo) @Index(IndexKind.Indexed) @Hidden() attachedTo?: Ref @Prop(TypeRef(core.class.Class), core.string.AttachedToClass) @Index(IndexKind.Indexed) @Hidden() attachedToClass?: Ref> // Indexable attributes of document. attributes!: Record @Prop(TypeBoolean(), getEmbeddedLabel('Removed')) @Hidden() removed!: boolean @Prop(TypeBoolean(), getEmbeddedLabel('NeedIndexing')) @Hidden() needIndex!: boolean // States for different stages @Prop(TypeRecord(), getEmbeddedLabel('Stages')) // @Index(IndexKind.Indexed) @Hidden() stages!: Record @Prop(TypeString(), getEmbeddedLabel('Generation')) @Hidden() generationId?: string } @MMixin(core.mixin.FullTextSearchContext, core.class.Class) export class TFullTextSearchContext extends TClass implements FullTextSearchContext {} @MMixin(core.mixin.ConfigurationElement, core.class.Class) export class TConfigurationElement extends TClass implements ConfigurationElement { @Prop(TypeIntlString(), core.string.Private) title!: IntlString @Prop(TypeIntlString(), core.string.Private) group!: IntlString } @Model(core.class.Configuration, core.class.Doc, DOMAIN_CONFIGURATION) export class TConfiguration extends TDoc implements Configuration { @Prop(TypeBoolean(), core.string.Private) enabled!: boolean } @MMixin(core.mixin.IndexConfiguration, core.class.Class) export class TIndexConfiguration extends TClass implements IndexingConfiguration { indexes!: (string | FieldIndexConfig)[] searchDisabled!: boolean } @Model(core.class.DomainIndexConfiguration, core.class.Doc, DOMAIN_MODEL) export class TDomainIndexConfiguration extends TDoc implements DomainIndexConfiguration { domain!: Domain } @UX(core.string.CollaborativeDoc) @Model(core.class.TypeCollaborativeDoc, core.class.Type) export class TTypeCollaborativeDoc extends TType {} @UX(core.string.CollaborativeDocVersion) @Model(core.class.TypeCollaborativeDocVersion, core.class.Type) export class TTypeCollaborativeDocVersion extends TType {} @UX(core.string.Rank) @Model(core.class.TypeRank, core.class.Type) export class TTypeRank extends TType {}