UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

72 lines (71 loc) 2.13 kB
import { IntegrationId } from './communication.public-types'; /** * Represents a primitive data type used in database fields. * @category Database */ export type PrimitiveFieldType = string | number | boolean | null | Date; /** * Represents a recursive field type structure for database documents, including primitives, arrays, and nested objects. * @category Database */ export type FieldType = PrimitiveFieldType | Array<FieldType> | { [key: string]: FieldType; }; /** * A type alias for a field name. * @category Database */ export type FieldName<T = any> = string & keyof T; /** * A type alias for a document id as string. * @category Database */ export type DocId = string; /** * A type alias for a document id object when the ID is a composite of primary keys. * @category Database */ export type DocIdObj = Record<FieldName, any>; /** * A type alias for a document id or a document id object. * @category Database */ export type DocIdOrDocIdObj = DocId | DocIdObj; /** * A type alias for a collection name. * @category Database */ export type CollectionName = string; /** * A generic document data type. * @category Database */ export type DocumentData = Record<FieldName, any | undefined>; /** * A type alias for timestamp field.. * @category Database */ export type DocTimestamp = number; /** * The structure of a Squid Document with metadata and dynamic fields. * @category Database */ export interface SquidDocument { [fieldName: string]: FieldType | undefined; /** The unique identifier of the document. */ __docId__: DocId; /** The timestamp of the document, typically in milliseconds. */ __ts__: DocTimestamp; } /** * The full document identifier, combining collection name, document ID, and integration ID. * @category Database */ export interface SquidDocIdObj { /** The name of the collection containing the document. */ collectionName: CollectionName; /** The unique identifier of the document within the collection. */ docId: DocId; /** The ID of the integration associated with the document. */ integrationId: IntegrationId; }