import { OneOf } from '.'; import { ReadOnlyAction } from '../actions/action'; import { PrimaryKey, Sequence } from './DataType'; type TriggerDataAttributeType = '$$triggerData$$'; type TriggerUuidAttributeType = '$$triggerUuid$$'; type PrimaryKeyAttributeType = 'id'; type CreateAtAttributeType = '$$createAt$$'; type UpdateAtAttributeType = '$$updateAt$$'; type DeleteAtAttributeType = '$$deleteAt$$'; type SeqAttributeType = '$$seq$$'; export declare const TriggerDataAttribute = "$$triggerData$$"; export declare const TriggerUuidAttribute = "$$triggerUuid$$"; export declare const PrimaryKeyAttribute = "id"; export declare const CreateAtAttribute = "$$createAt$$"; export declare const UpdateAtAttribute = "$$updateAt$$"; export declare const DeleteAtAttribute = "$$deleteAt$$"; export declare const SeqAttribute = "$$seq$$"; export type InstinctiveAttributes = PrimaryKeyAttributeType | CreateAtAttributeType | UpdateAtAttributeType | DeleteAtAttributeType | TriggerDataAttributeType | SeqAttributeType | TriggerUuidAttributeType; export declare const initinctiveAttributes: string[]; type FilterPart = { filter?: A extends 'create' ? undefined : F; indexFrom?: A extends 'create' ? undefined : number; count?: A extends 'create' ? undefined : number; }; export type SelectOption = { dontCollect?: boolean; blockTrigger?: true; forUpdate?: true | 'skip locked' | 'nowait'; includedDeleted?: true; ignoreAttrMiss?: true; dummy?: 1; }; export type OperateOption = { blockTrigger?: true; dontCollect?: boolean; dontCreateOper?: boolean; includedDeleted?: true; allowExists?: boolean; modiParentId?: string; modiParentEntity?: string; logId?: string; deletePhysically?: boolean; applyingModi?: boolean; dummy?: 1; }; export type FormUpdateData = Partial<{ [K in keyof Omit]: SH[K] | null; }>; export type FormCreateData = Partial & { id: string; }; export type Operation = { id: string; action: A; data: D; sorter?: S; bornAt?: number; } & FilterPart; export type Selection = { id?: string; action?: A; data: D; sorter?: S; } & FilterPart & { randomRange?: number; total?: number; distinct?: true; }; export interface EntityShape { id: PrimaryKey; $$seq$$: Sequence; $$createAt$$: number | Date; $$updateAt$$: number | Date; $$deleteAt$$?: number | Date | null; } export interface GeneralEntityShape extends EntityShape { [K: string]: any; } export type MakeAction = A; export interface EntityDef { Schema: GeneralEntityShape; OpSchema: GeneralEntityShape; Action: string; ParticularAction?: string; Selection: Selection<'select', Projection, Filter, Sorter>; Aggregation: DeduceAggregation; Operation: CUDOperation; CreateOperationData: CreateOperationData; Create: CreateOperation; CreateSingle: CreateSingleOperation; CreateMulti: CreateMultipleOperation; Update: UpdateOperation; Remove: RemoveOperation; Relation?: string; Filter: Filter; Projection: Projection; Sorter: Sorter; } export interface EntityDict { [E: string]: EntityDef; } export interface OtmSubProjection extends Omit, 'action'> { $entity: string; } export type AggregationOp = `#max-${number}` | `#min-${number}` | `#avg-${number}` | `#count-${number}` | `#sum-${number}`; export type DeduceAggregationData

= { [A in AggregationOp]?: P; } & OneOf<{ distinct?: true; '#aggr'?: P; }>; export type AggregationResult = Array<{ [A in AggregationOp]?: number | string; } & { '#data'?: Partial; }>; export type AttrFilter = { [K in keyof SH]?: any; }; type SortAttr = { [K: string]: any; }; type SorterItem = { $attr: SortAttr; $direction?: "asc" | "desc"; }; type Sorter = Array; type Filter = { [K: string]: any; }; type Projection = { [K: string]: any; }; export type DeduceAggregation

= Omit, F, S>, 'action'>; type CreateOperationData = { id: string; [K: string]: any; }; type CreateSingleOperation = Operation<'create', CreateOperationData, undefined, undefined>; type CreateMultipleOperation = Operation<'create', Array, undefined, undefined>; type CreateOperation = CreateSingleOperation | CreateMultipleOperation; type UpdateOperationData = { id?: never; [k: string]: any; }; export type UpdateOperation = Operation; type RemoveOperationData = { [k: string]: any; }; export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>; export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation; export type CreateOpResult = { id: string; a: 'c'; e: T; d: ED[T]['OpSchema'] | ED[T]['OpSchema'][]; }; export type UpdateOpResult = { id: string; a: string; e: T; d: UpdateOperationData; f?: Filter; }; export type RemoveOpResult = { id: string; a: 'r'; d: { [DeleteAtAttribute]: number; }; e: T; f?: Filter; }; export type RelationHierarchy = { [K in R]?: R[]; }; export type CascadeRelationItem = { cascadePath: string; relations?: string[]; }; export type CascadeRelationAuth = { [K in R]?: CascadeRelationItem | (CascadeRelationItem | CascadeRelationItem[])[]; }; export type SelectOpResult = { id?: string; a: 's'; d: { [T in keyof ED]?: { [ID: string]: Partial; }; }; }; export type OpRecord = CreateOpResult | UpdateOpResult | RemoveOpResult | SelectOpResult; export type OperationResult = { [K in keyof ED]?: { [A in ED[K]['Action']]?: number; }; }; export type ActionType = 'readOnly' | 'appendOnly' | 'excludeUpdate' | 'excludeRemove' | 'crud'; export type Configuration = { actionType?: ActionType; static?: boolean; }; export type AuthDeduceRelationMap = { [T in keyof ED]?: keyof ED[T]['OpSchema']; }; export type SelectFreeEntities = (keyof ED)[]; export type UpdateFreeDict = { [A in keyof ED]?: string[]; }; export type OtmKey = K | `${K}$${number}`; export interface SubDataDef { id: string; entity: T; filter: ED[T]['Filter']; } export {};