@intellia/workflow-sdk 0.1.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/README.md +66 -0
- package/dist/cjs/builder.js +336 -0
- package/dist/cjs/builder.js.map +1 -0
- package/dist/cjs/conditions.js +55 -0
- package/dist/cjs/conditions.js.map +1 -0
- package/dist/cjs/define-agent-ref.js +6 -0
- package/dist/cjs/define-agent-ref.js.map +1 -0
- package/dist/cjs/define-knowledge-base.js +6 -0
- package/dist/cjs/define-knowledge-base.js.map +1 -0
- package/dist/cjs/define-node.js +8 -0
- package/dist/cjs/define-node.js.map +1 -0
- package/dist/cjs/define-tool-workflow.js +34 -0
- package/dist/cjs/define-tool-workflow.js.map +1 -0
- package/dist/cjs/define-tool.js +6 -0
- package/dist/cjs/define-tool.js.map +1 -0
- package/dist/cjs/define-workflow.js +40 -0
- package/dist/cjs/define-workflow.js.map +1 -0
- package/dist/cjs/graph.js +3 -0
- package/dist/cjs/graph.js.map +1 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/node-type-support.js +27 -0
- package/dist/cjs/node-type-support.js.map +1 -0
- package/dist/cjs/refs.js +52 -0
- package/dist/cjs/refs.js.map +1 -0
- package/dist/cjs/schema.js +67 -0
- package/dist/cjs/schema.js.map +1 -0
- package/dist/esm/builder.js +331 -0
- package/dist/esm/builder.js.map +1 -0
- package/dist/esm/conditions.js +43 -0
- package/dist/esm/conditions.js.map +1 -0
- package/dist/esm/define-agent-ref.js +2 -0
- package/dist/esm/define-agent-ref.js.map +1 -0
- package/dist/esm/define-knowledge-base.js +2 -0
- package/dist/esm/define-knowledge-base.js.map +1 -0
- package/dist/esm/define-node.js +3 -0
- package/dist/esm/define-node.js.map +1 -0
- package/dist/esm/define-tool-workflow.js +30 -0
- package/dist/esm/define-tool-workflow.js.map +1 -0
- package/dist/esm/define-tool.js +2 -0
- package/dist/esm/define-tool.js.map +1 -0
- package/dist/esm/define-workflow.js +36 -0
- package/dist/esm/define-workflow.js.map +1 -0
- package/dist/esm/graph.js +1 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node-type-support.js +24 -0
- package/dist/esm/node-type-support.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/refs.js +42 -0
- package/dist/esm/refs.js.map +1 -0
- package/dist/esm/schema.js +62 -0
- package/dist/esm/schema.js.map +1 -0
- package/dist/index.d.ts +524 -0
- package/package.json +44 -0
- package/tsconfig.base.json +12 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NODE_TYPE_SUPPORT = exports.defineToolWorkflow = exports.jsonata = exports.isPresent = exports.isNull = exports.contains = exports.lte = exports.lt = exports.gte = exports.gt = exports.eq = exports.defineWorkflow = exports.IdAllocator = exports.Builder = exports.defineAgentRef = exports.defineKnowledgeBase = exports.defineTool = exports.defineWholeStateFunction = exports.defineFunction = exports.encodeValue = exports.tpl = exports.tplText = exports.isTpl = exports.refPath = exports.isRef = exports.handleFor = exports.artifact = exports.toJsonSchema = exports.z = void 0;
|
|
4
|
+
var schema_1 = require("./schema");
|
|
5
|
+
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return schema_1.z; } });
|
|
6
|
+
Object.defineProperty(exports, "toJsonSchema", { enumerable: true, get: function () { return schema_1.toJsonSchema; } });
|
|
7
|
+
Object.defineProperty(exports, "artifact", { enumerable: true, get: function () { return schema_1.artifact; } });
|
|
8
|
+
var refs_1 = require("./refs");
|
|
9
|
+
Object.defineProperty(exports, "handleFor", { enumerable: true, get: function () { return refs_1.handleFor; } });
|
|
10
|
+
Object.defineProperty(exports, "isRef", { enumerable: true, get: function () { return refs_1.isRef; } });
|
|
11
|
+
Object.defineProperty(exports, "refPath", { enumerable: true, get: function () { return refs_1.refPath; } });
|
|
12
|
+
Object.defineProperty(exports, "isTpl", { enumerable: true, get: function () { return refs_1.isTpl; } });
|
|
13
|
+
Object.defineProperty(exports, "tplText", { enumerable: true, get: function () { return refs_1.tplText; } });
|
|
14
|
+
Object.defineProperty(exports, "tpl", { enumerable: true, get: function () { return refs_1.tpl; } });
|
|
15
|
+
Object.defineProperty(exports, "encodeValue", { enumerable: true, get: function () { return refs_1.encodeValue; } });
|
|
16
|
+
var define_node_1 = require("./define-node");
|
|
17
|
+
Object.defineProperty(exports, "defineFunction", { enumerable: true, get: function () { return define_node_1.defineFunction; } });
|
|
18
|
+
Object.defineProperty(exports, "defineWholeStateFunction", { enumerable: true, get: function () { return define_node_1.defineWholeStateFunction; } });
|
|
19
|
+
var define_tool_1 = require("./define-tool");
|
|
20
|
+
Object.defineProperty(exports, "defineTool", { enumerable: true, get: function () { return define_tool_1.defineTool; } });
|
|
21
|
+
var define_knowledge_base_1 = require("./define-knowledge-base");
|
|
22
|
+
Object.defineProperty(exports, "defineKnowledgeBase", { enumerable: true, get: function () { return define_knowledge_base_1.defineKnowledgeBase; } });
|
|
23
|
+
var define_agent_ref_1 = require("./define-agent-ref");
|
|
24
|
+
Object.defineProperty(exports, "defineAgentRef", { enumerable: true, get: function () { return define_agent_ref_1.defineAgentRef; } });
|
|
25
|
+
var builder_1 = require("./builder");
|
|
26
|
+
Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
|
|
27
|
+
Object.defineProperty(exports, "IdAllocator", { enumerable: true, get: function () { return builder_1.IdAllocator; } });
|
|
28
|
+
var define_workflow_1 = require("./define-workflow");
|
|
29
|
+
Object.defineProperty(exports, "defineWorkflow", { enumerable: true, get: function () { return define_workflow_1.defineWorkflow; } });
|
|
30
|
+
var conditions_1 = require("./conditions");
|
|
31
|
+
Object.defineProperty(exports, "eq", { enumerable: true, get: function () { return conditions_1.eq; } });
|
|
32
|
+
Object.defineProperty(exports, "gt", { enumerable: true, get: function () { return conditions_1.gt; } });
|
|
33
|
+
Object.defineProperty(exports, "gte", { enumerable: true, get: function () { return conditions_1.gte; } });
|
|
34
|
+
Object.defineProperty(exports, "lt", { enumerable: true, get: function () { return conditions_1.lt; } });
|
|
35
|
+
Object.defineProperty(exports, "lte", { enumerable: true, get: function () { return conditions_1.lte; } });
|
|
36
|
+
Object.defineProperty(exports, "contains", { enumerable: true, get: function () { return conditions_1.contains; } });
|
|
37
|
+
Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return conditions_1.isNull; } });
|
|
38
|
+
Object.defineProperty(exports, "isPresent", { enumerable: true, get: function () { return conditions_1.isPresent; } });
|
|
39
|
+
Object.defineProperty(exports, "jsonata", { enumerable: true, get: function () { return conditions_1.jsonata; } });
|
|
40
|
+
var define_tool_workflow_1 = require("./define-tool-workflow");
|
|
41
|
+
Object.defineProperty(exports, "defineToolWorkflow", { enumerable: true, get: function () { return define_tool_workflow_1.defineToolWorkflow; } });
|
|
42
|
+
var node_type_support_1 = require("./node-type-support");
|
|
43
|
+
Object.defineProperty(exports, "NODE_TYPE_SUPPORT", { enumerable: true, get: function () { return node_type_support_1.NODE_TYPE_SUPPORT; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAqD;AAA5C,2FAAA,CAAC,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAClC,+BAQgB;AAPd,iGAAA,SAAS,OAAA;AACT,6FAAA,KAAK,OAAA;AACL,+FAAA,OAAO,OAAA;AACP,6FAAA,KAAK,OAAA;AACL,+FAAA,OAAO,OAAA;AACP,2FAAA,GAAG,OAAA;AACH,mGAAA,WAAW,OAAA;AAGb,6CAAyE;AAAhE,6GAAA,cAAc,OAAA;AAAE,uHAAA,wBAAwB,OAAA;AAEjD,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AASnB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAE5B,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AAEvB,qCAAiD;AAAxC,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAU7B,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAGvB,2CAA0F;AAAjF,gGAAA,EAAE,OAAA;AAAE,gGAAA,EAAE,OAAA;AAAE,iGAAA,GAAG,OAAA;AAAE,gGAAA,EAAE,OAAA;AAAE,iGAAA,GAAG,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,oGAAA,MAAM,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,qGAAA,OAAO,OAAA;AAEnE,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAE3B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NODE_TYPE_SUPPORT = void 0;
|
|
4
|
+
const builder_1 = require("./builder");
|
|
5
|
+
exports.NODE_TYPE_SUPPORT = {
|
|
6
|
+
trigger: {
|
|
7
|
+
status: "not-expressible",
|
|
8
|
+
reason: "Declared via defineWorkflow()'s `trigger` option (define-workflow.ts), not appended as a graph node — every workflow has exactly one, fixed at definition time, never authored mid-scope.",
|
|
9
|
+
},
|
|
10
|
+
approval: { status: "expressible", builder: builder_1.Builder.prototype.approval },
|
|
11
|
+
conditional: { status: "expressible", builder: builder_1.Builder.prototype.if },
|
|
12
|
+
end: {
|
|
13
|
+
status: "not-expressible",
|
|
14
|
+
reason: "Synthesized unconditionally by emitDefinition (workflow-compiler/src/emit.ts) as the workflow's implicit terminal node — every recorded scope needs exactly one, generated at emit time, never authored.",
|
|
15
|
+
},
|
|
16
|
+
noop: { status: "expressible", builder: builder_1.Builder.prototype.noop },
|
|
17
|
+
agent: { status: "expressible", builder: builder_1.Builder.prototype.agent },
|
|
18
|
+
"tool-call": { status: "expressible", builder: builder_1.Builder.prototype.toolCall },
|
|
19
|
+
function: { status: "expressible", builder: builder_1.Builder.prototype.function },
|
|
20
|
+
bash: { status: "expressible", builder: builder_1.Builder.prototype.bash },
|
|
21
|
+
parallel: { status: "expressible", builder: builder_1.Builder.prototype.parallel },
|
|
22
|
+
repeat: { status: "expressible", builder: builder_1.Builder.prototype.forEach },
|
|
23
|
+
"wait-for-callback": { status: "expressible", builder: builder_1.Builder.prototype.waitForCallback },
|
|
24
|
+
"set-output": { status: "expressible", builder: builder_1.Builder.prototype.setOutput },
|
|
25
|
+
"execute-workflow": { status: "expressible", builder: builder_1.Builder.prototype.executeWorkflow },
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=node-type-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-type-support.js","sourceRoot":"","sources":["../../src/node-type-support.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAevB,QAAA,iBAAiB,GAA8C;IAC1E,OAAO,EAAE;QACP,MAAM,EAAE,iBAAiB;QACzB,MAAM,EACJ,2LAA2L;KAC9L;IACD,QAAQ,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;IACxE,WAAW,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,EAAE,EAAE;IACrE,GAAG,EAAE;QACH,MAAM,EAAE,iBAAiB;QACzB,MAAM,EACJ,0MAA0M;KAC7M;IACD,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,IAAI,EAAE;IAChE,KAAK,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,KAAK,EAAE;IAClE,WAAW,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;IAC3E,QAAQ,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;IACxE,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,IAAI,EAAE;IAChE,QAAQ,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;IACxE,MAAM,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,OAAO,EAAE;IACrE,mBAAmB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,eAAe,EAAE;IAC1F,YAAY,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,SAAS,EAAE;IAC7E,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAO,CAAC,SAAS,CAAC,eAAe,EAAE;CACtC,CAAC"}
|
package/dist/cjs/refs.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeValue = exports.tpl = exports.handleFor = exports.tplText = exports.isTpl = exports.refPath = exports.isRef = void 0;
|
|
4
|
+
const REF = Symbol.for("hutly.workflow.ref");
|
|
5
|
+
const TPL = Symbol.for("hutly.workflow.tpl");
|
|
6
|
+
const isRef = (v) => typeof v === "object" && v !== null && REF in v;
|
|
7
|
+
exports.isRef = isRef;
|
|
8
|
+
const refPath = (r) => r[REF];
|
|
9
|
+
exports.refPath = refPath;
|
|
10
|
+
const isTpl = (v) => typeof v === "object" && v !== null && TPL in v;
|
|
11
|
+
exports.isTpl = isTpl;
|
|
12
|
+
const tplText = (t) => t[TPL];
|
|
13
|
+
exports.tplText = tplText;
|
|
14
|
+
const handleFor = (basePath) => new Proxy({}, {
|
|
15
|
+
get(_target, prop) {
|
|
16
|
+
if (prop === REF)
|
|
17
|
+
return basePath;
|
|
18
|
+
if (typeof prop === "symbol")
|
|
19
|
+
return undefined;
|
|
20
|
+
return (0, exports.handleFor)(`${basePath}.${prop}`);
|
|
21
|
+
},
|
|
22
|
+
has(_target, prop) {
|
|
23
|
+
return prop === REF;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
exports.handleFor = handleFor;
|
|
27
|
+
// Handlebars references the state root directly, with no leading `$.`.
|
|
28
|
+
const toHandlebars = (r) => `{{ ${(0, exports.refPath)(r).replace(/^\$\./, "")} }}`;
|
|
29
|
+
const tpl = (strings, ...vals) => {
|
|
30
|
+
let out = strings[0];
|
|
31
|
+
for (let i = 0; i < vals.length; i += 1) {
|
|
32
|
+
const v = vals[i];
|
|
33
|
+
out += (0, exports.isRef)(v) ? toHandlebars(v) : String(v);
|
|
34
|
+
out += strings[i + 1];
|
|
35
|
+
}
|
|
36
|
+
return { [TPL]: out };
|
|
37
|
+
};
|
|
38
|
+
exports.tpl = tpl;
|
|
39
|
+
const encodeValue = (v) => {
|
|
40
|
+
if ((0, exports.isRef)(v))
|
|
41
|
+
return (0, exports.refPath)(v);
|
|
42
|
+
if ((0, exports.isTpl)(v))
|
|
43
|
+
return (0, exports.tplText)(v);
|
|
44
|
+
if (Array.isArray(v))
|
|
45
|
+
return v.map(exports.encodeValue);
|
|
46
|
+
if (v !== null && typeof v === "object") {
|
|
47
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, (0, exports.encodeValue)(x)]));
|
|
48
|
+
}
|
|
49
|
+
return v;
|
|
50
|
+
};
|
|
51
|
+
exports.encodeValue = encodeValue;
|
|
52
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","s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AAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAA,mBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAClF,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.artifact = exports.toJsonSchema = exports.z = void 0;
|
|
4
|
+
const v4_1 = require("zod/v4");
|
|
5
|
+
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return v4_1.z; } });
|
|
6
|
+
// `z.toJSONSchema` reads `.describe()`/`.meta()` metadata via `z.globalRegistry`
|
|
7
|
+
// — a per-zod-module-instance `WeakMap`. A schema built by a DIFFERENT zod
|
|
8
|
+
// module instance (e.g. bundled separately into a vm-executed workflow entry
|
|
9
|
+
// — see `workflow-compiler/src/execute.ts`) has its own registry, so that
|
|
10
|
+
// lookup silently finds nothing, even though structural fields
|
|
11
|
+
// (type/properties/required) still convert correctly via duck-typed access.
|
|
12
|
+
// The schema's own `.description` getter, though, is a closure bound to
|
|
13
|
+
// whichever registry actually holds the metadata, so reading it works
|
|
14
|
+
// regardless of which zod instance built the schema — it's a plain property
|
|
15
|
+
// read, not an identity check. This walks the zod schema's PUBLIC, documented
|
|
16
|
+
// shape accessors (`.def.type`, `.shape`, `.element`, `.unwrap()`) in
|
|
17
|
+
// parallel with the JSON Schema `z.toJSONSchema` already produced, backfilling
|
|
18
|
+
// any `description` the registry lookup missed. Covers the constructs the SDK
|
|
19
|
+
// and the real corpus actually use (object/array/optional/default); anything
|
|
20
|
+
// else (union, record, nullable's `anyOf` wrapping, ...) falls through
|
|
21
|
+
// unmerged — no worse than before this existed, just not extended to those.
|
|
22
|
+
const backfillDescriptions = (t, node) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const description = t.description;
|
|
25
|
+
if (node.description === undefined && typeof description === "string") {
|
|
26
|
+
node.description = description;
|
|
27
|
+
}
|
|
28
|
+
const kind = (_a = t.def) === null || _a === void 0 ? void 0 : _a.type;
|
|
29
|
+
if (kind === "object" && node.properties) {
|
|
30
|
+
const shape = t.shape;
|
|
31
|
+
for (const [key, sub] of Object.entries(shape)) {
|
|
32
|
+
const propNode = node.properties[key];
|
|
33
|
+
if (propNode) {
|
|
34
|
+
backfillDescriptions(sub, propNode);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (kind === "array" && node.items) {
|
|
39
|
+
const element = t.element;
|
|
40
|
+
backfillDescriptions(element, node.items);
|
|
41
|
+
}
|
|
42
|
+
else if (kind === "optional" || kind === "default" || kind === "nonoptional") {
|
|
43
|
+
// These wrappers add no JSON Schema nesting level of their own (optional
|
|
44
|
+
// only affects `required`; default keeps the wrapped type's shape), so
|
|
45
|
+
// the inner schema's fields land at this SAME node.
|
|
46
|
+
const unwrap = t.unwrap;
|
|
47
|
+
if (typeof unwrap === "function") {
|
|
48
|
+
backfillDescriptions(unwrap(), node);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// The repo's ajv schemas and every hand-written workflow use draft-07; zod's
|
|
53
|
+
// default target is 2020-12, which ajv would reject.
|
|
54
|
+
const toJsonSchema = (t) => {
|
|
55
|
+
const result = v4_1.z.toJSONSchema(t, { target: "draft-7" });
|
|
56
|
+
backfillDescriptions(t, result);
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
exports.toJsonSchema = toJsonSchema;
|
|
60
|
+
// A pointer to bytes held out-of-band, so a large payload never rides the
|
|
61
|
+
// Step Functions state.
|
|
62
|
+
const artifact = () => v4_1.z.object({
|
|
63
|
+
artifactId: v4_1.z.string().max(64),
|
|
64
|
+
filename: v4_1.z.string().max(255),
|
|
65
|
+
});
|
|
66
|
+
exports.artifact = artifact;
|
|
67
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
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AAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC/E,yEAAyE;QACzE,uEAAuE;QACvE,oDAAoD;QACpD,MAAM,MAAM,GAAI,CAA6C,CAAC,MAAM,CAAC;QACrE,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,oBAAoB,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,6EAA6E;AAC7E,qDAAqD;AAC9C,MAAM,YAAY,GAAG,CAAC,CAAY,EAAc,EAAE;IACvD,MAAM,MAAM,GAAG,MAAC,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAe,CAAC;IACtE,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEF,0EAA0E;AAC1E,wBAAwB;AACjB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAC3B,MAAC,CAAC,MAAM,CAAC;IACP,UAAU,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;CAC9B,CAAC,CAAC;AAJQ,QAAA,QAAQ,YAIhB"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { encodeValue, handleFor, isRef, refPath } from "./refs";
|
|
2
|
+
export class IdAllocator {
|
|
3
|
+
constructor() {
|
|
4
|
+
// "trigger" is a platform-reserved key (WorkflowDefinition always keys the
|
|
5
|
+
// trigger node under it) — never hand it out to a user-named node.
|
|
6
|
+
this.used = new Set(["trigger"]);
|
|
7
|
+
}
|
|
8
|
+
allocate(name) {
|
|
9
|
+
const base = name
|
|
10
|
+
.toLowerCase()
|
|
11
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
12
|
+
.replace(/^_+|_+$/g, "") || "node";
|
|
13
|
+
let candidate = base;
|
|
14
|
+
let n = 1;
|
|
15
|
+
while (this.used.has(candidate)) {
|
|
16
|
+
n += 1;
|
|
17
|
+
candidate = `${base}_${n}`;
|
|
18
|
+
}
|
|
19
|
+
this.used.add(candidate);
|
|
20
|
+
return candidate;
|
|
21
|
+
}
|
|
22
|
+
// An explicit id is taken verbatim — never slugified or lower-cased the way
|
|
23
|
+
// `allocate` normalises a name into one. Shares `allocate`'s `used` set: it
|
|
24
|
+
// must not collide with, or be silently reassigned by, any other id,
|
|
25
|
+
// explicit or auto-derived.
|
|
26
|
+
reserve(id) {
|
|
27
|
+
if (id.length === 0) {
|
|
28
|
+
throw new Error("Explicit node id must not be empty.");
|
|
29
|
+
}
|
|
30
|
+
if (this.used.has(id)) {
|
|
31
|
+
throw new Error(`Node id "${id}" is already in use — explicit ids must be unique within a workflow.`);
|
|
32
|
+
}
|
|
33
|
+
this.used.add(id);
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class Builder {
|
|
38
|
+
constructor(ids) {
|
|
39
|
+
this.ids = ids;
|
|
40
|
+
this.scope = { nodes: [] };
|
|
41
|
+
}
|
|
42
|
+
push(node) {
|
|
43
|
+
this.scope.nodes.push(node);
|
|
44
|
+
return handleFor(`$.results.${node.id}`);
|
|
45
|
+
}
|
|
46
|
+
// Reserves the literal string when given; otherwise falls back to the
|
|
47
|
+
// method's own auto-basis.
|
|
48
|
+
resolveId(explicit, autoBasis) {
|
|
49
|
+
return explicit !== undefined ? this.ids.reserve(explicit) : this.ids.allocate(autoBasis);
|
|
50
|
+
}
|
|
51
|
+
function(def, inputOrOpts, maybeOpts) {
|
|
52
|
+
var _a;
|
|
53
|
+
if ("input" in def) {
|
|
54
|
+
const input = inputOrOpts;
|
|
55
|
+
const opts = maybeOpts !== null && maybeOpts !== void 0 ? maybeOpts : {};
|
|
56
|
+
const id = this.resolveId(opts.id, def.name);
|
|
57
|
+
return this.push({
|
|
58
|
+
kind: "function",
|
|
59
|
+
id,
|
|
60
|
+
name: def.name,
|
|
61
|
+
def,
|
|
62
|
+
modulePath: "",
|
|
63
|
+
input: encodeValue(input),
|
|
64
|
+
onFailure: this.resolveOnFailure(opts.onFailure),
|
|
65
|
+
onFailureRejoin: opts.onFailureRejoin,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const opts = (_a = inputOrOpts) !== null && _a !== void 0 ? _a : {};
|
|
69
|
+
const id = this.resolveId(opts.id, def.name);
|
|
70
|
+
return this.push({
|
|
71
|
+
kind: "function",
|
|
72
|
+
id,
|
|
73
|
+
name: def.name,
|
|
74
|
+
def,
|
|
75
|
+
modulePath: "",
|
|
76
|
+
input: "whole-state",
|
|
77
|
+
onFailure: this.resolveOnFailure(opts.onFailure),
|
|
78
|
+
onFailureRejoin: opts.onFailureRejoin,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
bash(scriptPath, spec) {
|
|
82
|
+
const id = this.resolveId(spec.id, spec.name);
|
|
83
|
+
return this.push({
|
|
84
|
+
kind: "bash",
|
|
85
|
+
id,
|
|
86
|
+
name: spec.name,
|
|
87
|
+
scriptPath,
|
|
88
|
+
output: spec.output,
|
|
89
|
+
secrets: spec.secrets,
|
|
90
|
+
timeoutSeconds: spec.timeoutSeconds,
|
|
91
|
+
async: spec.async,
|
|
92
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
93
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
toolCall(tool, instanceName, spec) {
|
|
97
|
+
var _a;
|
|
98
|
+
const id = this.resolveId(spec.id, instanceName);
|
|
99
|
+
return this.push({
|
|
100
|
+
kind: "tool-call",
|
|
101
|
+
id,
|
|
102
|
+
name: (_a = spec.name) !== null && _a !== void 0 ? _a : instanceName,
|
|
103
|
+
tool,
|
|
104
|
+
toolName: instanceName,
|
|
105
|
+
input: encodeValue(spec.input),
|
|
106
|
+
output: spec.output,
|
|
107
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
108
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
agent(spec) {
|
|
112
|
+
const id = this.resolveId(spec.id, spec.name);
|
|
113
|
+
return this.push({
|
|
114
|
+
kind: "agent",
|
|
115
|
+
id,
|
|
116
|
+
name: spec.name,
|
|
117
|
+
agentId: encodeValue(spec.agentId),
|
|
118
|
+
instructions: encodeValue(spec.instructions),
|
|
119
|
+
input: spec.input,
|
|
120
|
+
output: spec.output,
|
|
121
|
+
reasoning: spec.reasoning,
|
|
122
|
+
enabled: spec.enabled,
|
|
123
|
+
description: encodeValue(spec.description),
|
|
124
|
+
showWholeChainState: spec.showWholeChainState,
|
|
125
|
+
failBeforeRunningIf: encodeValue(spec.failBeforeRunningIf),
|
|
126
|
+
failAfterRunningIf: encodeValue(spec.failAfterRunningIf),
|
|
127
|
+
toolChoice: encodeValue(spec.toolChoice),
|
|
128
|
+
tools: spec.tools,
|
|
129
|
+
knowledgeBases: spec.knowledgeBases,
|
|
130
|
+
otherAgents: spec.otherAgents,
|
|
131
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
132
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
executeWorkflow(spec) {
|
|
136
|
+
const id = this.resolveId(spec.id, spec.name);
|
|
137
|
+
return this.push({
|
|
138
|
+
kind: "execute-workflow",
|
|
139
|
+
id,
|
|
140
|
+
name: spec.name,
|
|
141
|
+
workflow: spec.workflow,
|
|
142
|
+
// Stamped by execute.ts's stampModulePaths after record() returns —
|
|
143
|
+
// mirrors `function`'s own `modulePath: ""` placeholder above, keeping
|
|
144
|
+
// the bundler-specific stamping mechanism out of builder.ts.
|
|
145
|
+
modulePath: "",
|
|
146
|
+
organizationId: spec.organizationId,
|
|
147
|
+
// A bare Handle is a ref (encodeValue's isRef branch), so this honestly
|
|
148
|
+
// returns a string for the whole-value form and an object for the
|
|
149
|
+
// per-field form — matching what encodeValue actually does, not a
|
|
150
|
+
// narrower shape asserted over it.
|
|
151
|
+
input: encodeValue(spec.input),
|
|
152
|
+
output: spec.output,
|
|
153
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
154
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
approval(spec) {
|
|
158
|
+
const id = this.resolveId(spec.id, spec.name);
|
|
159
|
+
return this.push({
|
|
160
|
+
kind: "approval",
|
|
161
|
+
id,
|
|
162
|
+
name: spec.name,
|
|
163
|
+
notificationType: spec.notificationType,
|
|
164
|
+
callbackURL: encodeValue(spec.callbackURL),
|
|
165
|
+
emailAddress: encodeValue(spec.emailAddress),
|
|
166
|
+
otherEmails: encodeValue(spec.otherEmails),
|
|
167
|
+
phoneNumber: encodeValue(spec.phoneNumber),
|
|
168
|
+
message: encodeValue(spec.message),
|
|
169
|
+
output: spec.output,
|
|
170
|
+
defaultValues: encodeValue(spec.defaultValues),
|
|
171
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
172
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
waitForCallback(spec) {
|
|
176
|
+
const id = this.resolveId(spec.id, spec.name);
|
|
177
|
+
return this.push({
|
|
178
|
+
kind: "wait-for-callback",
|
|
179
|
+
id,
|
|
180
|
+
name: spec.name,
|
|
181
|
+
output: spec.output,
|
|
182
|
+
timeoutSeconds: spec.timeoutSeconds,
|
|
183
|
+
resume: spec.resume
|
|
184
|
+
? {
|
|
185
|
+
namespace: encodeValue(spec.resume.namespace),
|
|
186
|
+
lookupKey: encodeValue(spec.resume.lookupKey),
|
|
187
|
+
metadata: encodeValue(spec.resume.metadata),
|
|
188
|
+
by: spec.resume.by,
|
|
189
|
+
pendingFor: encodeValue(spec.resume.pendingFor),
|
|
190
|
+
}
|
|
191
|
+
: undefined,
|
|
192
|
+
onFailure: this.resolveOnFailure(spec.onFailure),
|
|
193
|
+
onFailureRejoin: spec.onFailureRejoin,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// Pure value transform, no scope side effect — the terminal-of-`build()`
|
|
197
|
+
// form (`return wf.output(shape)`). `setOutput` below is the statement
|
|
198
|
+
// form: a branch-local early return, distinct from this method's
|
|
199
|
+
// return-only contract.
|
|
200
|
+
output(shape) {
|
|
201
|
+
return encodeValue(shape);
|
|
202
|
+
}
|
|
203
|
+
// Statement form of "set output and stop here". No `onFailure` option: a
|
|
204
|
+
// Pass state can't Catch. Terminates when it's the last statement of its
|
|
205
|
+
// scope; otherwise continues into whatever follows, output already set.
|
|
206
|
+
setOutput(shape, opts) {
|
|
207
|
+
var _a;
|
|
208
|
+
const id = this.resolveId(opts === null || opts === void 0 ? void 0 : opts.id, "set_output");
|
|
209
|
+
this.scope.nodes.push({
|
|
210
|
+
kind: "set-output",
|
|
211
|
+
id,
|
|
212
|
+
name: (_a = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _a !== void 0 ? _a : "Set output",
|
|
213
|
+
output: encodeValue(shape),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
// Compiles to a Step Functions Pass state, which cannot Catch — so unlike
|
|
217
|
+
// every other builder method here, this one takes no `onFailure` of its own.
|
|
218
|
+
noop(name, opts) {
|
|
219
|
+
const id = this.resolveId(opts === null || opts === void 0 ? void 0 : opts.id, name);
|
|
220
|
+
this.scope.nodes.push({ kind: "noop", id, name });
|
|
221
|
+
}
|
|
222
|
+
if(cond, branches, opts) {
|
|
223
|
+
var _a, _b, _c;
|
|
224
|
+
const id = this.resolveId(opts === null || opts === void 0 ? void 0 : opts.id, "if");
|
|
225
|
+
const thenScope = (_a = this.recordBranch(branches.then)) !== null && _a !== void 0 ? _a : { nodes: [] };
|
|
226
|
+
if (thenScope.nodes.length === 0) {
|
|
227
|
+
throw new Error(`wf.if "then" branch is empty — a conditional's "then" branch must run at least one node.`);
|
|
228
|
+
}
|
|
229
|
+
const elseScope = this.recordBranch(branches.else);
|
|
230
|
+
this.scope.nodes.push({
|
|
231
|
+
kind: "conditional",
|
|
232
|
+
id,
|
|
233
|
+
name: (_b = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _b !== void 0 ? _b : "If",
|
|
234
|
+
choices: [
|
|
235
|
+
Object.assign(Object.assign({ id: (_c = opts === null || opts === void 0 ? void 0 : opts.choiceId) !== null && _c !== void 0 ? _c : `${id}_then` }, ((opts === null || opts === void 0 ? void 0 : opts.choiceName) !== undefined ? { name: opts.choiceName } : {})), { cond, scope: thenScope }),
|
|
236
|
+
],
|
|
237
|
+
defaultPath: elseScope !== null && elseScope !== void 0 ? elseScope : { nodes: [] },
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
// The platform's `ConditionalNode.choices` is genuinely an array — a
|
|
241
|
+
// JSON-Schema-Choice-state switch with N mutually exclusive branches plus a
|
|
242
|
+
// default, not just "one condition plus an else" (see graph.ts's
|
|
243
|
+
// conditional NodeSpec comment and the real corpus switches this exists
|
|
244
|
+
// for, e.g. workflows/realflow/credit-assessment/subworkflows/
|
|
245
|
+
// notify-commission-decision.yaml's APPROVE/DECLINE/REFER routing). `wf.if`
|
|
246
|
+
// stays the ergonomic single-condition form; this is the literal multi-way
|
|
247
|
+
// form — each branch keeps its own `id` (defaulting to a stable
|
|
248
|
+
// `choice_<n>` when the author doesn't care) so a decompiled definition's
|
|
249
|
+
// original choice ids round-trip instead of being renumbered.
|
|
250
|
+
choice(branches, opts = {}) {
|
|
251
|
+
var _a;
|
|
252
|
+
if (branches.length < 2) {
|
|
253
|
+
throw new Error(`wf.choice requires at least 2 branches, got ${branches.length} — use wf.if() for one condition plus an else.`);
|
|
254
|
+
}
|
|
255
|
+
const choices = branches.map((branch, i) => {
|
|
256
|
+
var _a, _b, _c;
|
|
257
|
+
const scope = (_a = this.recordBranch(branch.then)) !== null && _a !== void 0 ? _a : { nodes: [] };
|
|
258
|
+
if (scope.nodes.length === 0) {
|
|
259
|
+
throw new Error(`wf.choice branch "${(_b = branch.id) !== null && _b !== void 0 ? _b : i}" is empty — a branch must run at least one node.`);
|
|
260
|
+
}
|
|
261
|
+
return Object.assign(Object.assign({ id: (_c = branch.id) !== null && _c !== void 0 ? _c : `choice_${i + 1}` }, (branch.name !== undefined ? { name: branch.name } : {})), { cond: branch.cond, scope });
|
|
262
|
+
});
|
|
263
|
+
const elseScope = this.recordBranch(opts.else);
|
|
264
|
+
this.scope.nodes.push({
|
|
265
|
+
kind: "conditional",
|
|
266
|
+
id: this.resolveId(opts.id, "choice"),
|
|
267
|
+
name: (_a = opts.name) !== null && _a !== void 0 ? _a : "Choice",
|
|
268
|
+
choices,
|
|
269
|
+
defaultPath: elseScope !== null && elseScope !== void 0 ? elseScope : { nodes: [] },
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
parallel(branches, opts) {
|
|
273
|
+
var _a;
|
|
274
|
+
const branchCount = Object.keys(branches).length;
|
|
275
|
+
if (branchCount < 2) {
|
|
276
|
+
throw new Error(`wf.parallel requires at least 2 branches, got ${branchCount}.`);
|
|
277
|
+
}
|
|
278
|
+
for (const key of Object.keys(branches)) {
|
|
279
|
+
if (String(Number(key)) === key) {
|
|
280
|
+
throw new Error(`parallel branch key "${key}" is numeric. JavaScript reorders integer-like keys, ` +
|
|
281
|
+
`which would silently change branch order. Use a descriptive name.`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const id = this.resolveId(opts === null || opts === void 0 ? void 0 : opts.id, "parallel");
|
|
285
|
+
const branchSpecs = Object.entries(branches).map(([branchId, fn]) => {
|
|
286
|
+
var _a;
|
|
287
|
+
const scope = (_a = this.recordBranch(fn)) !== null && _a !== void 0 ? _a : { nodes: [] };
|
|
288
|
+
if (scope.nodes.length === 0) {
|
|
289
|
+
throw new Error(`parallel branch "${branchId}" is empty — a branch must run at least one node.`);
|
|
290
|
+
}
|
|
291
|
+
return { id: branchId, scope };
|
|
292
|
+
});
|
|
293
|
+
this.scope.nodes.push({
|
|
294
|
+
kind: "parallel",
|
|
295
|
+
id,
|
|
296
|
+
name: (_a = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _a !== void 0 ? _a : "Parallel",
|
|
297
|
+
branches: branchSpecs,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
forEach(items, body, opts) {
|
|
301
|
+
var _a, _b;
|
|
302
|
+
const id = this.resolveId(opts === null || opts === void 0 ? void 0 : opts.id, "for_each");
|
|
303
|
+
const scope = (_a = this.recordBranch(body)) !== null && _a !== void 0 ? _a : { nodes: [] };
|
|
304
|
+
if (scope.nodes.length === 0) {
|
|
305
|
+
throw new Error(`wf.forEach body is empty — a loop body must run at least one node.`);
|
|
306
|
+
}
|
|
307
|
+
this.scope.nodes.push({
|
|
308
|
+
kind: "repeat",
|
|
309
|
+
id,
|
|
310
|
+
name: (_b = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _b !== void 0 ? _b : "For each",
|
|
311
|
+
numberOrList: (isRef(items) ? refPath(items) : items),
|
|
312
|
+
scope,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
recordBranch(fn) {
|
|
316
|
+
if (!fn)
|
|
317
|
+
return undefined;
|
|
318
|
+
const child = new Builder(this.ids);
|
|
319
|
+
fn(child);
|
|
320
|
+
return child.scope;
|
|
321
|
+
}
|
|
322
|
+
// `"continue"` passes straight through as the sentinel emit.ts reads
|
|
323
|
+
// (there is no scope to record — the whole point is there are no extra
|
|
324
|
+
// nodes); anything else is recorded exactly like every other branch.
|
|
325
|
+
resolveOnFailure(onFailure) {
|
|
326
|
+
if (onFailure === "continue")
|
|
327
|
+
return "continue";
|
|
328
|
+
return this.recordBranch(onFailure);
|
|
329
|
+
}
|
|
330
|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CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;QACxF,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;YACpB,IAAI,EAAE,QAAQ;YACd,EAAE;YACF,IAAI,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,UAAU;YAC9B,YAAY,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAoB;YACxE,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,EAAyB;QACpC,IAAI,CAAC,EAAE;YAAE,OAAO,SAAS,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpC,EAAE,CAAC,KAAK,CAAC,CAAC;QACV,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,qEAAqE;IACrE,uEAAuE;IACvE,qEAAqE;IAC7D,gBAAgB,CAAC,SAAqB;QAC5C,IAAI,SAAS,KAAK,UAAU;YAAE,OAAO,UAAU,CAAC;QAChD,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isRef, refPath } from "./refs";
|
|
2
|
+
const dataTypeOf = (v) => {
|
|
3
|
+
if (typeof v === "number")
|
|
4
|
+
return "Numeric";
|
|
5
|
+
if (typeof v === "boolean")
|
|
6
|
+
return "Boolean";
|
|
7
|
+
return "String";
|
|
8
|
+
};
|
|
9
|
+
const compare = (comparison, target, value) => ({
|
|
10
|
+
kind: "comparison",
|
|
11
|
+
condition: {
|
|
12
|
+
variable: refPath(target),
|
|
13
|
+
comparison,
|
|
14
|
+
dataType: dataTypeOf(value),
|
|
15
|
+
value,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const eq = (t, v) => compare("Equals", t, v);
|
|
19
|
+
export const gt = (t, v) => compare("GreaterThan", t, v);
|
|
20
|
+
export const gte = (t, v) => compare("GreaterThanEquals", t, v);
|
|
21
|
+
export const lt = (t, v) => compare("LessThan", t, v);
|
|
22
|
+
export const lte = (t, v) => compare("LessThanEquals", t, v);
|
|
23
|
+
export const contains = (t, v) => compare("Contains", t, v);
|
|
24
|
+
export const isNull = (t) => compare("IsNull", t, true);
|
|
25
|
+
export const isPresent = (t) => compare("IsPresent", t, true);
|
|
26
|
+
export const jsonata = (strings, ...vals) => {
|
|
27
|
+
let expression = strings[0];
|
|
28
|
+
for (let i = 0; i < vals.length; i += 1) {
|
|
29
|
+
const v = vals[i];
|
|
30
|
+
if (isRef(v)) {
|
|
31
|
+
// `$.results.x` becomes `$results.x`, not `results.x`: the translator
|
|
32
|
+
// rewrites `$results`/`$trigger` to `$states.input....`, and a bare path
|
|
33
|
+
// is left alone and resolves against nothing at runtime.
|
|
34
|
+
expression += refPath(v).replace(/^\$\./, () => "$");
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
expression += typeof v === "string" ? JSON.stringify(v) : String(v);
|
|
38
|
+
}
|
|
39
|
+
expression += strings[i + 1];
|
|
40
|
+
}
|
|
41
|
+
return { kind: "jsonata", expression };
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/conditions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAA6B,MAAM,QAAQ,CAAC;AAMnE,MAAM,UAAU,GAAG,CAAC,CAA4B,EAAyB,EAAE;IACzE,IAAI,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B,EAAe,EAAE,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-knowledge-base.js","sourceRoot":"","sources":["../../src/define-knowledge-base.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAsB,EAAoB,EAAE,CAAC,IAAI,CAAC"}
|