@nocobase/plugin-flow-engine 2.1.0-alpha.40 → 2.1.0-alpha.46
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/client/index.js +1 -1
- 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 +28 -14
- package/dist/server/flow-surfaces/apply/matching.js +2 -0
- package/dist/server/flow-surfaces/authoring-validation.d.ts +1 -0
- package/dist/server/flow-surfaces/authoring-validation.js +1453 -151
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +21 -3
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +9 -9
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -1
- package/dist/server/flow-surfaces/catalog.js +26 -9
- package/dist/server/flow-surfaces/chart-config.js +231 -14
- package/dist/server/flow-surfaces/compose-compiler.d.ts +2 -0
- package/dist/server/flow-surfaces/compose-compiler.js +2 -0
- package/dist/server/flow-surfaces/compose-runtime.js +4 -7
- package/dist/server/flow-surfaces/configure-options.js +19 -8
- package/dist/server/flow-surfaces/contract-guard.js +40 -6
- package/dist/server/flow-surfaces/default-block-actions.js +2 -0
- package/dist/server/flow-surfaces/errors.d.ts +15 -0
- package/dist/server/flow-surfaces/errors.js +49 -3
- 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 +9 -1
- package/dist/server/flow-surfaces/filter-group.js +402 -3
- package/dist/server/flow-surfaces/locator.js +16 -2
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
- package/dist/server/flow-surfaces/route-sync.js +19 -2
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
- package/dist/server/flow-surfaces/runjs-authoring/ctx-libs-member-mismatch-stop/index.js +1 -1
- package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
- package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -7033
- package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
- package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
- package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
- package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
- package/dist/server/flow-surfaces/service-helpers.js +105 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +17 -3
- package/dist/server/flow-surfaces/service-utils.js +14 -5
- package/dist/server/flow-surfaces/service.d.ts +74 -15
- package/dist/server/flow-surfaces/service.js +1781 -193
- package/dist/server/flow-surfaces/template-service-utils.d.ts +1 -0
- package/dist/server/flow-surfaces/types.d.ts +3 -0
- package/dist/server/repository.d.ts +12 -1
- package/dist/server/repository.js +195 -23
- package/dist/swagger/flow-surfaces.d.ts +180 -2
- package/dist/swagger/flow-surfaces.examples.d.ts +11 -37
- package/dist/swagger/flow-surfaces.examples.js +6 -6
- package/dist/swagger/flow-surfaces.js +136 -54
- package/dist/swagger/index.d.ts +180 -2
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -349,33 +349,67 @@ function collectSchemaValueErrors(value, schema, path) {
|
|
|
349
349
|
function normalizeDomainValue(value, contract, context) {
|
|
350
350
|
const normalized = import_lodash.default.cloneDeep(value);
|
|
351
351
|
Object.entries(contract.pathSchemas || {}).forEach(([path, schema]) => {
|
|
352
|
-
if (!import_lodash.default.has(normalized, path)
|
|
352
|
+
if (!import_lodash.default.has(normalized, path)) {
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
if (isFilterGroupSchema(schema)) {
|
|
356
|
+
import_lodash.default.set(normalized, path, normalizeFilterGroupValue(import_lodash.default.get(normalized, path), context, path));
|
|
357
|
+
} else if (isLinkageRulesSchema(schema)) {
|
|
358
|
+
import_lodash.default.set(normalized, path, normalizeLinkageRulesValue(import_lodash.default.get(normalized, path), context, path));
|
|
359
|
+
}
|
|
356
360
|
});
|
|
357
361
|
return normalized;
|
|
358
362
|
}
|
|
359
363
|
function normalizeGroupValue(value, groupContract, context) {
|
|
360
364
|
const normalized = import_lodash.default.cloneDeep(value);
|
|
361
365
|
Object.entries(groupContract.pathSchemas || {}).forEach(([path, schema]) => {
|
|
362
|
-
if (!import_lodash.default.has(normalized, path)
|
|
366
|
+
if (!import_lodash.default.has(normalized, path)) {
|
|
363
367
|
return;
|
|
364
368
|
}
|
|
365
|
-
|
|
369
|
+
if (isFilterGroupSchema(schema)) {
|
|
370
|
+
import_lodash.default.set(normalized, path, normalizeFilterGroupValue(import_lodash.default.get(normalized, path), context, path));
|
|
371
|
+
} else if (isLinkageRulesSchema(schema)) {
|
|
372
|
+
import_lodash.default.set(normalized, path, normalizeLinkageRulesValue(import_lodash.default.get(normalized, path), context, path));
|
|
373
|
+
}
|
|
366
374
|
});
|
|
367
375
|
return normalized;
|
|
368
376
|
}
|
|
369
377
|
function isFilterGroupSchema(schema) {
|
|
370
378
|
return (schema == null ? void 0 : schema["x-flowSurfaceFormat"]) === "filter-group";
|
|
371
379
|
}
|
|
380
|
+
function isLinkageRulesSchema(schema) {
|
|
381
|
+
return (schema == null ? void 0 : schema["x-flowSurfaceFormat"]) === "linkage-rules";
|
|
382
|
+
}
|
|
372
383
|
function normalizeFilterGroupValue(value, context, path) {
|
|
373
384
|
const domainPath = context.groupKey ? `${context.domain}.${context.groupKey}.${path}` : `${context.domain}.${path}`;
|
|
374
385
|
return (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(
|
|
375
386
|
value,
|
|
376
|
-
`flowSurfaces updateSettings domain '${domainPath}' on '${context.use}' expects FilterGroup like ${import_filter_group.FLOW_SURFACE_FILTER_GROUP_EXAMPLE}
|
|
387
|
+
`flowSurfaces updateSettings domain '${domainPath}' on '${context.use}' expects FilterGroup like ${import_filter_group.FLOW_SURFACE_FILTER_GROUP_EXAMPLE}`,
|
|
388
|
+
{ strictDateValues: true }
|
|
377
389
|
);
|
|
378
390
|
}
|
|
391
|
+
function normalizeLinkageRulesValue(value, context, path) {
|
|
392
|
+
if (!Array.isArray(value)) {
|
|
393
|
+
return value;
|
|
394
|
+
}
|
|
395
|
+
return value.map((rule, index) => {
|
|
396
|
+
if (!import_lodash.default.isPlainObject(rule) || !import_lodash.default.has(rule, "condition")) {
|
|
397
|
+
return rule;
|
|
398
|
+
}
|
|
399
|
+
const normalizedRule = import_lodash.default.cloneDeep(rule);
|
|
400
|
+
const domainPath = context.groupKey ? `${context.domain}.${context.groupKey}.${path}[${index}].condition` : `${context.domain}.${path}[${index}].condition`;
|
|
401
|
+
import_lodash.default.set(
|
|
402
|
+
normalizedRule,
|
|
403
|
+
"condition",
|
|
404
|
+
(0, import_filter_group.normalizeFlowSurfaceCompatibleFilterGroupValue)(
|
|
405
|
+
import_lodash.default.get(normalizedRule, "condition"),
|
|
406
|
+
`flowSurfaces updateSettings domain '${domainPath}' on '${context.use}' expects FilterGroup or backend query filter like ${import_filter_group.FLOW_SURFACE_FILTER_GROUP_EXAMPLE}`,
|
|
407
|
+
{ strictDateValues: true }
|
|
408
|
+
)
|
|
409
|
+
);
|
|
410
|
+
return normalizedRule;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
379
413
|
function isContractDefinedFlowGroup(groupContract) {
|
|
380
414
|
if (!groupContract) {
|
|
381
415
|
return false;
|
|
@@ -104,6 +104,8 @@ const FLOW_SURFACE_DEFAULT_BLOCK_ACTIONS = {
|
|
|
104
104
|
],
|
|
105
105
|
calendar: [
|
|
106
106
|
{ type: "filter", scope: "actions" },
|
|
107
|
+
{ type: "turnPages", scope: "actions" },
|
|
108
|
+
{ type: "selectView", scope: "actions" },
|
|
107
109
|
{ type: "refresh", scope: "actions" },
|
|
108
110
|
{
|
|
109
111
|
type: "addNew",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type FlowSurfaceErrorType = 'bad_request' | 'forbidden' | 'conflict' | 'internal_error';
|
|
10
10
|
export interface FlowSurfaceErrorItem {
|
|
11
|
+
index?: number;
|
|
11
12
|
message: string;
|
|
12
13
|
type: FlowSurfaceErrorType;
|
|
13
14
|
code: string;
|
|
@@ -48,6 +49,20 @@ export declare class FlowSurfaceAggregateError extends FlowSurfaceError {
|
|
|
48
49
|
readonly errors: FlowSurfaceErrorItem[];
|
|
49
50
|
constructor(errors: FlowSurfaceErrorItemInput[], message?: string);
|
|
50
51
|
toResponseBody(): {
|
|
52
|
+
message: string;
|
|
53
|
+
errorCount: number;
|
|
54
|
+
details: {
|
|
55
|
+
requiredBlockPolicy?: {
|
|
56
|
+
requiredBlockTypes: string[];
|
|
57
|
+
fixStrategy: string;
|
|
58
|
+
doNotReplaceOrDrop: boolean;
|
|
59
|
+
};
|
|
60
|
+
errorCount: number;
|
|
61
|
+
mustFixAllErrorsBeforeRetry: boolean;
|
|
62
|
+
retryPolicy: string;
|
|
63
|
+
sameWriteRetryRequired: boolean;
|
|
64
|
+
agentInstruction: string;
|
|
65
|
+
};
|
|
51
66
|
errors: FlowSurfaceErrorItem[];
|
|
52
67
|
};
|
|
53
68
|
}
|
|
@@ -88,14 +88,27 @@ class FlowSurfaceInternalError extends FlowSurfaceError {
|
|
|
88
88
|
}
|
|
89
89
|
class FlowSurfaceAggregateError extends FlowSurfaceError {
|
|
90
90
|
errors;
|
|
91
|
-
constructor(errors, message
|
|
92
|
-
const normalizedErrors = errors.map(
|
|
93
|
-
|
|
91
|
+
constructor(errors, message) {
|
|
92
|
+
const normalizedErrors = errors.map(
|
|
93
|
+
(error, index) => normalizeFlowSurfaceErrorItemInput({
|
|
94
|
+
...error,
|
|
95
|
+
index: index + 1
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
super(
|
|
99
|
+
message || buildAggregateBadRequestMessage(normalizedErrors.length),
|
|
100
|
+
400,
|
|
101
|
+
"bad_request",
|
|
102
|
+
"FLOW_SURFACE_AUTHORING_VALIDATION_FAILED"
|
|
103
|
+
);
|
|
94
104
|
this.name = "FlowSurfaceAggregateError";
|
|
95
105
|
this.errors = normalizedErrors;
|
|
96
106
|
}
|
|
97
107
|
toResponseBody() {
|
|
98
108
|
return {
|
|
109
|
+
message: this.message,
|
|
110
|
+
errorCount: this.errors.length,
|
|
111
|
+
details: buildAggregateBadRequestDetails(this.errors),
|
|
99
112
|
errors: this.errors
|
|
100
113
|
};
|
|
101
114
|
}
|
|
@@ -162,6 +175,9 @@ function buildDefinedErrorItem(input) {
|
|
|
162
175
|
code: input.code,
|
|
163
176
|
status: input.status
|
|
164
177
|
};
|
|
178
|
+
if (typeof input.index !== "undefined") {
|
|
179
|
+
output.index = input.index;
|
|
180
|
+
}
|
|
165
181
|
if (typeof input.path !== "undefined") {
|
|
166
182
|
output.path = input.path;
|
|
167
183
|
}
|
|
@@ -176,6 +192,7 @@ function buildDefinedErrorItem(input) {
|
|
|
176
192
|
function normalizeFlowSurfaceErrorItemInput(input) {
|
|
177
193
|
return buildDefinedErrorItem({
|
|
178
194
|
message: input.message,
|
|
195
|
+
index: input.index,
|
|
179
196
|
type: input.type || "bad_request",
|
|
180
197
|
code: input.code || "FLOW_SURFACE_AUTHORING_VALIDATION_ERROR",
|
|
181
198
|
status: input.status || 400,
|
|
@@ -184,6 +201,35 @@ function normalizeFlowSurfaceErrorItemInput(input) {
|
|
|
184
201
|
details: input.details
|
|
185
202
|
});
|
|
186
203
|
}
|
|
204
|
+
function buildAggregateBadRequestMessage(errorCount) {
|
|
205
|
+
return `flowSurfaces authoring validation failed with ${errorCount} error(s); fix all errors before retrying the same write`;
|
|
206
|
+
}
|
|
207
|
+
function buildAggregateBadRequestDetails(errors) {
|
|
208
|
+
const requiredBlockTypes = Array.from(
|
|
209
|
+
new Set(
|
|
210
|
+
errors.map((error) => {
|
|
211
|
+
var _a;
|
|
212
|
+
return (_a = error.details) == null ? void 0 : _a.requiredBlockType;
|
|
213
|
+
}).filter(
|
|
214
|
+
(requiredBlockType) => typeof requiredBlockType === "string" && !!requiredBlockType
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
return {
|
|
219
|
+
errorCount: errors.length,
|
|
220
|
+
mustFixAllErrorsBeforeRetry: true,
|
|
221
|
+
retryPolicy: "fix_all_errors_before_retry_same_write",
|
|
222
|
+
sameWriteRetryRequired: true,
|
|
223
|
+
agentInstruction: "Read the complete errors[] array. Fix every listed error in one payload revision before retrying the same write. Do not fix only the first error and immediately retry. Do not drop, defer, or replace required chart, jsBlock, or JS/RunJS work to bypass validation.",
|
|
224
|
+
...requiredBlockTypes.length ? {
|
|
225
|
+
requiredBlockPolicy: {
|
|
226
|
+
requiredBlockTypes,
|
|
227
|
+
fixStrategy: "repair_same_block_type",
|
|
228
|
+
doNotReplaceOrDrop: true
|
|
229
|
+
}
|
|
230
|
+
} : {}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
187
233
|
// Annotate the CommonJS export names for ESM import in node:
|
|
188
234
|
0 && (module.exports = {
|
|
189
235
|
FlowSurfaceAggregateError,
|
|
@@ -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,13 @@ 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
|
|
14
|
+
export declare function assertFlowSurfaceFilterOperator(operator: unknown, path: string): void;
|
|
15
|
+
export declare function normalizeFlowSurfaceFilterDateValue(operator: unknown, value: unknown, path: string): unknown;
|
|
16
|
+
export declare function normalizeFlowSurfaceStrictFilterDateValue(operator: unknown, value: unknown, path: string): unknown;
|
|
17
|
+
export declare function normalizeFlowSurfaceFilterGroupValue(value: any, errorPrefix: string, options?: {
|
|
18
|
+
strictDateValues?: boolean;
|
|
19
|
+
}): any;
|
|
20
|
+
export declare function normalizeFlowSurfaceCompatibleFilterGroupValue(value: unknown, errorPrefix: string, options?: {
|
|
21
|
+
strictDateValues?: boolean;
|
|
22
|
+
}): any;
|
|
15
23
|
export declare function assertFlowSurfaceFilterGroupShape(filter: any): void;
|