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
|
|
|
|
|
2022-03-18 06:37:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type Markup = string
|
|
|
|
|
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-12-27 12:01:52 +00:00
|
|
|
hidden?: boolean
|
2021-08-03 16:55:52 +00:00
|
|
|
}
|
|
|
|
|
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 {
|
2022-02-11 18:12:12 +00:00
|
|
|
FullText,
|
|
|
|
Indexed
|
2021-08-26 17:59:08 +00:00
|
|
|
}
|
|
|
|
|
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
|
2022-05-19 07:14:05 +00:00
|
|
|
shortLabel?: IntlString
|
2022-05-05 14:50:28 +00:00
|
|
|
isCustom?: boolean
|
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-12-20 09:06:31 +00:00
|
|
|
sortingKey?: string
|
2021-08-03 16:55:52 +00:00
|
|
|
}
|
|
|
|
|
2022-04-01 05:57:22 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* Define a set of plugin to model document bindings.
|
|
|
|
*/
|
|
|
|
export interface PluginConfiguration extends Doc {
|
|
|
|
pluginId: string
|
|
|
|
transactions: Ref<Doc>[]
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2022-03-18 06:37:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
|
|
|
|
export interface TypeDate extends Type<Date> {
|
|
|
|
// If not set to true, will be false
|
|
|
|
withTime?: boolean
|
|
|
|
}
|
|
|
|
|
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>>
|
2022-02-16 09:02:31 +00:00
|
|
|
itemLabel?: IntlString
|
2021-12-06 09:16:04 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2022-04-23 03:45:55 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const DOMAIN_TRANSIENT = 'transient' as Domain
|
|
|
|
|
2022-05-23 15:53:33 +00:00
|
|
|
/**
|
|
|
|
* Special domain to access s3 blob data.
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const DOMAIN_BLOB = 'blob' 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-12-21 09:08:22 +00:00
|
|
|
archived: boolean
|
2021-08-03 16:55:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 17:51:42 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-08 08:43:11 +00:00
|
|
|
export interface Account extends Doc {
|
|
|
|
email: string
|
|
|
|
}
|
2022-01-24 18:30:13 +00:00
|
|
|
|
2022-04-23 03:45:55 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface UserStatus extends Doc {
|
|
|
|
online: boolean
|
|
|
|
}
|
|
|
|
|
2022-01-24 18:30:13 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Version extends Doc {
|
|
|
|
major: number
|
|
|
|
minor: number
|
|
|
|
patch: number
|
|
|
|
}
|
2022-05-23 15:53:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Blob data from s3 storage
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface BlobData extends Doc {
|
|
|
|
name: string
|
|
|
|
size: number
|
|
|
|
type: string
|
|
|
|
base64Data: string // base64 encoded data
|
|
|
|
}
|