@nocobase/flow-engine 2.1.0-alpha.1 → 2.1.0-alpha.2
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/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +2 -0
- package/lib/JSRunner.d.ts +6 -0
- package/lib/JSRunner.js +32 -2
- package/lib/ViewScopedFlowEngine.js +3 -0
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/dnd/gridDragPlanner.d.ts +1 -0
- package/lib/components/dnd/gridDragPlanner.js +53 -1
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +5 -1
- package/lib/components/variables/VariableInput.js +9 -4
- package/lib/components/variables/VariableTag.js +46 -39
- package/lib/components/variables/utils.d.ts +7 -0
- package/lib/components/variables/utils.js +42 -2
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +84 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +163 -22
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2267 -148
- package/lib/flowEngine.d.ts +21 -0
- package/lib/flowEngine.js +55 -13
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.js +17 -11
- package/lib/index.d.ts +7 -1
- package/lib/index.js +21 -0
- package/lib/locale/en-US.json +9 -2
- package/lib/locale/index.d.ts +14 -0
- package/lib/locale/zh-CN.json +8 -1
- package/lib/models/CollectionFieldModel.d.ts +1 -0
- package/lib/models/CollectionFieldModel.js +3 -2
- package/lib/models/flowModel.d.ts +7 -0
- package/lib/models/flowModel.js +66 -1
- package/lib/provider.js +7 -6
- package/lib/resources/baseRecordResource.d.ts +5 -0
- package/lib/resources/baseRecordResource.js +24 -0
- package/lib/resources/multiRecordResource.d.ts +1 -0
- package/lib/resources/multiRecordResource.js +11 -4
- package/lib/resources/singleRecordResource.js +2 -0
- package/lib/resources/sqlResource.d.ts +4 -3
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +706 -41
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/helpers.js +12 -1
- package/lib/runjs-context/setup.js +6 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
- package/lib/scheduler/ModelOperationScheduler.js +25 -21
- package/lib/types.d.ts +27 -0
- package/lib/utils/associationObjectVariable.d.ts +2 -2
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/createEphemeralContext.js +2 -2
- package/lib/utils/dateVariable.d.ts +16 -0
- package/lib/utils/dateVariable.js +380 -0
- package/lib/utils/exceptions.d.ts +7 -0
- package/lib/utils/exceptions.js +10 -0
- package/lib/utils/index.d.ts +8 -3
- package/lib/utils/index.js +45 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
- package/lib/utils/resolveRunJSObjectValues.js +61 -0
- package/lib/utils/runjsModuleLoader.d.ts +58 -0
- package/lib/utils/runjsModuleLoader.js +422 -0
- package/lib/utils/runjsTemplateCompat.d.ts +35 -0
- package/lib/utils/runjsTemplateCompat.js +743 -0
- package/lib/utils/runjsValue.d.ts +29 -0
- package/lib/utils/runjsValue.js +275 -0
- package/lib/utils/safeGlobals.d.ts +18 -8
- package/lib/utils/safeGlobals.js +164 -17
- package/lib/utils/schema-utils.d.ts +10 -0
- package/lib/utils/schema-utils.js +61 -0
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/useDialog.js +8 -3
- package/lib/views/useDrawer.js +7 -2
- package/lib/views/usePage.d.ts +4 -0
- package/lib/views/usePage.js +43 -6
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +4 -4
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/JSRunner.ts +44 -2
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/JSRunner.test.ts +64 -0
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flowContext.test.ts +693 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
- package/src/__tests__/flowRuntimeContext.test.ts +2 -1
- package/src/__tests__/flowSettings.open.test.tsx +123 -19
- package/src/__tests__/provider.test.tsx +0 -5
- package/src/__tests__/runjsContext.test.ts +10 -7
- package/src/__tests__/runjsContextImplementations.test.ts +34 -3
- package/src/__tests__/runjsContextRuntime.test.ts +3 -3
- package/src/__tests__/runjsContributions.test.ts +89 -0
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/__tests__/gridDragPlanner.test.ts +141 -1
- package/src/components/dnd/gridDragPlanner.ts +60 -0
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
- package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +13 -2
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/variables/VariableInput.tsx +12 -4
- package/src/components/variables/VariableTag.tsx +54 -45
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
- package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
- package/src/components/variables/__tests__/utils.test.ts +81 -3
- package/src/components/variables/utils.ts +67 -6
- package/src/data-source/index.ts +88 -110
- package/src/executor/FlowExecutor.ts +200 -23
- package/src/executor/__tests__/flowExecutor.test.ts +66 -0
- package/src/flowContext.ts +2986 -211
- package/src/flowEngine.ts +58 -13
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +18 -12
- package/src/index.ts +14 -1
- package/src/locale/en-US.json +9 -2
- package/src/locale/zh-CN.json +8 -1
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +554 -0
- package/src/models/__tests__/flowModel.clone.test.ts +416 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +94 -1
- package/src/provider.tsx +9 -7
- package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
- package/src/resources/__tests__/sqlResource.test.ts +60 -0
- package/src/resources/baseRecordResource.ts +31 -0
- package/src/resources/multiRecordResource.ts +11 -4
- package/src/resources/singleRecordResource.ts +3 -0
- package/src/resources/sqlResource.ts +11 -6
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +715 -44
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/helpers.ts +11 -1
- package/src/runjs-context/setup.ts +6 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +27 -21
- package/src/types.ts +38 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/runjsValue.test.ts +44 -0
- package/src/utils/__tests__/safeGlobals.test.ts +57 -2
- package/src/utils/__tests__/utils.test.ts +95 -0
- package/src/utils/associationObjectVariable.ts +2 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/createEphemeralContext.ts +5 -4
- package/src/utils/dateVariable.ts +397 -0
- package/src/utils/exceptions.ts +11 -0
- package/src/utils/index.ts +37 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/resolveRunJSObjectValues.ts +46 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/runjsValue.ts +287 -0
- package/src/utils/safeGlobals.ts +188 -17
- package/src/utils/schema-utils.ts +79 -0
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/useDialog.tsx +9 -2
- package/src/views/useDrawer.tsx +8 -1
- package/src/views/usePage.tsx +51 -5
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
package/lib/flowEngine.d.ts
CHANGED
|
@@ -84,6 +84,17 @@ export declare class FlowEngine {
|
|
|
84
84
|
private _previousEngine?;
|
|
85
85
|
private _nextEngine?;
|
|
86
86
|
private _resources;
|
|
87
|
+
/**
|
|
88
|
+
* Data change registry used to coordinate "refresh on active" across view-scoped engines.
|
|
89
|
+
*
|
|
90
|
+
* Keyed by: dataSourceKey -> resourceName -> version.
|
|
91
|
+
* - mark: increments version
|
|
92
|
+
* - get: returns current version (default 0)
|
|
93
|
+
*
|
|
94
|
+
* NOTE: ViewScopedFlowEngine proxies delegate non-local fields/methods to parents, so this
|
|
95
|
+
* registry naturally lives on the root engine instance and is shared across the whole view stack.
|
|
96
|
+
*/
|
|
97
|
+
private _dataSourceDirtyVersions;
|
|
87
98
|
/**
|
|
88
99
|
* 引擎事件总线(目前用于模型生命周期等事件)。
|
|
89
100
|
* ViewScopedFlowEngine 持有自己的实例,实现作用域隔离。
|
|
@@ -116,6 +127,16 @@ export declare class FlowEngine {
|
|
|
116
127
|
getScheduler(): ModelOperationScheduler;
|
|
117
128
|
/** 释放并清理当前引擎本地调度器(若存在) */
|
|
118
129
|
disposeScheduler(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Mark a data source resource as "dirty" (changed).
|
|
132
|
+
* This is used by data blocks to decide whether to refresh when a view becomes active.
|
|
133
|
+
*/
|
|
134
|
+
markDataSourceDirty(dataSourceKey: string, resourceName: string): number;
|
|
135
|
+
/**
|
|
136
|
+
* Get current dirty version for a data source resource.
|
|
137
|
+
* Returns 0 when no writes have been recorded.
|
|
138
|
+
*/
|
|
139
|
+
getDataSourceDirtyVersion(dataSourceKey: string, resourceName: string): number;
|
|
119
140
|
/** 在目标模型生命周期达成时执行操作(仅在 View 引擎本地存储计划) */
|
|
120
141
|
scheduleModelOperation(fromModelOrUid: FlowModel | string, toUid: string, fn: (model: FlowModel) => Promise<void> | void, options?: ScheduleOptions): ScheduledCancel;
|
|
121
142
|
/** 上一个引擎(根引擎为 undefined) */
|
package/lib/flowEngine.js
CHANGED
|
@@ -120,6 +120,17 @@ const _FlowEngine = class _FlowEngine {
|
|
|
120
120
|
__publicField(this, "_previousEngine");
|
|
121
121
|
__publicField(this, "_nextEngine");
|
|
122
122
|
__publicField(this, "_resources", /* @__PURE__ */ new Map());
|
|
123
|
+
/**
|
|
124
|
+
* Data change registry used to coordinate "refresh on active" across view-scoped engines.
|
|
125
|
+
*
|
|
126
|
+
* Keyed by: dataSourceKey -> resourceName -> version.
|
|
127
|
+
* - mark: increments version
|
|
128
|
+
* - get: returns current version (default 0)
|
|
129
|
+
*
|
|
130
|
+
* NOTE: ViewScopedFlowEngine proxies delegate non-local fields/methods to parents, so this
|
|
131
|
+
* registry naturally lives on the root engine instance and is shared across the whole view stack.
|
|
132
|
+
*/
|
|
133
|
+
__publicField(this, "_dataSourceDirtyVersions", /* @__PURE__ */ new Map());
|
|
123
134
|
/**
|
|
124
135
|
* 引擎事件总线(目前用于模型生命周期等事件)。
|
|
125
136
|
* ViewScopedFlowEngine 持有自己的实例,实现作用域隔离。
|
|
@@ -187,6 +198,33 @@ const _FlowEngine = class _FlowEngine {
|
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Mark a data source resource as "dirty" (changed).
|
|
203
|
+
* This is used by data blocks to decide whether to refresh when a view becomes active.
|
|
204
|
+
*/
|
|
205
|
+
markDataSourceDirty(dataSourceKey, resourceName) {
|
|
206
|
+
const dsKey = String(dataSourceKey || "main");
|
|
207
|
+
const resName = String(resourceName || "");
|
|
208
|
+
if (!resName) return this.getDataSourceDirtyVersion(dsKey, resName);
|
|
209
|
+
const ds = this._dataSourceDirtyVersions.get(dsKey) || /* @__PURE__ */ new Map();
|
|
210
|
+
if (!this._dataSourceDirtyVersions.has(dsKey)) {
|
|
211
|
+
this._dataSourceDirtyVersions.set(dsKey, ds);
|
|
212
|
+
}
|
|
213
|
+
const next = (ds.get(resName) || 0) + 1;
|
|
214
|
+
ds.set(resName, next);
|
|
215
|
+
return next;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get current dirty version for a data source resource.
|
|
219
|
+
* Returns 0 when no writes have been recorded.
|
|
220
|
+
*/
|
|
221
|
+
getDataSourceDirtyVersion(dataSourceKey, resourceName) {
|
|
222
|
+
var _a;
|
|
223
|
+
const dsKey = String(dataSourceKey || "main");
|
|
224
|
+
const resName = String(resourceName || "");
|
|
225
|
+
if (!resName) return 0;
|
|
226
|
+
return ((_a = this._dataSourceDirtyVersions.get(dsKey)) == null ? void 0 : _a.get(resName)) || 0;
|
|
227
|
+
}
|
|
190
228
|
/** 在目标模型生命周期达成时执行操作(仅在 View 引擎本地存储计划) */
|
|
191
229
|
scheduleModelOperation(fromModelOrUid, toUid, fn, options) {
|
|
192
230
|
return this.getScheduler().schedule(fromModelOrUid, toUid, fn, options);
|
|
@@ -724,22 +762,26 @@ const _FlowEngine = class _FlowEngine {
|
|
|
724
762
|
*/
|
|
725
763
|
async loadModel(options) {
|
|
726
764
|
if (!this.ensureModelRepository()) return;
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
765
|
+
const refresh = !!(options == null ? void 0 : options.refresh);
|
|
766
|
+
if (!refresh) {
|
|
767
|
+
const model = this.findModelByParentId(options.parentId, options.subKey);
|
|
768
|
+
if (model) {
|
|
769
|
+
return model;
|
|
770
|
+
}
|
|
771
|
+
const hydrated = this.hydrateModelFromPreviousEngines(options);
|
|
772
|
+
if (hydrated) {
|
|
773
|
+
return hydrated;
|
|
731
774
|
}
|
|
732
|
-
}
|
|
733
|
-
const model = this.findModelByParentId(options.parentId, options.subKey);
|
|
734
|
-
if (model) {
|
|
735
|
-
return model;
|
|
736
|
-
}
|
|
737
|
-
const hydrated = this.hydrateModelFromPreviousEngines(options);
|
|
738
|
-
if (hydrated) {
|
|
739
|
-
return hydrated;
|
|
740
775
|
}
|
|
741
776
|
const data = await this._modelRepository.findOne(options);
|
|
742
|
-
|
|
777
|
+
if (!(data == null ? void 0 : data.uid)) return null;
|
|
778
|
+
if (refresh) {
|
|
779
|
+
const existing = this.getModel(data.uid);
|
|
780
|
+
if (existing) {
|
|
781
|
+
this.removeModelWithSubModels(existing.uid);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return this.createModel(data);
|
|
743
785
|
}
|
|
744
786
|
/**
|
|
745
787
|
* Find a sub-model by parent model ID and subKey.
|
package/lib/flowI18n.js
CHANGED
|
@@ -56,11 +56,13 @@ const _FlowI18n = class _FlowI18n {
|
|
|
56
56
|
if (!keyOrTemplate || typeof keyOrTemplate !== "string") {
|
|
57
57
|
return keyOrTemplate;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if ((options == null ? void 0 : options.compareWith) && keyOrTemplate === options.compareWith) {
|
|
60
|
+
return keyOrTemplate;
|
|
61
|
+
}
|
|
62
|
+
if (this.isTemplate(keyOrTemplate)) {
|
|
63
|
+
return this.compileTemplate(keyOrTemplate);
|
|
62
64
|
}
|
|
63
|
-
return
|
|
65
|
+
return this.translateKey(keyOrTemplate, options);
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* 内部翻译方法
|
package/lib/flowSettings.js
CHANGED
|
@@ -62,7 +62,9 @@ var import_flowContext = require("./flowContext");
|
|
|
62
62
|
var import__ = require(".");
|
|
63
63
|
var import_useFlowSettingsContext = require("./hooks/useFlowSettingsContext");
|
|
64
64
|
var import_utils = require("./utils");
|
|
65
|
+
var import_exceptions = require("./utils/exceptions");
|
|
65
66
|
var import_useFlowStep = require("./hooks/useFlowStep");
|
|
67
|
+
var import_views = require("./views");
|
|
66
68
|
var _forceEnabled, _emitter;
|
|
67
69
|
const Panel = import_antd.Collapse.Panel;
|
|
68
70
|
const _FlowSettings = class _FlowSettings {
|
|
@@ -536,12 +538,9 @@ const _FlowSettings = class _FlowSettings {
|
|
|
536
538
|
};
|
|
537
539
|
let modeProps = typeof resolvedUiMode === "object" && resolvedUiMode ? resolvedUiMode.props || {} : {};
|
|
538
540
|
if (modeType === "embed") {
|
|
539
|
-
const target = document.querySelector(
|
|
541
|
+
const target = document.querySelector(`#${import_views.GLOBAL_EMBED_CONTAINER_ID}`);
|
|
540
542
|
const onOpen = modeProps.onOpen;
|
|
541
543
|
const onClose = modeProps.onClose;
|
|
542
|
-
if (target) {
|
|
543
|
-
target.innerHTML = "";
|
|
544
|
-
}
|
|
545
544
|
modeProps = {
|
|
546
545
|
target,
|
|
547
546
|
styles: {
|
|
@@ -551,15 +550,19 @@ const _FlowSettings = class _FlowSettings {
|
|
|
551
550
|
},
|
|
552
551
|
...modeProps,
|
|
553
552
|
onOpen() {
|
|
554
|
-
target
|
|
555
|
-
|
|
556
|
-
|
|
553
|
+
if (target) {
|
|
554
|
+
target.style.width = modeProps.width || "33.3%";
|
|
555
|
+
target.style.maxWidth = modeProps.maxWidth || "800px";
|
|
556
|
+
target.style.minWidth = modeProps.minWidth || "0px";
|
|
557
|
+
}
|
|
557
558
|
onOpen == null ? void 0 : onOpen();
|
|
558
559
|
},
|
|
559
560
|
onClose() {
|
|
560
|
-
target.
|
|
561
|
-
|
|
562
|
-
|
|
561
|
+
if (target && target.dataset[import_views.EMBED_REPLACING_DATA_KEY] !== "1") {
|
|
562
|
+
target.style.width = "auto";
|
|
563
|
+
target.style.maxWidth = "none";
|
|
564
|
+
target.style.minWidth = "auto";
|
|
565
|
+
}
|
|
563
566
|
onClose == null ? void 0 : onClose();
|
|
564
567
|
}
|
|
565
568
|
};
|
|
@@ -711,7 +714,10 @@ const _FlowSettings = class _FlowSettings {
|
|
|
711
714
|
console.error("FlowSettings.open: onSaved callback error", cbErr);
|
|
712
715
|
}
|
|
713
716
|
} catch (err) {
|
|
714
|
-
if (err instanceof import_utils.
|
|
717
|
+
if (err instanceof import_utils.FlowCancelSaveException) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (err instanceof import_utils.FlowExitException || err instanceof import_exceptions.FlowExitAllException) {
|
|
715
721
|
currentView.close();
|
|
716
722
|
return;
|
|
717
723
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
export * from './types';
|
|
10
10
|
export * from './utils';
|
|
11
11
|
export { compileRunJs } from './utils/jsxTransform';
|
|
12
|
+
export { registerRunJSLib } from './runjsLibs';
|
|
13
|
+
export type { RunJSLibCache, RunJSLibLoader } from './runjsLibs';
|
|
12
14
|
export * from './resources';
|
|
13
15
|
export * from './flowEngine';
|
|
14
16
|
export * from './hooks';
|
|
@@ -25,8 +27,12 @@ export * from './JSRunner';
|
|
|
25
27
|
export { getRunJSDocFor, createJSRunnerWithVersion, getRunJSScenesForModel, getRunJSScenesForContext, } from './runjs-context/helpers';
|
|
26
28
|
export { RunJSContextRegistry, getModelClassName } from './runjs-context/registry';
|
|
27
29
|
export { setupRunJSContexts } from './runjs-context/setup';
|
|
28
|
-
export {
|
|
30
|
+
export type { RunJSContextContribution, RunJSContextContributionApi } from './runjs-context/contributions';
|
|
31
|
+
export { registerRunJSContextContribution } from './runjs-context/contributions';
|
|
32
|
+
export type { RunJSSnippetLoader } from './runjs-context/snippets';
|
|
33
|
+
export { getSnippetBody, listSnippetsForContext, registerRunJSSnippet } from './runjs-context/snippets';
|
|
29
34
|
export * from './views';
|
|
35
|
+
export { DATA_SOURCE_DIRTY_EVENT, ENGINE_SCOPE_KEY, getEmitterViewActivatedVersion, VIEW_ACTIVATED_EVENT, VIEW_ACTIVATED_VERSION, VIEW_ENGINE_SCOPE, } from './views/viewEvents';
|
|
30
36
|
export * from './FlowDefinition';
|
|
31
37
|
export { createViewScopedEngine } from './ViewScopedFlowEngine';
|
|
32
38
|
export { createBlockScopedEngine } from './BlockScopedFlowEngine';
|
package/lib/index.js
CHANGED
|
@@ -27,23 +27,33 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var src_exports = {};
|
|
29
29
|
__export(src_exports, {
|
|
30
|
+
DATA_SOURCE_DIRTY_EVENT: () => import_viewEvents.DATA_SOURCE_DIRTY_EVENT,
|
|
31
|
+
ENGINE_SCOPE_KEY: () => import_viewEvents.ENGINE_SCOPE_KEY,
|
|
30
32
|
RunJSContextRegistry: () => import_registry.RunJSContextRegistry,
|
|
33
|
+
VIEW_ACTIVATED_EVENT: () => import_viewEvents.VIEW_ACTIVATED_EVENT,
|
|
34
|
+
VIEW_ACTIVATED_VERSION: () => import_viewEvents.VIEW_ACTIVATED_VERSION,
|
|
35
|
+
VIEW_ENGINE_SCOPE: () => import_viewEvents.VIEW_ENGINE_SCOPE,
|
|
31
36
|
compileRunJs: () => import_jsxTransform.compileRunJs,
|
|
32
37
|
createBlockScopedEngine: () => import_BlockScopedFlowEngine.createBlockScopedEngine,
|
|
33
38
|
createJSRunnerWithVersion: () => import_helpers.createJSRunnerWithVersion,
|
|
34
39
|
createViewScopedEngine: () => import_ViewScopedFlowEngine.createViewScopedEngine,
|
|
40
|
+
getEmitterViewActivatedVersion: () => import_viewEvents.getEmitterViewActivatedVersion,
|
|
35
41
|
getModelClassName: () => import_registry.getModelClassName,
|
|
36
42
|
getRunJSDocFor: () => import_helpers.getRunJSDocFor,
|
|
37
43
|
getRunJSScenesForContext: () => import_helpers.getRunJSScenesForContext,
|
|
38
44
|
getRunJSScenesForModel: () => import_helpers.getRunJSScenesForModel,
|
|
39
45
|
getSnippetBody: () => import_snippets.getSnippetBody,
|
|
40
46
|
listSnippetsForContext: () => import_snippets.listSnippetsForContext,
|
|
47
|
+
registerRunJSContextContribution: () => import_contributions.registerRunJSContextContribution,
|
|
48
|
+
registerRunJSLib: () => import_runjsLibs.registerRunJSLib,
|
|
49
|
+
registerRunJSSnippet: () => import_snippets.registerRunJSSnippet,
|
|
41
50
|
setupRunJSContexts: () => import_setup.setupRunJSContexts
|
|
42
51
|
});
|
|
43
52
|
module.exports = __toCommonJS(src_exports);
|
|
44
53
|
__reExport(src_exports, require("./types"), module.exports);
|
|
45
54
|
__reExport(src_exports, require("./utils"), module.exports);
|
|
46
55
|
var import_jsxTransform = require("./utils/jsxTransform");
|
|
56
|
+
var import_runjsLibs = require("./runjsLibs");
|
|
47
57
|
__reExport(src_exports, require("./resources"), module.exports);
|
|
48
58
|
__reExport(src_exports, require("./flowEngine"), module.exports);
|
|
49
59
|
__reExport(src_exports, require("./hooks"), module.exports);
|
|
@@ -60,24 +70,35 @@ __reExport(src_exports, require("./JSRunner"), module.exports);
|
|
|
60
70
|
var import_helpers = require("./runjs-context/helpers");
|
|
61
71
|
var import_registry = require("./runjs-context/registry");
|
|
62
72
|
var import_setup = require("./runjs-context/setup");
|
|
73
|
+
var import_contributions = require("./runjs-context/contributions");
|
|
63
74
|
var import_snippets = require("./runjs-context/snippets");
|
|
64
75
|
__reExport(src_exports, require("./views"), module.exports);
|
|
76
|
+
var import_viewEvents = require("./views/viewEvents");
|
|
65
77
|
__reExport(src_exports, require("./FlowDefinition"), module.exports);
|
|
66
78
|
var import_ViewScopedFlowEngine = require("./ViewScopedFlowEngine");
|
|
67
79
|
var import_BlockScopedFlowEngine = require("./BlockScopedFlowEngine");
|
|
68
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
81
|
0 && (module.exports = {
|
|
82
|
+
DATA_SOURCE_DIRTY_EVENT,
|
|
83
|
+
ENGINE_SCOPE_KEY,
|
|
70
84
|
RunJSContextRegistry,
|
|
85
|
+
VIEW_ACTIVATED_EVENT,
|
|
86
|
+
VIEW_ACTIVATED_VERSION,
|
|
87
|
+
VIEW_ENGINE_SCOPE,
|
|
71
88
|
compileRunJs,
|
|
72
89
|
createBlockScopedEngine,
|
|
73
90
|
createJSRunnerWithVersion,
|
|
74
91
|
createViewScopedEngine,
|
|
92
|
+
getEmitterViewActivatedVersion,
|
|
75
93
|
getModelClassName,
|
|
76
94
|
getRunJSDocFor,
|
|
77
95
|
getRunJSScenesForContext,
|
|
78
96
|
getRunJSScenesForModel,
|
|
79
97
|
getSnippetBody,
|
|
80
98
|
listSnippetsForContext,
|
|
99
|
+
registerRunJSContextContribution,
|
|
100
|
+
registerRunJSLib,
|
|
101
|
+
registerRunJSSnippet,
|
|
81
102
|
setupRunJSContexts,
|
|
82
103
|
...require("./types"),
|
|
83
104
|
...require("./utils"),
|
package/lib/locale/en-US.json
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"This is likely a NocoBase internals bug. Please open an issue at": "This is likely a NocoBase internals bug. Please open an issue at",
|
|
63
63
|
"This step has no configurable parameters": "This step has no configurable parameters",
|
|
64
64
|
"This variable is not available": "This variable is not available",
|
|
65
|
+
"Use return to output value": "Use return to output value",
|
|
65
66
|
"Try again": "Try again",
|
|
66
67
|
"Template created": "Template created",
|
|
67
68
|
"Template description": "Template description",
|
|
@@ -69,5 +70,11 @@
|
|
|
69
70
|
"Template name is required": "Template name is required",
|
|
70
71
|
"UID copied to clipboard": "UID copied to clipboard",
|
|
71
72
|
"createModelOptions must specify use property": "createModelOptions must specify \"use\" property",
|
|
72
|
-
"here": "here"
|
|
73
|
-
}
|
|
73
|
+
"here": "here",
|
|
74
|
+
"RunJS deprecated warning": "[RunJS][Deprecated] {{api}} is deprecated{{location}}",
|
|
75
|
+
"RunJS deprecated warning with message": "[RunJS][Deprecated] {{api}} {{message}}{{location}}",
|
|
76
|
+
"RunJS deprecated separator": "; ",
|
|
77
|
+
"RunJS deprecated replacedBy": "Use {{replacedBy}} instead",
|
|
78
|
+
"RunJS deprecated since": "since {{since}}",
|
|
79
|
+
"RunJS deprecated removedIn": "will be removed in {{removedIn}}"
|
|
80
|
+
}
|
package/lib/locale/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare const locales: {
|
|
|
71
71
|
"This is likely a NocoBase internals bug. Please open an issue at": string;
|
|
72
72
|
"This step has no configurable parameters": string;
|
|
73
73
|
"This variable is not available": string;
|
|
74
|
+
"Use return to output value": string;
|
|
74
75
|
"Try again": string;
|
|
75
76
|
"Template created": string;
|
|
76
77
|
"Template description": string;
|
|
@@ -79,6 +80,12 @@ export declare const locales: {
|
|
|
79
80
|
"UID copied to clipboard": string;
|
|
80
81
|
"createModelOptions must specify use property": string;
|
|
81
82
|
here: string;
|
|
83
|
+
"RunJS deprecated warning": string;
|
|
84
|
+
"RunJS deprecated warning with message": string;
|
|
85
|
+
"RunJS deprecated separator": string;
|
|
86
|
+
"RunJS deprecated replacedBy": string;
|
|
87
|
+
"RunJS deprecated since": string;
|
|
88
|
+
"RunJS deprecated removedIn": string;
|
|
82
89
|
};
|
|
83
90
|
'zh-CN': {
|
|
84
91
|
Add: string;
|
|
@@ -148,10 +155,17 @@ export declare const locales: {
|
|
|
148
155
|
"This is likely a NocoBase internals bug. Please open an issue at": string;
|
|
149
156
|
"This step has no configurable parameters": string;
|
|
150
157
|
"This variable is not available": string;
|
|
158
|
+
"Use return to output value": string;
|
|
151
159
|
"Try again": string;
|
|
152
160
|
"UID copied to clipboard": string;
|
|
153
161
|
"createModelOptions must specify use property": string;
|
|
154
162
|
here: string;
|
|
163
|
+
"RunJS deprecated warning": string;
|
|
164
|
+
"RunJS deprecated warning with message": string;
|
|
165
|
+
"RunJS deprecated separator": string;
|
|
166
|
+
"RunJS deprecated replacedBy": string;
|
|
167
|
+
"RunJS deprecated since": string;
|
|
168
|
+
"RunJS deprecated removedIn": string;
|
|
155
169
|
};
|
|
156
170
|
};
|
|
157
171
|
/**
|
package/lib/locale/zh-CN.json
CHANGED
|
@@ -66,8 +66,15 @@
|
|
|
66
66
|
"This is likely a NocoBase internals bug. Please open an issue at": "这可能是 NocoBase 内部错误。请在以下地址提交问题",
|
|
67
67
|
"This step has no configurable parameters": "此步骤没有可配置的参数",
|
|
68
68
|
"This variable is not available": "此变量不可用",
|
|
69
|
+
"Use return to output value": "使用 return 返回最终值",
|
|
69
70
|
"Try again": "重试",
|
|
70
71
|
"UID copied to clipboard": "UID 已复制到剪贴板",
|
|
71
72
|
"createModelOptions must specify use property": "createModelOptions 必须指定 \"use\" 属性",
|
|
72
|
-
"here": "这里"
|
|
73
|
+
"here": "这里",
|
|
74
|
+
"RunJS deprecated warning": "[RunJS][已废弃] {{api}}{{location}}",
|
|
75
|
+
"RunJS deprecated warning with message": "[RunJS][已废弃] {{api}} {{message}}{{location}}",
|
|
76
|
+
"RunJS deprecated separator": ";",
|
|
77
|
+
"RunJS deprecated replacedBy": "建议使用:{{replacedBy}}",
|
|
78
|
+
"RunJS deprecated since": "自 {{since}} 起",
|
|
79
|
+
"RunJS deprecated removedIn": "将在 {{removedIn}} 移除"
|
|
73
80
|
}
|
|
@@ -45,6 +45,7 @@ export declare class CollectionFieldModel<T extends DefaultStructure = DefaultSt
|
|
|
45
45
|
}): BindingOptions | null;
|
|
46
46
|
static bindModelToInterface(modelName: string, interfaceName: string | string[], options?: {
|
|
47
47
|
isDefault?: boolean;
|
|
48
|
+
order?: number;
|
|
48
49
|
defaultProps?: object | ((ctx: FlowEngineContext, fieldInstance: CollectionField) => object);
|
|
49
50
|
when?: (ctx: FlowEngineContext, fieldInstance: CollectionField) => boolean;
|
|
50
51
|
}): void;
|
|
@@ -182,7 +182,7 @@ const _CollectionFieldModel = class _CollectionFieldModel extends import_flowMod
|
|
|
182
182
|
if (!this.bindings.has(interfaceName)) {
|
|
183
183
|
return [];
|
|
184
184
|
}
|
|
185
|
-
const bindings = this.bindings.get(interfaceName);
|
|
185
|
+
const bindings = this.bindings.get(interfaceName).sort((a, b) => a.order - b.order);
|
|
186
186
|
return bindings.filter(
|
|
187
187
|
(binding) => ctx.engine.getModelClass(binding.modelName) && binding.when(ctx, collectionField)
|
|
188
188
|
);
|
|
@@ -245,7 +245,8 @@ const _CollectionFieldModel = class _CollectionFieldModel extends import_flowMod
|
|
|
245
245
|
modelName,
|
|
246
246
|
isDefault: options.isDefault || false,
|
|
247
247
|
defaultProps: options.defaultProps || null,
|
|
248
|
-
when: options.when || defaultWhen
|
|
248
|
+
when: options.when || defaultWhen,
|
|
249
|
+
order: options.order
|
|
249
250
|
});
|
|
250
251
|
this.currentBindings.set(interfaceName, bindings);
|
|
251
252
|
}
|
|
@@ -361,6 +361,13 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
361
361
|
}): Promise<void>;
|
|
362
362
|
get translate(): any;
|
|
363
363
|
serialize(): Record<string, any>;
|
|
364
|
+
/**
|
|
365
|
+
* 复制当前模型实例为一个新的实例。
|
|
366
|
+
* 新实例及其所有子模型都会有新的 uid,且不保留 root model 的 parent 关系。
|
|
367
|
+
* 内部所有引用旧 uid 的地方(如 parentId, parentUid 等)都会被替换为对应的新 uid。
|
|
368
|
+
* @returns {FlowModel} 复制后的新模型实例
|
|
369
|
+
*/
|
|
370
|
+
clone<T extends FlowModel = this>(): T;
|
|
364
371
|
/**
|
|
365
372
|
* Opens the flow settings dialog for this flow model.
|
|
366
373
|
* @param options - Configuration options for opening flow settings, excluding the model property
|
package/lib/models/flowModel.js
CHANGED
|
@@ -353,7 +353,18 @@ const _FlowModel = class _FlowModel {
|
|
|
353
353
|
const meta = Cls.meta;
|
|
354
354
|
const metaCreate = meta == null ? void 0 : meta.createModelOptions;
|
|
355
355
|
if (metaCreate && typeof metaCreate === "object" && metaCreate.subModels) {
|
|
356
|
-
|
|
356
|
+
const replaceArrays = /* @__PURE__ */ __name((objValue, srcValue) => {
|
|
357
|
+
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
|
|
358
|
+
return srcValue;
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
}, "replaceArrays");
|
|
362
|
+
mergedSubModels = import_lodash.default.mergeWith(
|
|
363
|
+
{},
|
|
364
|
+
import_lodash.default.cloneDeep(metaCreate.subModels || {}),
|
|
365
|
+
import_lodash.default.cloneDeep(subModels || {}),
|
|
366
|
+
replaceArrays
|
|
367
|
+
);
|
|
357
368
|
}
|
|
358
369
|
} catch (e) {
|
|
359
370
|
}
|
|
@@ -1119,6 +1130,60 @@ const _FlowModel = class _FlowModel {
|
|
|
1119
1130
|
}
|
|
1120
1131
|
return data;
|
|
1121
1132
|
}
|
|
1133
|
+
/**
|
|
1134
|
+
* 复制当前模型实例为一个新的实例。
|
|
1135
|
+
* 新实例及其所有子模型都会有新的 uid,且不保留 root model 的 parent 关系。
|
|
1136
|
+
* 内部所有引用旧 uid 的地方(如 parentId, parentUid 等)都会被替换为对应的新 uid。
|
|
1137
|
+
* @returns {FlowModel} 复制后的新模型实例
|
|
1138
|
+
*/
|
|
1139
|
+
clone() {
|
|
1140
|
+
if (!this.flowEngine) {
|
|
1141
|
+
throw new Error("FlowEngine is not set on this model. Please set flowEngine before cloning.");
|
|
1142
|
+
}
|
|
1143
|
+
const serialized = this.serialize();
|
|
1144
|
+
const uidMap = /* @__PURE__ */ new Map();
|
|
1145
|
+
const collectUids = /* @__PURE__ */ __name((data) => {
|
|
1146
|
+
if (data.uid && typeof data.uid === "string") {
|
|
1147
|
+
uidMap.set(data.uid, (0, import_secure.uid)());
|
|
1148
|
+
}
|
|
1149
|
+
if (data.subModels) {
|
|
1150
|
+
for (const key in data.subModels) {
|
|
1151
|
+
const subModel = data.subModels[key];
|
|
1152
|
+
if (Array.isArray(subModel)) {
|
|
1153
|
+
subModel.forEach((item) => collectUids(item));
|
|
1154
|
+
} else if (subModel && typeof subModel === "object") {
|
|
1155
|
+
collectUids(subModel);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}, "collectUids");
|
|
1160
|
+
collectUids(serialized);
|
|
1161
|
+
const replaceUidReferences = /* @__PURE__ */ __name((data, isRoot = false) => {
|
|
1162
|
+
if (data === null || data === void 0) {
|
|
1163
|
+
return data;
|
|
1164
|
+
}
|
|
1165
|
+
if (typeof data === "string") {
|
|
1166
|
+
return uidMap.get(data) ?? data;
|
|
1167
|
+
}
|
|
1168
|
+
if (Array.isArray(data)) {
|
|
1169
|
+
return data.map((item) => replaceUidReferences(item, false));
|
|
1170
|
+
}
|
|
1171
|
+
if (typeof data === "object") {
|
|
1172
|
+
const result = {};
|
|
1173
|
+
for (const key in data) {
|
|
1174
|
+
if (!Object.prototype.hasOwnProperty.call(data, key)) continue;
|
|
1175
|
+
if (isRoot && key === "parentId") {
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
result[key] = replaceUidReferences(data[key], false);
|
|
1179
|
+
}
|
|
1180
|
+
return result;
|
|
1181
|
+
}
|
|
1182
|
+
return data;
|
|
1183
|
+
}, "replaceUidReferences");
|
|
1184
|
+
const clonedData = replaceUidReferences(serialized, true);
|
|
1185
|
+
return this.flowEngine.createModel(clonedData);
|
|
1186
|
+
}
|
|
1122
1187
|
/**
|
|
1123
1188
|
* Opens the flow settings dialog for this flow model.
|
|
1124
1189
|
* @param options - Configuration options for opening flow settings, excluding the model property
|
package/lib/provider.js
CHANGED
|
@@ -79,17 +79,17 @@ const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) =
|
|
|
79
79
|
cache: false,
|
|
80
80
|
get: /* @__PURE__ */ __name((ctx) => new import_FlowView.FlowViewer(ctx, { drawer, embed, popover, dialog }), "get")
|
|
81
81
|
});
|
|
82
|
-
engine.context.defineProperty("themeToken", {
|
|
83
|
-
get: /* @__PURE__ */ __name(() => token, "get"),
|
|
84
|
-
observable: true,
|
|
85
|
-
cache: true
|
|
86
|
-
});
|
|
87
82
|
for (const item of Object.entries(context)) {
|
|
88
83
|
const [key, value] = item;
|
|
89
84
|
if (value) {
|
|
90
85
|
engine.context.defineProperty(key, { value });
|
|
91
86
|
}
|
|
92
87
|
}
|
|
88
|
+
engine.context.defineProperty("themeToken", {
|
|
89
|
+
get: /* @__PURE__ */ __name(() => token, "get"),
|
|
90
|
+
observable: true,
|
|
91
|
+
cache: true
|
|
92
|
+
});
|
|
93
93
|
engine.reactView.refresh();
|
|
94
94
|
}, [engine, drawer, modal, message, notification, config, popover, token, dialog, embed]);
|
|
95
95
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { ...config, locale: (_a = engine.context.locales) == null ? void 0 : _a.antd, popupMatchSelectWidth: false }, children, contextHolder, popoverContextHolder, pageContextHolder, dialogContextHolder);
|
|
@@ -97,9 +97,10 @@ const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) =
|
|
|
97
97
|
const useFlowEngine = /* @__PURE__ */ __name(({ throwError = true } = {}) => {
|
|
98
98
|
const context = (0, import_react.useContext)(FlowEngineReactContext);
|
|
99
99
|
if (!context && throwError) {
|
|
100
|
-
|
|
100
|
+
console.warn(
|
|
101
101
|
"useFlowEngine must be used within a FlowEngineProvider, and FlowEngineProvider must be supplied with an engine."
|
|
102
102
|
);
|
|
103
|
+
return;
|
|
103
104
|
}
|
|
104
105
|
return context;
|
|
105
106
|
}, "useFlowEngine");
|
|
@@ -30,6 +30,11 @@ export declare abstract class BaseRecordResource<TData = any> extends APIResourc
|
|
|
30
30
|
runAction<TData = any, TMeta = any>(action: string, options: any): Promise<any>;
|
|
31
31
|
setResourceName(resourceName: string): this;
|
|
32
32
|
getResourceName(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Mark current resource as dirty on the root FlowEngine.
|
|
35
|
+
* Used to coordinate "refresh on active" across view stacks.
|
|
36
|
+
*/
|
|
37
|
+
protected markDataSourceDirty(resourceName?: string): void;
|
|
33
38
|
setSourceId(sourceId: string | number): this;
|
|
34
39
|
getSourceId(): string | number;
|
|
35
40
|
setDataSourceKey(dataSourceKey: string): this;
|
|
@@ -44,6 +44,7 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
44
44
|
var import_apiResource = require("./apiResource");
|
|
45
45
|
var import_filterItem = require("./filterItem");
|
|
46
46
|
var import_flowResource = require("./flowResource");
|
|
47
|
+
var import_viewEvents = require("../views/viewEvents");
|
|
47
48
|
const _BaseRecordResource = class _BaseRecordResource extends import_apiResource.APIResource {
|
|
48
49
|
resourceName;
|
|
49
50
|
sourceId = null;
|
|
@@ -145,6 +146,29 @@ const _BaseRecordResource = class _BaseRecordResource extends import_apiResource
|
|
|
145
146
|
getResourceName() {
|
|
146
147
|
return this.resourceName;
|
|
147
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Mark current resource as dirty on the root FlowEngine.
|
|
151
|
+
* Used to coordinate "refresh on active" across view stacks.
|
|
152
|
+
*/
|
|
153
|
+
markDataSourceDirty(resourceName) {
|
|
154
|
+
var _a, _b;
|
|
155
|
+
const engine = this.context.engine;
|
|
156
|
+
if (!engine) return;
|
|
157
|
+
const dataSourceKey = this.getDataSourceKey() || "main";
|
|
158
|
+
const resName = resourceName || this.getResourceName();
|
|
159
|
+
if (!resName) return;
|
|
160
|
+
const affectedResourceNames = /* @__PURE__ */ new Set([String(resName)]);
|
|
161
|
+
if (typeof resName === "string" && resName.includes(".")) {
|
|
162
|
+
affectedResourceNames.add(resName.split(".")[0]);
|
|
163
|
+
}
|
|
164
|
+
for (const name of affectedResourceNames) {
|
|
165
|
+
engine.markDataSourceDirty(dataSourceKey, name);
|
|
166
|
+
}
|
|
167
|
+
(_b = (_a = engine.emitter) == null ? void 0 : _a.emit) == null ? void 0 : _b.call(_a, import_viewEvents.DATA_SOURCE_DIRTY_EVENT, {
|
|
168
|
+
dataSourceKey,
|
|
169
|
+
resourceNames: Array.from(affectedResourceNames)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
148
172
|
setSourceId(sourceId) {
|
|
149
173
|
this.sourceId = sourceId;
|
|
150
174
|
return this;
|
|
@@ -16,6 +16,7 @@ export declare class MultiRecordResource<TDataItem = any> extends BaseRecordReso
|
|
|
16
16
|
value: Record<string, any>;
|
|
17
17
|
};
|
|
18
18
|
private refreshTimer;
|
|
19
|
+
private refreshWaiters;
|
|
19
20
|
protected createActionOptions: {};
|
|
20
21
|
protected updateActionOptions: {};
|
|
21
22
|
protected _refreshActionName: string;
|