@lifi/composer-sdk 0.8.1 → 0.10.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.
Files changed (161) hide show
  1. package/README.md +4 -3
  2. package/dist/_virtual/_rolldown/runtime.cjs +33 -0
  3. package/dist/_virtual/_rolldown/runtime.js +13 -0
  4. package/dist/authoring/FlowBuilderCore.cjs +102 -120
  5. package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
  6. package/dist/authoring/FlowBuilderCore.d.cts +58 -61
  7. package/dist/authoring/FlowBuilderCore.d.ts +58 -61
  8. package/dist/authoring/FlowBuilderCore.js +99 -97
  9. package/dist/authoring/FlowBuilderCore.js.map +1 -1
  10. package/dist/authoring/handles.cjs +25 -40
  11. package/dist/authoring/handles.cjs.map +1 -1
  12. package/dist/authoring/handles.d.cts +33 -34
  13. package/dist/authoring/handles.d.ts +33 -34
  14. package/dist/authoring/handles.js +21 -13
  15. package/dist/authoring/handles.js.map +1 -1
  16. package/dist/authoring/raw.cjs +85 -44
  17. package/dist/authoring/raw.cjs.map +1 -1
  18. package/dist/authoring/raw.d.cts +8 -8
  19. package/dist/authoring/raw.d.ts +8 -8
  20. package/dist/authoring/raw.js +83 -19
  21. package/dist/authoring/raw.js.map +1 -1
  22. package/dist/authoring/signatureArgs.cjs +81 -103
  23. package/dist/authoring/signatureArgs.cjs.map +1 -1
  24. package/dist/authoring/signatureArgs.d.cts +63 -64
  25. package/dist/authoring/signatureArgs.d.ts +63 -64
  26. package/dist/authoring/signatureArgs.js +76 -75
  27. package/dist/authoring/signatureArgs.js.map +1 -1
  28. package/dist/client.cjs +172 -220
  29. package/dist/client.cjs.map +1 -1
  30. package/dist/client.d.cts +131 -131
  31. package/dist/client.d.ts +131 -131
  32. package/dist/client.js +165 -198
  33. package/dist/client.js.map +1 -1
  34. package/dist/discovery.cjs +0 -17
  35. package/dist/discovery.d.cts +57 -56
  36. package/dist/discovery.d.ts +57 -56
  37. package/dist/discovery.js +1 -1
  38. package/dist/errors.cjs +211 -159
  39. package/dist/errors.cjs.map +1 -1
  40. package/dist/errors.d.cts +84 -84
  41. package/dist/errors.d.ts +84 -84
  42. package/dist/errors.js +201 -120
  43. package/dist/errors.js.map +1 -1
  44. package/dist/generated/config.generated.cjs +0 -17
  45. package/dist/generated/config.generated.d.cts +804 -936
  46. package/dist/generated/config.generated.d.ts +804 -936
  47. package/dist/generated/config.generated.js +1 -1
  48. package/dist/generated/guards.generated.cjs +25 -35
  49. package/dist/generated/guards.generated.cjs.map +1 -1
  50. package/dist/generated/guards.generated.d.cts +20 -4
  51. package/dist/generated/guards.generated.d.ts +20 -4
  52. package/dist/generated/guards.generated.js +19 -11
  53. package/dist/generated/guards.generated.js.map +1 -1
  54. package/dist/generated/materialisers.generated.cjs +25 -35
  55. package/dist/generated/materialisers.generated.cjs.map +1 -1
  56. package/dist/generated/materialisers.generated.d.cts +17 -4
  57. package/dist/generated/materialisers.generated.d.ts +17 -4
  58. package/dist/generated/materialisers.generated.js +19 -11
  59. package/dist/generated/materialisers.generated.js.map +1 -1
  60. package/dist/generated/operations.generated.cjs +236 -277
  61. package/dist/generated/operations.generated.cjs.map +1 -1
  62. package/dist/generated/operations.generated.d.cts +719 -708
  63. package/dist/generated/operations.generated.d.ts +719 -708
  64. package/dist/generated/operations.generated.js +235 -256
  65. package/dist/generated/operations.generated.js.map +1 -1
  66. package/dist/generated/preconditions.generated.cjs +25 -35
  67. package/dist/generated/preconditions.generated.cjs.map +1 -1
  68. package/dist/generated/preconditions.generated.d.cts +17 -4
  69. package/dist/generated/preconditions.generated.d.ts +17 -4
  70. package/dist/generated/preconditions.generated.js +19 -11
  71. package/dist/generated/preconditions.generated.js.map +1 -1
  72. package/dist/index.cjs +131 -97
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +29 -43
  75. package/dist/index.d.ts +29 -43
  76. package/dist/index.js +96 -45
  77. package/dist/index.js.map +1 -1
  78. package/dist/outputs.cjs +11 -32
  79. package/dist/outputs.cjs.map +1 -1
  80. package/dist/outputs.d.cts +5 -5
  81. package/dist/outputs.d.ts +5 -5
  82. package/dist/outputs.js +10 -8
  83. package/dist/outputs.js.map +1 -1
  84. package/dist/raw.cjs +21 -33
  85. package/dist/raw.cjs.map +1 -1
  86. package/dist/raw.d.cts +8 -4
  87. package/dist/raw.d.ts +8 -4
  88. package/dist/raw.js +12 -7
  89. package/dist/raw.js.map +1 -1
  90. package/dist/reachability.cjs +82 -112
  91. package/dist/reachability.cjs.map +1 -1
  92. package/dist/reachability.d.cts +33 -59
  93. package/dist/reachability.d.ts +33 -59
  94. package/dist/reachability.js +81 -88
  95. package/dist/reachability.js.map +1 -1
  96. package/dist/resources.cjs +47 -32
  97. package/dist/resources.cjs.map +1 -1
  98. package/dist/resources.d.cts +50 -3
  99. package/dist/resources.d.ts +50 -3
  100. package/dist/resources.js +42 -9
  101. package/dist/resources.js.map +1 -1
  102. package/dist/responseSchemas.cjs +99 -111
  103. package/dist/responseSchemas.cjs.map +1 -1
  104. package/dist/responseSchemas.d.cts +34 -34
  105. package/dist/responseSchemas.d.ts +34 -34
  106. package/dist/responseSchemas.js +85 -66
  107. package/dist/responseSchemas.js.map +1 -1
  108. package/dist/routeAmount.cjs +61 -31
  109. package/dist/routeAmount.cjs.map +1 -1
  110. package/dist/routeAmount.d.cts +52 -2
  111. package/dist/routeAmount.d.ts +52 -2
  112. package/dist/routeAmount.js +56 -8
  113. package/dist/routeAmount.js.map +1 -1
  114. package/dist/run/inputs.cjs +56 -48
  115. package/dist/run/inputs.cjs.map +1 -1
  116. package/dist/run/inputs.d.cts +70 -74
  117. package/dist/run/inputs.d.ts +70 -74
  118. package/dist/run/inputs.js +54 -23
  119. package/dist/run/inputs.js.map +1 -1
  120. package/dist/run/simulate.cjs +38 -43
  121. package/dist/run/simulate.cjs.map +1 -1
  122. package/dist/run/simulate.d.cts +36 -36
  123. package/dist/run/simulate.d.ts +36 -36
  124. package/dist/run/simulate.js +37 -19
  125. package/dist/run/simulate.js.map +1 -1
  126. package/dist/sdk.cjs +55 -66
  127. package/dist/sdk.cjs.map +1 -1
  128. package/dist/sdk.d.cts +108 -111
  129. package/dist/sdk.d.ts +108 -111
  130. package/dist/sdk.js +52 -44
  131. package/dist/sdk.js.map +1 -1
  132. package/dist/types.cjs +0 -17
  133. package/dist/types.d.cts +22 -22
  134. package/dist/types.d.ts +22 -22
  135. package/dist/types.js +1 -1
  136. package/package.json +5 -5
  137. package/src/client.ts +2 -2
  138. package/src/examples/aaveClaimRewards.ts +2 -1
  139. package/src/examples/emitCustomEvent.ts +1 -2
  140. package/src/examples/run.ts +1 -1
  141. package/src/examples/transferTokens.ts +21 -17
  142. package/src/generated/config.generated.ts +20 -9
  143. package/src/generated/operations.generated.ts +28 -5
  144. package/dist/discovery.cjs.map +0 -1
  145. package/dist/discovery.js.map +0 -1
  146. package/dist/generated/config.generated.cjs.map +0 -1
  147. package/dist/generated/config.generated.js.map +0 -1
  148. package/dist/guards.generated-CDCgYGZo.d.cts +0 -24
  149. package/dist/guards.generated-CdYcs4h0.d.ts +0 -24
  150. package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
  151. package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
  152. package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
  153. package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
  154. package/dist/raw-BvRghN3r.d.ts +0 -20
  155. package/dist/raw-s1rer8X3.d.cts +0 -20
  156. package/dist/resources-BKlFxjo8.d.cts +0 -56
  157. package/dist/resources-CYis1_DS.d.ts +0 -56
  158. package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
  159. package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
  160. package/dist/types.cjs.map +0 -1
  161. package/dist/types.js.map +0 -1
