diff --git a/packages/api-client/src/types.ts b/packages/api-client/src/types.ts index 0dae84e3e3..820ae9c48f 100644 --- a/packages/api-client/src/types.ts +++ b/packages/api-client/src/types.ts @@ -14,33 +14,144 @@ // import { type ClientSocketFactory } from '@hcengineering/client' -import { type Client, type TxOperations } from '@hcengineering/core' +import { + type AttachedData, + type AttachedDoc, + type Class, + type Data, + type Doc, + type DocumentQuery, + type DocumentUpdate, + type FindOptions, + type FindResult, + type Hierarchy, + type Mixin, + type MixinData, + type MixinUpdate, + type ModelDb, + type Ref, + type Space, + type TxResult, + type WithLookup +} from '@hcengineering/core' import { type MarkupOperations } from './markup' /** * Platform API client * @public * */ -export type PlatformClient = AsyncDisposable & -Pick< -TxOperations, -| 'createDoc' -| 'updateDoc' -| 'removeDoc' -| 'addCollection' -| 'updateCollection' -| 'removeCollection' -| 'createMixin' -| 'updateMixin' -> & -Pick & -MarkupOperations +export type PlatformClient = { + getHierarchy: () => Hierarchy + + getModel: () => ModelDb + + close: () => Promise +} & FindOperations & +DocOperations & +CollectionOperations & +MixinOperations & +MarkupOperations & +AsyncDisposable + +/** + * @public + */ +export interface FindOperations { + findAll: ( + _class: Ref>, + query: DocumentQuery, + options?: FindOptions | undefined + ) => Promise> + + findOne: ( + _class: Ref>, + query: DocumentQuery, + options?: FindOptions | undefined + ) => Promise | undefined> +} + +/** + * @public + */ +export interface DocOperations { + createDoc: ( + _class: Ref>, + space: Ref, + attributes: Data, + id?: Ref + ) => Promise> + + updateDoc: ( + _class: Ref>, + space: Ref, + objectId: Ref, + operations: DocumentUpdate, + retrieve?: boolean + ) => Promise + + removeDoc: (_class: Ref>, space: Ref, objectId: Ref) => Promise +} + +/** + * @public + */ +export interface CollectionOperations { + addCollection: ( + _class: Ref>, + space: Ref, + attachedTo: Ref, + attachedToClass: Ref>, + collection: Extract | string, + attributes: AttachedData

, + id?: Ref

+ ) => Promise> + + updateCollection: ( + _class: Ref>, + space: Ref, + objectId: Ref

, + attachedTo: Ref, + attachedToClass: Ref>, + collection: Extract | string, + operations: DocumentUpdate

, + retrieve?: boolean + ) => Promise> + + removeCollection: ( + _class: Ref>, + space: Ref, + objectId: Ref

, + attachedTo: Ref, + attachedToClass: Ref>, + collection: Extract | string + ) => Promise> +} + +/** + * @public + */ +export interface MixinOperations { + createMixin: ( + objectId: Ref, + objectClass: Ref>, + objectSpace: Ref, + mixin: Ref>, + attributes: MixinData + ) => Promise + + updateMixin: ( + objectId: Ref, + objectClass: Ref>, + objectSpace: Ref, + mixin: Ref>, + attributes: MixinUpdate + ) => Promise +} /** * Configuration options for password-based authentication * @public */ - export interface PasswordAuthOptions { /** User's email address */ email: string