@nocobase/plugin-flow-engine 2.1.0-beta.41 → 2.1.0-beta.42
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/dist/externalVersion.js +9 -9
- package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
- package/dist/node_modules/acorn/package.json +1 -1
- package/dist/node_modules/acorn-jsx/package.json +1 -1
- package/dist/node_modules/acorn-walk/package.json +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/apply/compiler.js +10 -11
- package/dist/server/flow-surfaces/authoring-validation.d.ts +1 -0
- package/dist/server/flow-surfaces/authoring-validation.js +614 -6
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -1
- package/dist/server/flow-surfaces/chart-config.js +192 -11
- package/dist/server/flow-surfaces/contract-guard.js +1 -1
- package/dist/server/flow-surfaces/event-flow-normalizer.d.ts +19 -0
- package/dist/server/flow-surfaces/event-flow-normalizer.js +128 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +2 -0
- package/dist/server/flow-surfaces/filter-group.js +295 -0
- package/dist/server/flow-surfaces/route-sync.js +19 -2
- package/dist/server/flow-surfaces/service-utils.js +1 -1
- package/dist/server/flow-surfaces/service.d.ts +3 -1
- package/dist/server/flow-surfaces/service.js +128 -64
- package/package.json +2 -2
|
@@ -588,12 +588,16 @@ function prepareFlowSurfaceApplyBlueprintDocument(input) {
|
|
|
588
588
|
if (tabs.length > 1 && (page == null ? void 0 : page.enableTabs) === false) {
|
|
589
589
|
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint page.enableTabs cannot be false when tabs.length > 1`);
|
|
590
590
|
}
|
|
591
|
+
const normalizedPage = tabs.length === 1 ? {
|
|
592
|
+
...page || {},
|
|
593
|
+
enableTabs: false
|
|
594
|
+
} : page;
|
|
591
595
|
return {
|
|
592
596
|
version: "1",
|
|
593
597
|
mode,
|
|
594
598
|
...target ? { target } : {},
|
|
595
599
|
...navigation ? { navigation } : {},
|
|
596
|
-
...
|
|
600
|
+
...normalizedPage ? { page: normalizedPage } : {},
|
|
597
601
|
...defaults ? { defaults } : {},
|
|
598
602
|
tabs,
|
|
599
603
|
assets,
|
|
@@ -64,7 +64,91 @@ __export(chart_config_exports, {
|
|
|
64
64
|
module.exports = __toCommonJS(chart_config_exports);
|
|
65
65
|
var import_lodash = __toESM(require("lodash"));
|
|
66
66
|
var import_errors = require("./errors");
|
|
67
|
+
var import_filter_group = require("./filter-group");
|
|
67
68
|
const CHART_REPAIR_HINT = "This is a chart payload shape problem. Repair the current chart query/visual mappings and keep the chart block type. Do not change this block type to table, jsBlock, actionPanel, gridCard, or another block type. KPI / summary numbers should use jsBlock; charts are for trends, distributions, rankings, and visual analysis.";
|
|
69
|
+
const CHART_FORBIDDEN_FALLBACKS = [
|
|
70
|
+
"table",
|
|
71
|
+
"list",
|
|
72
|
+
"jsBlock",
|
|
73
|
+
"actionPanel",
|
|
74
|
+
"gridCard",
|
|
75
|
+
"markdown",
|
|
76
|
+
"drop chart",
|
|
77
|
+
"defer chart"
|
|
78
|
+
];
|
|
79
|
+
const CHART_REPAIR_STEPS = [
|
|
80
|
+
"Keep the block type as chart.",
|
|
81
|
+
"Repair the chart query and visual mappings on the current chart payload.",
|
|
82
|
+
"Retry the chart payload instead of replacing the chart with another block type, omitting it, or deferring it."
|
|
83
|
+
];
|
|
84
|
+
const CHART_EXPECTED_SHAPE = {
|
|
85
|
+
settings: {
|
|
86
|
+
query: {
|
|
87
|
+
mode: "builder",
|
|
88
|
+
resource: {
|
|
89
|
+
dataSourceKey: "main",
|
|
90
|
+
collectionName: "employees"
|
|
91
|
+
},
|
|
92
|
+
measures: [
|
|
93
|
+
{
|
|
94
|
+
field: "id",
|
|
95
|
+
aggregation: "count",
|
|
96
|
+
alias: "employeeCount"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
visual: {
|
|
101
|
+
mode: "basic",
|
|
102
|
+
type: "bar",
|
|
103
|
+
mappings: {
|
|
104
|
+
x: "status",
|
|
105
|
+
y: "employeeCount"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function withChartRepairDetails(details = {}) {
|
|
111
|
+
return {
|
|
112
|
+
...details,
|
|
113
|
+
requiredBlockType: "chart",
|
|
114
|
+
fixStrategy: "repair_same_block_type",
|
|
115
|
+
repairHint: CHART_REPAIR_HINT,
|
|
116
|
+
repairSteps: CHART_REPAIR_STEPS,
|
|
117
|
+
expectedShape: CHART_EXPECTED_SHAPE,
|
|
118
|
+
repairExample: {
|
|
119
|
+
settings: {
|
|
120
|
+
query: {
|
|
121
|
+
mode: "builder",
|
|
122
|
+
resource: {
|
|
123
|
+
dataSourceKey: "main",
|
|
124
|
+
collectionName: "<collectionName>"
|
|
125
|
+
},
|
|
126
|
+
measures: [
|
|
127
|
+
{
|
|
128
|
+
field: "id",
|
|
129
|
+
aggregation: "count",
|
|
130
|
+
alias: "recordCount"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
dimensions: [
|
|
134
|
+
{
|
|
135
|
+
field: "<dimensionField>"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
visual: {
|
|
140
|
+
mode: "basic",
|
|
141
|
+
type: "bar",
|
|
142
|
+
mappings: {
|
|
143
|
+
x: "<dimensionField>",
|
|
144
|
+
y: "recordCount"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
forbiddenFallbacks: CHART_FORBIDDEN_FALLBACKS
|
|
150
|
+
};
|
|
151
|
+
}
|
|
68
152
|
function withChartRepairMessage(message) {
|
|
69
153
|
return `${message}. ${CHART_REPAIR_HINT}`;
|
|
70
154
|
}
|
|
@@ -86,10 +170,6 @@ const CHART_SORT_DIRECTIONS = ["asc", "desc"];
|
|
|
86
170
|
const CHART_SORT_NULLS = ["default", "first", "last"];
|
|
87
171
|
const CHART_LABEL_TYPES = ["value", "percent"];
|
|
88
172
|
const CHART_FUNNEL_SORTS = ["descending", "ascending"];
|
|
89
|
-
const EMPTY_FILTER_GROUP = {
|
|
90
|
-
logic: "$and",
|
|
91
|
-
items: []
|
|
92
|
-
};
|
|
93
173
|
const CHART_SAFE_DEFAULT_HINTS = [
|
|
94
174
|
{
|
|
95
175
|
key: "builder_basic_minimal",
|
|
@@ -406,7 +486,7 @@ function fromPersistedOrder(input) {
|
|
|
406
486
|
return CHART_SORT_DIRECTION_SET.has(normalized) ? normalized : void 0;
|
|
407
487
|
}
|
|
408
488
|
function createEmptyFilterGroup() {
|
|
409
|
-
return import_lodash.default.cloneDeep(
|
|
489
|
+
return import_lodash.default.cloneDeep(import_filter_group.FLOW_SURFACE_EMPTY_FILTER_GROUP);
|
|
410
490
|
}
|
|
411
491
|
function assertAllowedKeys(input, allowed, label) {
|
|
412
492
|
const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
|
|
@@ -530,13 +610,106 @@ function normalizeChartSortingItem(input, index) {
|
|
|
530
610
|
nulls: normalizeOptionalEnumValue(normalized.nulls, CHART_SORT_NULLS_SET, `${label}.nulls`)
|
|
531
611
|
});
|
|
532
612
|
}
|
|
613
|
+
function isFilterGroupLike(input) {
|
|
614
|
+
return import_lodash.default.isPlainObject(input) && isBackendQueryLogicKey(input.logic) && Array.isArray(input.items);
|
|
615
|
+
}
|
|
616
|
+
function assertFilterGroupKeys(input, label) {
|
|
617
|
+
if (!isFilterGroupLike(input)) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const unsupportedKeys = Object.keys(input).filter((key) => key !== "logic" && key !== "items");
|
|
621
|
+
if (unsupportedKeys.length) {
|
|
622
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label} does not support: ${unsupportedKeys.join(", ")}`);
|
|
623
|
+
}
|
|
624
|
+
if (Array.isArray(input.items)) {
|
|
625
|
+
input.items.forEach((item, index) => {
|
|
626
|
+
assertFilterGroupKeys(item, `${label}.items[${index}]`);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function isBackendQueryLogicKey(key) {
|
|
631
|
+
return key === "$and" || key === "$or";
|
|
632
|
+
}
|
|
633
|
+
function getBackendQueryLogicKey(input, label) {
|
|
634
|
+
const keys = Object.keys(input);
|
|
635
|
+
const logicKeys = keys.filter(isBackendQueryLogicKey);
|
|
636
|
+
if (!logicKeys.length) {
|
|
637
|
+
return void 0;
|
|
638
|
+
}
|
|
639
|
+
if (logicKeys.length > 1 || keys.length > 1) {
|
|
640
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
641
|
+
`${label}: cannot convert backend query filter with mixed logical and field conditions`
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
return logicKeys[0];
|
|
645
|
+
}
|
|
646
|
+
function convertBackendFieldConditionToFilterItems(field, condition, label) {
|
|
647
|
+
if (!field.trim() || field.startsWith("$")) {
|
|
648
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label}: cannot convert backend query filter field "${field}"`);
|
|
649
|
+
}
|
|
650
|
+
if (!import_lodash.default.isPlainObject(condition)) {
|
|
651
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label}.${field}: backend query filter condition must be an object`);
|
|
652
|
+
}
|
|
653
|
+
const operators = Object.keys(condition);
|
|
654
|
+
if (!operators.length) {
|
|
655
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label}.${field}: backend query filter condition cannot be empty`);
|
|
656
|
+
}
|
|
657
|
+
return operators.map((operator) => {
|
|
658
|
+
if (!operator.startsWith("$")) {
|
|
659
|
+
(0, import_filter_group.assertFlowSurfaceFilterOperator)(operator, `${label}.${field}.${operator}`);
|
|
660
|
+
}
|
|
661
|
+
if (!operator.startsWith("$") || isBackendQueryLogicKey(operator)) {
|
|
662
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
663
|
+
`${label}.${field}: cannot convert backend query filter operator "${operator}"`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
path: field,
|
|
668
|
+
operator,
|
|
669
|
+
value: import_lodash.default.cloneDeep(condition[operator])
|
|
670
|
+
};
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function convertBackendQueryFilterToFilterGroup(input, label) {
|
|
674
|
+
const logicKey = getBackendQueryLogicKey(input, label);
|
|
675
|
+
if (logicKey) {
|
|
676
|
+
const operands = input[logicKey];
|
|
677
|
+
if (!Array.isArray(operands)) {
|
|
678
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label}.${logicKey}: backend query filter operands must be an array`);
|
|
679
|
+
}
|
|
680
|
+
return {
|
|
681
|
+
logic: logicKey,
|
|
682
|
+
items: operands.map(
|
|
683
|
+
(operand, index) => convertBackendQueryOperandToFilterItem(operand, `${label}.${logicKey}[${index}]`)
|
|
684
|
+
)
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
return {
|
|
688
|
+
logic: "$and",
|
|
689
|
+
items: Object.entries(input).flatMap(
|
|
690
|
+
([field, condition]) => convertBackendFieldConditionToFilterItems(field, condition, label)
|
|
691
|
+
)
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function convertBackendQueryOperandToFilterItem(input, label) {
|
|
695
|
+
if (isFilterGroupLike(input)) {
|
|
696
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${label}: cannot mix filter groups with backend query filters`);
|
|
697
|
+
}
|
|
698
|
+
const group = convertBackendQueryFilterToFilterGroup(ensurePlainObject(input, label), label);
|
|
699
|
+
if (group.logic === "$and" && group.items.length === 1) {
|
|
700
|
+
return group.items[0];
|
|
701
|
+
}
|
|
702
|
+
return group;
|
|
703
|
+
}
|
|
533
704
|
function normalizeFilterGroupValue(input, label) {
|
|
534
705
|
if (import_lodash.default.isUndefined(input) || import_lodash.default.isNull(input)) {
|
|
535
706
|
return void 0;
|
|
536
707
|
}
|
|
537
708
|
const normalized = ensurePlainObject(input, label);
|
|
538
|
-
|
|
539
|
-
|
|
709
|
+
assertFilterGroupKeys(normalized, label);
|
|
710
|
+
const filterGroup = !Object.keys(normalized).length || isFilterGroupLike(normalized) ? (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(normalized, label) : (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(convertBackendQueryFilterToFilterGroup(normalized, label), label);
|
|
711
|
+
validateFilterGroupPaths(filterGroup, label);
|
|
712
|
+
return filterGroup;
|
|
540
713
|
}
|
|
541
714
|
function validateFilterGroupPaths(input, label) {
|
|
542
715
|
const items = Array.isArray(input == null ? void 0 : input.items) ? input.items : [];
|
|
@@ -568,6 +741,7 @@ function inferQueryMode(query) {
|
|
|
568
741
|
}
|
|
569
742
|
function validateLooseChartQuery(query) {
|
|
570
743
|
inferQueryMode(query);
|
|
744
|
+
validateChartQueryFilterOperators(query);
|
|
571
745
|
if (!hasOwn(query, "resource") || !hasOwn(query, "collectionPath")) {
|
|
572
746
|
return;
|
|
573
747
|
}
|
|
@@ -582,6 +756,11 @@ function validateLooseChartQuery(query) {
|
|
|
582
756
|
);
|
|
583
757
|
}
|
|
584
758
|
}
|
|
759
|
+
function validateChartQueryFilterOperators(query) {
|
|
760
|
+
if (hasOwn(query, "filter")) {
|
|
761
|
+
normalizeFilterGroupValue(query.filter, "chart query.filter");
|
|
762
|
+
}
|
|
763
|
+
}
|
|
585
764
|
function canStrictNormalizeChartQuery(query) {
|
|
586
765
|
validateLooseChartQuery(query);
|
|
587
766
|
const mode = inferQueryMode(query);
|
|
@@ -605,7 +784,10 @@ function mergeChartQuerySection(current, patch) {
|
|
|
605
784
|
const nextMode = inferQueryMode(normalizedPatch);
|
|
606
785
|
const modeChanged = currentMode && currentMode !== nextMode;
|
|
607
786
|
const base = modeChanged ? {} : current || {};
|
|
608
|
-
const merged = mergeReplaceArrays(base, normalizedPatch);
|
|
787
|
+
const merged = mergeReplaceArrays(base, import_lodash.default.omit(normalizedPatch, ["filter"]));
|
|
788
|
+
if (hasOwn(normalizedPatch, "filter")) {
|
|
789
|
+
merged.filter = import_lodash.default.cloneDeep(normalizedPatch.filter);
|
|
790
|
+
}
|
|
609
791
|
if (nextMode !== "builder") {
|
|
610
792
|
return merged;
|
|
611
793
|
}
|
|
@@ -1092,10 +1274,9 @@ function assertBasicVisualMappingsAgainstBuilderQuery(builderVisual, query) {
|
|
|
1092
1274
|
),
|
|
1093
1275
|
void 0,
|
|
1094
1276
|
{
|
|
1095
|
-
details: {
|
|
1096
|
-
repairHint: CHART_REPAIR_HINT,
|
|
1277
|
+
details: withChartRepairDetails({
|
|
1097
1278
|
allowedOutputs: Array.from(allowedOutputs)
|
|
1098
|
-
}
|
|
1279
|
+
})
|
|
1099
1280
|
}
|
|
1100
1281
|
);
|
|
1101
1282
|
}
|
|
@@ -165,7 +165,7 @@ class FlowSurfaceContractGuard {
|
|
|
165
165
|
if (typeof on === "string" && !allowedDirectEvents.has(eventName)) {
|
|
166
166
|
(0, import_errors.throwBadRequest)(`flowSurfaces flow '${key}' event '${eventName}' is not allowed on '${node == null ? void 0 : node.use}'`);
|
|
167
167
|
}
|
|
168
|
-
if (typeof on !== "string" && !allowedObjectEvents.has(eventName)) {
|
|
168
|
+
if (typeof on !== "string" && !allowedObjectEvents.has(eventName) && !allowedDirectEvents.has(eventName)) {
|
|
169
169
|
(0, import_errors.throwBadRequest)(`flowSurfaces flow '${key}' event '${eventName}' is not allowed on '${node == null ? void 0 : node.use}'`);
|
|
170
170
|
}
|
|
171
171
|
const phase = onObj == null ? void 0 : onObj.phase;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export type FlowSurfaceEventFlowRecord = Record<string, unknown>;
|
|
10
|
+
export type FlowSurfaceEventFlowRegistry = Record<string, FlowSurfaceEventFlowRecord>;
|
|
11
|
+
export declare function buildFlowSurfaceEmptyEventCondition(): {
|
|
12
|
+
logic: string;
|
|
13
|
+
items: any[];
|
|
14
|
+
};
|
|
15
|
+
export declare function normalizeFlowSurfaceEventFlowOn(on: unknown): unknown;
|
|
16
|
+
export declare function normalizeFlowSurfaceEventFlow(actionName: string, key: string, flowInput: unknown): FlowSurfaceEventFlowRecord;
|
|
17
|
+
export declare function normalizeFlowSurfaceEventFlowRegistry(actionName: string, flowRegistry: Record<string, unknown>): FlowSurfaceEventFlowRegistry;
|
|
18
|
+
export declare function normalizeFlowSurfaceEventFlowRegistry<T>(actionName: string, flowRegistry: T): T;
|
|
19
|
+
export declare function isFlowSurfaceBeforeAllEventFlow(flow: unknown): boolean;
|
|
@@ -0,0 +1,128 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var event_flow_normalizer_exports = {};
|
|
38
|
+
__export(event_flow_normalizer_exports, {
|
|
39
|
+
buildFlowSurfaceEmptyEventCondition: () => buildFlowSurfaceEmptyEventCondition,
|
|
40
|
+
isFlowSurfaceBeforeAllEventFlow: () => isFlowSurfaceBeforeAllEventFlow,
|
|
41
|
+
normalizeFlowSurfaceEventFlow: () => normalizeFlowSurfaceEventFlow,
|
|
42
|
+
normalizeFlowSurfaceEventFlowOn: () => normalizeFlowSurfaceEventFlowOn,
|
|
43
|
+
normalizeFlowSurfaceEventFlowRegistry: () => normalizeFlowSurfaceEventFlowRegistry
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(event_flow_normalizer_exports);
|
|
46
|
+
var import_lodash = __toESM(require("lodash"));
|
|
47
|
+
var import_errors = require("./errors");
|
|
48
|
+
function asPlainRecord(value) {
|
|
49
|
+
return import_lodash.default.isPlainObject(value) ? value : null;
|
|
50
|
+
}
|
|
51
|
+
function buildFlowSurfaceEmptyEventCondition() {
|
|
52
|
+
return { logic: "$and", items: [] };
|
|
53
|
+
}
|
|
54
|
+
function normalizeFlowSurfaceEventFlowOn(on) {
|
|
55
|
+
if (typeof on === "string") {
|
|
56
|
+
const eventName2 = on.trim();
|
|
57
|
+
if (!eventName2) {
|
|
58
|
+
return on;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
eventName: eventName2,
|
|
62
|
+
defaultParams: {
|
|
63
|
+
condition: buildFlowSurfaceEmptyEventCondition()
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const onRecord = asPlainRecord(on);
|
|
68
|
+
if (!onRecord) {
|
|
69
|
+
return on;
|
|
70
|
+
}
|
|
71
|
+
const next = import_lodash.default.cloneDeep(onRecord);
|
|
72
|
+
const eventName = String(next.eventName || "").trim();
|
|
73
|
+
if (eventName) {
|
|
74
|
+
next.eventName = eventName;
|
|
75
|
+
}
|
|
76
|
+
const phase = String(next.phase || "").trim();
|
|
77
|
+
if (!phase || phase === "beforeAllFlows") {
|
|
78
|
+
delete next.phase;
|
|
79
|
+
} else {
|
|
80
|
+
next.phase = phase;
|
|
81
|
+
}
|
|
82
|
+
const defaultParams = asPlainRecord(next.defaultParams) || {};
|
|
83
|
+
if (!asPlainRecord(defaultParams.condition)) {
|
|
84
|
+
defaultParams.condition = buildFlowSurfaceEmptyEventCondition();
|
|
85
|
+
}
|
|
86
|
+
next.defaultParams = defaultParams;
|
|
87
|
+
return next;
|
|
88
|
+
}
|
|
89
|
+
function normalizeFlowSurfaceEventFlow(actionName, key, flowInput) {
|
|
90
|
+
const flowRecord = asPlainRecord(flowInput);
|
|
91
|
+
if (!flowRecord) {
|
|
92
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} flow '${key}' must be an object`);
|
|
93
|
+
}
|
|
94
|
+
const flow = import_lodash.default.cloneDeep(flowRecord);
|
|
95
|
+
flow.key = key;
|
|
96
|
+
if (asPlainRecord(flow.on) || typeof flow.on === "string") {
|
|
97
|
+
flow.on = normalizeFlowSurfaceEventFlowOn(flow.on);
|
|
98
|
+
}
|
|
99
|
+
if (import_lodash.default.isUndefined(flow.steps)) {
|
|
100
|
+
flow.steps = {};
|
|
101
|
+
}
|
|
102
|
+
return flow;
|
|
103
|
+
}
|
|
104
|
+
function normalizeFlowSurfaceEventFlowRegistry(actionName, flowRegistry) {
|
|
105
|
+
const registryRecord = asPlainRecord(flowRegistry);
|
|
106
|
+
if (!registryRecord) {
|
|
107
|
+
return flowRegistry;
|
|
108
|
+
}
|
|
109
|
+
return Object.fromEntries(
|
|
110
|
+
Object.entries(registryRecord).map(([key, flow]) => [key, normalizeFlowSurfaceEventFlow(actionName, key, flow)])
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function isFlowSurfaceBeforeAllEventFlow(flow) {
|
|
114
|
+
const flowRecord = asPlainRecord(flow);
|
|
115
|
+
if (!flowRecord) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const onRecord = asPlainRecord(normalizeFlowSurfaceEventFlowOn(flowRecord.on));
|
|
119
|
+
return Boolean(onRecord) && typeof (onRecord == null ? void 0 : onRecord.eventName) === "string" && (typeof onRecord.phase === "undefined" || onRecord.phase === "beforeAllFlows");
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
buildFlowSurfaceEmptyEventCondition,
|
|
124
|
+
isFlowSurfaceBeforeAllEventFlow,
|
|
125
|
+
normalizeFlowSurfaceEventFlow,
|
|
126
|
+
normalizeFlowSurfaceEventFlowOn,
|
|
127
|
+
normalizeFlowSurfaceEventFlowRegistry
|
|
128
|
+
});
|
|
@@ -11,5 +11,7 @@ export declare const FLOW_SURFACE_EMPTY_FILTER_GROUP: {
|
|
|
11
11
|
items: any[];
|
|
12
12
|
};
|
|
13
13
|
export declare const FLOW_SURFACE_FILTER_GROUP_EXAMPLE: string;
|
|
14
|
+
export declare function assertFlowSurfaceFilterOperator(operator: unknown, path: string): void;
|
|
15
|
+
export declare function normalizeFlowSurfaceFilterDateValue(operator: unknown, value: unknown, path: string): unknown;
|
|
14
16
|
export declare function normalizeFlowSurfaceFilterGroupValue(value: any, errorPrefix: string): any;
|
|
15
17
|
export declare function assertFlowSurfaceFilterGroupShape(filter: any): void;
|