/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ import { Cache } from '@nocobase/cache'; import { Repository, Transaction, Transactionable } from '@nocobase/database'; import { ChildOptions, SchemaNode, TargetPosition } from './dao/ui_schema_node_dao'; export interface GetJsonSchemaOptions { includeAsyncNode?: boolean; readFromCache?: boolean; transaction?: Transaction; } export interface GetPropertiesOptions { readFromCache?: boolean; transaction?: Transaction; } export interface FlowModelNodeSnapshot { uid: string; options: Record; parentId: string | null; subKey: string | null; async: boolean; } export type FlowModelAttachPosition = 'first' | 'last' | TargetPosition; export interface FlowModelAttachOptions { parentId: string; subKey: string; subType: 'array' | 'object'; position?: FlowModelAttachPosition; } type FlowModelMovePosition = 'before' | 'after'; interface FlowModelMoveOptions { sourceId: string; targetId: string; position?: FlowModelMovePosition; } type BreakRemoveOnType = { [key: string]: any; }; export interface removeParentOptions extends Transactionable { removeParentsIfNoChildren?: boolean; breakRemoveOn?: BreakRemoveOnType; } interface InsertAdjacentOptions extends removeParentOptions { wrap?: any; } export declare function transaction(transactionAbleArgPosition?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; export declare class FlowModelRepository extends Repository { cache: Cache; get flowModelsTableName(): any; get flowModelTreePathTableName(): any; static schemaToSingleNodes(schema: any, carry?: SchemaNode[], childOptions?: ChildOptions): SchemaNode[]; setCache(cache: Cache): void; /** * clear cache with xUid which in flowModelTreePath's Path * @param {string} xUid * @param {Transaction} transaction * @returns {Promise} */ clearXUidPathCache(xUid: string, transaction: Transaction): Promise; tableNameAdapter(tableName: any): any; sqlAdapter(sql: string): string; getProperties(uid: string, options?: GetPropertiesOptions): Promise>; getParentJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise; getParentProperty(uid: string, options?: GetPropertiesOptions): Promise; getJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise; static optionsToJson(options: any): any; private static getSortNumber; private static compareBySortAndUid; nodesToSchema(nodes: any, rootUid: any): { uid: any; "x-async": boolean; }; clearAncestor(uid: string, options?: Transactionable): Promise; emitAfterSaveEvent(s: any, options: any): Promise; patch(newSchema: any, options?: any): Promise; initializeActionContext(newSchema: any, options?: any): Promise; batchPatch(schemas: any[], options?: any): Promise; removeEmptyParents(options: Transactionable & { uid: string; breakRemoveOn?: BreakRemoveOnType; }): Promise; recursivelyRemoveIfNoChildren(options: Transactionable & { uid: string; breakRemoveOn?: BreakRemoveOnType; }): Promise; remove(uid: string, options?: Transactionable & removeParentOptions): Promise; insertAdjacent(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd', target: string, schema: any, options?: InsertAdjacentOptions): Promise; duplicate(modelUid: string, options?: Transactionable): Promise; private dedupeNodesForDuplicate; private replaceStepParamsModelUids; insert(schema: any, options?: Transactionable): Promise; insertNewSchema(schema: any, options?: Transactionable & { returnNode?: boolean; }): Promise; insertSingleNode(schema: SchemaNode, options: Transactionable & removeParentOptions): Promise; protected updateNode(uid: string, schema: any, transaction?: Transaction): Promise; protected childrenCount(uid: any, transaction: any): Promise; protected isLeafNode(uid: any, transaction: any): Promise; protected findParentUid(uid: any, transaction?: any): Promise; private findSiblingInfo; private findSiblingSortRows; private writeSiblingSorts; private normalizeSiblingSorts; private isAncestorOf; private updateModelParentOptions; protected findNodeSchemaWithParent(uid: any, transaction: any): Promise<{ parentUid: string; schema: any; }>; protected isSingleChild(uid: any, transaction: any): Promise; protected insertBeside(targetUid: string, schema: any, side: 'before' | 'after', options?: InsertAdjacentOptions): Promise; protected insertInner(targetUid: string, schema: any, position: 'first' | 'last', options?: InsertAdjacentOptions): Promise; protected insertAfterBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise; protected insertBeforeEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise; protected insertBeforeBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise; protected insertAfterEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise; protected insertNodes(nodes: SchemaNode[], options?: Transactionable): Promise; private doGetProperties; findNodesById(uid: string, options?: GetJsonSchemaOptions): Promise; private doGetJsonSchema; private ignoreSchemaProperties; private breakOnMatched; private schemaExists; private regenerateUid; private insertSchemaRecord; private prepareSingleNodeForInsert; static modelToSingleNodes(model: any, parentChildOptions?: any): SchemaNode[]; static nodeToModel(node: any): any; static nodesToModel(nodes: any[], rootUid: string): any; insertModel(model: any, options?: Transactionable): Promise; updateSingleNode(node: SchemaNode, options?: Transactionable): Promise; upsertModel(model: any, options?: Transactionable): Promise; findModelById(uid: string, options?: GetJsonSchemaOptions): Promise; findModelNodeSnapshotById(uid: string, options?: Transactionable): Promise; private findModelUidByParentId; findModelNodeSnapshotByParentId(parentUid: string, options?: Transactionable & { subKey?: string; }): Promise; findModelByParentId(parentUid: string, options?: GetJsonSchemaOptions & { subKey?: string; }): Promise; attach(uid: string, attachOptions: FlowModelAttachOptions, options?: Transactionable): Promise; move(options: FlowModelMoveOptions, transactionOptions?: Transactionable): Promise; } export default FlowModelRepository;