@nocobase/plugin-flow-engine 2.1.0-beta.2 → 2.1.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -661
- package/README.md +79 -9
- package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
- package/dist/ai/ai-employees/nathan/index.js +41 -0
- package/dist/ai/ai-employees/nathan/prompt.md +132 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
- package/dist/ai/docs/runjs/context/block-model.md +35 -35
- package/dist/ai/docs/runjs/context/collection-field.md +53 -51
- package/dist/ai/docs/runjs/context/collection.md +39 -39
- package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
- package/dist/ai/docs/runjs/context/data-source.md +52 -44
- package/dist/ai/docs/runjs/context/element.md +44 -38
- package/dist/ai/docs/runjs/context/exit-all.md +37 -35
- package/dist/ai/docs/runjs/context/exit.md +38 -35
- package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
- package/dist/ai/docs/runjs/context/form.md +57 -57
- package/dist/ai/docs/runjs/context/get-model.md +22 -21
- package/dist/ai/docs/runjs/context/get-value.md +20 -19
- package/dist/ai/docs/runjs/context/get-var.md +61 -55
- package/dist/ai/docs/runjs/context/i18n.md +17 -14
- package/dist/ai/docs/runjs/context/import-async.md +333 -45
- package/dist/ai/docs/runjs/context/init-resource.md +20 -20
- package/dist/ai/docs/runjs/context/libs.md +31 -31
- package/dist/ai/docs/runjs/context/location.md +34 -31
- package/dist/ai/docs/runjs/context/logger.md +41 -40
- package/dist/ai/docs/runjs/context/make-resource.md +27 -26
- package/dist/ai/docs/runjs/context/message.md +42 -41
- package/dist/ai/docs/runjs/context/modal.md +44 -44
- package/dist/ai/docs/runjs/context/model.md +36 -33
- package/dist/ai/docs/runjs/context/notification.md +41 -40
- package/dist/ai/docs/runjs/context/off.md +14 -14
- package/dist/ai/docs/runjs/context/on.md +30 -29
- package/dist/ai/docs/runjs/context/open-view.md +40 -40
- package/dist/ai/docs/runjs/context/render.md +37 -32
- package/dist/ai/docs/runjs/context/request.md +46 -45
- package/dist/ai/docs/runjs/context/require-async.md +28 -25
- package/dist/ai/docs/runjs/context/resource.md +34 -34
- package/dist/ai/docs/runjs/context/route.md +36 -34
- package/dist/ai/docs/runjs/context/router.md +43 -31
- package/dist/ai/docs/runjs/context/set-value.md +18 -17
- package/dist/ai/docs/runjs/context/sql.md +7 -15
- package/dist/ai/docs/runjs/context/t.md +20 -17
- package/dist/ai/docs/runjs/context/view.md +49 -46
- package/dist/ai/docs/runjs/document.md +1 -0
- package/dist/ai/docs/runjs/import-modules.md +32 -32
- package/dist/ai/docs/runjs/index.md +13 -13
- package/dist/ai/docs/runjs/jsx.md +19 -19
- package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
- package/dist/ai/docs/runjs/render.md +15 -15
- package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
- package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
- package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
- package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
- package/dist/ai/docs/runjs/window.md +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +12 -11
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/ses/dist/ses.cjs +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/collections/flowsql.js +1 -0
- package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
- package/dist/server/flow-surfaces/action-scope.js +156 -0
- package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
- package/dist/server/flow-surfaces/apply/compiler.js +969 -0
- package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
- package/dist/server/flow-surfaces/apply/layout.js +175 -0
- package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
- package/dist/server/flow-surfaces/apply/matching.js +181 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
- package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
- package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
- package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
- package/dist/server/flow-surfaces/approval/builder.js +384 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
- package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
- package/dist/server/flow-surfaces/approval/index.js +40 -0
- package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
- package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
- package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
- package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +192 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1029 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
- package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
- package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
- package/dist/server/flow-surfaces/blueprint/index.js +44 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +211 -0
- package/dist/server/flow-surfaces/builder.js +1097 -0
- package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
- package/dist/server/flow-surfaces/catalog-smart.js +239 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
- package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
- package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
- package/dist/server/flow-surfaces/catalog.d.ts +78 -0
- package/dist/server/flow-surfaces/catalog.js +3577 -0
- package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
- package/dist/server/flow-surfaces/chart-config.js +1394 -0
- package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
- package/dist/server/flow-surfaces/compose-compiler.js +167 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
- package/dist/server/flow-surfaces/compose-runtime.js +375 -0
- package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
- package/dist/server/flow-surfaces/configure-options.js +860 -0
- package/dist/server/flow-surfaces/constants.d.ts +351 -0
- package/dist/server/flow-surfaces/constants.js +104 -0
- package/dist/server/flow-surfaces/context.d.ts +72 -0
- package/dist/server/flow-surfaces/context.js +556 -0
- package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
- package/dist/server/flow-surfaces/contract-guard.js +402 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
- package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
- package/dist/server/flow-surfaces/default-action-popup.js +322 -0
- package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
- package/dist/server/flow-surfaces/default-block-actions.js +209 -0
- package/dist/server/flow-surfaces/errors.d.ts +47 -0
- package/dist/server/flow-surfaces/errors.js +145 -0
- package/dist/server/flow-surfaces/executor.d.ts +23 -0
- package/dist/server/flow-surfaces/executor.js +132 -0
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +83 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
- package/dist/server/flow-surfaces/filter-group.js +94 -0
- package/dist/server/flow-surfaces/index.d.ts +11 -0
- package/dist/server/flow-surfaces/index.js +302 -0
- package/dist/server/flow-surfaces/locator.d.ts +28 -0
- package/dist/server/flow-surfaces/locator.js +240 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +134 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +61 -0
- package/dist/server/flow-surfaces/placement.d.ts +33 -0
- package/dist/server/flow-surfaces/placement.js +198 -0
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
- package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
- package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/compiler.js +376 -0
- package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
- package/dist/server/flow-surfaces/planning/context.js +139 -0
- package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
- package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
- package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
- package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
- package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
- package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/runtime.js +259 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
- package/dist/server/flow-surfaces/planning/step-link.js +104 -0
- package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
- package/dist/server/flow-surfaces/planning/types.js +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
- package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
- package/dist/server/flow-surfaces/reaction/errors.js +69 -0
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
- package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
- package/dist/server/flow-surfaces/reaction/meta.js +451 -0
- package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
- package/dist/server/flow-surfaces/reaction/registry.js +206 -0
- package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
- package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
- package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
- package/dist/server/flow-surfaces/reaction/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
- package/dist/server/flow-surfaces/reaction/utils.js +67 -0
- package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
- package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
- package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
- package/dist/server/flow-surfaces/reference-guards.js +103 -0
- package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
- package/dist/server/flow-surfaces/route-sync.js +392 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +310 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
- package/dist/server/flow-surfaces/service-utils.js +811 -0
- package/dist/server/flow-surfaces/service.d.ts +814 -0
- package/dist/server/flow-surfaces/service.js +14276 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +271 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +440 -0
- package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
- package/dist/server/flow-surfaces/template-compatibility.js +189 -0
- package/dist/server/flow-surfaces/template-display.d.ts +20 -0
- package/dist/server/flow-surfaces/template-display.js +289 -0
- package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
- package/dist/server/flow-surfaces/template-service-utils.js +281 -0
- package/dist/server/flow-surfaces/types.d.ts +288 -0
- package/dist/server/flow-surfaces/types.js +24 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +7 -2
- package/dist/server/plugin.d.ts +0 -1
- package/dist/server/plugin.js +9 -34
- package/dist/server/repository.js +0 -5
- package/dist/server/variables/resolve.d.ts +21 -0
- package/dist/server/variables/resolve.js +79 -0
- package/dist/swagger/flow-surfaces.d.ts +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1572 -0
- package/dist/swagger/flow-surfaces.examples.js +1805 -0
- package/dist/swagger/flow-surfaces.js +5322 -0
- package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
- package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
- package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
- package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
- package/dist/swagger/index.d.ts +5969 -0
- package/dist/swagger/index.js +50 -0
- package/package.json +3 -3
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { FLOW_SURFACE_MUTATE_OP_TYPES, FLOW_SURFACE_PLAN_STEP_ACTIONS } from './constants';
|
|
10
|
+
export type FlowSurfaceNodeDomain = 'props' | 'decoratorProps' | 'stepParams' | 'flowRegistry';
|
|
11
|
+
export type FlowSurfaceMergeStrategy = 'deep' | 'replace';
|
|
12
|
+
export type FlowSurfaceActionScope = 'block' | 'record' | 'form' | 'filterForm' | 'actionPanel';
|
|
13
|
+
export type FlowSurfaceContainerKind = 'page' | 'tab' | 'grid' | 'block' | 'node';
|
|
14
|
+
export type FlowSurfaceReadLocator = {
|
|
15
|
+
uid?: string;
|
|
16
|
+
pageSchemaUid?: string;
|
|
17
|
+
tabSchemaUid?: string;
|
|
18
|
+
routeId?: string;
|
|
19
|
+
};
|
|
20
|
+
export type FlowSurfacePlanStepLink = {
|
|
21
|
+
step: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
};
|
|
24
|
+
export type FlowSurfaceKeySelector = {
|
|
25
|
+
key: string;
|
|
26
|
+
};
|
|
27
|
+
export type FlowSurfaceLocatorSelector = {
|
|
28
|
+
locator: FlowSurfaceReadLocator;
|
|
29
|
+
};
|
|
30
|
+
export type FlowSurfaceSurfaceSelector = FlowSurfaceKeySelector | FlowSurfaceLocatorSelector;
|
|
31
|
+
export type FlowSurfacePlanSelector = FlowSurfaceSurfaceSelector | FlowSurfacePlanStepLink;
|
|
32
|
+
export type FlowSurfaceBindKey = {
|
|
33
|
+
key: string;
|
|
34
|
+
locator: FlowSurfaceReadLocator;
|
|
35
|
+
expectedKind?: 'page' | 'tab' | 'grid' | 'block' | 'fieldHost' | 'action' | 'popupHost' | 'popupPage' | 'popupTab' | 'node';
|
|
36
|
+
rebind?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type FlowSurfaceWriteTarget = {
|
|
39
|
+
uid: string;
|
|
40
|
+
};
|
|
41
|
+
export type FlowSurfaceResolveTarget = FlowSurfaceReadLocator | FlowSurfaceWriteTarget;
|
|
42
|
+
export type FlowSurfaceConfigureOptionValueType = 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
43
|
+
export type FlowSurfaceConfigureOption = {
|
|
44
|
+
type: FlowSurfaceConfigureOptionValueType;
|
|
45
|
+
description?: string;
|
|
46
|
+
enum?: Array<string | number | boolean>;
|
|
47
|
+
example?: any;
|
|
48
|
+
supportsFlowContext?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type FlowSurfaceConfigureOptions = Record<string, FlowSurfaceConfigureOption>;
|
|
51
|
+
export type FlowSurfaceReadTarget = {
|
|
52
|
+
locator: FlowSurfaceReadLocator;
|
|
53
|
+
uid: string;
|
|
54
|
+
kind: FlowSurfaceContainerKind;
|
|
55
|
+
};
|
|
56
|
+
export type FlowSurfaceDomainContract = {
|
|
57
|
+
allowedKeys: string[];
|
|
58
|
+
wildcard?: boolean;
|
|
59
|
+
mergeStrategy: FlowSurfaceMergeStrategy;
|
|
60
|
+
schema: Record<string, any>;
|
|
61
|
+
pathSchemas?: Record<string, Record<string, any>>;
|
|
62
|
+
groups?: Record<string, FlowSurfaceDomainGroupContract>;
|
|
63
|
+
};
|
|
64
|
+
export type FlowSurfaceEventCapabilities = {
|
|
65
|
+
direct?: string[];
|
|
66
|
+
object?: string[];
|
|
67
|
+
};
|
|
68
|
+
export type FlowSurfaceDomainGroupContract = {
|
|
69
|
+
allowedPaths: string[];
|
|
70
|
+
clearable?: boolean;
|
|
71
|
+
mergeStrategy: FlowSurfaceMergeStrategy;
|
|
72
|
+
schema: Record<string, any>;
|
|
73
|
+
eventBindingSteps?: string[] | '*';
|
|
74
|
+
pathSchemas?: Record<string, Record<string, any>>;
|
|
75
|
+
};
|
|
76
|
+
export type FlowSurfaceEventBindingContract = {
|
|
77
|
+
stepKeys?: string[] | '*';
|
|
78
|
+
};
|
|
79
|
+
export type FlowSurfaceLayoutCapabilities = {
|
|
80
|
+
supported: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type FlowSurfaceNodeContract = {
|
|
83
|
+
editableDomains: FlowSurfaceNodeDomain[];
|
|
84
|
+
domains: Partial<Record<FlowSurfaceNodeDomain, FlowSurfaceDomainContract>>;
|
|
85
|
+
eventCapabilities?: FlowSurfaceEventCapabilities;
|
|
86
|
+
layoutCapabilities?: FlowSurfaceLayoutCapabilities;
|
|
87
|
+
eventBindings?: Record<string, FlowSurfaceEventBindingContract>;
|
|
88
|
+
};
|
|
89
|
+
export type FlowSurfaceResourceBindingKey = 'currentCollection' | 'currentRecord' | 'associatedRecords' | 'otherRecords';
|
|
90
|
+
export type FlowSurfaceResourceBindingAssociationField = {
|
|
91
|
+
key: string;
|
|
92
|
+
label: string;
|
|
93
|
+
collectionName: string;
|
|
94
|
+
associationName?: string;
|
|
95
|
+
};
|
|
96
|
+
export type FlowSurfaceResourceBindingOption = {
|
|
97
|
+
key: FlowSurfaceResourceBindingKey;
|
|
98
|
+
label: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
requires?: string[];
|
|
101
|
+
dataSourceKey?: string;
|
|
102
|
+
collectionName?: string;
|
|
103
|
+
associationFields?: FlowSurfaceResourceBindingAssociationField[];
|
|
104
|
+
};
|
|
105
|
+
export type FlowSurfaceSemanticResourceInput = {
|
|
106
|
+
binding: FlowSurfaceResourceBindingKey;
|
|
107
|
+
dataSourceKey?: string;
|
|
108
|
+
collectionName?: string;
|
|
109
|
+
associationField?: string;
|
|
110
|
+
};
|
|
111
|
+
export type FlowSurfaceCatalogItem = {
|
|
112
|
+
key: string;
|
|
113
|
+
label: string;
|
|
114
|
+
use: string;
|
|
115
|
+
kind: 'page' | 'tab' | 'block' | 'field' | 'action';
|
|
116
|
+
scope?: FlowSurfaceActionScope;
|
|
117
|
+
scene?: string;
|
|
118
|
+
requiredInitParams?: string[];
|
|
119
|
+
allowedContainerUses?: string[];
|
|
120
|
+
editableDomains?: FlowSurfaceNodeDomain[];
|
|
121
|
+
settingsSchema?: Record<string, any>;
|
|
122
|
+
settingsContract?: Partial<Record<FlowSurfaceNodeDomain, FlowSurfaceDomainContract>>;
|
|
123
|
+
configureOptions?: FlowSurfaceConfigureOptions;
|
|
124
|
+
resourceBindings?: FlowSurfaceResourceBindingOption[];
|
|
125
|
+
eventCapabilities?: FlowSurfaceEventCapabilities;
|
|
126
|
+
layoutCapabilities?: FlowSurfaceLayoutCapabilities;
|
|
127
|
+
createSupported?: boolean;
|
|
128
|
+
fieldUse?: string;
|
|
129
|
+
wrapperUse?: string;
|
|
130
|
+
renderer?: string;
|
|
131
|
+
type?: string;
|
|
132
|
+
associationPathName?: string;
|
|
133
|
+
defaultTargetUid?: string;
|
|
134
|
+
targetBlockUid?: string;
|
|
135
|
+
};
|
|
136
|
+
export type FlowSurfaceCatalogSection = 'blocks' | 'fields' | 'actions' | 'recordActions' | 'node';
|
|
137
|
+
export type FlowSurfaceCatalogExpand = 'item.configureOptions' | 'item.contracts' | 'item.allowedContainerUses' | 'node.contracts';
|
|
138
|
+
export type FlowSurfaceCatalogPopupScenario = {
|
|
139
|
+
kind: 'plainPopup' | 'recordPopup' | 'associationPopup';
|
|
140
|
+
scene: 'new' | 'one' | 'many' | 'select' | 'subForm' | 'bulkEditForm' | 'generic';
|
|
141
|
+
hasCurrentRecord: boolean;
|
|
142
|
+
hasAssociationContext: boolean;
|
|
143
|
+
};
|
|
144
|
+
export type FlowSurfaceCatalogFieldContainerScenario = {
|
|
145
|
+
kind: 'form' | 'details' | 'table' | 'filter-form';
|
|
146
|
+
targetMode?: 'single' | 'multiple';
|
|
147
|
+
};
|
|
148
|
+
export type FlowSurfaceCatalogActionContainerScenario = {
|
|
149
|
+
scope: FlowSurfaceActionScope;
|
|
150
|
+
ownerUse?: string;
|
|
151
|
+
recordActionContainerUse?: string;
|
|
152
|
+
};
|
|
153
|
+
export type FlowSurfaceCatalogScenario = {
|
|
154
|
+
surfaceKind: 'global' | FlowSurfaceContainerKind;
|
|
155
|
+
popup?: FlowSurfaceCatalogPopupScenario;
|
|
156
|
+
fieldContainer?: FlowSurfaceCatalogFieldContainerScenario;
|
|
157
|
+
actionContainer?: FlowSurfaceCatalogActionContainerScenario;
|
|
158
|
+
};
|
|
159
|
+
export type FlowSurfaceCatalogNodeInfo = {
|
|
160
|
+
editableDomains: FlowSurfaceNodeDomain[];
|
|
161
|
+
configureOptions: FlowSurfaceConfigureOptions;
|
|
162
|
+
settingsSchema?: Record<string, any>;
|
|
163
|
+
settingsContract?: Partial<Record<FlowSurfaceNodeDomain, FlowSurfaceDomainContract>>;
|
|
164
|
+
eventCapabilities?: FlowSurfaceEventCapabilities;
|
|
165
|
+
layoutCapabilities?: FlowSurfaceLayoutCapabilities;
|
|
166
|
+
};
|
|
167
|
+
export type FlowSurfaceCatalogValues = {
|
|
168
|
+
target?: FlowSurfaceWriteTarget;
|
|
169
|
+
sections?: FlowSurfaceCatalogSection[];
|
|
170
|
+
expand?: FlowSurfaceCatalogExpand[];
|
|
171
|
+
};
|
|
172
|
+
export type FlowSurfaceResolvedTarget = {
|
|
173
|
+
target: FlowSurfaceResolveTarget;
|
|
174
|
+
uid: string;
|
|
175
|
+
kind: FlowSurfaceContainerKind;
|
|
176
|
+
node?: any;
|
|
177
|
+
route?: any;
|
|
178
|
+
pageRoute?: any;
|
|
179
|
+
tabRoute?: any;
|
|
180
|
+
pageModel?: any;
|
|
181
|
+
};
|
|
182
|
+
export type FlowSurfaceCatalogResponse = {
|
|
183
|
+
target: FlowSurfaceResolvedTarget | null;
|
|
184
|
+
scenario: FlowSurfaceCatalogScenario;
|
|
185
|
+
selectedSections: FlowSurfaceCatalogSection[];
|
|
186
|
+
blocks?: FlowSurfaceCatalogItem[];
|
|
187
|
+
fields?: FlowSurfaceCatalogItem[];
|
|
188
|
+
actions?: FlowSurfaceCatalogItem[];
|
|
189
|
+
recordActions?: FlowSurfaceCatalogItem[];
|
|
190
|
+
node?: FlowSurfaceCatalogNodeInfo;
|
|
191
|
+
};
|
|
192
|
+
export type FlowSurfaceNodeSpec = {
|
|
193
|
+
uid?: string;
|
|
194
|
+
clientKey?: string;
|
|
195
|
+
sortIndex?: number;
|
|
196
|
+
async?: boolean;
|
|
197
|
+
use: string;
|
|
198
|
+
popup?: Record<string, any>;
|
|
199
|
+
props?: Record<string, any>;
|
|
200
|
+
decoratorProps?: Record<string, any>;
|
|
201
|
+
stepParams?: Record<string, any>;
|
|
202
|
+
flowRegistry?: Record<string, any>;
|
|
203
|
+
subModels?: Record<string, FlowSurfaceNodeSpec | FlowSurfaceNodeSpec[]>;
|
|
204
|
+
};
|
|
205
|
+
export type FlowSurfaceNodeSubModel = FlowSurfaceNodeSpec | FlowSurfaceNodeSpec[];
|
|
206
|
+
export type FlowSurfaceNodeDefaults = Partial<Pick<FlowSurfaceNodeSpec, 'async' | 'props' | 'decoratorProps' | 'stepParams' | 'flowRegistry' | 'subModels'>>;
|
|
207
|
+
export type FlowSurfaceApplyMode = 'replace';
|
|
208
|
+
export type FlowSurfaceComposeMode = 'append' | 'replace';
|
|
209
|
+
export type FlowSurfaceApplySpec = {
|
|
210
|
+
popup?: Record<string, any>;
|
|
211
|
+
props?: Record<string, any>;
|
|
212
|
+
decoratorProps?: Record<string, any>;
|
|
213
|
+
stepParams?: Record<string, any>;
|
|
214
|
+
flowRegistry?: Record<string, any>;
|
|
215
|
+
subModels?: Record<string, FlowSurfaceNodeSpec | FlowSurfaceNodeSpec[]>;
|
|
216
|
+
};
|
|
217
|
+
export type FlowSurfaceAtomicFlag = true;
|
|
218
|
+
export type FlowSurfaceMutateValues = {
|
|
219
|
+
ops?: FlowSurfaceMutateOp[];
|
|
220
|
+
atomic?: true;
|
|
221
|
+
};
|
|
222
|
+
export type FlowSurfaceApplyValues = {
|
|
223
|
+
target: FlowSurfaceWriteTarget;
|
|
224
|
+
spec: FlowSurfaceApplySpec;
|
|
225
|
+
mode?: 'replace';
|
|
226
|
+
};
|
|
227
|
+
export type FlowSurfaceComposeValues = {
|
|
228
|
+
target: FlowSurfaceWriteTarget;
|
|
229
|
+
mode?: FlowSurfaceComposeMode;
|
|
230
|
+
blocks?: Array<Record<string, any>>;
|
|
231
|
+
layout?: Record<string, any>;
|
|
232
|
+
};
|
|
233
|
+
export type FlowSurfaceConfigureValues = {
|
|
234
|
+
target: FlowSurfaceWriteTarget;
|
|
235
|
+
changes: Record<string, any>;
|
|
236
|
+
};
|
|
237
|
+
export type FlowSurfaceContextVarInfo = {
|
|
238
|
+
title?: string;
|
|
239
|
+
type?: string;
|
|
240
|
+
interface?: string;
|
|
241
|
+
description?: string;
|
|
242
|
+
enumValues?: string[];
|
|
243
|
+
min?: number;
|
|
244
|
+
max?: number;
|
|
245
|
+
disabled?: boolean;
|
|
246
|
+
disabledReason?: string;
|
|
247
|
+
properties?: Record<string, FlowSurfaceContextVarInfo>;
|
|
248
|
+
};
|
|
249
|
+
export type FlowSurfaceContextValues = {
|
|
250
|
+
target: FlowSurfaceWriteTarget;
|
|
251
|
+
path?: string;
|
|
252
|
+
maxDepth?: number;
|
|
253
|
+
};
|
|
254
|
+
export type FlowSurfaceContextResponse = {
|
|
255
|
+
vars: Record<string, FlowSurfaceContextVarInfo>;
|
|
256
|
+
};
|
|
257
|
+
export type FlowSurfaceDescribeValues = {
|
|
258
|
+
locator: FlowSurfaceReadLocator;
|
|
259
|
+
bindKeys?: FlowSurfaceBindKey[];
|
|
260
|
+
};
|
|
261
|
+
export type FlowSurfacePlanStepAction = (typeof FLOW_SURFACE_PLAN_STEP_ACTIONS)[number];
|
|
262
|
+
export type FlowSurfacePlanStep = {
|
|
263
|
+
id?: string;
|
|
264
|
+
action: FlowSurfacePlanStepAction;
|
|
265
|
+
selectors?: {
|
|
266
|
+
target?: FlowSurfacePlanSelector;
|
|
267
|
+
source?: FlowSurfacePlanSelector;
|
|
268
|
+
};
|
|
269
|
+
values?: Record<string, any>;
|
|
270
|
+
};
|
|
271
|
+
export type FlowSurfacePlanRequestValues = {
|
|
272
|
+
surface?: FlowSurfaceSurfaceSelector;
|
|
273
|
+
plan: {
|
|
274
|
+
steps?: FlowSurfacePlanStep[];
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
export type FlowSurfaceMutateOpType = (typeof FLOW_SURFACE_MUTATE_OP_TYPES)[number];
|
|
278
|
+
export type FlowSurfaceMutateOp = {
|
|
279
|
+
opId?: string;
|
|
280
|
+
type: FlowSurfaceMutateOpType;
|
|
281
|
+
target?: FlowSurfaceWriteTarget;
|
|
282
|
+
values?: Record<string, any>;
|
|
283
|
+
};
|
|
284
|
+
export type FlowSurfaceExecutorContext = {
|
|
285
|
+
transaction?: any;
|
|
286
|
+
keys: Map<string, any>;
|
|
287
|
+
clientKeyToUid: Record<string, string>;
|
|
288
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var types_exports = {};
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -37,12 +37,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
37
37
|
var server_exports = {};
|
|
38
38
|
__export(server_exports, {
|
|
39
39
|
FlowModelRepository: () => import_repository.FlowModelRepository,
|
|
40
|
-
default: () => import_plugin.default
|
|
40
|
+
default: () => import_plugin.default,
|
|
41
|
+
resolveVariablesBatch: () => import_resolve.resolveVariablesBatch,
|
|
42
|
+
resolveVariablesTemplate: () => import_resolve.resolveVariablesTemplate
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(server_exports);
|
|
43
45
|
var import_plugin = __toESM(require("./plugin"));
|
|
44
46
|
var import_repository = require("./repository");
|
|
47
|
+
var import_resolve = require("./variables/resolve");
|
|
45
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
49
|
0 && (module.exports = {
|
|
47
|
-
FlowModelRepository
|
|
50
|
+
FlowModelRepository,
|
|
51
|
+
resolveVariablesBatch,
|
|
52
|
+
resolveVariablesTemplate
|
|
48
53
|
});
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import PluginUISchemaStorageServer from './server';
|
|
10
10
|
export declare class PluginFlowEngineServer extends PluginUISchemaStorageServer {
|
|
11
|
-
private globalContext;
|
|
12
11
|
afterAdd(): Promise<void>;
|
|
13
12
|
beforeLoad(): Promise<void>;
|
|
14
13
|
getDatabaseByDataSourceKey(dataSourceKey?: string): import("@nocobase/database").default;
|
package/dist/server/plugin.js
CHANGED
|
@@ -41,13 +41,10 @@ __export(plugin_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(plugin_exports);
|
|
43
43
|
var import_utils = require("@nocobase/utils");
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
var import_utils2 = require("./variables/utils");
|
|
49
|
-
class PluginFlowEngineServer extends import_server2.default {
|
|
50
|
-
globalContext;
|
|
44
|
+
var import_flow_surfaces = require("./flow-surfaces");
|
|
45
|
+
var import_server = __toESM(require("./server"));
|
|
46
|
+
var import_resolve = require("./variables/resolve");
|
|
47
|
+
class PluginFlowEngineServer extends import_server.default {
|
|
51
48
|
async afterAdd() {
|
|
52
49
|
}
|
|
53
50
|
async beforeLoad() {
|
|
@@ -62,12 +59,11 @@ class PluginFlowEngineServer extends import_server2.default {
|
|
|
62
59
|
return cm.db;
|
|
63
60
|
}
|
|
64
61
|
async load() {
|
|
65
|
-
var _a, _b;
|
|
66
62
|
await super.load();
|
|
63
|
+
(0, import_flow_surfaces.registerFlowSurfacesResource)(this);
|
|
67
64
|
this.app.auditManager.registerAction("flowSql:save");
|
|
68
65
|
this.app.auditManager.registerAction("flowModels:save");
|
|
69
66
|
this.app.auditManager.registerAction("flowModels:duplicate");
|
|
70
|
-
this.globalContext = new import_contexts.GlobalContext((_b = (_a = this.app.environment) == null ? void 0 : _a.getVariables) == null ? void 0 : _b.call(_a));
|
|
71
67
|
this.app.acl.allow("flowSql", "runById", "loggedIn");
|
|
72
68
|
this.app.acl.allow("flowSql", "getBind", "loggedIn");
|
|
73
69
|
this.app.acl.allow("variables", "resolve", "loggedIn");
|
|
@@ -77,28 +73,12 @@ class PluginFlowEngineServer extends import_server2.default {
|
|
|
77
73
|
actions: {
|
|
78
74
|
// 解析 JSON 模板中的 ctx 变量
|
|
79
75
|
resolve: async (ctx, next) => {
|
|
80
|
-
var
|
|
81
|
-
const raw = ((
|
|
76
|
+
var _a, _b;
|
|
77
|
+
const raw = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? {};
|
|
82
78
|
const values = typeof (raw == null ? void 0 : raw.values) !== "undefined" ? raw.values : raw;
|
|
83
79
|
if (Array.isArray(values == null ? void 0 : values.batch)) {
|
|
84
80
|
const batchItems = values.batch;
|
|
85
|
-
await (0,
|
|
86
|
-
ctx,
|
|
87
|
-
batchItems.map((it) => ({
|
|
88
|
-
template: it.template,
|
|
89
|
-
contextParams: it.contextParams || {}
|
|
90
|
-
}))
|
|
91
|
-
);
|
|
92
|
-
const results = [];
|
|
93
|
-
for (const item of batchItems) {
|
|
94
|
-
const template2 = (item == null ? void 0 : item.template) ?? {};
|
|
95
|
-
const contextParams2 = (item == null ? void 0 : item.contextParams) || {};
|
|
96
|
-
const requestCtx2 = new import_contexts.HttpRequestContext(ctx);
|
|
97
|
-
requestCtx2.delegate(this.globalContext);
|
|
98
|
-
await import_registry.variables.attachUsedVariables(requestCtx2, ctx, template2, contextParams2);
|
|
99
|
-
const resolved2 = await (0, import_resolver.resolveJsonTemplate)(template2, requestCtx2);
|
|
100
|
-
results.push({ id: item == null ? void 0 : item.id, data: resolved2 });
|
|
101
|
-
}
|
|
81
|
+
const results = await (0, import_resolve.resolveVariablesBatch)(ctx, batchItems);
|
|
102
82
|
ctx.body = { results };
|
|
103
83
|
await next();
|
|
104
84
|
return;
|
|
@@ -111,12 +91,7 @@ class PluginFlowEngineServer extends import_server2.default {
|
|
|
111
91
|
}
|
|
112
92
|
const template = values.template;
|
|
113
93
|
const contextParams = (values == null ? void 0 : values.contextParams) || {};
|
|
114
|
-
await (0,
|
|
115
|
-
const requestCtx = new import_contexts.HttpRequestContext(ctx);
|
|
116
|
-
requestCtx.delegate(this.globalContext);
|
|
117
|
-
await import_registry.variables.attachUsedVariables(requestCtx, ctx, template, contextParams);
|
|
118
|
-
const resolved = await (0, import_resolver.resolveJsonTemplate)(template, requestCtx);
|
|
119
|
-
ctx.body = resolved;
|
|
94
|
+
ctx.body = await (0, import_resolve.resolveVariablesTemplate)(ctx, template, contextParams);
|
|
120
95
|
await next();
|
|
121
96
|
}
|
|
122
97
|
}
|
|
@@ -793,11 +793,6 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
|
|
|
793
793
|
transaction: transaction2
|
|
794
794
|
});
|
|
795
795
|
if (oldParentUid !== null && oldParentUid !== parentUid) {
|
|
796
|
-
await this.database.emitAsync("uiSchemaMove", savedNode, {
|
|
797
|
-
transaction: transaction2,
|
|
798
|
-
oldParentUid,
|
|
799
|
-
parentUid
|
|
800
|
-
});
|
|
801
796
|
if (options.removeParentsIfNoChildren) {
|
|
802
797
|
await this.recursivelyRemoveIfNoChildren({
|
|
803
798
|
transaction: transaction2,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResourcerContext } from '@nocobase/resourcer';
|
|
10
|
+
import { JSONValue } from '../template/resolver';
|
|
11
|
+
type ResolveBatchItem = {
|
|
12
|
+
id?: string | number;
|
|
13
|
+
template: JSONValue;
|
|
14
|
+
contextParams?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
export declare function resolveVariablesTemplate(ctx: ResourcerContext, template: JSONValue, contextParams?: Record<string, unknown>): Promise<any>;
|
|
17
|
+
export declare function resolveVariablesBatch(ctx: ResourcerContext, items: ResolveBatchItem[]): Promise<{
|
|
18
|
+
id?: string | number;
|
|
19
|
+
data: unknown;
|
|
20
|
+
}[]>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var resolve_exports = {};
|
|
28
|
+
__export(resolve_exports, {
|
|
29
|
+
resolveVariablesBatch: () => resolveVariablesBatch,
|
|
30
|
+
resolveVariablesTemplate: () => resolveVariablesTemplate
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(resolve_exports);
|
|
33
|
+
var import_contexts = require("../template/contexts");
|
|
34
|
+
var import_resolver = require("../template/resolver");
|
|
35
|
+
var import_registry = require("./registry");
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
const GLOBAL_CONTEXT_KEY = Symbol.for("nocobase.flow-engine.variables.global-context");
|
|
38
|
+
function getGlobalContext(ctx) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const app = ctx.app;
|
|
41
|
+
if (!app[GLOBAL_CONTEXT_KEY]) {
|
|
42
|
+
app[GLOBAL_CONTEXT_KEY] = new import_contexts.GlobalContext((_b = (_a = app.environment) == null ? void 0 : _a.getVariables) == null ? void 0 : _b.call(_a));
|
|
43
|
+
}
|
|
44
|
+
return app[GLOBAL_CONTEXT_KEY];
|
|
45
|
+
}
|
|
46
|
+
async function resolveVariablesTemplate(ctx, template, contextParams = {}) {
|
|
47
|
+
await (0, import_utils.prefetchRecordsForResolve)(ctx, [{ template, contextParams }]);
|
|
48
|
+
return resolveVariablesTemplateWithPrefetchedRecords(ctx, template, contextParams);
|
|
49
|
+
}
|
|
50
|
+
async function resolveVariablesTemplateWithPrefetchedRecords(ctx, template, contextParams = {}) {
|
|
51
|
+
const requestCtx = new import_contexts.HttpRequestContext(ctx);
|
|
52
|
+
requestCtx.delegate(getGlobalContext(ctx));
|
|
53
|
+
await import_registry.variables.attachUsedVariables(requestCtx, ctx, template, contextParams);
|
|
54
|
+
return (0, import_resolver.resolveJsonTemplate)(template, requestCtx);
|
|
55
|
+
}
|
|
56
|
+
async function resolveVariablesBatch(ctx, items) {
|
|
57
|
+
await (0, import_utils.prefetchRecordsForResolve)(
|
|
58
|
+
ctx,
|
|
59
|
+
items.map((item) => ({
|
|
60
|
+
template: (item == null ? void 0 : item.template) ?? {},
|
|
61
|
+
contextParams: (item == null ? void 0 : item.contextParams) || {}
|
|
62
|
+
}))
|
|
63
|
+
);
|
|
64
|
+
const results = [];
|
|
65
|
+
for (const item of items) {
|
|
66
|
+
const data = await resolveVariablesTemplateWithPrefetchedRecords(
|
|
67
|
+
ctx,
|
|
68
|
+
(item == null ? void 0 : item.template) ?? {},
|
|
69
|
+
(item == null ? void 0 : item.contextParams) || {}
|
|
70
|
+
);
|
|
71
|
+
results.push({ id: item == null ? void 0 : item.id, data });
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
resolveVariablesBatch,
|
|
78
|
+
resolveVariablesTemplate
|
|
79
|
+
});
|