package/README.md CHANGED
@@ -109,7 +109,7 @@ if (result.status === 'success') {
109
109
 
110
110
  **Runtime inputs (materialisers)**: a materialiser tells the backend how to fund a flow input when the transaction executes.
111
111
 
112
- - `directDeposit({ amount })` pulls exactly `amount`.
112
+ - `directDeposit({ amount })` pulls exactly `amount`. For a token the compose token registry flags non-exact (stETH, Aave aTokens), a transfer credits a wei or two off, so the deposit instead pulls up to `amount` and asserts it received at least `amount` less 4 wei.
113
113
  - `directDeposit({ amount, allowNonExact: true })` permits a capped ERC-20 deposit of up to `amount`; `directDeposit({ allowNonExact: true })` deposits with no on-chain cap (ERC-20 only).
114
114
  - `balanceOf({ owner })` reads a current balance.
115
115
  - `call({ target, calldata })` measures the balance delta after an arbitrary contract call.
@@ -425,7 +425,7 @@ try {
425
425
 
426
426
  `kind` is the backend's finer-grained classification, e.g. `simulation_revert`, `guard_error`, or `price_impact_exceeded`. When `kind` is `simulation_revert`, `err.details` has the same shape as `result.simulationRevert`.
427
427
 
428
- A `preparation_error` (HTTP 422) means some prepared ops (ops that fetch external quotes at compile time, such as `lifi.swap`) failed while others succeeded, e.g. a mixed basket with one unroutable leg. Narrow with `isComposePreparationError`, drop the failed node ids from the flow, and resubmit:
428
+ A `preparation_error` (HTTP 422) means some prepared ops (ops that fetch external quotes at compile time, such as `lifi.swap`) failed while others succeeded, e.g. a mixed basket with one unroutable leg. A `failedOps` entry whose `kind` is `resolution_error` hit an upstream outage rather than a dead route, so keep that node when resubmitting. When every failed op hit an outage, the error is a 503 `resolution_error` instead: retry the same flow. Narrow with `isComposePreparationError`, drop the other failed node ids from the flow, and resubmit:
429
429
 
430
430
  ```ts
431
431
  import { isComposePreparationError } from '@lifi/composer-sdk';
@@ -438,7 +438,8 @@ try {
438
438
  console.error(op.callId, op.op, op.kind, op.message);
439
439
  }
440
440
  // Only the prepared ops that succeeded, not the rest of the flow. To retry,
441
- // remove the failedOps callIds from the original flow.
441
+ // remove the failedOps callIds from the original flow, keeping any whose
442
+ // kind is 'resolution_error'.
442
443
  console.error('prepared ok:', err.succeededOps);
443
444
  }
444
445
  }
@@ -0,0 +1,33 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ return target;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ //#endregion
32
+ exports.__exportAll = __exportAll;
33
+ exports.__toESM = __toESM;
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -1,124 +1,106 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var FlowBuilderCore_exports = {};
20
- __export(FlowBuilderCore_exports, {
21
- createFlowBuilderCore: () => createFlowBuilderCore
22
- });
23
- module.exports = __toCommonJS(FlowBuilderCore_exports);
24
- var import_compose_spec = require("@lifi/compose-spec");
25
- var import_handles = require("./handles.js");
26
- var import_raw = require("./raw.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_authoring_handles = require("./handles.cjs");
3
+ const require_authoring_raw = require("./raw.cjs");
4
+ let _lifi_compose_spec = require("@lifi/compose-spec");
5
+ //#region src/authoring/FlowBuilderCore.ts
27
6
  const isResource = (decl) => typeof decl === "object" && decl !== null && "kind" in decl;
7
+ /**
8
+ * Creates a new flow builder targeting the given chain.
9
+ *
10
+ * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).
11
+ * @param options - Flow configuration including input declarations.
12
+ * @returns A {@link FlowBuilderInternal} instance.
13
+ * @internal
14
+ */
28
15
  const createFlowBuilderCore = (chainId, options) => {
29
- const id = options.name ?? crypto.randomUUID();
30
- const flowInputs = [];
31
- const nodes = [];
32
- const nodeIds = /* @__PURE__ */ new Set();
33
- const inputHandles = {};
34
- for (const [name, decl] of Object.entries(options.inputs)) {
35
- if (isResource(decl)) {
36
- if (decl.chainId !== chainId) {
37
- throw new Error(
38
- `Input "${name}" has chainId ${decl.chainId} but flow targets chain ${chainId}`
39
- );
40
- }
41
- flowInputs.push({ name, resource: decl });
42
- inputHandles[name] = { _tag: "input", inputName: name, resource: decl };
43
- } else {
44
- flowInputs.push({ name, type: decl });
45
- inputHandles[name] = { _tag: "input", inputName: name };
46
- }
47
- }
48
- const call = (nodeId, op, args, outputs, families) => {
49
- if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: "${nodeId}"`);
50
- nodeIds.add(nodeId);
51
- const bind = {};
52
- for (const [key, val] of Object.entries(args.bind)) {
53
- bind[key] = (0, import_handles.toBindValue)(val);
54
- }
55
- const config = args.config ?? {};
56
- const node = {
57
- id: nodeId,
58
- op,
59
- bind,
60
- config,
61
- ...args.guards && args.guards.length > 0 && { guards: args.guards }
62
- };
63
- nodes.push(node);
64
- const outputHandle = (portName) => ({
65
- _tag: "output",
66
- nodeId,
67
- portName
68
- });
69
- return new Proxy({}, {
70
- get: (_target, prop) => {
71
- if (typeof prop !== "string" || prop === "then") return void 0;
72
- if (!Object.hasOwn(outputs, prop)) {
73
- throw new Error(
74
- `Op "${op}" has no output port "${prop}". Valid ports: ${Object.keys(
75
- outputs
76
- ).join(", ")}`
77
- );
78
- }
79
- const countFrom = families?.[prop];
80
- if (countFrom === void 0) return outputHandle(prop);
81
- const size = (0, import_compose_spec.familySize)({ name: prop, countFrom }, config);
82
- return Array.from(
83
- { length: size },
84
- (_, index) => outputHandle((0, import_compose_spec.instancePortName)(prop, index))
85
- );
86
- }
87
- });
88
- };
89
- const untypedOp = (nodeId, op, args) => {
90
- if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: "${nodeId}"`);
91
- nodeIds.add(nodeId);
92
- const node = {
93
- id: nodeId,
94
- op,
95
- bind: args.bind,
96
- config: args.config,
97
- ...args.guards && args.guards.length > 0 && { guards: args.guards }
98
- };
99
- nodes.push(node);
100
- };
101
- const build = () => ({
102
- version: 1,
103
- id,
104
- chainId,
105
- inputs: [...flowInputs],
106
- nodes: [...nodes]
107
- });
108
- const context = {
109
- sender: (0, import_raw.ref)("context.sender"),
110
- executionAddress: (0, import_raw.ref)("context.executionAddress")
111
- };
112
- return {
113
- context,
114
- inputs: inputHandles,
115
- call,
116
- untypedOp,
117
- build
118
- };
16
+ const id = options.name ?? crypto.randomUUID();
17
+ const flowInputs = [];
18
+ const nodes = [];
19
+ const nodeIds = /* @__PURE__ */ new Set();
20
+ const inputHandles = {};
21
+ for (const [name, decl] of Object.entries(options.inputs)) if (isResource(decl)) {
22
+ if (decl.chainId !== chainId) throw new Error(`Input "${name}" has chainId ${decl.chainId} but flow targets chain ${chainId}`);
23
+ flowInputs.push({
24
+ name,
25
+ resource: decl
26
+ });
27
+ inputHandles[name] = {
28
+ _tag: "input",
29
+ inputName: name,
30
+ resource: decl
31
+ };
32
+ } else {
33
+ flowInputs.push({
34
+ name,
35
+ type: decl
36
+ });
37
+ inputHandles[name] = {
38
+ _tag: "input",
39
+ inputName: name
40
+ };
41
+ }
42
+ const call = (nodeId, op, args, outputs, families) => {
43
+ if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: "${nodeId}"`);
44
+ nodeIds.add(nodeId);
45
+ const bind = {};
46
+ for (const [key, val] of Object.entries(args.bind)) bind[key] = require_authoring_handles.toBindValue(val);
47
+ const config = args.config ?? {};
48
+ const node = {
49
+ id: nodeId,
50
+ op,
51
+ bind,
52
+ config,
53
+ ...args.guards && args.guards.length > 0 && { guards: args.guards }
54
+ };
55
+ nodes.push(node);
56
+ const outputHandle = (portName) => ({
57
+ _tag: "output",
58
+ nodeId,
59
+ portName
60
+ });
61
+ return new Proxy({}, { get: (_target, prop) => {
62
+ if (typeof prop !== "string" || prop === "then") return void 0;
63
+ if (!Object.hasOwn(outputs, prop)) throw new Error(`Op "${op}" has no output port "${prop}". Valid ports: ${Object.keys(outputs).join(", ")}`);
64
+ const countFrom = families?.[prop];
65
+ if (countFrom === void 0) return outputHandle(prop);
66
+ const size = (0, _lifi_compose_spec.familySize)({
67
+ name: prop,
68
+ countFrom
69
+ }, config);
70
+ return Array.from({ length: size }, (_, index) => outputHandle((0, _lifi_compose_spec.instancePortName)(prop, index)));
71
+ } });
72
+ };
73
+ const untypedOp = (nodeId, op, args) => {
74
+ if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: "${nodeId}"`);
75
+ nodeIds.add(nodeId);
76
+ const node = {
77
+ id: nodeId,
78
+ op,
79
+ bind: args.bind,
80
+ config: args.config,
81
+ ...args.guards && args.guards.length > 0 && { guards: args.guards }
82
+ };
83
+ nodes.push(node);
84
+ };
85
+ const build = () => ({
86
+ version: 1,
87
+ id,
88
+ chainId,
89
+ inputs: [...flowInputs],
90
+ nodes: [...nodes]
91
+ });
92
+ return {
93
+ context: {
94
+ sender: require_authoring_raw.ref("context.sender"),
95
+ executionAddress: require_authoring_raw.ref("context.executionAddress")
96
+ },
97
+ inputs: inputHandles,
98
+ call,
99
+ untypedOp,
100
+ build
101
+ };
119
102
  };
120
- // Annotate the CommonJS export names for ESM import in node:
121
- 0 && (module.exports = {
122
- createFlowBuilderCore
123
- });
103
+ //#endregion
104
+ exports.createFlowBuilderCore = createFlowBuilderCore;
105
+
124
106
  //# sourceMappingURL=FlowBuilderCore.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/authoring/FlowBuilderCore.ts"],"sourcesContent":["import {\n type AppliedGuard,\n type BindValue,\n type Call,\n familySize,\n type Flow,\n type FlowInput,\n instancePortName,\n type Ref,\n type Resource,\n type SolType,\n} from '@lifi/compose-spec';\n\nimport type {\n InputDecl,\n InputSchema,\n OutputKind,\n TypedGuard,\n TypedLiteral,\n TypedRef,\n} from '../types.js';\n\nimport type {\n InputHandle,\n OutputHandle,\n ResourceInputHandle,\n} from './handles.js';\nimport { toBindValue } from './handles.js';\nimport { ref } from './raw.js';\n\n/**\n * Arguments for calling an operation node in a flow.\n */\nexport interface CallArgs {\n /** Maps parameter names to input/output handles or raw `$ref` pointers. */\n readonly bind: Record<string, AnyBindable>;\n /** Optional operation-specific configuration. */\n readonly config?: object;\n /** Optional guards (e.g. slippage checks) applied to this operation's outputs. */\n readonly guards?: readonly TypedGuard[];\n}\n\n/**\n * Any value that can be bound to an operation parameter: an input handle, an\n * output handle from a previous operation, a typed `$ref` pointer, a typed\n * literal, or a bare `{ $ref }` pointer.\n *\n * This is the bind type of {@link FlowBuilderInternal.call}, the entry point\n * every generated operation lowers into — not a public authoring surface. A\n * bare `Ref` belongs here because a generated op resolves its own typed binds\n * to wire refs (`toBindRef` in `./signatureArgs.js`) before calling it. Typed\n * operation slots use `Bindable<T>`, which rejects a bare `Ref`; see\n * `RefBindable` in `./handles.js`.\n *\n * Use `raw.ref<T>()` to create a typed ref from a raw path string, and\n * `raw.literal<T>()` to bake in a constant.\n */\nexport type AnyBindable =\n InputHandle | OutputHandle | TypedRef | TypedLiteral | Ref;\n\n/**\n * Provides references to runtime context values available inside a flow.\n * Access via `builder.context`.\n */\nexport interface ContextAccessor {\n /** A `$ref` pointing to the transaction sender (signer) address. */\n readonly sender: TypedRef<'address'>;\n /** A `$ref` pointing to the on-chain execution (proxy) address. */\n readonly executionAddress: TypedRef<'address'>;\n}\n\ntype InputHandleOf<D extends InputDecl> = D extends Resource\n ? ResourceInputHandle\n : D extends SolType\n ? InputHandle<D>\n : InputHandle;\n\n/**\n * A mapped type that converts an input schema into typed handles.\n * Resource inputs produce {@link ResourceInputHandle}; scalar inputs produce {@link InputHandle}.\n *\n * @typeParam T - The flow's input schema.\n */\nexport type InputHandles<T extends InputSchema> = {\n readonly [K in keyof T]: InputHandleOf<T[K]>;\n};\n\n/**\n * Options for creating a new flow builder.\n *\n * @typeParam T - The flow's input schema.\n */\nexport interface FlowOptions<T extends InputSchema> {\n /** Optional human-readable name for the flow. Defaults to a random UUID. */\n readonly name?: string;\n /** Input declarations mapping names to resource or scalar types. */\n readonly inputs: T;\n}\n\n/**\n * A Flow document branded with its input schema for type-safe request building.\n *\n * The `__inputs` field is a phantom type — it exists only at compile time for\n * TypeScript inference and is never present at runtime.\n */\nexport type TypedFlow<T extends InputSchema = InputSchema> = Flow & {\n readonly __inputs?: T;\n};\n\n/**\n * Core flow builder interface providing low-level access to flow construction.\n *\n * For most use cases, prefer the {@link FlowBuilder} type returned by `sdk.flow()`\n * which adds generated operation methods and a `compile` method.\n *\n * @typeParam T - The flow's input schema.\n */\nexport interface FlowBuilderCore<T extends InputSchema = InputSchema> {\n /** Runtime context references (sender address, execution address). */\n readonly context: ContextAccessor;\n /** Typed handles for each declared flow input, used to bind inputs to operations. */\n readonly inputs: InputHandles<T>;\n /**\n * Appends an untyped operation node to the flow. This is an escape hatch\n * for operations not yet covered by the generated methods.\n *\n * Use `raw.ref<T>()` to reference this node's outputs in subsequent typed\n * operations.\n *\n * @param id - Unique node identifier within the flow.\n * @param op - The operation name (e.g. `\"custom.vaultQuery\"`).\n * @param args - Bind map, config, and optional guards for the node.\n * @throws Error if a node with the same `id` already exists in the flow.\n */\n readonly untypedOp: (\n id: string,\n op: string,\n args: {\n readonly bind: Record<string, BindValue>;\n readonly config: Record<string, unknown>;\n readonly guards?: readonly AppliedGuard[];\n },\n ) => void;\n /** Serialises the builder state into a {@link TypedFlow} document. */\n readonly build: () => TypedFlow<T>;\n}\n\n/** Maps output port names to their output kind for compile-time and runtime validation. */\nexport type OutputSpec = Record<string, OutputKind>;\n\n/**\n * Maps each output family's port name to the config key that sizes it: an\n * array (one instance per element) or a non-negative integer count.\n * A family port is also listed in the {@link OutputSpec}, as `'resource'`.\n */\nexport type FamilySpec = Readonly<Record<string, string>>;\n\n/** The handles `call` returns for an {@link OutputSpec} and its families. */\nexport type OutputHandles<O extends OutputSpec, F extends FamilySpec> = {\n readonly [K in keyof O & string]: K extends keyof F\n ? readonly OutputHandle<'resource'>[]\n : OutputHandle<O[K]>;\n};\n\n/** Internal interface exposed to bindGeneratedOps — not part of the public API. */\nexport interface FlowBuilderInternal<\n T extends InputSchema = InputSchema,\n> extends FlowBuilderCore<T> {\n readonly call: <\n O extends OutputSpec,\n F extends FamilySpec = Record<never, string>,\n >(\n nodeId: string,\n op: string,\n args: CallArgs,\n outputs: O,\n families?: F,\n ) => OutputHandles<O, F>;\n}\n\nconst isResource = (decl: InputDecl): decl is Resource =>\n typeof decl === 'object' && decl !== null && 'kind' in decl;\n\n/**\n * Creates a new flow builder targeting the given chain.\n *\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilderInternal} instance.\n * @internal\n */\nexport const createFlowBuilderCore = <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n): FlowBuilderInternal<T> => {\n const id = options.name ?? crypto.randomUUID();\n const flowInputs: FlowInput[] = [];\n const nodes: Call[] = [];\n const nodeIds = new Set<string>();\n\n const inputHandles = {} as Record<string, InputHandle | ResourceInputHandle>;\n for (const [name, decl] of Object.entries(options.inputs)) {\n if (isResource(decl)) {\n if (decl.chainId !== chainId) {\n throw new Error(\n `Input \"${name}\" has chainId ${decl.chainId} but flow targets chain ${chainId}`,\n );\n }\n flowInputs.push({ name, resource: decl });\n inputHandles[name] = { _tag: 'input', inputName: name, resource: decl };\n } else {\n flowInputs.push({ name, type: decl });\n inputHandles[name] = { _tag: 'input', inputName: name };\n }\n }\n\n const call = <\n O extends OutputSpec,\n F extends FamilySpec = Record<never, string>,\n >(\n nodeId: string,\n op: string,\n args: CallArgs,\n outputs: O,\n families?: F,\n ): OutputHandles<O, F> => {\n if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: \"${nodeId}\"`);\n nodeIds.add(nodeId);\n\n const bind: Record<string, BindValue> = {};\n for (const [key, val] of Object.entries(args.bind)) {\n bind[key] = toBindValue(val);\n }\n\n const config = (args.config ?? {}) as Record<string, unknown>;\n const node: Call = {\n id: nodeId,\n op,\n bind,\n config,\n ...(args.guards && args.guards.length > 0 && { guards: args.guards }),\n };\n nodes.push(node);\n\n const outputHandle = (portName: string): OutputHandle => ({\n _tag: 'output',\n nodeId,\n portName,\n });\n return new Proxy({} as OutputHandles<O, F>, {\n get: (\n _target,\n prop,\n ): OutputHandle | readonly OutputHandle[] | undefined => {\n if (typeof prop !== 'string' || prop === 'then') return undefined;\n // Own-key only: the trap sees every property a consumer reads, so `in`\n // would answer a handle for `toString` or `constructor` instead of the\n // unknown-port error.\n if (!Object.hasOwn(outputs, prop)) {\n throw new Error(\n `Op \"${op}\" has no output port \"${prop}\". Valid ports: ${Object.keys(\n outputs,\n ).join(', ')}`,\n );\n }\n const countFrom = families?.[prop];\n if (countFrom === undefined) return outputHandle(prop);\n const size = familySize({ name: prop, countFrom }, config);\n return Array.from({ length: size }, (_, index) =>\n outputHandle(instancePortName(prop, index)),\n );\n },\n });\n };\n\n const untypedOp = (\n nodeId: string,\n op: string,\n args: {\n readonly bind: Record<string, BindValue>;\n readonly config: Record<string, unknown>;\n readonly guards?: readonly AppliedGuard[];\n },\n ): void => {\n if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: \"${nodeId}\"`);\n nodeIds.add(nodeId);\n const node: Call = {\n id: nodeId,\n op,\n bind: args.bind,\n config: args.config,\n ...(args.guards && args.guards.length > 0 && { guards: args.guards }),\n };\n nodes.push(node);\n };\n\n const build = (): TypedFlow<T> => ({\n version: 1,\n id,\n chainId,\n inputs: [...flowInputs],\n nodes: [...nodes],\n });\n\n const context: ContextAccessor = {\n sender: ref<'address'>('context.sender'),\n executionAddress: ref<'address'>('context.executionAddress'),\n };\n\n return {\n context,\n inputs: inputHandles as InputHandles<T>,\n call,\n untypedOp,\n build,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAWO;AAgBP,qBAA4B;AAC5B,iBAAoB;AAwJpB,MAAM,aAAa,CAAC,SAClB,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU;AAUlD,MAAM,wBAAwB,CACnC,SACA,YAC2B;AAC3B,QAAM,KAAK,QAAQ,QAAQ,OAAO,WAAW;AAC7C,QAAM,aAA0B,CAAC;AACjC,QAAM,QAAgB,CAAC;AACvB,QAAM,UAAU,oBA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Core.cjs","names":["toBindValue","familySize","instancePortName","ref"],"sources":["../../src/authoring/FlowBuilderCore.ts"],"sourcesContent":["import {\n type AppliedGuard,\n type BindValue,\n type Call,\n familySize,\n type Flow,\n type FlowInput,\n instancePortName,\n type Ref,\n type Resource,\n type SolType,\n} from '@lifi/compose-spec';\n\nimport type {\n InputDecl,\n InputSchema,\n OutputKind,\n TypedGuard,\n TypedLiteral,\n TypedRef,\n} from '../types.js';\n\nimport type {\n InputHandle,\n OutputHandle,\n ResourceInputHandle,\n} from './handles.js';\nimport { toBindValue } from './handles.js';\nimport { ref } from './raw.js';\n\n/**\n * Arguments for calling an operation node in a flow.\n */\nexport interface CallArgs {\n /** Maps parameter names to input/output handles or raw `$ref` pointers. */\n readonly bind: Record<string, AnyBindable>;\n /** Optional operation-specific configuration. */\n readonly config?: object;\n /** Optional guards (e.g. slippage checks) applied to this operation's outputs. */\n readonly guards?: readonly TypedGuard[];\n}\n\n/**\n * Any value that can be bound to an operation parameter: an input handle, an\n * output handle from a previous operation, a typed `$ref` pointer, a typed\n * literal, or a bare `{ $ref }` pointer.\n *\n * This is the bind type of {@link FlowBuilderInternal.call}, the entry point\n * every generated operation lowers into — not a public authoring surface. A\n * bare `Ref` belongs here because a generated op resolves its own typed binds\n * to wire refs (`toBindRef` in `./signatureArgs.js`) before calling it. Typed\n * operation slots use `Bindable<T>`, which rejects a bare `Ref`; see\n * `RefBindable` in `./handles.js`.\n *\n * Use `raw.ref<T>()` to create a typed ref from a raw path string, and\n * `raw.literal<T>()` to bake in a constant.\n */\nexport type AnyBindable =\n InputHandle | OutputHandle | TypedRef | TypedLiteral | Ref;\n\n/**\n * Provides references to runtime context values available inside a flow.\n * Access via `builder.context`.\n */\nexport interface ContextAccessor {\n /** A `$ref` pointing to the transaction sender (signer) address. */\n readonly sender: TypedRef<'address'>;\n /** A `$ref` pointing to the on-chain execution (proxy) address. */\n readonly executionAddress: TypedRef<'address'>;\n}\n\ntype InputHandleOf<D extends InputDecl> = D extends Resource\n ? ResourceInputHandle\n : D extends SolType\n ? InputHandle<D>\n : InputHandle;\n\n/**\n * A mapped type that converts an input schema into typed handles.\n * Resource inputs produce {@link ResourceInputHandle}; scalar inputs produce {@link InputHandle}.\n *\n * @typeParam T - The flow's input schema.\n */\nexport type InputHandles<T extends InputSchema> = {\n readonly [K in keyof T]: InputHandleOf<T[K]>;\n};\n\n/**\n * Options for creating a new flow builder.\n *\n * @typeParam T - The flow's input schema.\n */\nexport interface FlowOptions<T extends InputSchema> {\n /** Optional human-readable name for the flow. Defaults to a random UUID. */\n readonly name?: string;\n /** Input declarations mapping names to resource or scalar types. */\n readonly inputs: T;\n}\n\n/**\n * A Flow document branded with its input schema for type-safe request building.\n *\n * The `__inputs` field is a phantom type — it exists only at compile time for\n * TypeScript inference and is never present at runtime.\n */\nexport type TypedFlow<T extends InputSchema = InputSchema> = Flow & {\n readonly __inputs?: T;\n};\n\n/**\n * Core flow builder interface providing low-level access to flow construction.\n *\n * For most use cases, prefer the {@link FlowBuilder} type returned by `sdk.flow()`\n * which adds generated operation methods and a `compile` method.\n *\n * @typeParam T - The flow's input schema.\n */\nexport interface FlowBuilderCore<T extends InputSchema = InputSchema> {\n /** Runtime context references (sender address, execution address). */\n readonly context: ContextAccessor;\n /** Typed handles for each declared flow input, used to bind inputs to operations. */\n readonly inputs: InputHandles<T>;\n /**\n * Appends an untyped operation node to the flow. This is an escape hatch\n * for operations not yet covered by the generated methods.\n *\n * Use `raw.ref<T>()` to reference this node's outputs in subsequent typed\n * operations.\n *\n * @param id - Unique node identifier within the flow.\n * @param op - The operation name (e.g. `\"custom.vaultQuery\"`).\n * @param args - Bind map, config, and optional guards for the node.\n * @throws Error if a node with the same `id` already exists in the flow.\n */\n readonly untypedOp: (\n id: string,\n op: string,\n args: {\n readonly bind: Record<string, BindValue>;\n readonly config: Record<string, unknown>;\n readonly guards?: readonly AppliedGuard[];\n },\n ) => void;\n /** Serialises the builder state into a {@link TypedFlow} document. */\n readonly build: () => TypedFlow<T>;\n}\n\n/** Maps output port names to their output kind for compile-time and runtime validation. */\nexport type OutputSpec = Record<string, OutputKind>;\n\n/**\n * Maps each output family's port name to the config key that sizes it: an\n * array (one instance per element) or a non-negative integer count.\n * A family port is also listed in the {@link OutputSpec}, as `'resource'`.\n */\nexport type FamilySpec = Readonly<Record<string, string>>;\n\n/** The handles `call` returns for an {@link OutputSpec} and its families. */\nexport type OutputHandles<O extends OutputSpec, F extends FamilySpec> = {\n readonly [K in keyof O & string]: K extends keyof F\n ? readonly OutputHandle<'resource'>[]\n : OutputHandle<O[K]>;\n};\n\n/** Internal interface exposed to bindGeneratedOps — not part of the public API. */\nexport interface FlowBuilderInternal<\n T extends InputSchema = InputSchema,\n> extends FlowBuilderCore<T> {\n readonly call: <\n O extends OutputSpec,\n F extends FamilySpec = Record<never, string>,\n >(\n nodeId: string,\n op: string,\n args: CallArgs,\n outputs: O,\n families?: F,\n ) => OutputHandles<O, F>;\n}\n\nconst isResource = (decl: InputDecl): decl is Resource =>\n typeof decl === 'object' && decl !== null && 'kind' in decl;\n\n/**\n * Creates a new flow builder targeting the given chain.\n *\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilderInternal} instance.\n * @internal\n */\nexport const createFlowBuilderCore = <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n): FlowBuilderInternal<T> => {\n const id = options.name ?? crypto.randomUUID();\n const flowInputs: FlowInput[] = [];\n const nodes: Call[] = [];\n const nodeIds = new Set<string>();\n\n const inputHandles = {} as Record<string, InputHandle | ResourceInputHandle>;\n for (const [name, decl] of Object.entries(options.inputs)) {\n if (isResource(decl)) {\n if (decl.chainId !== chainId) {\n throw new Error(\n `Input \"${name}\" has chainId ${decl.chainId} but flow targets chain ${chainId}`,\n );\n }\n flowInputs.push({ name, resource: decl });\n inputHandles[name] = { _tag: 'input', inputName: name, resource: decl };\n } else {\n flowInputs.push({ name, type: decl });\n inputHandles[name] = { _tag: 'input', inputName: name };\n }\n }\n\n const call = <\n O extends OutputSpec,\n F extends FamilySpec = Record<never, string>,\n >(\n nodeId: string,\n op: string,\n args: CallArgs,\n outputs: O,\n families?: F,\n ): OutputHandles<O, F> => {\n if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: \"${nodeId}\"`);\n nodeIds.add(nodeId);\n\n const bind: Record<string, BindValue> = {};\n for (const [key, val] of Object.entries(args.bind)) {\n bind[key] = toBindValue(val);\n }\n\n const config = (args.config ?? {}) as Record<string, unknown>;\n const node: Call = {\n id: nodeId,\n op,\n bind,\n config,\n ...(args.guards && args.guards.length > 0 && { guards: args.guards }),\n };\n nodes.push(node);\n\n const outputHandle = (portName: string): OutputHandle => ({\n _tag: 'output',\n nodeId,\n portName,\n });\n return new Proxy({} as OutputHandles<O, F>, {\n get: (\n _target,\n prop,\n ): OutputHandle | readonly OutputHandle[] | undefined => {\n if (typeof prop !== 'string' || prop === 'then') return undefined;\n // Own-key only: the trap sees every property a consumer reads, so `in`\n // would answer a handle for `toString` or `constructor` instead of the\n // unknown-port error.\n if (!Object.hasOwn(outputs, prop)) {\n throw new Error(\n `Op \"${op}\" has no output port \"${prop}\". Valid ports: ${Object.keys(\n outputs,\n ).join(', ')}`,\n );\n }\n const countFrom = families?.[prop];\n if (countFrom === undefined) return outputHandle(prop);\n const size = familySize({ name: prop, countFrom }, config);\n return Array.from({ length: size }, (_, index) =>\n outputHandle(instancePortName(prop, index)),\n );\n },\n });\n };\n\n const untypedOp = (\n nodeId: string,\n op: string,\n args: {\n readonly bind: Record<string, BindValue>;\n readonly config: Record<string, unknown>;\n readonly guards?: readonly AppliedGuard[];\n },\n ): void => {\n if (nodeIds.has(nodeId)) throw new Error(`Duplicate node id: \"${nodeId}\"`);\n nodeIds.add(nodeId);\n const node: Call = {\n id: nodeId,\n op,\n bind: args.bind,\n config: args.config,\n ...(args.guards && args.guards.length > 0 && { guards: args.guards }),\n };\n nodes.push(node);\n };\n\n const build = (): TypedFlow<T> => ({\n version: 1,\n id,\n chainId,\n inputs: [...flowInputs],\n nodes: [...nodes],\n });\n\n const context: ContextAccessor = {\n sender: ref<'address'>('context.sender'),\n executionAddress: ref<'address'>('context.executionAddress'),\n };\n\n return {\n context,\n inputs: inputHandles as InputHandles<T>,\n call,\n untypedOp,\n build,\n };\n};\n"],"mappings":";;;;;AAoLA,MAAM,cAAc,SAClB,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU;;;;;;;;;AAUzD,MAAa,yBACX,SACA,YAC2B;CAC3B,MAAM,KAAK,QAAQ,QAAQ,OAAO,WAAW;CAC7C,MAAM,aAA0B,CAAC;CACjC,MAAM,QAAgB,CAAC;CACvB,MAAM,0BAAU,IAAI,IAAY;CAEhC,MAAM,eAAe,CAAC;CACtB,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,QAAQ,MAAM,GACtD,IAAI,WAAW,IAAI,GAAG;EACpB,IAAI,KAAK,YAAY,SACnB,MAAM,IAAI,MACR,UAAU,KAAK,gBAAgB,KAAK,QAAQ,0BAA0B,SACxE;EAEF,WAAW,KAAK;GAAE;GAAM,UAAU;EAAK,CAAC;EACxC,aAAa,QAAQ;GAAE,MAAM;GAAS,WAAW;GAAM,UAAU;EAAK;CACxE,OAAO;EACL,WAAW,KAAK;GAAE;GAAM,MAAM;EAAK,CAAC;EACpC,aAAa,QAAQ;GAAE,MAAM;GAAS,WAAW;EAAK;CACxD;CAGF,MAAM,QAIJ,QACA,IACA,MACA,SACA,aACwB;EACxB,IAAI,QAAQ,IAAI,MAAM,GAAG,MAAM,IAAI,MAAM,uBAAuB,OAAO,EAAE;EACzE,QAAQ,IAAI,MAAM;EAElB,MAAM,OAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,IAAI,GAC/C,KAAK,OAAOA,0BAAAA,YAAY,GAAG;EAG7B,MAAM,SAAU,KAAK,UAAU,CAAC;EAChC,MAAM,OAAa;GACjB,I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sBAAAA,IAAe,0BAA0B;EAIrD;EACN,QAAQ;EACR;EACA;EACA;CACF;AACF"}
