@kubuild/core 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/commands.d.ts +41 -2
- package/dist/commands.d.ts.map +1 -1
- package/dist/conditional-resolver.d.ts +45 -0
- package/dist/conditional-resolver.d.ts.map +1 -0
- package/dist/index.cjs +1346 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1320 -1
- package/dist/index.js.map +1 -1
- package/dist/interpolator.d.ts +50 -0
- package/dist/interpolator.d.ts.map +1 -0
- package/dist/pipeline-executor.d.ts +136 -0
- package/dist/pipeline-executor.d.ts.map +1 -0
- package/dist/state-store.d.ts +128 -0
- package/dist/state-store.d.ts.map +1 -0
- package/dist/validation-engine.d.ts +39 -0
- package/dist/validation-engine.d.ts.map +1 -0
- package/package.json +11 -12
package/dist/index.js
CHANGED
|
@@ -851,7 +851,10 @@ function findMissingComponentNodes(rootNode, registry, knownTypes) {
|
|
|
851
851
|
// src/commands.ts
|
|
852
852
|
import {
|
|
853
853
|
StyleDefinitionSchema,
|
|
854
|
-
ResponsiveStylesSchema
|
|
854
|
+
ResponsiveStylesSchema,
|
|
855
|
+
AnimationConfigSchema,
|
|
856
|
+
ActionPipelineSchema,
|
|
857
|
+
FormConfigSchema
|
|
855
858
|
} from "@kubuild/schema";
|
|
856
859
|
|
|
857
860
|
// src/command-tree-utils.ts
|
|
@@ -1280,6 +1283,97 @@ function duplicateNode(document, params) {
|
|
|
1280
1283
|
}
|
|
1281
1284
|
};
|
|
1282
1285
|
}
|
|
1286
|
+
function updateAnimation(document, params) {
|
|
1287
|
+
const { nodeId, animation, merge = true } = params;
|
|
1288
|
+
const newDoc = deepClone(document);
|
|
1289
|
+
const loc = findNodeLocation(newDoc.document, nodeId);
|
|
1290
|
+
if (!loc) {
|
|
1291
|
+
throw new Error(`Cannot update animation: Node with ID "${nodeId}" not found in document.`);
|
|
1292
|
+
}
|
|
1293
|
+
const targetNode = loc.node;
|
|
1294
|
+
const previousAnimation = targetNode.animation ? deepClone(targetNode.animation) : void 0;
|
|
1295
|
+
if (animation === null) {
|
|
1296
|
+
delete targetNode.animation;
|
|
1297
|
+
} else {
|
|
1298
|
+
const currentAnimation = targetNode.animation ? deepClone(targetNode.animation) : {};
|
|
1299
|
+
const candidate = merge ? { ...currentAnimation, ...deepClone(animation) } : deepClone(animation);
|
|
1300
|
+
targetNode.animation = AnimationConfigSchema.parse(candidate);
|
|
1301
|
+
}
|
|
1302
|
+
return {
|
|
1303
|
+
document: newDoc,
|
|
1304
|
+
event: {
|
|
1305
|
+
type: "ANIMATION_UPDATED",
|
|
1306
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1307
|
+
nodeId,
|
|
1308
|
+
parentId: loc.parent ? loc.parent.id : void 0,
|
|
1309
|
+
payload: {
|
|
1310
|
+
animation: targetNode.animation,
|
|
1311
|
+
previousAnimation
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
function updateActions(document, params) {
|
|
1317
|
+
const { nodeId, actions } = params;
|
|
1318
|
+
const newDoc = deepClone(document);
|
|
1319
|
+
const loc = findNodeLocation(newDoc.document, nodeId);
|
|
1320
|
+
if (!loc) {
|
|
1321
|
+
throw new Error(`Cannot update actions: Node with ID "${nodeId}" not found in document.`);
|
|
1322
|
+
}
|
|
1323
|
+
const targetNode = loc.node;
|
|
1324
|
+
const previousActions = targetNode.actions ? deepClone(targetNode.actions) : void 0;
|
|
1325
|
+
if (actions === null || Array.isArray(actions) && actions.length === 0) {
|
|
1326
|
+
delete targetNode.actions;
|
|
1327
|
+
} else {
|
|
1328
|
+
targetNode.actions = ActionPipelineSchema.array().parse(actions);
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
document: newDoc,
|
|
1332
|
+
event: {
|
|
1333
|
+
type: "ACTIONS_UPDATED",
|
|
1334
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1335
|
+
nodeId,
|
|
1336
|
+
parentId: loc.parent ? loc.parent.id : void 0,
|
|
1337
|
+
payload: {
|
|
1338
|
+
actions: targetNode.actions,
|
|
1339
|
+
previousActions
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
function updateFormConfig(document, params) {
|
|
1345
|
+
const { nodeId, formConfig, merge = true } = params;
|
|
1346
|
+
const newDoc = deepClone(document);
|
|
1347
|
+
const loc = findNodeLocation(newDoc.document, nodeId);
|
|
1348
|
+
if (!loc) {
|
|
1349
|
+
throw new Error(`Cannot update formConfig: Node with ID "${nodeId}" not found in document.`);
|
|
1350
|
+
}
|
|
1351
|
+
const targetNode = loc.node;
|
|
1352
|
+
const previousFormConfig = targetNode.formConfig ? deepClone(targetNode.formConfig) : void 0;
|
|
1353
|
+
if (formConfig === null) {
|
|
1354
|
+
delete targetNode.formConfig;
|
|
1355
|
+
} else {
|
|
1356
|
+
const currentFormConfig = targetNode.formConfig ? deepClone(targetNode.formConfig) : { formId: nodeId };
|
|
1357
|
+
const candidate = merge ? { ...currentFormConfig, ...deepClone(formConfig) } : deepClone(formConfig);
|
|
1358
|
+
if (!candidate.formId) {
|
|
1359
|
+
candidate.formId = nodeId;
|
|
1360
|
+
}
|
|
1361
|
+
targetNode.formConfig = FormConfigSchema.parse(candidate);
|
|
1362
|
+
}
|
|
1363
|
+
return {
|
|
1364
|
+
document: newDoc,
|
|
1365
|
+
event: {
|
|
1366
|
+
type: "FORM_CONFIG_UPDATED",
|
|
1367
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1368
|
+
nodeId,
|
|
1369
|
+
parentId: loc.parent ? loc.parent.id : void 0,
|
|
1370
|
+
payload: {
|
|
1371
|
+
formConfig: targetNode.formConfig,
|
|
1372
|
+
previousFormConfig
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1283
1377
|
|
|
1284
1378
|
// src/history.ts
|
|
1285
1379
|
var DEFAULT_MAX_HISTORY = 50;
|
|
@@ -3544,7 +3638,1205 @@ function areNodeIdsCompletelyDistinct(docA, docB) {
|
|
|
3544
3638
|
}
|
|
3545
3639
|
return true;
|
|
3546
3640
|
}
|
|
3641
|
+
|
|
3642
|
+
// src/interpolator.ts
|
|
3643
|
+
var FORBIDDEN_KEY_SEGMENTS3 = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
3644
|
+
var TEMPLATE_EXPRESSION_REGEX = /\{\{\s*([a-zA-Z0-9_$.,\-[\]\s]+?)\s*\}\}/g;
|
|
3645
|
+
var EXACT_TEMPLATE_REGEX = /^\{\{\s*([a-zA-Z0-9_$.,\-[\]\s]+?)\s*\}\}$/;
|
|
3646
|
+
function hasTemplateExpressions(text) {
|
|
3647
|
+
if (typeof text !== "string") return false;
|
|
3648
|
+
return /\{\{\s*[\s\S]+?\s*\}\}/.test(text);
|
|
3649
|
+
}
|
|
3650
|
+
function extractTemplateVariables(text) {
|
|
3651
|
+
if (!text || typeof text !== "string") return [];
|
|
3652
|
+
const matches = [];
|
|
3653
|
+
const regex = new RegExp(TEMPLATE_EXPRESSION_REGEX.source, "g");
|
|
3654
|
+
let match;
|
|
3655
|
+
while ((match = regex.exec(text)) !== null) {
|
|
3656
|
+
if (match[1]) {
|
|
3657
|
+
const trimmed = match[1].trim();
|
|
3658
|
+
if (trimmed && !matches.includes(trimmed)) {
|
|
3659
|
+
matches.push(trimmed);
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
return matches;
|
|
3664
|
+
}
|
|
3665
|
+
function resolvePropertyPath(source, path, fallback) {
|
|
3666
|
+
const defaultFallback = arguments.length < 3 ? "" : fallback;
|
|
3667
|
+
if (!path || typeof path !== "string" || source === null || source === void 0) {
|
|
3668
|
+
return defaultFallback;
|
|
3669
|
+
}
|
|
3670
|
+
const normalizedPath = path.replace(/\[(\d+)\]/g, ".$1");
|
|
3671
|
+
const segments = normalizedPath.split(".").map((s) => s.trim()).filter(Boolean);
|
|
3672
|
+
if (segments.length === 0) {
|
|
3673
|
+
return defaultFallback;
|
|
3674
|
+
}
|
|
3675
|
+
let current = source;
|
|
3676
|
+
for (const segment of segments) {
|
|
3677
|
+
if (FORBIDDEN_KEY_SEGMENTS3.has(segment)) {
|
|
3678
|
+
return defaultFallback;
|
|
3679
|
+
}
|
|
3680
|
+
if (current === null || current === void 0) {
|
|
3681
|
+
return defaultFallback;
|
|
3682
|
+
}
|
|
3683
|
+
if (typeof current !== "object") {
|
|
3684
|
+
return defaultFallback;
|
|
3685
|
+
}
|
|
3686
|
+
if (Array.isArray(current)) {
|
|
3687
|
+
const index = Number(segment);
|
|
3688
|
+
if (!Number.isInteger(index) || index < 0 || index >= current.length) {
|
|
3689
|
+
return defaultFallback;
|
|
3690
|
+
}
|
|
3691
|
+
current = current[index];
|
|
3692
|
+
} else if (Object.prototype.hasOwnProperty.call(current, segment)) {
|
|
3693
|
+
current = current[segment];
|
|
3694
|
+
} else {
|
|
3695
|
+
return defaultFallback;
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
if (current === void 0 || typeof current === "function") {
|
|
3699
|
+
return defaultFallback;
|
|
3700
|
+
}
|
|
3701
|
+
return current;
|
|
3702
|
+
}
|
|
3703
|
+
function interpolateTemplateString(template, context, fallback = "") {
|
|
3704
|
+
if (!template || typeof template !== "string") return "";
|
|
3705
|
+
if (!hasTemplateExpressions(template)) return template;
|
|
3706
|
+
return template.replace(/\{\{\s*([a-zA-Z0-9_$.,\-[\]\s]+?)\s*\}\}/g, (_match, rawKey) => {
|
|
3707
|
+
const key = rawKey.trim();
|
|
3708
|
+
if (!key) return fallback;
|
|
3709
|
+
const resolved = resolvePropertyPath(context, key, fallback);
|
|
3710
|
+
if (resolved === void 0 || resolved === null) {
|
|
3711
|
+
return fallback;
|
|
3712
|
+
}
|
|
3713
|
+
if (typeof resolved === "object") {
|
|
3714
|
+
try {
|
|
3715
|
+
return JSON.stringify(resolved);
|
|
3716
|
+
} catch {
|
|
3717
|
+
return fallback;
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
return String(resolved);
|
|
3721
|
+
});
|
|
3722
|
+
}
|
|
3723
|
+
function interpolateValue(value, context) {
|
|
3724
|
+
if (value === null || value === void 0) {
|
|
3725
|
+
return value;
|
|
3726
|
+
}
|
|
3727
|
+
if (typeof value === "string") {
|
|
3728
|
+
const trimmed = value.trim();
|
|
3729
|
+
const exactMatch = EXACT_TEMPLATE_REGEX.exec(trimmed);
|
|
3730
|
+
if (exactMatch && exactMatch[1]) {
|
|
3731
|
+
const key = exactMatch[1].trim();
|
|
3732
|
+
return resolvePropertyPath(context, key, "");
|
|
3733
|
+
}
|
|
3734
|
+
return interpolateTemplateString(value, context);
|
|
3735
|
+
}
|
|
3736
|
+
if (Array.isArray(value)) {
|
|
3737
|
+
return value.map((item) => interpolateValue(item, context));
|
|
3738
|
+
}
|
|
3739
|
+
if (typeof value === "object") {
|
|
3740
|
+
const result = {};
|
|
3741
|
+
for (const [k, v] of Object.entries(value)) {
|
|
3742
|
+
if (!FORBIDDEN_KEY_SEGMENTS3.has(k)) {
|
|
3743
|
+
result[k] = interpolateValue(v, context);
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
return result;
|
|
3747
|
+
}
|
|
3748
|
+
return value;
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
// src/validation-engine.ts
|
|
3752
|
+
function isEmptyValue(value) {
|
|
3753
|
+
if (value === void 0 || value === null) {
|
|
3754
|
+
return true;
|
|
3755
|
+
}
|
|
3756
|
+
if (typeof value === "string") {
|
|
3757
|
+
return value.trim().length === 0;
|
|
3758
|
+
}
|
|
3759
|
+
if (Array.isArray(value)) {
|
|
3760
|
+
return value.length === 0;
|
|
3761
|
+
}
|
|
3762
|
+
if (typeof value === "boolean") {
|
|
3763
|
+
return value === false;
|
|
3764
|
+
}
|
|
3765
|
+
return false;
|
|
3766
|
+
}
|
|
3767
|
+
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3768
|
+
var URL_REGEX = /^(https?:\/\/)([\w.-]+)(:[0-9]+)?(\/.*)?$/i;
|
|
3769
|
+
function applyFieldTransform(value, transform) {
|
|
3770
|
+
if (value === void 0 || value === null || !transform) {
|
|
3771
|
+
return value;
|
|
3772
|
+
}
|
|
3773
|
+
if (typeof value === "string") {
|
|
3774
|
+
switch (transform) {
|
|
3775
|
+
case "trim":
|
|
3776
|
+
return value.trim();
|
|
3777
|
+
case "lowercase":
|
|
3778
|
+
return value.toLowerCase();
|
|
3779
|
+
case "uppercase":
|
|
3780
|
+
return value.toUpperCase();
|
|
3781
|
+
case "number": {
|
|
3782
|
+
const trimmed = value.trim();
|
|
3783
|
+
if (trimmed === "") return value;
|
|
3784
|
+
const num = Number(trimmed);
|
|
3785
|
+
return Number.isNaN(num) ? value : num;
|
|
3786
|
+
}
|
|
3787
|
+
default:
|
|
3788
|
+
return value;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
if (typeof value === "number" && transform === "number") {
|
|
3792
|
+
return value;
|
|
3793
|
+
}
|
|
3794
|
+
return value;
|
|
3795
|
+
}
|
|
3796
|
+
function evaluateRule(rule, value, allFormValues) {
|
|
3797
|
+
const isValueEmpty2 = isEmptyValue(value);
|
|
3798
|
+
if (rule.type !== "required" && isValueEmpty2) {
|
|
3799
|
+
return null;
|
|
3800
|
+
}
|
|
3801
|
+
switch (rule.type) {
|
|
3802
|
+
case "required": {
|
|
3803
|
+
if (isValueEmpty2) {
|
|
3804
|
+
return rule.message;
|
|
3805
|
+
}
|
|
3806
|
+
return null;
|
|
3807
|
+
}
|
|
3808
|
+
case "email": {
|
|
3809
|
+
if (typeof value !== "string" || !EMAIL_REGEX.test(value.trim())) {
|
|
3810
|
+
return rule.message;
|
|
3811
|
+
}
|
|
3812
|
+
return null;
|
|
3813
|
+
}
|
|
3814
|
+
case "url": {
|
|
3815
|
+
if (typeof value !== "string" || !URL_REGEX.test(value.trim())) {
|
|
3816
|
+
return rule.message;
|
|
3817
|
+
}
|
|
3818
|
+
return null;
|
|
3819
|
+
}
|
|
3820
|
+
case "min_length": {
|
|
3821
|
+
const min = Number(rule.value);
|
|
3822
|
+
if (Number.isFinite(min)) {
|
|
3823
|
+
if (typeof value === "string" && value.length < min) {
|
|
3824
|
+
return rule.message;
|
|
3825
|
+
}
|
|
3826
|
+
if (Array.isArray(value) && value.length < min) {
|
|
3827
|
+
return rule.message;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
return null;
|
|
3831
|
+
}
|
|
3832
|
+
case "max_length": {
|
|
3833
|
+
const max = Number(rule.value);
|
|
3834
|
+
if (Number.isFinite(max)) {
|
|
3835
|
+
if (typeof value === "string" && value.length > max) {
|
|
3836
|
+
return rule.message;
|
|
3837
|
+
}
|
|
3838
|
+
if (Array.isArray(value) && value.length > max) {
|
|
3839
|
+
return rule.message;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
return null;
|
|
3843
|
+
}
|
|
3844
|
+
case "numeric_min": {
|
|
3845
|
+
const min = Number(rule.value);
|
|
3846
|
+
const num = Number(value);
|
|
3847
|
+
if (Number.isNaN(num) || !Number.isFinite(num) || num < min) {
|
|
3848
|
+
return rule.message;
|
|
3849
|
+
}
|
|
3850
|
+
return null;
|
|
3851
|
+
}
|
|
3852
|
+
case "numeric_max": {
|
|
3853
|
+
const max = Number(rule.value);
|
|
3854
|
+
const num = Number(value);
|
|
3855
|
+
if (Number.isNaN(num) || !Number.isFinite(num) || num > max) {
|
|
3856
|
+
return rule.message;
|
|
3857
|
+
}
|
|
3858
|
+
return null;
|
|
3859
|
+
}
|
|
3860
|
+
case "pattern":
|
|
3861
|
+
case "custom_regex": {
|
|
3862
|
+
try {
|
|
3863
|
+
const patternStr = String(rule.value || "");
|
|
3864
|
+
const regex = new RegExp(patternStr);
|
|
3865
|
+
if (!regex.test(String(value ?? ""))) {
|
|
3866
|
+
return rule.message;
|
|
3867
|
+
}
|
|
3868
|
+
} catch {
|
|
3869
|
+
return rule.message;
|
|
3870
|
+
}
|
|
3871
|
+
return null;
|
|
3872
|
+
}
|
|
3873
|
+
case "match_field": {
|
|
3874
|
+
const targetFieldName = String(rule.value || "");
|
|
3875
|
+
const targetValue = allFormValues?.[targetFieldName];
|
|
3876
|
+
if (value !== targetValue) {
|
|
3877
|
+
return rule.message;
|
|
3878
|
+
}
|
|
3879
|
+
return null;
|
|
3880
|
+
}
|
|
3881
|
+
default:
|
|
3882
|
+
return null;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
function validateFieldValue(value, rules, allFormValues) {
|
|
3886
|
+
if (!rules || !Array.isArray(rules) || rules.length === 0) {
|
|
3887
|
+
return null;
|
|
3888
|
+
}
|
|
3889
|
+
for (const rule of rules) {
|
|
3890
|
+
const error = evaluateRule(rule, value, allFormValues);
|
|
3891
|
+
if (error) {
|
|
3892
|
+
return error;
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
return null;
|
|
3896
|
+
}
|
|
3897
|
+
async function validateFieldValueAsync(value, rules, allFormValues) {
|
|
3898
|
+
return validateFieldValue(value, rules, allFormValues);
|
|
3899
|
+
}
|
|
3900
|
+
function validateForm(values, fieldConfigs) {
|
|
3901
|
+
const errors = {};
|
|
3902
|
+
if (!fieldConfigs) {
|
|
3903
|
+
return errors;
|
|
3904
|
+
}
|
|
3905
|
+
if (Array.isArray(fieldConfigs)) {
|
|
3906
|
+
for (const field of fieldConfigs) {
|
|
3907
|
+
if (!field?.name) continue;
|
|
3908
|
+
let value = values?.[field.name];
|
|
3909
|
+
if (field.transform) {
|
|
3910
|
+
value = applyFieldTransform(value, field.transform);
|
|
3911
|
+
}
|
|
3912
|
+
const rules = [...field.rules || []];
|
|
3913
|
+
if (field.required && !rules.some((r) => r.type === "required")) {
|
|
3914
|
+
rules.unshift({
|
|
3915
|
+
type: "required",
|
|
3916
|
+
message: `${field.label || field.name} is required`
|
|
3917
|
+
});
|
|
3918
|
+
}
|
|
3919
|
+
const error = validateFieldValue(value, rules, values);
|
|
3920
|
+
if (error) {
|
|
3921
|
+
errors[field.name] = error;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
} else if (typeof fieldConfigs === "object") {
|
|
3925
|
+
for (const [fieldName, config] of Object.entries(fieldConfigs)) {
|
|
3926
|
+
let value = values?.[fieldName];
|
|
3927
|
+
let rules = [];
|
|
3928
|
+
if (Array.isArray(config)) {
|
|
3929
|
+
rules = config;
|
|
3930
|
+
} else if (config && typeof config === "object") {
|
|
3931
|
+
if (config.transform) {
|
|
3932
|
+
value = applyFieldTransform(value, config.transform);
|
|
3933
|
+
}
|
|
3934
|
+
rules = [...config.rules || []];
|
|
3935
|
+
if (config.required && !rules.some((r) => r.type === "required")) {
|
|
3936
|
+
rules.unshift({
|
|
3937
|
+
type: "required",
|
|
3938
|
+
message: `${config.label || fieldName} is required`
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
const error = validateFieldValue(value, rules, values);
|
|
3943
|
+
if (error) {
|
|
3944
|
+
errors[fieldName] = error;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
return errors;
|
|
3949
|
+
}
|
|
3950
|
+
async function validateFormAsync(values, fieldConfigs) {
|
|
3951
|
+
return validateForm(values, fieldConfigs);
|
|
3952
|
+
}
|
|
3953
|
+
function isFormValid(errors) {
|
|
3954
|
+
return Object.keys(errors).length === 0;
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
|
+
// src/conditional-resolver.ts
|
|
3958
|
+
function isConditionGroup(item) {
|
|
3959
|
+
return typeof item === "object" && item !== null && "combinator" in item && "conditions" in item;
|
|
3960
|
+
}
|
|
3961
|
+
function isValueEmpty(value) {
|
|
3962
|
+
if (value === void 0 || value === null) {
|
|
3963
|
+
return true;
|
|
3964
|
+
}
|
|
3965
|
+
if (typeof value === "string") {
|
|
3966
|
+
return value.trim().length === 0;
|
|
3967
|
+
}
|
|
3968
|
+
if (Array.isArray(value)) {
|
|
3969
|
+
return value.length === 0;
|
|
3970
|
+
}
|
|
3971
|
+
if (typeof value === "object") {
|
|
3972
|
+
return Object.keys(value).length === 0;
|
|
3973
|
+
}
|
|
3974
|
+
return false;
|
|
3975
|
+
}
|
|
3976
|
+
function evaluateOperator(operator, actual, expected, options) {
|
|
3977
|
+
let act = actual;
|
|
3978
|
+
let exp = expected;
|
|
3979
|
+
if (options?.trimStrings) {
|
|
3980
|
+
if (typeof act === "string") act = act.trim();
|
|
3981
|
+
if (typeof exp === "string") exp = exp.trim();
|
|
3982
|
+
}
|
|
3983
|
+
if (options?.caseInsensitive) {
|
|
3984
|
+
if (typeof act === "string") act = act.toLowerCase();
|
|
3985
|
+
if (typeof exp === "string") exp = exp.toLowerCase();
|
|
3986
|
+
}
|
|
3987
|
+
switch (operator) {
|
|
3988
|
+
case "equals": {
|
|
3989
|
+
if (act === exp) return true;
|
|
3990
|
+
if (typeof act === "number" && typeof exp === "string" && exp.trim() !== "") {
|
|
3991
|
+
const numExp = Number(exp);
|
|
3992
|
+
return !Number.isNaN(numExp) && act === numExp;
|
|
3993
|
+
}
|
|
3994
|
+
if (typeof act === "string" && typeof exp === "number" && act.trim() !== "") {
|
|
3995
|
+
const numAct = Number(act);
|
|
3996
|
+
return !Number.isNaN(numAct) && numAct === exp;
|
|
3997
|
+
}
|
|
3998
|
+
if (typeof act === "boolean" && typeof exp === "string") {
|
|
3999
|
+
return act === (exp.toLowerCase() === "true");
|
|
4000
|
+
}
|
|
4001
|
+
if (typeof act === "string" && typeof exp === "boolean") {
|
|
4002
|
+
return act.toLowerCase() === "true" === exp;
|
|
4003
|
+
}
|
|
4004
|
+
return false;
|
|
4005
|
+
}
|
|
4006
|
+
case "not_equals":
|
|
4007
|
+
return !evaluateOperator("equals", actual, expected, options);
|
|
4008
|
+
case "is_truthy":
|
|
4009
|
+
if (Array.isArray(act)) {
|
|
4010
|
+
return act.length > 0;
|
|
4011
|
+
}
|
|
4012
|
+
if (act && typeof act === "object") {
|
|
4013
|
+
return Object.keys(act).length > 0;
|
|
4014
|
+
}
|
|
4015
|
+
return Boolean(act);
|
|
4016
|
+
case "is_falsy":
|
|
4017
|
+
return !evaluateOperator("is_truthy", actual, void 0, options);
|
|
4018
|
+
case "is_empty":
|
|
4019
|
+
return isValueEmpty(actual);
|
|
4020
|
+
case "is_not_empty":
|
|
4021
|
+
return !isValueEmpty(actual);
|
|
4022
|
+
case "contains": {
|
|
4023
|
+
if (typeof act === "string") {
|
|
4024
|
+
const needle = options?.caseInsensitive && typeof exp === "string" ? exp : String(exp ?? "");
|
|
4025
|
+
return act.includes(needle);
|
|
4026
|
+
}
|
|
4027
|
+
if (Array.isArray(act)) {
|
|
4028
|
+
if (options?.caseInsensitive && typeof exp === "string") {
|
|
4029
|
+
return act.some((item) => typeof item === "string" && item.toLowerCase() === exp);
|
|
4030
|
+
}
|
|
4031
|
+
return act.includes(exp);
|
|
4032
|
+
}
|
|
4033
|
+
if (act && typeof act === "object") {
|
|
4034
|
+
return exp !== void 0 && String(exp) in act;
|
|
4035
|
+
}
|
|
4036
|
+
return false;
|
|
4037
|
+
}
|
|
4038
|
+
case "not_contains":
|
|
4039
|
+
return !evaluateOperator("contains", actual, expected, options);
|
|
4040
|
+
case "starts_with": {
|
|
4041
|
+
if (typeof act !== "string") return false;
|
|
4042
|
+
const prefix = options?.caseInsensitive && typeof exp === "string" ? exp : String(exp ?? "");
|
|
4043
|
+
return act.startsWith(prefix);
|
|
4044
|
+
}
|
|
4045
|
+
case "ends_with": {
|
|
4046
|
+
if (typeof act !== "string") return false;
|
|
4047
|
+
const suffix = options?.caseInsensitive && typeof exp === "string" ? exp : String(exp ?? "");
|
|
4048
|
+
return act.endsWith(suffix);
|
|
4049
|
+
}
|
|
4050
|
+
case "gt": {
|
|
4051
|
+
const actNum = Number(act);
|
|
4052
|
+
const expNum = Number(exp);
|
|
4053
|
+
return !Number.isNaN(actNum) && !Number.isNaN(expNum) && actNum > expNum;
|
|
4054
|
+
}
|
|
4055
|
+
case "gte": {
|
|
4056
|
+
const actNum = Number(act);
|
|
4057
|
+
const expNum = Number(exp);
|
|
4058
|
+
return !Number.isNaN(actNum) && !Number.isNaN(expNum) && actNum >= expNum;
|
|
4059
|
+
}
|
|
4060
|
+
case "lt": {
|
|
4061
|
+
const actNum = Number(act);
|
|
4062
|
+
const expNum = Number(exp);
|
|
4063
|
+
return !Number.isNaN(actNum) && !Number.isNaN(expNum) && actNum < expNum;
|
|
4064
|
+
}
|
|
4065
|
+
case "lte": {
|
|
4066
|
+
const actNum = Number(act);
|
|
4067
|
+
const expNum = Number(exp);
|
|
4068
|
+
return !Number.isNaN(actNum) && !Number.isNaN(expNum) && actNum <= expNum;
|
|
4069
|
+
}
|
|
4070
|
+
case "in": {
|
|
4071
|
+
if (Array.isArray(exp)) {
|
|
4072
|
+
if (options?.caseInsensitive && typeof act === "string") {
|
|
4073
|
+
return exp.some((item) => typeof item === "string" && item.toLowerCase() === act);
|
|
4074
|
+
}
|
|
4075
|
+
return exp.includes(act);
|
|
4076
|
+
}
|
|
4077
|
+
if (typeof exp === "string") {
|
|
4078
|
+
return exp.includes(String(act ?? ""));
|
|
4079
|
+
}
|
|
4080
|
+
return false;
|
|
4081
|
+
}
|
|
4082
|
+
case "not_in":
|
|
4083
|
+
return !evaluateOperator("in", actual, expected, options);
|
|
4084
|
+
case "regex": {
|
|
4085
|
+
try {
|
|
4086
|
+
const patternStr = String(exp ?? "");
|
|
4087
|
+
const flags = options?.caseInsensitive ? "i" : "";
|
|
4088
|
+
const regex = new RegExp(patternStr, flags);
|
|
4089
|
+
return regex.test(String(act ?? ""));
|
|
4090
|
+
} catch {
|
|
4091
|
+
return false;
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
default:
|
|
4095
|
+
return true;
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
function evaluateCondition(condition, context, options) {
|
|
4099
|
+
if (!condition) return true;
|
|
4100
|
+
const rawField = condition.field;
|
|
4101
|
+
if (!rawField || typeof rawField !== "string") return true;
|
|
4102
|
+
const fieldPath = rawField.replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4103
|
+
const actualValue = resolvePropertyPath(context, fieldPath, void 0);
|
|
4104
|
+
return evaluateOperator(condition.operator, actualValue, condition.value, options);
|
|
4105
|
+
}
|
|
4106
|
+
function evaluateConditionGroup(group, context, options) {
|
|
4107
|
+
if (!group || !Array.isArray(group.conditions) || group.conditions.length === 0) {
|
|
4108
|
+
return true;
|
|
4109
|
+
}
|
|
4110
|
+
const combinator = group.combinator === "or" ? "or" : "and";
|
|
4111
|
+
if (combinator === "and") {
|
|
4112
|
+
return group.conditions.every((item) => {
|
|
4113
|
+
if (isConditionGroup(item)) {
|
|
4114
|
+
return evaluateConditionGroup(item, context, options);
|
|
4115
|
+
}
|
|
4116
|
+
return evaluateCondition(item, context, options);
|
|
4117
|
+
});
|
|
4118
|
+
}
|
|
4119
|
+
return group.conditions.some((item) => {
|
|
4120
|
+
if (isConditionGroup(item)) {
|
|
4121
|
+
return evaluateConditionGroup(item, context, options);
|
|
4122
|
+
}
|
|
4123
|
+
return evaluateCondition(item, context, options);
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
function evaluateConditions(conditions, context, combinator = "and", options) {
|
|
4127
|
+
return evaluateConditionGroup({ combinator, conditions }, context, options);
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
// src/pipeline-executor.ts
|
|
4131
|
+
var ActionTimeoutError = class extends Error {
|
|
4132
|
+
stepId;
|
|
4133
|
+
timeoutMs;
|
|
4134
|
+
constructor(message, timeoutMs, stepId) {
|
|
4135
|
+
super(message);
|
|
4136
|
+
this.name = "ActionTimeoutError";
|
|
4137
|
+
this.timeoutMs = timeoutMs;
|
|
4138
|
+
this.stepId = stepId;
|
|
4139
|
+
}
|
|
4140
|
+
};
|
|
4141
|
+
var ActionCancellationError = class extends Error {
|
|
4142
|
+
stepId;
|
|
4143
|
+
constructor(message = "Action execution cancelled", stepId) {
|
|
4144
|
+
super(message);
|
|
4145
|
+
this.name = "ActionCancellationError";
|
|
4146
|
+
this.stepId = stepId;
|
|
4147
|
+
}
|
|
4148
|
+
};
|
|
4149
|
+
function evaluateActionCondition(condition, context) {
|
|
4150
|
+
return evaluateCondition(condition, context);
|
|
4151
|
+
}
|
|
4152
|
+
function normalizeAbortError(reason, stepId) {
|
|
4153
|
+
if (reason instanceof ActionTimeoutError) {
|
|
4154
|
+
return reason;
|
|
4155
|
+
}
|
|
4156
|
+
if (reason instanceof ActionCancellationError) {
|
|
4157
|
+
return reason;
|
|
4158
|
+
}
|
|
4159
|
+
const msg = reason instanceof Error ? reason.message : "Action execution cancelled";
|
|
4160
|
+
return new ActionCancellationError(msg, stepId);
|
|
4161
|
+
}
|
|
4162
|
+
function createTimeoutAbortSignal(parentSignal, timeoutMs, timeoutMessage, stepId) {
|
|
4163
|
+
const controller = new AbortController();
|
|
4164
|
+
let timerId;
|
|
4165
|
+
const onParentAbort = () => {
|
|
4166
|
+
controller.abort(normalizeAbortError(parentSignal?.reason, stepId));
|
|
4167
|
+
};
|
|
4168
|
+
if (parentSignal) {
|
|
4169
|
+
if (parentSignal.aborted) {
|
|
4170
|
+
onParentAbort();
|
|
4171
|
+
} else {
|
|
4172
|
+
parentSignal.addEventListener("abort", onParentAbort, { once: true });
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
if (timeoutMs !== void 0 && timeoutMs > 0) {
|
|
4176
|
+
timerId = setTimeout(() => {
|
|
4177
|
+
controller.abort(
|
|
4178
|
+
new ActionTimeoutError(
|
|
4179
|
+
timeoutMessage || `Action execution timed out after ${timeoutMs}ms`,
|
|
4180
|
+
timeoutMs,
|
|
4181
|
+
stepId
|
|
4182
|
+
)
|
|
4183
|
+
);
|
|
4184
|
+
}, timeoutMs);
|
|
4185
|
+
}
|
|
4186
|
+
const cleanup = () => {
|
|
4187
|
+
if (timerId !== void 0) {
|
|
4188
|
+
clearTimeout(timerId);
|
|
4189
|
+
}
|
|
4190
|
+
if (parentSignal) {
|
|
4191
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
4192
|
+
}
|
|
4193
|
+
};
|
|
4194
|
+
return { signal: controller.signal, cleanup };
|
|
4195
|
+
}
|
|
4196
|
+
var ActionPipelineExecutor = class {
|
|
4197
|
+
handlers = /* @__PURE__ */ new Map();
|
|
4198
|
+
defaultTimeout;
|
|
4199
|
+
throwOnError;
|
|
4200
|
+
constructor(options) {
|
|
4201
|
+
this.defaultTimeout = options?.defaultTimeout;
|
|
4202
|
+
this.throwOnError = options?.throwOnError ?? false;
|
|
4203
|
+
this.registerBuiltInHandlers();
|
|
4204
|
+
if (options?.handlers) {
|
|
4205
|
+
for (const [type, handler] of Object.entries(options.handlers)) {
|
|
4206
|
+
this.registerHandler(type, handler);
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
/**
|
|
4211
|
+
* Registers default built-in handlers for core step types like `set_state` and `reset_form`.
|
|
4212
|
+
*/
|
|
4213
|
+
registerBuiltInHandlers() {
|
|
4214
|
+
this.registerHandler("set_state", (step, context) => {
|
|
4215
|
+
const key = String(step.payload?.key || "");
|
|
4216
|
+
const value = step.payload?.value;
|
|
4217
|
+
const scope = String(step.payload?.scope || "runtime");
|
|
4218
|
+
if (!key) return;
|
|
4219
|
+
if (!context.state) context.state = {};
|
|
4220
|
+
if (!context.variables) context.variables = {};
|
|
4221
|
+
if (scope === "runtime" || scope === "document") {
|
|
4222
|
+
context.state[key] = value;
|
|
4223
|
+
context.variables[key] = value;
|
|
4224
|
+
} else {
|
|
4225
|
+
context.state[key] = value;
|
|
4226
|
+
}
|
|
4227
|
+
return { key, value, scope };
|
|
4228
|
+
});
|
|
4229
|
+
this.registerHandler("reset_form", (_step, context) => {
|
|
4230
|
+
if (context.form && typeof context.form === "object") {
|
|
4231
|
+
for (const k of Object.keys(context.form)) {
|
|
4232
|
+
context.form[k] = "";
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
return { reset: true };
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* Registers a handler for a step type.
|
|
4240
|
+
*/
|
|
4241
|
+
registerHandler(type, handler) {
|
|
4242
|
+
this.handlers.set(type, handler);
|
|
4243
|
+
return this;
|
|
4244
|
+
}
|
|
4245
|
+
/**
|
|
4246
|
+
* Unregisters a handler for a step type.
|
|
4247
|
+
*/
|
|
4248
|
+
unregisterHandler(type) {
|
|
4249
|
+
this.handlers.delete(type);
|
|
4250
|
+
return this;
|
|
4251
|
+
}
|
|
4252
|
+
/**
|
|
4253
|
+
* Checks if a handler exists for a step type.
|
|
4254
|
+
*/
|
|
4255
|
+
hasHandler(type) {
|
|
4256
|
+
return this.handlers.has(type);
|
|
4257
|
+
}
|
|
4258
|
+
/**
|
|
4259
|
+
* Gets the registered handler for a step type.
|
|
4260
|
+
*/
|
|
4261
|
+
getHandler(type) {
|
|
4262
|
+
return this.handlers.get(type);
|
|
4263
|
+
}
|
|
4264
|
+
/**
|
|
4265
|
+
* Executes a full ActionPipeline sequentially with support for timeouts, cancellation,
|
|
4266
|
+
* condition evaluation, and branching.
|
|
4267
|
+
*/
|
|
4268
|
+
async execute(pipeline, options) {
|
|
4269
|
+
const startTime = Date.now();
|
|
4270
|
+
const context = options?.context ?? {};
|
|
4271
|
+
if (!context.variables) context.variables = {};
|
|
4272
|
+
if (!context.state) context.state = {};
|
|
4273
|
+
if (!context.form) context.form = {};
|
|
4274
|
+
if (!context.stepResults) context.stepResults = {};
|
|
4275
|
+
const timeoutMs = options?.timeout ?? this.defaultTimeout;
|
|
4276
|
+
const { signal, cleanup } = createTimeoutAbortSignal(
|
|
4277
|
+
options?.signal,
|
|
4278
|
+
timeoutMs,
|
|
4279
|
+
`Pipeline "${pipeline.id}" timed out after ${timeoutMs}ms`
|
|
4280
|
+
);
|
|
4281
|
+
let pipelineStatus = "completed";
|
|
4282
|
+
let pipelineError = void 0;
|
|
4283
|
+
const allStepResults = [];
|
|
4284
|
+
try {
|
|
4285
|
+
if (pipeline.enabled === false) {
|
|
4286
|
+
return {
|
|
4287
|
+
pipelineId: pipeline.id,
|
|
4288
|
+
success: true,
|
|
4289
|
+
status: "completed",
|
|
4290
|
+
stepResults: [],
|
|
4291
|
+
context,
|
|
4292
|
+
durationMs: Date.now() - startTime
|
|
4293
|
+
};
|
|
4294
|
+
}
|
|
4295
|
+
const { success, results, error } = await this.executeSteps(
|
|
4296
|
+
pipeline.steps,
|
|
4297
|
+
context,
|
|
4298
|
+
signal,
|
|
4299
|
+
options
|
|
4300
|
+
);
|
|
4301
|
+
allStepResults.push(...results);
|
|
4302
|
+
if (!success) {
|
|
4303
|
+
pipelineStatus = signal.aborted ? "cancelled" : "failed";
|
|
4304
|
+
pipelineError = error;
|
|
4305
|
+
}
|
|
4306
|
+
} catch (err) {
|
|
4307
|
+
pipelineStatus = signal.aborted ? "cancelled" : "failed";
|
|
4308
|
+
pipelineError = err;
|
|
4309
|
+
} finally {
|
|
4310
|
+
cleanup();
|
|
4311
|
+
}
|
|
4312
|
+
const isSuccess = pipelineStatus === "completed";
|
|
4313
|
+
const result = {
|
|
4314
|
+
pipelineId: pipeline.id,
|
|
4315
|
+
success: isSuccess,
|
|
4316
|
+
status: pipelineStatus,
|
|
4317
|
+
stepResults: allStepResults,
|
|
4318
|
+
context,
|
|
4319
|
+
error: pipelineError,
|
|
4320
|
+
durationMs: Date.now() - startTime
|
|
4321
|
+
};
|
|
4322
|
+
const shouldThrow = options?.throwOnError ?? this.throwOnError;
|
|
4323
|
+
if (!isSuccess && shouldThrow) {
|
|
4324
|
+
throw pipelineError || new Error(`Action pipeline "${pipeline.id}" failed`);
|
|
4325
|
+
}
|
|
4326
|
+
return result;
|
|
4327
|
+
}
|
|
4328
|
+
/**
|
|
4329
|
+
* Executes an ordered list of ActionSteps sequentially.
|
|
4330
|
+
*/
|
|
4331
|
+
async executeSteps(steps, context, parentSignal, options) {
|
|
4332
|
+
const results = [];
|
|
4333
|
+
for (const step of steps) {
|
|
4334
|
+
if (parentSignal.aborted) {
|
|
4335
|
+
const cancelError = normalizeAbortError(parentSignal.reason, step.id);
|
|
4336
|
+
const cancelledResult = {
|
|
4337
|
+
stepId: step.id,
|
|
4338
|
+
stepType: step.type,
|
|
4339
|
+
status: "cancelled",
|
|
4340
|
+
error: cancelError,
|
|
4341
|
+
durationMs: 0
|
|
4342
|
+
};
|
|
4343
|
+
results.push(cancelledResult);
|
|
4344
|
+
context.stepResults[step.id] = cancelledResult;
|
|
4345
|
+
return { success: false, results, error: cancelError };
|
|
4346
|
+
}
|
|
4347
|
+
const stepResult = await this.executeSingleStep(step, context, parentSignal, options);
|
|
4348
|
+
results.push(stepResult);
|
|
4349
|
+
context.stepResults[step.id] = stepResult;
|
|
4350
|
+
if (stepResult.status === "error" || stepResult.status === "cancelled") {
|
|
4351
|
+
if (!step.continueOnError) {
|
|
4352
|
+
return { success: false, results, error: stepResult.error };
|
|
4353
|
+
}
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
return { success: true, results };
|
|
4357
|
+
}
|
|
4358
|
+
/**
|
|
4359
|
+
* Executes a single ActionStep with condition checking, payload interpolation, timeout,
|
|
4360
|
+
* handler execution, response context passing, and branch execution.
|
|
4361
|
+
*/
|
|
4362
|
+
async executeSingleStep(step, context, parentSignal, options) {
|
|
4363
|
+
const stepStartTime = Date.now();
|
|
4364
|
+
if (step.condition && !evaluateActionCondition(step.condition, context)) {
|
|
4365
|
+
const skippedResult = {
|
|
4366
|
+
stepId: step.id,
|
|
4367
|
+
stepType: step.type,
|
|
4368
|
+
status: "skipped",
|
|
4369
|
+
durationMs: Date.now() - stepStartTime
|
|
4370
|
+
};
|
|
4371
|
+
options?.onStepComplete?.(step, skippedResult, context);
|
|
4372
|
+
return skippedResult;
|
|
4373
|
+
}
|
|
4374
|
+
options?.onStepStart?.(step, context);
|
|
4375
|
+
const stepTimeout = step.timeout;
|
|
4376
|
+
const { signal: stepSignal, cleanup: cleanupStepSignal } = createTimeoutAbortSignal(
|
|
4377
|
+
parentSignal,
|
|
4378
|
+
stepTimeout,
|
|
4379
|
+
`Step "${step.id}" timed out after ${stepTimeout}ms`,
|
|
4380
|
+
step.id
|
|
4381
|
+
);
|
|
4382
|
+
const rawPayload = step.payload || {};
|
|
4383
|
+
const interpolatedPayload = interpolateValue(rawPayload, context) || {};
|
|
4384
|
+
const resolvedStep = {
|
|
4385
|
+
...step,
|
|
4386
|
+
payload: interpolatedPayload
|
|
4387
|
+
};
|
|
4388
|
+
const customHandler = options?.handlers?.[step.type];
|
|
4389
|
+
const handler = customHandler || this.getHandler(step.type);
|
|
4390
|
+
let stepOutput;
|
|
4391
|
+
let stepError;
|
|
4392
|
+
let stepStatus = "success";
|
|
4393
|
+
const subResults = [];
|
|
4394
|
+
try {
|
|
4395
|
+
if (!handler) {
|
|
4396
|
+
throw new Error(`No handler registered for action step type: "${step.type}"`);
|
|
4397
|
+
}
|
|
4398
|
+
if (stepSignal.aborted) {
|
|
4399
|
+
throw normalizeAbortError(stepSignal.reason, step.id);
|
|
4400
|
+
}
|
|
4401
|
+
stepOutput = await handler(resolvedStep, context, stepSignal);
|
|
4402
|
+
if (stepOutput !== void 0) {
|
|
4403
|
+
context.response = stepOutput;
|
|
4404
|
+
}
|
|
4405
|
+
delete context.lastError;
|
|
4406
|
+
if (interpolatedPayload.responseMapping && typeof interpolatedPayload.responseMapping === "object") {
|
|
4407
|
+
const mapping = interpolatedPayload.responseMapping;
|
|
4408
|
+
for (const [targetVar, sourcePath] of Object.entries(mapping)) {
|
|
4409
|
+
const evalContext = {
|
|
4410
|
+
...context,
|
|
4411
|
+
response: stepOutput !== void 0 ? stepOutput : context.response
|
|
4412
|
+
};
|
|
4413
|
+
const cleanPath = String(sourcePath).replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4414
|
+
const mappedVal = resolvePropertyPath(evalContext, cleanPath, void 0);
|
|
4415
|
+
if (mappedVal !== void 0) {
|
|
4416
|
+
if (!context.variables) context.variables = {};
|
|
4417
|
+
context.variables[targetVar] = mappedVal;
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
if (step.onSuccess && Array.isArray(step.onSuccess) && step.onSuccess.length > 0) {
|
|
4422
|
+
const successBranch = await this.executeSteps(
|
|
4423
|
+
step.onSuccess,
|
|
4424
|
+
context,
|
|
4425
|
+
stepSignal,
|
|
4426
|
+
options
|
|
4427
|
+
);
|
|
4428
|
+
subResults.push(...successBranch.results);
|
|
4429
|
+
if (!successBranch.success) {
|
|
4430
|
+
stepStatus = "error";
|
|
4431
|
+
stepError = successBranch.error;
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
stepError = err;
|
|
4436
|
+
stepStatus = stepSignal.aborted ? "cancelled" : "error";
|
|
4437
|
+
context.lastError = err;
|
|
4438
|
+
context.error = err;
|
|
4439
|
+
if (step.onError && Array.isArray(step.onError) && step.onError.length > 0) {
|
|
4440
|
+
try {
|
|
4441
|
+
const errorBranch = await this.executeSteps(
|
|
4442
|
+
step.onError,
|
|
4443
|
+
context,
|
|
4444
|
+
parentSignal,
|
|
4445
|
+
// Use parent signal so error branch can run even if step timed out
|
|
4446
|
+
options
|
|
4447
|
+
);
|
|
4448
|
+
subResults.push(...errorBranch.results);
|
|
4449
|
+
} catch (onErrorErr) {
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4452
|
+
} finally {
|
|
4453
|
+
cleanupStepSignal();
|
|
4454
|
+
}
|
|
4455
|
+
const result = {
|
|
4456
|
+
stepId: step.id,
|
|
4457
|
+
stepType: step.type,
|
|
4458
|
+
status: stepStatus,
|
|
4459
|
+
data: stepOutput,
|
|
4460
|
+
error: stepError,
|
|
4461
|
+
durationMs: Date.now() - stepStartTime,
|
|
4462
|
+
...subResults.length > 0 ? { subResults } : {}
|
|
4463
|
+
};
|
|
4464
|
+
options?.onStepComplete?.(step, result, context);
|
|
4465
|
+
return result;
|
|
4466
|
+
}
|
|
4467
|
+
};
|
|
4468
|
+
async function executeActionPipeline(pipeline, options) {
|
|
4469
|
+
const executor = new ActionPipelineExecutor();
|
|
4470
|
+
return executor.execute(pipeline, options);
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
// src/state-store.ts
|
|
4474
|
+
var FORBIDDEN_KEY_SEGMENTS4 = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
4475
|
+
function createDefaultFormState(initialValues) {
|
|
4476
|
+
const init = initialValues ? { ...initialValues } : {};
|
|
4477
|
+
return {
|
|
4478
|
+
values: { ...init },
|
|
4479
|
+
errors: {},
|
|
4480
|
+
touched: {},
|
|
4481
|
+
isSubmitting: false,
|
|
4482
|
+
isValid: true,
|
|
4483
|
+
dirty: false,
|
|
4484
|
+
initialValues: { ...init }
|
|
4485
|
+
};
|
|
4486
|
+
}
|
|
4487
|
+
function cloneState(obj) {
|
|
4488
|
+
if (obj === null || typeof obj !== "object") {
|
|
4489
|
+
return obj;
|
|
4490
|
+
}
|
|
4491
|
+
if (Array.isArray(obj)) {
|
|
4492
|
+
return obj.map((item) => cloneState(item));
|
|
4493
|
+
}
|
|
4494
|
+
const copy = {};
|
|
4495
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
4496
|
+
if (!FORBIDDEN_KEY_SEGMENTS4.has(k)) {
|
|
4497
|
+
copy[k] = cloneState(v);
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
return copy;
|
|
4501
|
+
}
|
|
4502
|
+
function setNestedPath(target, path, value) {
|
|
4503
|
+
if (!path || typeof path !== "string" || !target || typeof target !== "object") {
|
|
4504
|
+
return false;
|
|
4505
|
+
}
|
|
4506
|
+
const normalized = path.replace(/\[(\d+)\]/g, ".$1");
|
|
4507
|
+
const segments = normalized.split(".").map((s) => s.trim()).filter(Boolean);
|
|
4508
|
+
if (segments.length === 0) return false;
|
|
4509
|
+
let current = target;
|
|
4510
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
4511
|
+
const seg = segments[i];
|
|
4512
|
+
if (FORBIDDEN_KEY_SEGMENTS4.has(seg)) return false;
|
|
4513
|
+
if (current[seg] === void 0 || current[seg] === null || typeof current[seg] !== "object") {
|
|
4514
|
+
current[seg] = {};
|
|
4515
|
+
}
|
|
4516
|
+
current = current[seg];
|
|
4517
|
+
}
|
|
4518
|
+
const lastSeg = segments[segments.length - 1];
|
|
4519
|
+
if (FORBIDDEN_KEY_SEGMENTS4.has(lastSeg)) return false;
|
|
4520
|
+
current[lastSeg] = value;
|
|
4521
|
+
return true;
|
|
4522
|
+
}
|
|
4523
|
+
function deleteNestedPath(target, path) {
|
|
4524
|
+
if (!path || typeof path !== "string" || !target || typeof target !== "object") {
|
|
4525
|
+
return false;
|
|
4526
|
+
}
|
|
4527
|
+
const normalized = path.replace(/\[(\d+)\]/g, ".$1");
|
|
4528
|
+
const segments = normalized.split(".").map((s) => s.trim()).filter(Boolean);
|
|
4529
|
+
if (segments.length === 0) return false;
|
|
4530
|
+
let current = target;
|
|
4531
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
4532
|
+
const seg = segments[i];
|
|
4533
|
+
if (FORBIDDEN_KEY_SEGMENTS4.has(seg) || !(seg in current) || typeof current[seg] !== "object") {
|
|
4534
|
+
return false;
|
|
4535
|
+
}
|
|
4536
|
+
current = current[seg];
|
|
4537
|
+
}
|
|
4538
|
+
const lastSeg = segments[segments.length - 1];
|
|
4539
|
+
if (FORBIDDEN_KEY_SEGMENTS4.has(lastSeg) || !(lastSeg in current)) {
|
|
4540
|
+
return false;
|
|
4541
|
+
}
|
|
4542
|
+
delete current[lastSeg];
|
|
4543
|
+
return true;
|
|
4544
|
+
}
|
|
4545
|
+
var RuntimeStateStore = class _RuntimeStateStore {
|
|
4546
|
+
state;
|
|
4547
|
+
listeners = /* @__PURE__ */ new Set();
|
|
4548
|
+
pathListeners = /* @__PURE__ */ new Map();
|
|
4549
|
+
formListeners = /* @__PURE__ */ new Map();
|
|
4550
|
+
isBatching = false;
|
|
4551
|
+
batchOldState;
|
|
4552
|
+
isNotifying = false;
|
|
4553
|
+
constructor(initialState) {
|
|
4554
|
+
this.state = {
|
|
4555
|
+
variables: initialState?.variables ? { ...initialState.variables } : {},
|
|
4556
|
+
forms: initialState?.forms ? cloneState(initialState.forms) : {},
|
|
4557
|
+
state: initialState?.state ? { ...initialState.state } : {},
|
|
4558
|
+
...initialState
|
|
4559
|
+
};
|
|
4560
|
+
}
|
|
4561
|
+
/**
|
|
4562
|
+
* Retrieves a value at a specified path or the entire state snapshot.
|
|
4563
|
+
*/
|
|
4564
|
+
get(path, fallback) {
|
|
4565
|
+
if (!path || path.trim() === "") {
|
|
4566
|
+
return this.getSnapshot();
|
|
4567
|
+
}
|
|
4568
|
+
const cleanPath = path.replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4569
|
+
const resolved = resolvePropertyPath(this.state, cleanPath, fallback);
|
|
4570
|
+
return resolved;
|
|
4571
|
+
}
|
|
4572
|
+
/**
|
|
4573
|
+
* Gets an immutable snapshot of the current state.
|
|
4574
|
+
*/
|
|
4575
|
+
getSnapshot() {
|
|
4576
|
+
return cloneState(this.state);
|
|
4577
|
+
}
|
|
4578
|
+
/**
|
|
4579
|
+
* Sets a value at a dotted path and notifies subscribers.
|
|
4580
|
+
*/
|
|
4581
|
+
set(path, value) {
|
|
4582
|
+
if (!path) return this;
|
|
4583
|
+
const oldState = this.isBatching ? void 0 : cloneState(this.state);
|
|
4584
|
+
const cleanPath = path.replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4585
|
+
const success = setNestedPath(this.state, cleanPath, value);
|
|
4586
|
+
if (!success) return this;
|
|
4587
|
+
if (!this.isBatching && oldState) {
|
|
4588
|
+
this.notifyChanges(oldState, this.state);
|
|
4589
|
+
}
|
|
4590
|
+
return this;
|
|
4591
|
+
}
|
|
4592
|
+
/**
|
|
4593
|
+
* Performs multiple updates atomically, triggering subscriber notifications once.
|
|
4594
|
+
*/
|
|
4595
|
+
setBatch(updates) {
|
|
4596
|
+
if (!updates || typeof updates !== "object") return this;
|
|
4597
|
+
const oldState = this.batchOldState || cloneState(this.state);
|
|
4598
|
+
this.isBatching = true;
|
|
4599
|
+
this.batchOldState = oldState;
|
|
4600
|
+
try {
|
|
4601
|
+
for (const [path, value] of Object.entries(updates)) {
|
|
4602
|
+
this.set(path, value);
|
|
4603
|
+
}
|
|
4604
|
+
} finally {
|
|
4605
|
+
this.isBatching = false;
|
|
4606
|
+
this.batchOldState = void 0;
|
|
4607
|
+
this.notifyChanges(oldState, this.state);
|
|
4608
|
+
}
|
|
4609
|
+
return this;
|
|
4610
|
+
}
|
|
4611
|
+
/**
|
|
4612
|
+
* Deletes a property at the specified path.
|
|
4613
|
+
*/
|
|
4614
|
+
delete(path) {
|
|
4615
|
+
if (!path) return false;
|
|
4616
|
+
const oldState = this.isBatching ? void 0 : cloneState(this.state);
|
|
4617
|
+
const cleanPath = path.replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4618
|
+
const deleted = deleteNestedPath(this.state, cleanPath);
|
|
4619
|
+
if (deleted && !this.isBatching && oldState) {
|
|
4620
|
+
this.notifyChanges(oldState, this.state);
|
|
4621
|
+
}
|
|
4622
|
+
return deleted;
|
|
4623
|
+
}
|
|
4624
|
+
/**
|
|
4625
|
+
* Resets the store state to an initial or clean state.
|
|
4626
|
+
*/
|
|
4627
|
+
reset(initialState) {
|
|
4628
|
+
const oldState = cloneState(this.state);
|
|
4629
|
+
this.state = {
|
|
4630
|
+
variables: initialState?.variables ? { ...initialState.variables } : {},
|
|
4631
|
+
forms: initialState?.forms ? cloneState(initialState.forms) : {},
|
|
4632
|
+
state: initialState?.state ? { ...initialState.state } : {},
|
|
4633
|
+
...initialState
|
|
4634
|
+
};
|
|
4635
|
+
this.notifyChanges(oldState, this.state);
|
|
4636
|
+
return this;
|
|
4637
|
+
}
|
|
4638
|
+
/**
|
|
4639
|
+
* Subscribes a listener to any state changes.
|
|
4640
|
+
*/
|
|
4641
|
+
subscribe(listener) {
|
|
4642
|
+
this.listeners.add(listener);
|
|
4643
|
+
return () => {
|
|
4644
|
+
this.listeners.delete(listener);
|
|
4645
|
+
};
|
|
4646
|
+
}
|
|
4647
|
+
/**
|
|
4648
|
+
* Subscribes a listener to changes on a top-level key.
|
|
4649
|
+
*/
|
|
4650
|
+
subscribeKey(key, listener) {
|
|
4651
|
+
return this.subscribePath(key, listener);
|
|
4652
|
+
}
|
|
4653
|
+
/**
|
|
4654
|
+
* Subscribes a listener to changes at a specific dotted path.
|
|
4655
|
+
*/
|
|
4656
|
+
subscribePath(path, listener) {
|
|
4657
|
+
const cleanPath = path.replace(/^\{\{\s*/, "").replace(/\s*\}\}$/, "").trim();
|
|
4658
|
+
if (!this.pathListeners.has(cleanPath)) {
|
|
4659
|
+
this.pathListeners.set(cleanPath, /* @__PURE__ */ new Set());
|
|
4660
|
+
}
|
|
4661
|
+
const set = this.pathListeners.get(cleanPath);
|
|
4662
|
+
set.add(listener);
|
|
4663
|
+
return () => {
|
|
4664
|
+
set.delete(listener);
|
|
4665
|
+
if (set.size === 0) {
|
|
4666
|
+
this.pathListeners.delete(cleanPath);
|
|
4667
|
+
}
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
/**
|
|
4671
|
+
* Subscribes a listener to changes of a specific form state.
|
|
4672
|
+
*/
|
|
4673
|
+
subscribeForm(formId, listener) {
|
|
4674
|
+
if (!this.formListeners.has(formId)) {
|
|
4675
|
+
this.formListeners.set(formId, /* @__PURE__ */ new Set());
|
|
4676
|
+
}
|
|
4677
|
+
const set = this.formListeners.get(formId);
|
|
4678
|
+
set.add(listener);
|
|
4679
|
+
return () => {
|
|
4680
|
+
set.delete(listener);
|
|
4681
|
+
if (set.size === 0) {
|
|
4682
|
+
this.formListeners.delete(formId);
|
|
4683
|
+
}
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4686
|
+
/**
|
|
4687
|
+
* Notifies all relevant listeners when state changes.
|
|
4688
|
+
*/
|
|
4689
|
+
notifyChanges(oldState, newState) {
|
|
4690
|
+
if (this.isNotifying) return;
|
|
4691
|
+
this.isNotifying = true;
|
|
4692
|
+
try {
|
|
4693
|
+
const readOnlyNew = Object.freeze(cloneState(newState));
|
|
4694
|
+
const readOnlyOld = Object.freeze(cloneState(oldState));
|
|
4695
|
+
for (const listener of this.listeners) {
|
|
4696
|
+
try {
|
|
4697
|
+
listener(readOnlyNew, readOnlyOld);
|
|
4698
|
+
} catch {
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
for (const [path, listeners] of this.pathListeners.entries()) {
|
|
4702
|
+
const oldVal = resolvePropertyPath(oldState, path, void 0);
|
|
4703
|
+
const newVal = resolvePropertyPath(newState, path, void 0);
|
|
4704
|
+
if (oldVal !== newVal) {
|
|
4705
|
+
for (const listener of listeners) {
|
|
4706
|
+
try {
|
|
4707
|
+
listener(newVal, oldVal);
|
|
4708
|
+
} catch {
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
for (const [formId, listeners] of this.formListeners.entries()) {
|
|
4714
|
+
const oldForm = oldState.forms?.[formId];
|
|
4715
|
+
const newForm = newState.forms?.[formId];
|
|
4716
|
+
if (oldForm !== newForm) {
|
|
4717
|
+
for (const listener of listeners) {
|
|
4718
|
+
try {
|
|
4719
|
+
listener(newForm || createDefaultFormState(), oldForm);
|
|
4720
|
+
} catch {
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
} finally {
|
|
4726
|
+
this.isNotifying = false;
|
|
4727
|
+
}
|
|
4728
|
+
}
|
|
4729
|
+
// ==========================================
|
|
4730
|
+
// Form State Management Helpers
|
|
4731
|
+
// ==========================================
|
|
4732
|
+
/**
|
|
4733
|
+
* Retrieves the FormState for a formId, initializing default form state if not present.
|
|
4734
|
+
*/
|
|
4735
|
+
getForm(formId) {
|
|
4736
|
+
if (!this.state.forms[formId]) {
|
|
4737
|
+
this.state.forms[formId] = createDefaultFormState();
|
|
4738
|
+
}
|
|
4739
|
+
return this.state.forms[formId];
|
|
4740
|
+
}
|
|
4741
|
+
/**
|
|
4742
|
+
* Updates a single field value in a form and marks dirty if changed from initial.
|
|
4743
|
+
*/
|
|
4744
|
+
setFormFieldValue(formId, fieldName, value) {
|
|
4745
|
+
const form = this.getForm(formId);
|
|
4746
|
+
const oldValues = { ...form.values };
|
|
4747
|
+
form.values[fieldName] = value;
|
|
4748
|
+
const initialVal = form.initialValues?.[fieldName];
|
|
4749
|
+
form.dirty = Object.keys(form.values).some((k) => form.values[k] !== form.initialValues?.[k]);
|
|
4750
|
+
this.set(`forms.${formId}.values.${fieldName}`, value);
|
|
4751
|
+
return this;
|
|
4752
|
+
}
|
|
4753
|
+
/**
|
|
4754
|
+
* Sets or clears an error for a form field.
|
|
4755
|
+
*/
|
|
4756
|
+
setFormFieldError(formId, fieldName, error) {
|
|
4757
|
+
const form = this.getForm(formId);
|
|
4758
|
+
if (error) {
|
|
4759
|
+
form.errors[fieldName] = error;
|
|
4760
|
+
} else {
|
|
4761
|
+
delete form.errors[fieldName];
|
|
4762
|
+
}
|
|
4763
|
+
form.isValid = Object.keys(form.errors).length === 0;
|
|
4764
|
+
this.set(`forms.${formId}.errors`, { ...form.errors });
|
|
4765
|
+
this.set(`forms.${formId}.isValid`, form.isValid);
|
|
4766
|
+
return this;
|
|
4767
|
+
}
|
|
4768
|
+
/**
|
|
4769
|
+
* Marks a form field as touched (or untouched).
|
|
4770
|
+
*/
|
|
4771
|
+
setFormFieldTouched(formId, fieldName, touched = true) {
|
|
4772
|
+
const form = this.getForm(formId);
|
|
4773
|
+
form.touched[fieldName] = touched;
|
|
4774
|
+
this.set(`forms.${formId}.touched.${fieldName}`, touched);
|
|
4775
|
+
return this;
|
|
4776
|
+
}
|
|
4777
|
+
/**
|
|
4778
|
+
* Updates multiple form errors simultaneously.
|
|
4779
|
+
*/
|
|
4780
|
+
setFormErrors(formId, errors) {
|
|
4781
|
+
const form = this.getForm(formId);
|
|
4782
|
+
form.errors = { ...errors };
|
|
4783
|
+
form.isValid = Object.keys(errors).length === 0;
|
|
4784
|
+
this.set(`forms.${formId}.errors`, form.errors);
|
|
4785
|
+
this.set(`forms.${formId}.isValid`, form.isValid);
|
|
4786
|
+
return this;
|
|
4787
|
+
}
|
|
4788
|
+
/**
|
|
4789
|
+
* Sets multiple form field values simultaneously.
|
|
4790
|
+
*/
|
|
4791
|
+
setFormValues(formId, values, replace = false) {
|
|
4792
|
+
const form = this.getForm(formId);
|
|
4793
|
+
form.values = replace ? { ...values } : { ...form.values, ...values };
|
|
4794
|
+
form.dirty = Object.keys(form.values).some((k) => form.values[k] !== form.initialValues?.[k]);
|
|
4795
|
+
this.set(`forms.${formId}.values`, { ...form.values });
|
|
4796
|
+
this.set(`forms.${formId}.dirty`, form.dirty);
|
|
4797
|
+
return this;
|
|
4798
|
+
}
|
|
4799
|
+
/**
|
|
4800
|
+
* Sets the submitting status of a form.
|
|
4801
|
+
*/
|
|
4802
|
+
setFormSubmitting(formId, isSubmitting) {
|
|
4803
|
+
const form = this.getForm(formId);
|
|
4804
|
+
form.isSubmitting = isSubmitting;
|
|
4805
|
+
this.set(`forms.${formId}.isSubmitting`, isSubmitting);
|
|
4806
|
+
return this;
|
|
4807
|
+
}
|
|
4808
|
+
/**
|
|
4809
|
+
* Resets a form's values, errors, touched, and submitting state to defaults or specified values.
|
|
4810
|
+
*/
|
|
4811
|
+
resetForm(formId, initialValues) {
|
|
4812
|
+
const newFormState = createDefaultFormState(
|
|
4813
|
+
initialValues || this.state.forms[formId]?.initialValues
|
|
4814
|
+
);
|
|
4815
|
+
this.set(`forms.${formId}`, newFormState);
|
|
4816
|
+
return this;
|
|
4817
|
+
}
|
|
4818
|
+
// ==========================================
|
|
4819
|
+
// Scoping & Isolation
|
|
4820
|
+
// ==========================================
|
|
4821
|
+
/**
|
|
4822
|
+
* Creates an isolated child scope store for a page or component container.
|
|
4823
|
+
*/
|
|
4824
|
+
createScope(scopeId, initialValues) {
|
|
4825
|
+
const scopedState = {
|
|
4826
|
+
variables: { ...initialValues || {} },
|
|
4827
|
+
forms: {},
|
|
4828
|
+
state: {}
|
|
4829
|
+
};
|
|
4830
|
+
return new _RuntimeStateStore(scopedState);
|
|
4831
|
+
}
|
|
4832
|
+
};
|
|
4833
|
+
function createRuntimeStore(initialState) {
|
|
4834
|
+
return new RuntimeStateStore(initialState);
|
|
4835
|
+
}
|
|
3547
4836
|
export {
|
|
4837
|
+
ActionCancellationError,
|
|
4838
|
+
ActionPipelineExecutor,
|
|
4839
|
+
ActionTimeoutError,
|
|
3548
4840
|
CORE_BUILTIN_COMPONENTS,
|
|
3549
4841
|
DEFAULT_DOCUMENT_SECURITY_LIMITS,
|
|
3550
4842
|
DEFAULT_MAX_HISTORY,
|
|
@@ -3552,6 +4844,8 @@ export {
|
|
|
3552
4844
|
DocumentHistoryManager,
|
|
3553
4845
|
HistoryEngine,
|
|
3554
4846
|
MigrationRegistry,
|
|
4847
|
+
RuntimeStateStore,
|
|
4848
|
+
applyFieldTransform,
|
|
3555
4849
|
areNodeIdsCompletelyDistinct,
|
|
3556
4850
|
buildSampleVariablesFromCatalog,
|
|
3557
4851
|
calculateChecksum,
|
|
@@ -3565,16 +4859,26 @@ export {
|
|
|
3565
4859
|
compareManifestsSemantically,
|
|
3566
4860
|
containsProhibitedKeys,
|
|
3567
4861
|
createBlankDocument,
|
|
4862
|
+
createDefaultFormState,
|
|
4863
|
+
createRuntimeStore,
|
|
3568
4864
|
createTemplateRecord,
|
|
3569
4865
|
deepClone,
|
|
3570
4866
|
defaultIdGenerator,
|
|
3571
4867
|
defaultMigrationRegistry,
|
|
3572
4868
|
defaultRenameAssetStrategy,
|
|
3573
4869
|
duplicateNode,
|
|
4870
|
+
evaluateActionCondition,
|
|
4871
|
+
evaluateCondition,
|
|
4872
|
+
evaluateConditionGroup,
|
|
4873
|
+
evaluateConditions,
|
|
4874
|
+
evaluateOperator,
|
|
4875
|
+
evaluateRule,
|
|
4876
|
+
executeActionPipeline,
|
|
3574
4877
|
exportPackage,
|
|
3575
4878
|
exportStoraPackage,
|
|
3576
4879
|
extractRequirementsFromTree,
|
|
3577
4880
|
extractTemplateRequirements,
|
|
4881
|
+
extractTemplateVariables,
|
|
3578
4882
|
findMissingComponentNodes,
|
|
3579
4883
|
findNodeById,
|
|
3580
4884
|
findNodeLocation,
|
|
@@ -3583,14 +4887,21 @@ export {
|
|
|
3583
4887
|
getNavigationTarget,
|
|
3584
4888
|
getNodeAncestors,
|
|
3585
4889
|
getParentNodeId,
|
|
4890
|
+
hasTemplateExpressions,
|
|
3586
4891
|
importPackage,
|
|
3587
4892
|
importStoraPackage,
|
|
3588
4893
|
insertNode,
|
|
3589
4894
|
inspectPackage,
|
|
4895
|
+
interpolateTemplateString,
|
|
4896
|
+
interpolateValue,
|
|
4897
|
+
isConditionGroup,
|
|
3590
4898
|
isDangerousAssetFilename,
|
|
3591
4899
|
isDangerousPath,
|
|
3592
4900
|
isDescendantOf,
|
|
4901
|
+
isEmptyValue,
|
|
4902
|
+
isFormValid,
|
|
3593
4903
|
isSafeUrl,
|
|
4904
|
+
isValueEmpty,
|
|
3594
4905
|
migrateDocument,
|
|
3595
4906
|
moveNode,
|
|
3596
4907
|
preflightPackage,
|
|
@@ -3600,15 +4911,23 @@ export {
|
|
|
3600
4911
|
removeNode,
|
|
3601
4912
|
resolveBinding,
|
|
3602
4913
|
resolveBindingValue,
|
|
4914
|
+
resolvePropertyPath,
|
|
3603
4915
|
sanitizeFilename,
|
|
3604
4916
|
sanitizeHtml,
|
|
3605
4917
|
sanitizeUrl,
|
|
3606
4918
|
saveDraftAsTemplate,
|
|
3607
4919
|
sha256Sync,
|
|
4920
|
+
updateActions,
|
|
4921
|
+
updateAnimation,
|
|
4922
|
+
updateFormConfig,
|
|
3608
4923
|
updateProps,
|
|
3609
4924
|
updateStyle,
|
|
3610
4925
|
validateDocument,
|
|
3611
4926
|
validateDocumentSecurity,
|
|
4927
|
+
validateFieldValue,
|
|
4928
|
+
validateFieldValueAsync,
|
|
4929
|
+
validateForm,
|
|
4930
|
+
validateFormAsync,
|
|
3612
4931
|
validateTemplate
|
|
3613
4932
|
};
|
|
3614
4933
|
//# sourceMappingURL=index.js.map
|