UNPKG

@nocobase/flow-engine

Version:

A standalone flow engine for NocoBase, managing workflows, models, and actions.

52 lines (51 loc) 2.81 kB
/** * 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 type { FlowContext, PropertyMeta, PropertyMetaFactory } from '../flowContext'; import type { JSONValue } from './params-resolvers'; import type { Collection } from '../data-source'; import { type RecordRef, type ServerContextParams } from '../utils/serverContextParams'; export declare function inferRecordRef(ctx: FlowContext): RecordRef | undefined; export declare function inferParentRecordRef(ctx: FlowContext): RecordRef | undefined; export type RecordParamsBuilder = (ctx: FlowContext) => RecordRef | Promise<RecordRef> | undefined; /** * Build a PropertyMeta for a record-like property with variablesParams included. */ export declare function buildRecordMeta(collectionAccessor: () => Collection | null, title?: string, paramsBuilder?: RecordParamsBuilder): Promise<PropertyMeta | null>; /** * Convenience helper to create a PropertyMetaFactory for a record-like variable. * It sets the factory.title so UI can display an immediate label before lazy resolution. */ export declare function createRecordMetaFactory(collectionAccessor: () => Collection | null, title: string, paramsBuilder?: RecordParamsBuilder): PropertyMetaFactory; /** * Sugar for the most common case: a current record meta bound to FlowContext. * - Title: t('Current record') * - Params: inferRecordRef(ctx) */ export declare function createCurrentRecordMetaFactory(ctx: FlowContext, collectionAccessor: () => Collection | null): PropertyMetaFactory; /** * Extract top-level ctx variable names used inside a JSON template. * Supports dot and bracket notations, e.g. {{ ctx.record.id }}, {{ ctx['parentRecord'].name }}. */ export declare const extractUsedVariableNames: any; /** * Extract used top-level ctx variables with their subpaths. * Returns a map: varName -> string[] subPaths * Examples: * - {{ ctx.user.id }} => { user: ['id'] } * - {{ ctx['user'].roles[0].name }} => { user: ['roles[0].name'] } * - {{ ctx.view.record.id }} => { view: ['record.id'] } * - {{ ctx.twice(21) }} => { twice: [''] } // method call -> empty subPath */ export declare const extractUsedVariablePaths: any; /** * 根据模板中用到的 ctx 变量,收集并构建服务端解析所需的 contextParams。 * - 通过 FlowContext 的 PropertyMeta.buildVariablesParams 收集 RecordRef * - 仅包含模板中实际使用到的顶层变量键,避免无谓膨胀 */ export declare function collectContextParamsForTemplate(ctx: FlowContext, template: JSONValue): Promise<ServerContextParams | undefined>;