@@ -1,17 +1,17 @@
1
- import { Ref, Resource, SolType, BindValue, AppliedGuard, Flow } from '@lifi/compose-spec';
2
- import { TypedRef, TypedLiteral, InputSchema, InputDecl, TypedGuard, OutputKind } from '../types.cjs';
3
- import { InputHandle, OutputHandle, ResourceInputHandle } from './handles.cjs';
4
-
1
+ import { InputDecl, InputSchema, OutputKind, TypedGuard, TypedLiteral, TypedRef } from "../types.cjs";
2
+ import { InputHandle, OutputHandle, ResourceInputHandle } from "./handles.cjs";
3
+ import { AppliedGuard, BindValue, Flow, Ref, Resource, SolType } from "@lifi/compose-spec";
4
+ //#region src/authoring/FlowBuilderCore.d.ts
5
5
  /**
6
6
  * Arguments for calling an operation node in a flow.
7
7
  */
8
- interface CallArgs {
9
- /** Maps parameter names to input/output handles or raw `$ref` pointers. */
10
- readonly bind: Record<string, AnyBindable>;
11
- /** Optional operation-specific configuration. */
12
- readonly config?: object;
13
- /** Optional guards (e.g. slippage checks) applied to this operation's outputs. */
14
- readonly guards?: readonly TypedGuard[];
8
+ export interface CallArgs {
9
+ /** Maps parameter names to input/output handles or raw `$ref` pointers. */
10
+ readonly bind: Record<string, AnyBindable>;
11
+ /** Optional operation-specific configuration. */
12
+ readonly config?: object;
13
+ /** Optional guards (e.g. slippage checks) applied to this operation's outputs. */
14
+ readonly guards?: readonly TypedGuard[];
15
15
  }
16
16
  /**
17
17
  * Any value that can be bound to an operation parameter: an input handle, an
@@ -28,16 +28,16 @@ interface CallArgs {
28
28
  * Use `raw.ref<T>()` to create a typed ref from a raw path string, and
29
29
  * `raw.literal<T>()` to bake in a constant.
30
30
  */
31
- type AnyBindable = InputHandle | OutputHandle | TypedRef | TypedLiteral | Ref;
31
+ export type AnyBindable = InputHandle | OutputHandle | TypedRef | TypedLiteral | Ref;
32
32
  /**
33
33
  * Provides references to runtime context values available inside a flow.
34
34
  * Access via `builder.context`.
35
35
  */
36
- interface ContextAccessor {
37
- /** A `$ref` pointing to the transaction sender (signer) address. */
38
- readonly sender: TypedRef<'address'>;
39
- /** A `$ref` pointing to the on-chain execution (proxy) address. */
40
- readonly executionAddress: TypedRef<'address'>;
36
+ export interface ContextAccessor {
37
+ /** A `$ref` pointing to the transaction sender (signer) address. */
38
+ readonly sender: TypedRef<"address">;
39
+ /** A `$ref` pointing to the on-chain execution (proxy) address. */
40
+ readonly executionAddress: TypedRef<"address">;
41
41
  }
42
42
  type InputHandleOf<D extends InputDecl> = D extends Resource ? ResourceInputHandle : D extends SolType ? InputHandle<D> : InputHandle;
43
43
  /**
@@ -46,19 +46,17 @@ type InputHandleOf<D extends InputDecl> = D extends Resource ? ResourceInputHand
46
46
  *
47
47
  * @typeParam T - The flow's input schema.
48
48
  */
49
- type InputHandles<T extends InputSchema> = {
50
- readonly [K in keyof T]: InputHandleOf<T[K]>;
51
- };
49
+ export type InputHandles<T extends InputSchema> = { readonly [K in keyof T]: InputHandleOf<T[K]>; };
52
50
  /**
53
51
  * Options for creating a new flow builder.
54
52
  *
55
53
  * @typeParam T - The flow's input schema.
56
54
  */
57
- interface FlowOptions<T extends InputSchema> {
58
- /** Optional human-readable name for the flow. Defaults to a random UUID. */
59
- readonly name?: string;
60
- /** Input declarations mapping names to resource or scalar types. */
61
- readonly inputs: T;
55
+ export interface FlowOptions<T extends InputSchema> {
56
+ /** Optional human-readable name for the flow. Defaults to a random UUID. */
57
+ readonly name?: string;
58
+ /** Input declarations mapping names to resource or scalar types. */
59
+ readonly inputs: T;
62
60
  }
63
61
  /**
64
62
  * A Flow document branded with its input schema for type-safe request building.
@@ -66,8 +64,8 @@ interface FlowOptions<T extends InputSchema> {
66
64
  * The `__inputs` field is a phantom type — it exists only at compile time for
67
65
  * TypeScript inference and is never present at runtime.
68
66
  */
69
- type TypedFlow<T extends InputSchema = InputSchema> = Flow & {
70
- readonly __inputs?: T;
67
+ export type TypedFlow<T extends InputSchema = InputSchema> = Flow & {
68
+ readonly __inputs?: T;
71
69
  };
72
70
  /**
73
71
  * Core flow builder interface providing low-level access to flow construction.
@@ -77,46 +75,44 @@ type TypedFlow<T extends InputSchema = InputSchema> = Flow & {
77
75
  *
78
76
  * @typeParam T - The flow's input schema.
79
77
  */
80
- interface FlowBuilderCore<T extends InputSchema = InputSchema> {
81
- /** Runtime context references (sender address, execution address). */
82
- readonly context: ContextAccessor;
83
- /** Typed handles for each declared flow input, used to bind inputs to operations. */
84
- readonly inputs: InputHandles<T>;
85
- /**
86
- * Appends an untyped operation node to the flow. This is an escape hatch
87
- * for operations not yet covered by the generated methods.
88
- *
89
- * Use `raw.ref<T>()` to reference this node's outputs in subsequent typed
90
- * operations.
91
- *
92
- * @param id - Unique node identifier within the flow.
93
- * @param op - The operation name (e.g. `"custom.vaultQuery"`).
94
- * @param args - Bind map, config, and optional guards for the node.
95
- * @throws Error if a node with the same `id` already exists in the flow.
96
- */
97
- readonly untypedOp: (id: string, op: string, args: {
98
- readonly bind: Record<string, BindValue>;
99
- readonly config: Record<string, unknown>;
100
- readonly guards?: readonly AppliedGuard[];
101
- }) => void;
102
- /** Serialises the builder state into a {@link TypedFlow} document. */
103
- readonly build: () => TypedFlow<T>;
78
+ export interface FlowBuilderCore<T extends InputSchema = InputSchema> {
79
+ /** Runtime context references (sender address, execution address). */
80
+ readonly context: ContextAccessor;
81
+ /** Typed handles for each declared flow input, used to bind inputs to operations. */
82
+ readonly inputs: InputHandles<T>;
83
+ /**
84
+ * Appends an untyped operation node to the flow. This is an escape hatch
85
+ * for operations not yet covered by the generated methods.
86
+ *
87
+ * Use `raw.ref<T>()` to reference this node's outputs in subsequent typed
88
+ * operations.
89
+ *
90
+ * @param id - Unique node identifier within the flow.
91
+ * @param op - The operation name (e.g. `"custom.vaultQuery"`).
92
+ * @param args - Bind map, config, and optional guards for the node.
93
+ * @throws Error if a node with the same `id` already exists in the flow.
94
+ */
95
+ readonly untypedOp: (id: string, op: string, args: {
96
+ readonly bind: Record<string, BindValue>;
97
+ readonly config: Record<string, unknown>;
98
+ readonly guards?: readonly AppliedGuard[];
99
+ }) => void;
100
+ /** Serialises the builder state into a {@link TypedFlow} document. */
101
+ readonly build: () => TypedFlow<T>;
104
102
  }
105
103
  /** Maps output port names to their output kind for compile-time and runtime validation. */
106
- type OutputSpec = Record<string, OutputKind>;
104
+ export type OutputSpec = Record<string, OutputKind>;
107
105
  /**
108
106
  * Maps each output family's port name to the config key that sizes it: an
109
107
  * array (one instance per element) or a non-negative integer count.
110
108
  * A family port is also listed in the {@link OutputSpec}, as `'resource'`.
111
109
  */
112
- type FamilySpec = Readonly<Record<string, string>>;
110
+ export type FamilySpec = Readonly<Record<string, string>>;
113
111
  /** The handles `call` returns for an {@link OutputSpec} and its families. */
114
- type OutputHandles<O extends OutputSpec, F extends FamilySpec> = {
115
- readonly [K in keyof O & string]: K extends keyof F ? readonly OutputHandle<'resource'>[] : OutputHandle<O[K]>;
116
- };
112
+ export type OutputHandles<O extends OutputSpec, F extends FamilySpec> = { readonly [K in keyof O & string]: K extends keyof F ? readonly OutputHandle<"resource">[] : OutputHandle<O[K]>; };
117
113
  /** Internal interface exposed to bindGeneratedOps — not part of the public API. */
118
- interface FlowBuilderInternal<T extends InputSchema = InputSchema> extends FlowBuilderCore<T> {
119
- readonly call: <O extends OutputSpec, F extends FamilySpec = Record<never, string>>(nodeId: string, op: string, args: CallArgs, outputs: O, families?: F) => OutputHandles<O, F>;
114
+ export interface FlowBuilderInternal<T extends InputSchema = InputSchema> extends FlowBuilderCore<T> {
115
+ readonly call: <O extends OutputSpec, F extends FamilySpec = Record<never, string>>(nodeId: string, op: string, args: CallArgs, outputs: O, families?: F) => OutputHandles<O, F>;
120
116
  }
121
117
  /**
122
118
  * Creates a new flow builder targeting the given chain.
@@ -126,6 +122,7 @@ interface FlowBuilderInternal<T extends InputSchema = InputSchema> extends FlowB
126
122
  * @returns A {@link FlowBuilderInternal} instance.
127
123
  * @internal
128
124
  */
129
- declare const createFlowBuilderCore: <T extends InputSchema>(chainId: number, options: FlowOptions<T>) => FlowBuilderInternal<T>;
130
-
131
- export { type AnyBindable, type CallArgs, type ContextAccessor, type FamilySpec, type FlowBuilderCore, type FlowBuilderInternal, type FlowOptions, type InputHandles, type OutputHandles, type OutputSpec, type TypedFlow, createFlowBuilderCore };
125
+ export declare const createFlowBuilderCore: <T extends InputSchema>(chainId: number, options: FlowOptions<T>) => FlowBuilderInternal<T>;
126
+ //#endregion
127
+ export {};
128
+ //# sourceMappingURL=FlowBuilderCore.d.cts.map