mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-03 18:24:53 +00:00
various changes
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
{
|
||||
"$schema": "../../../schemas/plugin-nodes.schema.json",
|
||||
"category": {
|
||||
"id": "string",
|
||||
"name": "String",
|
||||
"color": "#9b59b6",
|
||||
"icon": "type"
|
||||
},
|
||||
"nodes": [
|
||||
{
|
||||
"id": "string.concat",
|
||||
"name": "Concat",
|
||||
"description": "Concatenate strings",
|
||||
"icon": "link",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "values": [], "separator": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.format",
|
||||
"name": "Format",
|
||||
"description": "Format string with template variables",
|
||||
"icon": "file-text",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "template": "", "values": {} }
|
||||
},
|
||||
{
|
||||
"id": "string.length",
|
||||
"name": "Length",
|
||||
"description": "Get string length",
|
||||
"icon": "hash",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.lower",
|
||||
"name": "Lowercase",
|
||||
"description": "Convert to lowercase",
|
||||
"icon": "type",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.upper",
|
||||
"name": "Uppercase",
|
||||
"description": "Convert to uppercase",
|
||||
"icon": "type",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.trim",
|
||||
"name": "Trim",
|
||||
"description": "Remove whitespace from start and end",
|
||||
"icon": "scissors",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.replace",
|
||||
"name": "Replace",
|
||||
"description": "Replace occurrences in string",
|
||||
"icon": "refresh-cw",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "", "search": "", "replace": "", "all": true }
|
||||
},
|
||||
{
|
||||
"id": "string.split",
|
||||
"name": "Split",
|
||||
"description": "Split string into array",
|
||||
"icon": "scissors",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "", "separator": "," }
|
||||
},
|
||||
{
|
||||
"id": "string.join",
|
||||
"name": "Join",
|
||||
"description": "Join array into string",
|
||||
"icon": "link",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "values": [], "separator": "," }
|
||||
},
|
||||
{
|
||||
"id": "string.substring",
|
||||
"name": "Substring",
|
||||
"description": "Extract portion of string",
|
||||
"icon": "crop",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "", "start": 0, "end": null }
|
||||
},
|
||||
{
|
||||
"id": "string.includes",
|
||||
"name": "Includes",
|
||||
"description": "Check if string contains substring",
|
||||
"icon": "search",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["true", "false"],
|
||||
"defaultConfig": { "value": "", "search": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.startsWith",
|
||||
"name": "Starts With",
|
||||
"description": "Check if string starts with substring",
|
||||
"icon": "skip-back",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["true", "false"],
|
||||
"defaultConfig": { "value": "", "search": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.endsWith",
|
||||
"name": "Ends With",
|
||||
"description": "Check if string ends with substring",
|
||||
"icon": "skip-forward",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["true", "false"],
|
||||
"defaultConfig": { "value": "", "search": "" }
|
||||
},
|
||||
{
|
||||
"id": "string.padStart",
|
||||
"name": "Pad Start",
|
||||
"description": "Pad string at start to target length",
|
||||
"icon": "align-left",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "", "length": 0, "padChar": " " }
|
||||
},
|
||||
{
|
||||
"id": "string.padEnd",
|
||||
"name": "Pad End",
|
||||
"description": "Pad string at end to target length",
|
||||
"icon": "align-right",
|
||||
"inputs": ["main"],
|
||||
"outputs": ["main"],
|
||||
"defaultConfig": { "value": "", "length": 0, "padChar": " " }
|
||||
}
|
||||
]
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Workflow plugin: String manipulation operations.
|
||||
*/
|
||||
import { NodeExecutor, ExecuteInputs, ExecuteResult } from '../../base';
|
||||
export declare class StringConcat implements NodeExecutor {
|
||||
readonly nodeType = "string.concat";
|
||||
readonly category = "string";
|
||||
readonly description = "Concatenate multiple strings with an optional separator";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringFormat implements NodeExecutor {
|
||||
readonly nodeType = "string.format";
|
||||
readonly category = "string";
|
||||
readonly description = "Format string with variables using {key} placeholders";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringLength implements NodeExecutor {
|
||||
readonly nodeType = "string.length";
|
||||
readonly category = "string";
|
||||
readonly description = "Get the length of a string";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringLower implements NodeExecutor {
|
||||
readonly nodeType = "string.lower";
|
||||
readonly category = "string";
|
||||
readonly description = "Convert string to lowercase";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringUpper implements NodeExecutor {
|
||||
readonly nodeType = "string.upper";
|
||||
readonly category = "string";
|
||||
readonly description = "Convert string to uppercase";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringTrim implements NodeExecutor {
|
||||
readonly nodeType = "string.trim";
|
||||
readonly category = "string";
|
||||
readonly description = "Trim whitespace from string (both ends, start only, or end only)";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringReplace implements NodeExecutor {
|
||||
readonly nodeType = "string.replace";
|
||||
readonly category = "string";
|
||||
readonly description = "Replace substring in string (single or all occurrences)";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringSplit implements NodeExecutor {
|
||||
readonly nodeType = "string.split";
|
||||
readonly category = "string";
|
||||
readonly description = "Split string into array by separator";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringJoin implements NodeExecutor {
|
||||
readonly nodeType = "string.join";
|
||||
readonly category = "string";
|
||||
readonly description = "Join array elements into string with separator";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringSubstring implements NodeExecutor {
|
||||
readonly nodeType = "string.substring";
|
||||
readonly category = "string";
|
||||
readonly description = "Extract substring from string by start and end index";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringIncludes implements NodeExecutor {
|
||||
readonly nodeType = "string.includes";
|
||||
readonly category = "string";
|
||||
readonly description = "Check if string contains a substring";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringStartsWith implements NodeExecutor {
|
||||
readonly nodeType = "string.startsWith";
|
||||
readonly category = "string";
|
||||
readonly description = "Check if string starts with a prefix";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringEndsWith implements NodeExecutor {
|
||||
readonly nodeType = "string.endsWith";
|
||||
readonly category = "string";
|
||||
readonly description = "Check if string ends with a suffix";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringPadStart implements NodeExecutor {
|
||||
readonly nodeType = "string.padStart";
|
||||
readonly category = "string";
|
||||
readonly description = "Pad string at the start to reach target length";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare class StringPadEnd implements NodeExecutor {
|
||||
readonly nodeType = "string.padEnd";
|
||||
readonly category = "string";
|
||||
readonly description = "Pad string at the end to reach target length";
|
||||
execute(inputs: ExecuteInputs): ExecuteResult;
|
||||
}
|
||||
export declare const stringPluginClasses: {
|
||||
'string.concat': typeof StringConcat;
|
||||
'string.format': typeof StringFormat;
|
||||
'string.length': typeof StringLength;
|
||||
'string.lower': typeof StringLower;
|
||||
'string.upper': typeof StringUpper;
|
||||
'string.trim': typeof StringTrim;
|
||||
'string.replace': typeof StringReplace;
|
||||
'string.split': typeof StringSplit;
|
||||
'string.join': typeof StringJoin;
|
||||
'string.substring': typeof StringSubstring;
|
||||
'string.includes': typeof StringIncludes;
|
||||
'string.startsWith': typeof StringStartsWith;
|
||||
'string.endsWith': typeof StringEndsWith;
|
||||
'string.padStart': typeof StringPadStart;
|
||||
'string.padEnd': typeof StringPadEnd;
|
||||
};
|
||||
export default stringPluginClasses;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAyB,MAAM,YAAY,CAAC;AAU/F,qBAAa,YAAa,YAAW,YAAY;IAC/C,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,QAAQ,YAAY;IAC7B,QAAQ,CAAC,WAAW,6DAA6D;IAEjF,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;CAM9C;AAED,qBAAa,YAAa,YAAW,YAAY;IAC/C,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,QAAQ,YAAY;IAC7B,QAAQ,CAAC,WAAW,2DAA2D;IAE/E,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;CAS9C;AAED,qBAAa,YAAa,YAAW,YAAY;IAC/C,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,QAAQ,YAAY;I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0,0 +1,264 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Workflow plugin: String manipulation operations.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringPluginClasses = exports.StringPadEnd = exports.StringPadStart = exports.StringEndsWith = exports.StringStartsWith = exports.StringIncludes = exports.StringSubstring = exports.StringJoin = exports.StringSplit = exports.StringReplace = exports.StringTrim = exports.StringUpper = exports.StringLower = exports.StringLength = exports.StringFormat = exports.StringConcat = void 0;
|
||||
const base_1 = require("../../base");
|
||||
const template_engine_1 = require("../../../executor/ts/utils/template-engine");
|
||||
const resolve = (value, ctx) => {
|
||||
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
||||
return (0, template_engine_1.interpolateTemplate)(value, ctx);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
class StringConcat {
|
||||
constructor() {
|
||||
this.nodeType = 'string.concat';
|
||||
this.category = 'string';
|
||||
this.description = 'Concatenate multiple strings with an optional separator';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const values = (inputs.node.parameters.values || []).map((v) => resolve(v, ctx));
|
||||
const separator = resolve(inputs.node.parameters.separator ?? '', ctx);
|
||||
return { result: values.join(separator) };
|
||||
}
|
||||
}
|
||||
exports.StringConcat = StringConcat;
|
||||
class StringFormat {
|
||||
constructor() {
|
||||
this.nodeType = 'string.format';
|
||||
this.category = 'string';
|
||||
this.description = 'Format string with variables using {key} placeholders';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const template = resolve(inputs.node.parameters.template || '', ctx);
|
||||
const variables = inputs.node.parameters.variables || {};
|
||||
const result = template.replace(/\{(\w+)\}/g, (_, key) => variables[key] !== undefined ? String(variables[key]) : `{${key}}`);
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringFormat = StringFormat;
|
||||
class StringLength {
|
||||
constructor() {
|
||||
this.nodeType = 'string.length';
|
||||
this.category = 'string';
|
||||
this.description = 'Get the length of a string';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
return { result: value.length };
|
||||
}
|
||||
}
|
||||
exports.StringLength = StringLength;
|
||||
class StringLower {
|
||||
constructor() {
|
||||
this.nodeType = 'string.lower';
|
||||
this.category = 'string';
|
||||
this.description = 'Convert string to lowercase';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
return { result: value.toLowerCase() };
|
||||
}
|
||||
}
|
||||
exports.StringLower = StringLower;
|
||||
class StringUpper {
|
||||
constructor() {
|
||||
this.nodeType = 'string.upper';
|
||||
this.category = 'string';
|
||||
this.description = 'Convert string to uppercase';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
return { result: value.toUpperCase() };
|
||||
}
|
||||
}
|
||||
exports.StringUpper = StringUpper;
|
||||
class StringTrim {
|
||||
constructor() {
|
||||
this.nodeType = 'string.trim';
|
||||
this.category = 'string';
|
||||
this.description = 'Trim whitespace from string (both ends, start only, or end only)';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const mode = inputs.node.parameters.mode || 'both';
|
||||
let result;
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
result = value.trimStart();
|
||||
break;
|
||||
case 'end':
|
||||
result = value.trimEnd();
|
||||
break;
|
||||
default: result = value.trim();
|
||||
}
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringTrim = StringTrim;
|
||||
class StringReplace {
|
||||
constructor() {
|
||||
this.nodeType = 'string.replace';
|
||||
this.category = 'string';
|
||||
this.description = 'Replace substring in string (single or all occurrences)';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const search = resolve(inputs.node.parameters.search || '', ctx);
|
||||
const replacement = resolve(inputs.node.parameters.replacement ?? '', ctx);
|
||||
const all = inputs.node.parameters.all ?? false;
|
||||
const result = all
|
||||
? value.replaceAll(search, replacement)
|
||||
: value.replace(search, replacement);
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringReplace = StringReplace;
|
||||
class StringSplit {
|
||||
constructor() {
|
||||
this.nodeType = 'string.split';
|
||||
this.category = 'string';
|
||||
this.description = 'Split string into array by separator';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const separator = resolve(inputs.node.parameters.separator ?? ',', ctx);
|
||||
const limit = inputs.node.parameters.limit;
|
||||
const result = limit ? value.split(separator, limit) : value.split(separator);
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringSplit = StringSplit;
|
||||
class StringJoin {
|
||||
constructor() {
|
||||
this.nodeType = 'string.join';
|
||||
this.category = 'string';
|
||||
this.description = 'Join array elements into string with separator';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const values = resolve(inputs.node.parameters.values || [], ctx);
|
||||
const separator = resolve(inputs.node.parameters.separator ?? ',', ctx);
|
||||
const result = Array.isArray(values) ? values.join(separator) : String(values);
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringJoin = StringJoin;
|
||||
class StringSubstring {
|
||||
constructor() {
|
||||
this.nodeType = 'string.substring';
|
||||
this.category = 'string';
|
||||
this.description = 'Extract substring from string by start and end index';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const startIdx = inputs.node.parameters.start ?? 0;
|
||||
const endIdx = inputs.node.parameters.end;
|
||||
const result = endIdx !== undefined ? value.substring(startIdx, endIdx) : value.substring(startIdx);
|
||||
return { result };
|
||||
}
|
||||
}
|
||||
exports.StringSubstring = StringSubstring;
|
||||
class StringIncludes {
|
||||
constructor() {
|
||||
this.nodeType = 'string.includes';
|
||||
this.category = 'string';
|
||||
this.description = 'Check if string contains a substring';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const search = String(resolve(inputs.node.parameters.search || '', ctx));
|
||||
return { result: value.includes(search) };
|
||||
}
|
||||
}
|
||||
exports.StringIncludes = StringIncludes;
|
||||
class StringStartsWith {
|
||||
constructor() {
|
||||
this.nodeType = 'string.startsWith';
|
||||
this.category = 'string';
|
||||
this.description = 'Check if string starts with a prefix';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const prefix = String(resolve(inputs.node.parameters.prefix || '', ctx));
|
||||
return { result: value.startsWith(prefix) };
|
||||
}
|
||||
}
|
||||
exports.StringStartsWith = StringStartsWith;
|
||||
class StringEndsWith {
|
||||
constructor() {
|
||||
this.nodeType = 'string.endsWith';
|
||||
this.category = 'string';
|
||||
this.description = 'Check if string ends with a suffix';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const suffix = String(resolve(inputs.node.parameters.suffix || '', ctx));
|
||||
return { result: value.endsWith(suffix) };
|
||||
}
|
||||
}
|
||||
exports.StringEndsWith = StringEndsWith;
|
||||
class StringPadStart {
|
||||
constructor() {
|
||||
this.nodeType = 'string.padStart';
|
||||
this.category = 'string';
|
||||
this.description = 'Pad string at the start to reach target length';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const length = inputs.node.parameters.length || value.length;
|
||||
const fillString = resolve(inputs.node.parameters.fillString ?? ' ', ctx);
|
||||
return { result: value.padStart(length, fillString) };
|
||||
}
|
||||
}
|
||||
exports.StringPadStart = StringPadStart;
|
||||
class StringPadEnd {
|
||||
constructor() {
|
||||
this.nodeType = 'string.padEnd';
|
||||
this.category = 'string';
|
||||
this.description = 'Pad string at the end to reach target length';
|
||||
}
|
||||
execute(inputs) {
|
||||
const ctx = (0, base_1.createTemplateContext)(inputs);
|
||||
const value = String(resolve(inputs.node.parameters.value || '', ctx));
|
||||
const length = inputs.node.parameters.length || value.length;
|
||||
const fillString = resolve(inputs.node.parameters.fillString ?? ' ', ctx);
|
||||
return { result: value.padEnd(length, fillString) };
|
||||
}
|
||||
}
|
||||
exports.StringPadEnd = StringPadEnd;
|
||||
// Export all string plugin classes
|
||||
exports.stringPluginClasses = {
|
||||
'string.concat': StringConcat,
|
||||
'string.format': StringFormat,
|
||||
'string.length': StringLength,
|
||||
'string.lower': StringLower,
|
||||
'string.upper': StringUpper,
|
||||
'string.trim': StringTrim,
|
||||
'string.replace': StringReplace,
|
||||
'string.split': StringSplit,
|
||||
'string.join': StringJoin,
|
||||
'string.substring': StringSubstring,
|
||||
'string.includes': StringIncludes,
|
||||
'string.startsWith': StringStartsWith,
|
||||
'string.endsWith': StringEndsWith,
|
||||
'string.padStart': StringPadStart,
|
||||
'string.padEnd': StringPadEnd,
|
||||
};
|
||||
exports.default = exports.stringPluginClasses;
|
||||
//# sourceMappingURL=index.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import { NodeExecutor, ExecuteInputs, ExecuteResult, createTemplateContext } from '../../base';
|
||||
import { interpolateTemplate } from '../../../executor/ts/utils/template-engine';
|
||||
import { interpolateTemplate } from '../../../../executor/ts/utils/template-engine';
|
||||
|
||||
const resolve = (value: any, ctx: any): any => {
|
||||
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
||||
|
||||
Reference in New Issue
Block a user