// // Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2021 Hardcore Engineering Inc. // // 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 type { Asset, IntlString, Plugin } from '@hcengineering/platform' /** * @public */ export type Ref = string & { __ref: T } /** * @public */ export type PrimitiveType = number | string | boolean | undefined | Ref /** * @public */ export type Timestamp = number /** * @public */ export type Markup = string /** * @public */ export type Hyperlink = string /** * @public */ export type CollectionSize = T[]['length'] /** * @public * * String representation of {@link https://www.npmjs.com/package/lexorank LexoRank} type */ export type Rank = string /** * @public */ export interface Obj { _class: Ref> } /** * @public */ export interface Doc extends Obj { _id: Ref space: Ref modifiedOn: Timestamp modifiedBy: Ref createdBy?: Ref // Marked as optional since it will be filled by platform. createdOn?: Timestamp // Marked as optional since it will be filled by platform. } /** * @public */ export type PropertyType = any /** * @public */ export interface UXObject extends Obj { label: IntlString icon?: Asset hidden?: boolean readonly?: boolean } /** * @public */ export interface AttachedDoc< Parent extends Doc = Doc, Collection extends Extract | string = Extract | string, S extends Space = Space > extends Doc { attachedTo: Ref attachedToClass: Ref> collection: Collection } /** * @public */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface Type extends UXObject {} /** * @public */ export enum IndexKind { /** * Attribute with this index annotation should be added to elastic for search * Could be added to string or Ref attribute * TODO: rename properly for better code readability */ FullText, /** * For attribute with this annotation should be created an index in mongo database * * Also mean to include into Elastic search. */ Indexed, // Same as indexed but for descending IndexedDsc } /** * @public */ export interface Enum extends Doc { name: string enumValues: string[] } /** * @public */ export interface Attribute extends Doc, UXObject { attributeOf: Ref> name: string type: Type index?: IndexKind shortLabel?: IntlString isCustom?: boolean defaultValue?: any // Extra customization properties [key: string]: any } /** * @public */ export type AnyAttribute = Attribute> /** * @public */ export enum ClassifierKind { CLASS, INTERFACE, MIXIN } /** * @public */ export interface Classifier extends Doc, UXObject { kind: ClassifierKind } /** * @public */ export type Domain = string & { __domain: true } /** * @public */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface Interface extends Classifier { extends?: Ref>[] } /** * @public */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface Class extends Classifier { extends?: Ref> implements?: Ref>[] domain?: Domain shortLabel?: string sortingKey?: string filteringKey?: string pluralLabel?: IntlString } /** * @public * Define a set of plugin to model document bindings. */ export interface PluginConfiguration extends Doc { pluginId: Plugin transactions: Ref[] label?: IntlString icon?: Asset description?: IntlString enabled: boolean // If specified, will show beta/testing label in UI. beta: boolean // If defined, will only remove classes in list. classFilter?: Ref>[] } /** * @public */ export type Mixin = Class // D A T A /** * @public */ export type Data = Omit /** * @public */ export type AttachedData = Omit /** * @public */ export type DocData = T extends AttachedDoc ? AttachedData : Data // T Y P E S /** * @public */ export enum DateRangeMode { DATE = 'date', TIME = 'time', DATETIME = 'datetime', TIMEONLY = 'timeonly' } /** * @public */ export interface TypeDate extends Type { // If not set date mode default mode: DateRangeMode // If not set to true, will be false withShift: boolean } /** * @public */ export interface RefTo extends Type>> { to: Ref> } /** * @public */ export interface Collection extends Type> { of: Ref> itemLabel?: IntlString } /** * @public */ export type Arr = T[] /** * @public */ export interface ArrOf extends Type { of: Type } /** * @public */ export interface EnumOf extends Type { of: Ref } /** * @public */ export interface TypeHyperlink extends Type {} /** * @public * * A type for some custom serialized field with a set of editors */ export interface TypeAny extends Type { presenter: AnyComponent editor?: AnyComponent } /** * @public */ export const DOMAIN_MODEL = 'model' as Domain /** * @public */ export const DOMAIN_CONFIGURATION = '_configuration' as Domain /** * @public */ export const DOMAIN_MIGRATION = '_migrations' as Domain /** * @public */ export const DOMAIN_TRANSIENT = 'transient' as Domain /** * Special domain to access s3 blob data. * @public */ export const DOMAIN_BLOB = 'blob' as Domain /** * Special domain to access s3 blob data. * @public */ export const DOMAIN_FULLTEXT_BLOB = 'fulltext-blob' as Domain /** * Special domain to access s3 blob data. * @public */ export const DOMAIN_DOC_INDEX_STATE = 'doc-index-state' as Domain // S P A C E /** * @public */ export interface Space extends Doc { name: string description: string private: boolean members: Arr> archived: boolean } /** * @public * * Space with custom configured type */ export interface TypedSpace extends Space { type: Ref } /** * @public * * Is used to describe "types" for space type */ export interface SpaceTypeDescriptor extends Doc { name: IntlString description: IntlString icon: Asset baseClass: Ref> // Child class of Space for which the space type can be defined availablePermissions: Ref[] } /** * @public * * Customisable space type allowing to configure space roles and permissions within them */ export interface SpaceType extends Doc { name: string shortDescription?: string descriptor: Ref targetClass: Ref> // A dynamic mixin for Spaces to hold custom attributes and roles assignment of the space type roles: CollectionSize } /** * @public * Role defines permissions for employees assigned to this role within the space */ export interface Role extends AttachedDoc { name: string permissions: Ref[] } /** * @public * Defines assignment of employees to a role within a space */ export type RolesAssignment = Record, Ref[] | undefined> /** * @public * Permission is a basic access control item in the system */ export interface Permission extends Doc { label: IntlString description?: IntlString icon?: Asset } /** * @public */ export interface Account extends Doc { email: string role: AccountRole } /** * @public */ export enum AccountRole { Guest = 'GUEST', User = 'USER', Maintainer = 'MAINTAINER', Owner = 'OWNER' } /** * @public */ export const roleOrder: Record = { [AccountRole.Guest]: 1, [AccountRole.User]: 2, [AccountRole.Maintainer]: 3, [AccountRole.Owner]: 4 } /** * @public */ export interface UserStatus extends Doc { online: boolean user: Ref } /** * @public */ export interface Version extends Doc { major: number minor: number patch: number } /** * @public */ export interface MigrationState extends Doc { plugin: string state: string } /** * @public */ export function versionToString (version: Version | Data): string { return `${version?.major}.${version?.minor}.${version?.patch}` } /** * Blob data from s3 storage * @public */ export interface BlobData extends Doc { name: string size: number type: string base64Data: string // base64 encoded data } /** * Blob data from s3 storage * @public */ export interface FullTextData extends Doc { data: any } /** * @public * * Define status for full text indexing */ export interface DocIndexState extends Doc { objectClass: Ref> attachedTo?: Ref attachedToClass?: Ref> generationId?: string // States for stages stages: Record removed: boolean // Indexable attributes, including child ones. attributes: Record // Full Summary fullSummary?: Markup | null shortSummary?: Markup | null } /** * @public */ export interface IndexStageState extends Doc { stageId: string attributes: Record } /** * @public * * If defined for class, this class will be enabled for embedding search like openai. */ export interface FullTextSearchContext extends Class { fullTextSummary?: boolean forceIndex?: boolean // If defined, will propagate changes to child's with defined set of classes propagate?: Ref>[] // If defined, will propagate all document from child's based on class propagateClasses?: Ref>[] // Do we need to propagate child value to parent one. Default(true) parentPropagate?: boolean childProcessingAllowed?: boolean } /** * @public */ export interface ConfigurationElement extends Class { // Title will be presented to owner. title: IntlString // Group for grouping. group: IntlString } /** * @public * * Define configuration value configuration for workspace. * * Configuration is accessible only for owners of workspace and under hood services. */ export interface Configuration extends Doc { enabled: boolean } /** * @public */ export type RelatedDocument = Pick /** * @public */ export enum IndexOrder { Ascending = 1, Descending = -1 } /** * @public */ export type FieldIndex = { [P in keyof T]?: IndexOrder } & Record /** * @public * * Mixin for extra indexing fields. */ export interface IndexingConfiguration extends Class { // Define a list of extra index definitions. indexes: (FieldIndex | string)[] searchDisabled?: boolean }