@nocobase/flow-engine 2.0.0-alpha.21 → 2.0.0-alpha.23
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/components/settings/independents/dropdown/FlowsDropdownButton.js +2 -2
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +3 -3
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +2 -2
- package/lib/flowEngine.js +6 -4
- package/lib/flowSettings.js +5 -5
- package/lib/utils/params-resolvers.js +1 -1
- package/lib/utils/schema-utils.js +2 -2
- package/package.json +4 -4
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +1 -1
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +2 -2
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +1 -1
- package/src/flowEngine.ts +8 -4
- package/src/flowSettings.ts +1 -1
- package/src/utils/params-resolvers.ts +1 -1
- package/src/utils/schema-utils.ts +1 -1
|
@@ -96,7 +96,7 @@ const FlowsDropdownButtonWithModel = (0, import_react.observer)(
|
|
|
96
96
|
const flowsArray = Array.from(flows.values());
|
|
97
97
|
return flowsArray.map((flow) => {
|
|
98
98
|
const configurableSteps = Object.entries(flow.steps).map(([stepKey, stepDefinition]) => {
|
|
99
|
-
var _a
|
|
99
|
+
var _a;
|
|
100
100
|
const actionStep = stepDefinition;
|
|
101
101
|
if (actionStep.hideInSettings) {
|
|
102
102
|
return null;
|
|
@@ -104,7 +104,7 @@ const FlowsDropdownButtonWithModel = (0, import_react.observer)(
|
|
|
104
104
|
const stepUiSchema = actionStep.uiSchema || {};
|
|
105
105
|
let actionUiSchema = {};
|
|
106
106
|
if (actionStep.use) {
|
|
107
|
-
const action = (
|
|
107
|
+
const action = (_a = model.getAction) == null ? void 0 : _a.call(model, actionStep.use);
|
|
108
108
|
if (action && action.uiSchema) {
|
|
109
109
|
actionUiSchema = action.uiSchema;
|
|
110
110
|
}
|
|
@@ -222,7 +222,7 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
222
222
|
flowsArray.map(async (flow) => {
|
|
223
223
|
const configurableSteps = await Promise.all(
|
|
224
224
|
Object.entries(flow.steps).map(async ([stepKey, stepDefinition]) => {
|
|
225
|
-
var _a
|
|
225
|
+
var _a;
|
|
226
226
|
const actionStep = stepDefinition;
|
|
227
227
|
if (actionStep.hideInSettings) {
|
|
228
228
|
return null;
|
|
@@ -232,9 +232,9 @@ const DefaultSettingsIcon = /* @__PURE__ */ __name(({
|
|
|
232
232
|
let stepTitle = actionStep.title;
|
|
233
233
|
if (actionStep.use) {
|
|
234
234
|
try {
|
|
235
|
-
const action = (
|
|
235
|
+
const action = (_a = targetModel.getAction) == null ? void 0 : _a.call(targetModel, actionStep.use);
|
|
236
236
|
hasActionUiSchema = action && action.uiSchema != null;
|
|
237
|
-
stepTitle = stepTitle || action.title;
|
|
237
|
+
stepTitle = stepTitle || (action == null ? void 0 : action.title);
|
|
238
238
|
} catch (error) {
|
|
239
239
|
console.warn(t("Failed to get action {{action}}", { action: actionStep.use }), ":", error);
|
|
240
240
|
}
|
|
@@ -122,7 +122,7 @@ const FlowsContextMenuWithModel = (0, import_react.observer)(
|
|
|
122
122
|
const flowsArray = Array.from(flows.values());
|
|
123
123
|
return flowsArray.map((flow) => {
|
|
124
124
|
const configurableSteps = Object.entries(flow.steps).map(([stepKey, stepDefinition]) => {
|
|
125
|
-
var _a
|
|
125
|
+
var _a;
|
|
126
126
|
const actionStep = stepDefinition;
|
|
127
127
|
if (actionStep.hideInSettings) {
|
|
128
128
|
return null;
|
|
@@ -130,7 +130,7 @@ const FlowsContextMenuWithModel = (0, import_react.observer)(
|
|
|
130
130
|
const stepUiSchema = actionStep.uiSchema || {};
|
|
131
131
|
let actionUiSchema = {};
|
|
132
132
|
if (actionStep.use) {
|
|
133
|
-
const action = (
|
|
133
|
+
const action = (_a = model.getAction) == null ? void 0 : _a.call(model, actionStep.use);
|
|
134
134
|
if (action && action.uiSchema) {
|
|
135
135
|
actionUiSchema = action.uiSchema;
|
|
136
136
|
}
|
package/lib/flowEngine.js
CHANGED
|
@@ -714,7 +714,8 @@ const _FlowEngine = class _FlowEngine {
|
|
|
714
714
|
console.error("FlowModel.moveTo: Parent subModels must be an array to perform move operation.");
|
|
715
715
|
return false;
|
|
716
716
|
}
|
|
717
|
-
const
|
|
717
|
+
const subModelsCopy = [...subModels];
|
|
718
|
+
const findIndex = /* @__PURE__ */ __name((model) => subModelsCopy.findIndex((item) => item.uid === model.uid), "findIndex");
|
|
718
719
|
const currentIndex = findIndex(sourceModel2);
|
|
719
720
|
const targetIndex = findIndex(targetModel2);
|
|
720
721
|
if (currentIndex === -1 || targetIndex === -1) {
|
|
@@ -725,11 +726,12 @@ const _FlowEngine = class _FlowEngine {
|
|
|
725
726
|
console.warn("FlowModel.moveTo: Current model is already at the target position. No action taken.");
|
|
726
727
|
return false;
|
|
727
728
|
}
|
|
728
|
-
const [movedModel] =
|
|
729
|
-
|
|
730
|
-
|
|
729
|
+
const [movedModel] = subModelsCopy.splice(currentIndex, 1);
|
|
730
|
+
subModelsCopy.splice(targetIndex, 0, movedModel);
|
|
731
|
+
subModelsCopy.forEach((model, index) => {
|
|
731
732
|
model.sortIndex = index;
|
|
732
733
|
});
|
|
734
|
+
sourceModel2.parent.subModels[sourceModel2.subKey] = subModelsCopy;
|
|
733
735
|
return true;
|
|
734
736
|
}, "move");
|
|
735
737
|
move(sourceModel, targetModel);
|
package/lib/flowSettings.js
CHANGED
|
@@ -438,7 +438,7 @@ const _FlowSettings = class _FlowSettings {
|
|
|
438
438
|
* @returns {Promise<boolean>} 是否成功打开弹窗
|
|
439
439
|
*/
|
|
440
440
|
async open(options) {
|
|
441
|
-
var _a, _b, _c, _d, _e
|
|
441
|
+
var _a, _b, _c, _d, _e;
|
|
442
442
|
__privateGet(this, _emitter).emit("beforeOpen", options);
|
|
443
443
|
const { model, flowKey, flowKeys, stepKey, uiMode = "dialog", preset, onCancel, onSaved } = options;
|
|
444
444
|
if (!model) {
|
|
@@ -473,7 +473,7 @@ const _FlowSettings = class _FlowSettings {
|
|
|
473
473
|
let actionDefaultParams = {};
|
|
474
474
|
let uiMode2;
|
|
475
475
|
if (step.use) {
|
|
476
|
-
const action = (
|
|
476
|
+
const action = (_b = model.getAction) == null ? void 0 : _b.call(model, step.use);
|
|
477
477
|
if (action) {
|
|
478
478
|
actionDefaultParams = action.defaultParams || {};
|
|
479
479
|
stepTitle = stepTitle || action.title;
|
|
@@ -511,7 +511,7 @@ const _FlowSettings = class _FlowSettings {
|
|
|
511
511
|
}
|
|
512
512
|
if (entries.length === 0) {
|
|
513
513
|
if (!preset) {
|
|
514
|
-
(
|
|
514
|
+
(_c = message == null ? void 0 : message.info) == null ? void 0 : _c.call(message, t("This model has no configurable flow settings"));
|
|
515
515
|
}
|
|
516
516
|
return false;
|
|
517
517
|
}
|
|
@@ -523,7 +523,7 @@ const _FlowSettings = class _FlowSettings {
|
|
|
523
523
|
const scopes = {
|
|
524
524
|
// 为 schema 表达式提供上下文能力(可在表达式中使用 useFlowSettingsContext 等)
|
|
525
525
|
useFlowSettingsContext: import_useFlowSettingsContext.useFlowSettingsContext,
|
|
526
|
-
...((
|
|
526
|
+
...((_d = flowEngine == null ? void 0 : flowEngine.flowSettings) == null ? void 0 : _d.scopes) || {}
|
|
527
527
|
};
|
|
528
528
|
let modeProps = typeof resolvedUiMode === "object" && resolvedUiMode ? resolvedUiMode.props || {} : {};
|
|
529
529
|
if (modeType === "embed") {
|
|
@@ -537,7 +537,7 @@ const _FlowSettings = class _FlowSettings {
|
|
|
537
537
|
target,
|
|
538
538
|
styles: {
|
|
539
539
|
body: {
|
|
540
|
-
padding: (
|
|
540
|
+
padding: (_e = flowEngine.context.themeToken) == null ? void 0 : _e.padding
|
|
541
541
|
}
|
|
542
542
|
},
|
|
543
543
|
...modeProps,
|
|
@@ -277,7 +277,7 @@ async function compileExpression(expression, ctx) {
|
|
|
277
277
|
if (segs.length === 0) return base;
|
|
278
278
|
return (0, import_shared.getValuesByPath)(base, segs.join("."));
|
|
279
279
|
}, "resolveDotOnlyPath");
|
|
280
|
-
const singleMatch = expression.match(/^\{\{\s*(
|
|
280
|
+
const singleMatch = expression.match(/^\s*\{\{\s*([^{}]+?)\s*\}\}\s*$/);
|
|
281
281
|
if (singleMatch) {
|
|
282
282
|
const inner = singleMatch[1];
|
|
283
283
|
const dotPath = matchDotOnly(inner);
|
|
@@ -131,14 +131,14 @@ function compileUiSchema(scope, uiSchema, options = {}) {
|
|
|
131
131
|
}
|
|
132
132
|
__name(compileUiSchema, "compileUiSchema");
|
|
133
133
|
async function resolveStepUiSchema(model, flow, step) {
|
|
134
|
-
var _a
|
|
134
|
+
var _a;
|
|
135
135
|
const flowRuntimeContext = new import_flowContext.FlowRuntimeContext(model, flow.key, "settings");
|
|
136
136
|
(0, import_setupRuntimeContextSteps.setupRuntimeContextSteps)(flowRuntimeContext, flow.steps, model, flow.key);
|
|
137
137
|
flowRuntimeContext.defineProperty("currentStep", { value: step });
|
|
138
138
|
let stepUiSchema = step.uiSchema;
|
|
139
139
|
if (step.use) {
|
|
140
140
|
try {
|
|
141
|
-
const action = (
|
|
141
|
+
const action = (_a = model.getAction) == null ? void 0 : _a.call(model, step.use);
|
|
142
142
|
if (action && action.uiSchema) {
|
|
143
143
|
stepUiSchema = stepUiSchema || action.uiSchema;
|
|
144
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.0.0-alpha.
|
|
12
|
-
"@nocobase/shared": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/sdk": "2.0.0-alpha.23",
|
|
12
|
+
"@nocobase/shared": "2.0.0-alpha.23",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"dompurify": "^3.0.2",
|
|
15
15
|
"lodash": "^4.x",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
],
|
|
35
35
|
"author": "NocoBase Team",
|
|
36
36
|
"license": "AGPL-3.0",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ea67a7ad1c12fce26e0fff992f33de10901eff6a"
|
|
38
38
|
}
|
|
@@ -132,7 +132,7 @@ const FlowsDropdownButtonWithModel: React.FC<ModelProvidedProps> = observer(
|
|
|
132
132
|
// 如果step使用了action,也获取action的uiSchema
|
|
133
133
|
let actionUiSchema = {};
|
|
134
134
|
if (actionStep.use) {
|
|
135
|
-
const action = model.
|
|
135
|
+
const action = model.getAction?.(actionStep.use);
|
|
136
136
|
if (action && action.uiSchema) {
|
|
137
137
|
actionUiSchema = action.uiSchema;
|
|
138
138
|
}
|
|
@@ -278,9 +278,9 @@ export const DefaultSettingsIcon: React.FC<DefaultSettingsIconProps> = ({
|
|
|
278
278
|
let stepTitle = actionStep.title;
|
|
279
279
|
if (actionStep.use) {
|
|
280
280
|
try {
|
|
281
|
-
const action = targetModel.
|
|
281
|
+
const action = targetModel.getAction?.(actionStep.use);
|
|
282
282
|
hasActionUiSchema = action && action.uiSchema != null;
|
|
283
|
-
stepTitle = stepTitle || action
|
|
283
|
+
stepTitle = stepTitle || action?.title;
|
|
284
284
|
} catch (error) {
|
|
285
285
|
console.warn(t('Failed to get action {{action}}', { action: actionStep.use }), ':', error);
|
|
286
286
|
}
|
|
@@ -162,7 +162,7 @@ const FlowsContextMenuWithModel: React.FC<ModelProvidedProps> = observer(
|
|
|
162
162
|
// 如果step使用了action,也获取action的uiSchema
|
|
163
163
|
let actionUiSchema = {};
|
|
164
164
|
if (actionStep.use) {
|
|
165
|
-
const action = model.
|
|
165
|
+
const action = model.getAction?.(actionStep.use);
|
|
166
166
|
if (action && action.uiSchema) {
|
|
167
167
|
actionUiSchema = action.uiSchema;
|
|
168
168
|
}
|
package/src/flowEngine.ts
CHANGED
|
@@ -848,7 +848,8 @@ export class FlowEngine {
|
|
|
848
848
|
return false;
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
-
const
|
|
851
|
+
const subModelsCopy = [...subModels];
|
|
852
|
+
const findIndex = (model: FlowModel) => subModelsCopy.findIndex((item) => item.uid === model.uid);
|
|
852
853
|
|
|
853
854
|
const currentIndex = findIndex(sourceModel);
|
|
854
855
|
const targetIndex = findIndex(targetModel);
|
|
@@ -864,14 +865,17 @@ export class FlowEngine {
|
|
|
864
865
|
}
|
|
865
866
|
|
|
866
867
|
// 使用splice直接移动数组元素(O(n)比排序O(n log n)更快)
|
|
867
|
-
const [movedModel] =
|
|
868
|
-
|
|
868
|
+
const [movedModel] = subModelsCopy.splice(currentIndex, 1);
|
|
869
|
+
subModelsCopy.splice(targetIndex, 0, movedModel);
|
|
869
870
|
|
|
870
871
|
// 重新分配连续的sortIndex
|
|
871
|
-
|
|
872
|
+
subModelsCopy.forEach((model, index) => {
|
|
872
873
|
model.sortIndex = index;
|
|
873
874
|
});
|
|
874
875
|
|
|
876
|
+
// 更新父模型的subModels引用
|
|
877
|
+
sourceModel.parent.subModels[sourceModel.subKey] = subModelsCopy;
|
|
878
|
+
|
|
875
879
|
return true;
|
|
876
880
|
};
|
|
877
881
|
move(sourceModel, targetModel);
|
package/src/flowSettings.ts
CHANGED
|
@@ -604,7 +604,7 @@ export class FlowSettings {
|
|
|
604
604
|
let actionDefaultParams: Record<string, any> = {};
|
|
605
605
|
let uiMode;
|
|
606
606
|
if (step.use) {
|
|
607
|
-
const action =
|
|
607
|
+
const action = model.getAction?.(step.use);
|
|
608
608
|
if (action) {
|
|
609
609
|
actionDefaultParams = action.defaultParams || {};
|
|
610
610
|
stepTitle = stepTitle || action.title;
|
|
@@ -440,7 +440,7 @@ async function compileExpression<TModel extends FlowModel = FlowModel>(expressio
|
|
|
440
440
|
* ✅ "{{ctx.user}}" -> 捕获: "ctx.user"
|
|
441
441
|
* ❌ "Hello {{ ctx.user }}" -> 不匹配(不是纯表达式)
|
|
442
442
|
*/
|
|
443
|
-
const singleMatch = expression.match(/^\{\{\s*(
|
|
443
|
+
const singleMatch = expression.match(/^\s*\{\{\s*([^{}]+?)\s*\}\}\s*$/);
|
|
444
444
|
if (singleMatch) {
|
|
445
445
|
const inner = singleMatch[1];
|
|
446
446
|
const dotPath = matchDotOnly(inner);
|
|
@@ -181,7 +181,7 @@ export async function resolveStepUiSchema<TModel extends FlowModel = FlowModel>(
|
|
|
181
181
|
|
|
182
182
|
if (step.use) {
|
|
183
183
|
try {
|
|
184
|
-
const action = model.
|
|
184
|
+
const action = model.getAction?.(step.use);
|
|
185
185
|
if (action && action.uiSchema) {
|
|
186
186
|
stepUiSchema = stepUiSchema || action.uiSchema;
|
|
187
187
|
}
|