diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index ae0d1f56da..d1a924bd52 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -19,13 +19,27 @@ import type { IntlString, Asset, Resource } from '@anticrm/platform' * @public */ export type Ref = string & { __ref: T } + +/** + * @public + */ export type PrimitiveType = number | string | boolean | undefined | Ref + +/** + * @public + */ export type Timestamp = number +/** + * @public + */ export interface Obj { _class: Ref> } +/** + * @public + */ export interface Doc extends Obj { _id: Ref space: Ref @@ -33,35 +47,62 @@ export interface Doc extends Obj { modifiedBy: Ref } +/** + * @public + */ export type PropertyType = any +/** + * @public + */ export interface UXObject extends Obj { label?: IntlString icon?: Asset } +/** + * @public + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface Type extends UXObject {} +/** + * @public + */ export interface Attribute extends Doc, UXObject { attributeOf: Ref> name: string type: Type } +/** + * @public + */ export type AnyAttribute = Attribute> +/** + * @public + */ export enum ClassifierKind { CLASS, 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 Class extends Classifier { extends?: Ref> @@ -69,34 +110,61 @@ export interface Class extends Classifier { triggers?: Trigger[] } +/** + * @public + */ export type Mixin = Class // D A T A +/** + * @public + */ export type Data = Omit // T Y P E S +/** + * @public + */ export interface RefTo extends Type>> { to: Ref> } +/** + * @public + */ export type Bag = Record +/** + * @public + */ export interface BagOf extends Type> { of: Type } +/** + * @public + */ export type Arr = T[] +/** + * @public + */ export interface ArrOf extends Type { of: Type } +/** + * @public + */ export const DOMAIN_MODEL = 'model' as Domain // S E C U R I T Y +/** + * @public + */ export interface Space extends Doc { name: string description: string @@ -104,29 +172,50 @@ export interface Space extends Doc { members: Arr> } +/** + * @public + */ export interface Account extends Doc {} // T X +/** + * @public + */ export interface TxFactory { createTxCreateDoc: (_class: Ref>, space: Ref, attributes: Data) => TxCreateDoc createTxMixin: (objectId: Ref, objectClass: Ref>, mixin: Ref>, attributes: ExtendedAttributes) => TxMixin } +/** + * @public + */ export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise> +/** + * @public + */ export interface Tx extends Doc { objectId: Ref objectClass: Ref> objectSpace: Ref } +/** + * @public + */ export interface TxCreateDoc extends Tx { attributes: Data } +/** + * @public + */ export type ExtendedAttributes = Omit +/** + * @public + */ export interface TxMixin extends Tx { mixin: Ref> attributes: ExtendedAttributes