mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 15:20:18 +00:00
add docs to classes.ts
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
19dedf7137
commit
41796f346c
@ -19,13 +19,27 @@ import type { IntlString, Asset, Resource } from '@anticrm/platform'
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type Ref<T extends Doc> = string & { __ref: T }
|
export type Ref<T extends Doc> = string & { __ref: T }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type PrimitiveType = number | string | boolean | undefined | Ref<Doc>
|
export type PrimitiveType = number | string | boolean | undefined | Ref<Doc>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Timestamp = number
|
export type Timestamp = number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Obj {
|
export interface Obj {
|
||||||
_class: Ref<Class<this>>
|
_class: Ref<Class<this>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Doc extends Obj {
|
export interface Doc extends Obj {
|
||||||
_id: Ref<this>
|
_id: Ref<this>
|
||||||
space: Ref<Space>
|
space: Ref<Space>
|
||||||
@ -33,35 +47,62 @@ export interface Doc extends Obj {
|
|||||||
modifiedBy: Ref<Account>
|
modifiedBy: Ref<Account>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type PropertyType = any
|
export type PropertyType = any
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface UXObject extends Obj {
|
export interface UXObject extends Obj {
|
||||||
label?: IntlString
|
label?: IntlString
|
||||||
icon?: Asset
|
icon?: Asset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export interface Type<T extends PropertyType> extends UXObject {}
|
export interface Type<T extends PropertyType> extends UXObject {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Attribute<T extends PropertyType> extends Doc, UXObject {
|
export interface Attribute<T extends PropertyType> extends Doc, UXObject {
|
||||||
attributeOf: Ref<Class<Obj>>
|
attributeOf: Ref<Class<Obj>>
|
||||||
name: string
|
name: string
|
||||||
type: Type<T>
|
type: Type<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type AnyAttribute = Attribute<Type<any>>
|
export type AnyAttribute = Attribute<Type<any>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export enum ClassifierKind {
|
export enum ClassifierKind {
|
||||||
CLASS,
|
CLASS,
|
||||||
MIXIN
|
MIXIN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Classifier extends Doc, UXObject {
|
export interface Classifier extends Doc, UXObject {
|
||||||
kind: ClassifierKind
|
kind: ClassifierKind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Domain = string & { __domain: true }
|
export type Domain = string & { __domain: true }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export interface Class<T extends Obj> extends Classifier {
|
export interface Class<T extends Obj> extends Classifier {
|
||||||
extends?: Ref<Class<Obj>>
|
extends?: Ref<Class<Obj>>
|
||||||
@ -69,34 +110,61 @@ export interface Class<T extends Obj> extends Classifier {
|
|||||||
triggers?: Trigger[]
|
triggers?: Trigger[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Mixin<T extends Doc> = Class<T>
|
export type Mixin<T extends Doc> = Class<T>
|
||||||
|
|
||||||
// D A T A
|
// D A T A
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Data<T extends Doc> = Omit<T, keyof Doc>
|
export type Data<T extends Doc> = Omit<T, keyof Doc>
|
||||||
|
|
||||||
// T Y P E S
|
// T Y P E S
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface RefTo<T extends Doc> extends Type<Ref<Class<T>>> {
|
export interface RefTo<T extends Doc> extends Type<Ref<Class<T>>> {
|
||||||
to: Ref<Class<T>>
|
to: Ref<Class<T>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Bag<T extends PropertyType> = Record<string, T>
|
export type Bag<T extends PropertyType> = Record<string, T>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface BagOf<T extends PropertyType> extends Type<Bag<T>> {
|
export interface BagOf<T extends PropertyType> extends Type<Bag<T>> {
|
||||||
of: Type<T>
|
of: Type<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Arr<T extends PropertyType> = T[]
|
export type Arr<T extends PropertyType> = T[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface ArrOf<T extends PropertyType> extends Type<T[]> {
|
export interface ArrOf<T extends PropertyType> extends Type<T[]> {
|
||||||
of: Type<T>
|
of: Type<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export const DOMAIN_MODEL = 'model' as Domain
|
export const DOMAIN_MODEL = 'model' as Domain
|
||||||
|
|
||||||
// S E C U R I T Y
|
// S E C U R I T Y
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Space extends Doc {
|
export interface Space extends Doc {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
@ -104,29 +172,50 @@ export interface Space extends Doc {
|
|||||||
members: Arr<Ref<Account>>
|
members: Arr<Ref<Account>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Account extends Doc {}
|
export interface Account extends Doc {}
|
||||||
|
|
||||||
// T X
|
// T X
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface TxFactory {
|
export interface TxFactory {
|
||||||
createTxCreateDoc: <T extends Doc>(_class: Ref<Class<T>>, space: Ref<Space>, attributes: Data<T>) => TxCreateDoc<T>
|
createTxCreateDoc: <T extends Doc>(_class: Ref<Class<T>>, space: Ref<Space>, attributes: Data<T>) => TxCreateDoc<T>
|
||||||
createTxMixin: <D extends Doc, M extends D>(objectId: Ref<D>, objectClass: Ref<Class<D>>, mixin: Ref<Mixin<M>>, attributes: ExtendedAttributes<D, M>) => TxMixin<D, M>
|
createTxMixin: <D extends Doc, M extends D>(objectId: Ref<D>, objectClass: Ref<Class<D>>, mixin: Ref<Mixin<M>>, attributes: ExtendedAttributes<D, M>) => TxMixin<D, M>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Tx<T extends Doc = Doc> extends Doc {
|
export interface Tx<T extends Doc = Doc> extends Doc {
|
||||||
objectId: Ref<T>
|
objectId: Ref<T>
|
||||||
objectClass: Ref<Class<T>>
|
objectClass: Ref<Class<T>>
|
||||||
objectSpace: Ref<Space>
|
objectSpace: Ref<Space>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface TxCreateDoc<T extends Doc> extends Tx<T> {
|
export interface TxCreateDoc<T extends Doc> extends Tx<T> {
|
||||||
attributes: Data<T>
|
attributes: Data<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export type ExtendedAttributes<D extends Doc, M extends D> = Omit<M, keyof D>
|
export type ExtendedAttributes<D extends Doc, M extends D> = Omit<M, keyof D>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface TxMixin<D extends Doc, M extends D> extends Tx<D> {
|
export interface TxMixin<D extends Doc, M extends D> extends Tx<D> {
|
||||||
mixin: Ref<Mixin<M>>
|
mixin: Ref<Mixin<M>>
|
||||||
attributes: ExtendedAttributes<D, M>
|
attributes: ExtendedAttributes<D, M>
|
||||||
|
Loading…
Reference in New Issue
Block a user