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 {
|
|
|
|
label?: IntlString
|
|
|
|
icon?: Asset
|
|
|
|
}
|
|
|
|
|
2021-09-14 08:10:32 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AttachedDoc extends Doc {
|
|
|
|
attachedTo: Ref<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 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,
|
|
|
|
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-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>>
|
|
|
|
domain?: Domain
|
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
// 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-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-09-05 12:03:33 +00:00
|
|
|
|
|
|
|
// S T A T E
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-09-17 08:28:15 +00:00
|
|
|
export interface State extends Doc {
|
|
|
|
title: string
|
|
|
|
color: string
|
2021-09-05 12:03:33 +00:00
|
|
|
}
|
2021-09-22 08:41:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpaceWithStates extends Space {
|
|
|
|
states: Arr<Ref<State>>
|
|
|
|
}
|