@flowgram.ai/runtime-js 0.2.19 → 0.2.21
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/esm/index.js +29 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1041,6 +1041,32 @@ var WorkflowRuntimeState = class {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
return result;
|
|
1043
1043
|
}
|
|
1044
|
+
parseTemplate(template) {
|
|
1045
|
+
if (template?.type !== "template") {
|
|
1046
|
+
throw new Error(`invalid template value: ${template}`);
|
|
1047
|
+
}
|
|
1048
|
+
if (!template.content) {
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
1051
|
+
const parsedValue = template.content.replace(
|
|
1052
|
+
/\{\{([^\}]+)\}\}/g,
|
|
1053
|
+
(match, pattern) => {
|
|
1054
|
+
const ref = pattern.trim().split(".");
|
|
1055
|
+
const variable = this.parseRef({
|
|
1056
|
+
type: "ref",
|
|
1057
|
+
content: ref
|
|
1058
|
+
});
|
|
1059
|
+
if (!variable) {
|
|
1060
|
+
return "";
|
|
1061
|
+
}
|
|
1062
|
+
return variable.value;
|
|
1063
|
+
}
|
|
1064
|
+
);
|
|
1065
|
+
return {
|
|
1066
|
+
type: WorkflowVariableType.String,
|
|
1067
|
+
value: parsedValue
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1044
1070
|
parseValue(flowValue) {
|
|
1045
1071
|
if (!flowValue?.type) {
|
|
1046
1072
|
throw new Error(`invalid flow value type: ${flowValue.type}`);
|
|
@@ -1059,6 +1085,9 @@ var WorkflowRuntimeState = class {
|
|
|
1059
1085
|
if (flowValue.type === "ref") {
|
|
1060
1086
|
return this.parseRef(flowValue);
|
|
1061
1087
|
}
|
|
1088
|
+
if (flowValue.type === "template") {
|
|
1089
|
+
return this.parseTemplate(flowValue);
|
|
1090
|
+
}
|
|
1062
1091
|
throw new Error(`unknown flow value type: ${flowValue.type}`);
|
|
1063
1092
|
}
|
|
1064
1093
|
isExecutedNode(node) {
|