@ixo/editor 5.19.0 → 5.20.0-experimental.1

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.
@@ -1,63 +0,0 @@
1
- import {
2
- isRuntimeRef
3
- } from "./chunk-67477PYU.mjs";
4
-
5
- // src/core/lib/flowCompiler/resolveRefs.ts
6
- function resolveRuntimeRefs(nb, getNodeOutput, triggerContext) {
7
- return resolveValue(nb, getNodeOutput, triggerContext);
8
- }
9
- function resolveValue(value, getNodeOutput, triggerContext) {
10
- if (isRuntimeRef(value)) {
11
- return resolveRef(value.$ref, getNodeOutput, triggerContext);
12
- }
13
- if (Array.isArray(value)) {
14
- return value.map((item) => resolveValue(item, getNodeOutput, triggerContext));
15
- }
16
- if (typeof value === "object" && value !== null) {
17
- const result = {};
18
- for (const [key, val] of Object.entries(value)) {
19
- result[key] = resolveValue(val, getNodeOutput, triggerContext);
20
- }
21
- return result;
22
- }
23
- return value;
24
- }
25
- function resolveRef(ref, getNodeOutput, triggerContext) {
26
- if (ref.startsWith("trigger.payload.")) {
27
- if (!triggerContext) {
28
- throw new Error(`Trigger ref "${ref}" used outside of a listener invocation context. trigger.payload.* refs are only valid on block.event-triggered blocks.`);
29
- }
30
- const fieldPath2 = ref.slice("trigger.payload.".length);
31
- return getNestedValue(triggerContext.payload, fieldPath2);
32
- }
33
- if (triggerContext && Object.prototype.hasOwnProperty.call(triggerContext.refSnapshots, ref)) {
34
- return triggerContext.refSnapshots[ref];
35
- }
36
- const outputIndex = ref.indexOf(".output.");
37
- if (outputIndex === -1) {
38
- throw new Error(`Invalid runtime reference "${ref}". Expected format: "nodeId.output.fieldPath" or "trigger.payload.fieldPath"`);
39
- }
40
- const nodeId = ref.slice(0, outputIndex);
41
- const fieldPath = ref.slice(outputIndex + ".output.".length);
42
- const output = getNodeOutput(nodeId);
43
- if (!output) {
44
- return void 0;
45
- }
46
- return getNestedValue(output, fieldPath);
47
- }
48
- function getNestedValue(obj, path) {
49
- const parts = path.split(".");
50
- let current = obj;
51
- for (const part of parts) {
52
- if (current == null || typeof current !== "object") {
53
- return void 0;
54
- }
55
- current = current[part];
56
- }
57
- return current;
58
- }
59
-
60
- export {
61
- resolveRuntimeRefs
62
- };
63
- //# sourceMappingURL=chunk-K4YAG7AQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/lib/flowCompiler/resolveRefs.ts"],"sourcesContent":["import { isRuntimeRef } from '../../types/baseUcan';\n\n/**\n * Context passed to resolveRuntimeRefs when resolving inputs for a triggered\n * listener block. The runtime constructs this from a PendingInvocation when\n * the assignee invokes the listener.\n *\n * - `payload`: the frozen event payload, used to resolve `trigger.payload.*` refs\n * - `refSnapshots`: frozen `nodeId.output.*` values captured at queue time,\n * used to resolve those refs against the moment of emission rather than\n * current state. See docs/events-and-triggers-plan.md §3.5.1 for the\n * Sally → Mike scenario this fixes.\n */\nexport interface TriggerResolutionContext {\n payload: Record<string, unknown>;\n refSnapshots: Record<string, unknown>;\n}\n\n/**\n * Resolve runtime references in an nb (caveats) object.\n *\n * At compile time, `{ \"$ref\": \"nodeId.output.fieldPath\" }` values are serialized\n * as-is into the block's `inputs` JSON string. At execution time, this function\n * replaces them with actual output values from upstream nodes.\n *\n * Two ref namespaces are supported:\n * - `nodeId.output.fieldPath` — looked up via `getNodeOutput`. When a\n * `triggerContext` is provided AND `refSnapshots[ref]` exists, the\n * snapshot is preferred over the live lookup. This is the load-bearing\n * fix for the lag-time scenario where multiple pending invocations are\n * queued and the source block re-runs before the assignee acts on them.\n * - `trigger.payload.fieldPath` — looked up in `triggerContext.payload`.\n * Only valid when `triggerContext` is provided (i.e. resolving inputs\n * for a triggered listener invocation). Compile-time validation in\n * compiler.ts guarantees these only appear on `block.event`-triggered\n * blocks.\n *\n * @param nb - The caveats object (may contain nested RuntimeRef values)\n * @param getNodeOutput - Lookup function for upstream node outputs\n * @param triggerContext - Optional, present only for triggered listener invocations\n * @returns A new object with all $ref values resolved\n */\nexport function resolveRuntimeRefs(\n nb: Record<string, unknown>,\n getNodeOutput: (nodeId: string) => Record<string, unknown> | undefined,\n triggerContext?: TriggerResolutionContext\n): Record<string, unknown> {\n return resolveValue(nb, getNodeOutput, triggerContext) as Record<string, unknown>;\n}\n\nfunction resolveValue(value: unknown, getNodeOutput: (nodeId: string) => Record<string, unknown> | undefined, triggerContext?: TriggerResolutionContext): unknown {\n if (isRuntimeRef(value)) {\n return resolveRef(value.$ref, getNodeOutput, triggerContext);\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => resolveValue(item, getNodeOutput, triggerContext));\n }\n\n if (typeof value === 'object' && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n result[key] = resolveValue(val, getNodeOutput, triggerContext);\n }\n return result;\n }\n\n return value;\n}\n\n/**\n * Resolve a single $ref string.\n *\n * Supported forms:\n * - \"trigger.payload.fieldPath\" — looked up in triggerContext.payload\n * - \"nodeId.output.fieldPath\" — looked up in triggerContext.refSnapshots first\n * (if present), falling back to getNodeOutput. Snapshot preference is\n * what makes the Sally → Mike scenario produce frozen values per pending\n * invocation.\n */\nfunction resolveRef(ref: string, getNodeOutput: (nodeId: string) => Record<string, unknown> | undefined, triggerContext?: TriggerResolutionContext): unknown {\n // trigger.payload.* — only valid when a triggerContext is provided\n if (ref.startsWith('trigger.payload.')) {\n if (!triggerContext) {\n throw new Error(`Trigger ref \"${ref}\" used outside of a listener invocation context. trigger.payload.* refs are only valid on block.event-triggered blocks.`);\n }\n const fieldPath = ref.slice('trigger.payload.'.length);\n return getNestedValue(triggerContext.payload, fieldPath);\n }\n\n // nodeId.output.fieldPath — prefer the snapshot if we're inside a trigger context\n if (triggerContext && Object.prototype.hasOwnProperty.call(triggerContext.refSnapshots, ref)) {\n return triggerContext.refSnapshots[ref];\n }\n\n // Parse \"nodeId.output.fieldPath\"\n const outputIndex = ref.indexOf('.output.');\n if (outputIndex === -1) {\n throw new Error(`Invalid runtime reference \"${ref}\". Expected format: \"nodeId.output.fieldPath\" or \"trigger.payload.fieldPath\"`);\n }\n\n const nodeId = ref.slice(0, outputIndex);\n const fieldPath = ref.slice(outputIndex + '.output.'.length);\n\n const output = getNodeOutput(nodeId);\n if (!output) {\n return undefined;\n }\n\n // Traverse the field path (supports dot notation)\n return getNestedValue(output, fieldPath);\n}\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n\n for (const part of parts) {\n if (current == null || typeof current !== 'object') {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n\n return current;\n}\n"],"mappings":";;;;;AA0CO,SAAS,mBACd,IACA,eACA,gBACyB;AACzB,SAAO,aAAa,IAAI,eAAe,cAAc;AACvD;AAEA,SAAS,aAAa,OAAgB,eAAwE,gBAAoD;AAChK,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,WAAW,MAAM,MAAM,eAAe,cAAc;AAAA,EAC7D;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,SAAS,aAAa,MAAM,eAAe,cAAc,CAAC;AAAA,EAC9E;AAEA,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,UAAM,SAAkC,CAAC;AACzC,eAAW,CAAC,KAAK,GAAG,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC9C,aAAO,GAAG,IAAI,aAAa,KAAK,eAAe,cAAc;AAAA,IAC/D;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAYA,SAAS,WAAW,KAAa,eAAwE,gBAAoD;AAE3J,MAAI,IAAI,WAAW,kBAAkB,GAAG;AACtC,QAAI,CAAC,gBAAgB;AACnB,YAAM,IAAI,MAAM,gBAAgB,GAAG,yHAAyH;AAAA,IAC9J;AACA,UAAMA,aAAY,IAAI,MAAM,mBAAmB,MAAM;AACrD,WAAO,eAAe,eAAe,SAASA,UAAS;AAAA,EACzD;AAGA,MAAI,kBAAkB,OAAO,UAAU,eAAe,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