2021-08-03 16:55:52 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
2021-08-04 21:17:53 +00:00
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
2021-08-03 16:55:52 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2021-08-05 06:47:54 +00:00
|
|
|
import type { IntlString, Asset } from '@anticrm/platform'
|
2021-08-03 16:55:52 +00:00
|
|
|
|
2021-08-04 17:35:29 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Ref<T extends Doc> = string & { __ref: T }
|
2021-08-04 17:51:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type PrimitiveType = number | string | boolean | undefined | Ref<Doc>
|
2021-08-04 17:51:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Timestamp = number
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface Obj {
|
|
|
|
_class: Ref<Class<this>>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface Doc extends Obj {
|
|
|
|
_id: Ref<this>
|
|
|
|
space: Ref<Space>
|
|
|
|
modifiedOn: Timestamp
|
|
|
|
modifiedBy: Ref<Account>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type PropertyType = any
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface UXObject extends Obj {
|
2021-10-05 09:18:37 +00:00
|
|
|
label: IntlString
|
2021-08-03 16:55:52 +00:00
|
|
|
icon?: Asset
|
|
|
|
}
|
|
|
|
|
2021-09-14 08:10:32 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AttachedDoc extends Doc {
|
|
|
|
attachedTo: Ref<Doc>
|
2021-10-23 14:03:37 +00:00
|
|
|
attachedToClass: Ref<Class<Doc>>
|
2021-11-17 08:47:30 +00:00
|
|
|
collection: string
|
2021-09-14 08:10:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
export interface Type<T extends PropertyType> extends UXObject {}
|
|
|
|
|
2021-08-26 17:59:08 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export enum IndexKind {
|
|
|
|
FullText
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface Attribute<T extends PropertyType> extends Doc, UXObject {
|
|
|
|
attributeOf: Ref<Class<Obj>>
|
|
|
|
name: string
|
|
|
|
type: Type<T>
|
2021-08-26 17:59:08 +00:00
|
|
|
index?: IndexKind
|
2021-08-03 16:55:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type AnyAttribute = Attribute<Type<any>>
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export enum ClassifierKind {
|
|
|
|
CLASS,
|
2021-12-01 20:25:28 +00:00
|
|
|
INTERFACE,
|
2021-08-03 16:55:52 +00:00
|
|
|
MIXIN
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface Classifier extends Doc, UXObject {
|
|
|
|
kind: ClassifierKind
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Domain = string & { __domain: true }
|
|
|
|
|
2021-12-01 20:25:28 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
export interface Interface<T extends Doc> extends Classifier {
|
|
|
|
extends?: Ref<Interface<Doc>>[]
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
export interface Class<T extends Obj> extends Classifier {
|
|
|
|
extends?: Ref<Class<Obj>>
|
2021-12-01 20:25:28 +00:00
|
|
|
implements?: Ref<Interface<Doc>>[]
|
2021-08-03 16:55:52 +00:00
|
|
|
domain?: Domain
|
2021-10-14 09:44:25 +00:00
|
|
|
shortLabel?: IntlString
|
2021-08-03 16:55:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Mixin<T extends Doc> = Class<T>
|
|
|
|
|
|
|
|
// D A T A
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Data<T extends Doc> = Omit<T, keyof Doc>
|
|
|
|
|
2021-10-30 10:13:55 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type AttachedData<T extends AttachedDoc> = Omit<T, keyof AttachedDoc>
|
|
|
|
|
2021-08-03 16:55:52 +00:00
|
|
|
// T Y P E S
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface RefTo<T extends Doc> extends Type<Ref<Class<T>>> {
|
|
|
|
to: Ref<Class<T>>
|
|
|
|
}
|
|
|
|
|
2021-12-06 09:16:04 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Collection<T extends AttachedDoc> extends Type<number> {
|
|
|
|
of: Ref<Class<T>>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Bag<T extends PropertyType> = Record<string, T>
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface BagOf<T extends PropertyType> extends Type<Bag<T>> {
|
|
|
|
of: Type<T>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export type Arr<T extends PropertyType> = T[]
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface ArrOf<T extends PropertyType> extends Type<T[]> {
|
|
|
|
of: Type<T>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export const DOMAIN_MODEL = 'model' as Domain
|
|
|
|
|
2021-09-22 08:41:03 +00:00
|
|
|
// S P A C E
|
2021-08-03 16:55:52 +00:00
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-03 16:55:52 +00:00
|
|
|
export interface Space extends Doc {
|
|
|
|
name: string
|
|
|
|
description: string
|
|
|
|
private: boolean
|
|
|
|
members: Arr<Ref<Account>>
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-08 08:43:11 +00:00
|
|
|
export interface Account extends Doc {
|
|
|
|
email: string
|
|
|
|
}
|
2021-12-17 09:08:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface DocWithRank extends Doc {
|
|
|
|
rank: string
|
|
|
|
}
|