@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/index.js CHANGED
@@ -1081,6 +1081,32 @@ var WorkflowRuntimeState = class {
1081
1081
  }
1082
1082
  return result;
1083
1083
  }
1084
+ parseTemplate(template) {
1085
+ if (template?.type !== "template") {
1086
+ throw new Error(`invalid template value: ${template}`);
1087
+ }
1088
+ if (!template.content) {
1089
+ return null;
1090
+ }
1091
+ const parsedValue = template.content.replace(
1092
+ /\{\{([^\}]+)\}\}/g,
1093
+ (match, pattern) => {
1094
+ const ref = pattern.trim().split(".");
1095
+ const variable = this.parseRef({
1096
+ type: "ref",
1097
+ content: ref
1098
+ });
1099
+ if (!variable) {
1100
+ return "";
1101
+ }
1102
+ return variable.value;
1103
+ }
1104
+ );
1105
+ return {
1106
+ type: WorkflowVariableType.String,
1107
+ value: parsedValue
1108
+ };
1109
+ }
1084
1110
  parseValue(flowValue) {
1085
1111
  if (!flowValue?.type) {
1086
1112
  throw new Error(`invalid flow value type: ${flowValue.type}`);
@@ -1099,6 +1125,9 @@ var WorkflowRuntimeState = class {
1099
1125
  if (flowValue.type === "ref") {
1100
1126
  return this.parseRef(flowValue);
1101
1127
  }
1128
+ if (flowValue.type === "template") {
1129
+ return this.parseTemplate(flowValue);
1130
+ }
1102
1131
  throw new Error(`unknown flow value type: ${flowValue.type}`);
1103
1132
  }
1104
1133
  isExecutedNode(node) {