@lifi/composer-sdk 0.7.1 → 0.9.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 (165) hide show
  1. package/README.md +5 -2
  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 +805 -895
  46. package/dist/generated/config.generated.d.ts +805 -895
  47. package/dist/generated/config.generated.js +1 -1
  48. package/dist/generated/guards.generated.cjs +27 -31
  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 +21 -8
  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 -250
  61. package/dist/generated/operations.generated.cjs.map +1 -1
  62. package/dist/generated/operations.generated.d.cts +740 -657
  63. package/dist/generated/operations.generated.d.ts +740 -657
  64. package/dist/generated/operations.generated.js +235 -229
  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 +4 -4
  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 +14 -1
  141. package/src/examples/transferTokens.ts +21 -17
  142. package/src/examples/uniswapV2AddLiquidity.ts +106 -0
  143. package/src/examples/uniswapV3Mint.ts +95 -0
  144. package/src/generated/config.generated.ts +102 -47
  145. package/src/generated/guards.generated.ts +9 -0
  146. package/src/generated/operations.generated.ts +161 -5
  147. package/src/index.ts +0 -3
  148. package/dist/discovery.cjs.map +0 -1
  149. package/dist/discovery.js.map +0 -1
  150. package/dist/generated/config.generated.cjs.map +0 -1
  151. package/dist/generated/config.generated.js.map +0 -1
  152. package/dist/guards.generated-BPLFwe7y.d.ts +0 -19
  153. package/dist/guards.generated-M3VAIevI.d.cts +0 -19
  154. package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
  155. package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
  156. package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
  157. package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
  158. package/dist/raw-BvRghN3r.d.ts +0 -20
  159. package/dist/raw-s1rer8X3.d.cts +0 -20
  160. package/dist/resources-BKlFxjo8.d.cts +0 -56
  161. package/dist/resources-CYis1_DS.d.ts +0 -56
  162. package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
  163. package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
  164. package/dist/types.cjs.map +0 -1
  165. package/dist/types.js.map +0 -1
@@ -1,3 +1,50 @@
1
- import './types.cjs';
2
- export { E as Erc20Resource, N as NativeResource, R as Resource, e as erc20, n as native } from './resources-BKlFxjo8.cjs';
3
- import '@lifi/compose-spec';
1
+ import { Address } from "./types.cjs";
2
+ declare namespace resources_d_exports {
3
+ export { Erc20Resource, NativeResource, Resource, erc20, native };
4
+ }
5
+ /** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */
6
+ export interface NativeResource {
7
+ readonly kind: "native";
8
+ readonly chainId: number;
9
+ }
10
+ /** A resource declaration representing an ERC-20 token at a specific address. */
11
+ export interface Erc20Resource {
12
+ readonly kind: "erc20";
13
+ readonly token: Address;
14
+ readonly chainId: number;
15
+ }
16
+ /** A token resource — either the chain's native token or an ERC-20. */
17
+ export type Resource = NativeResource | Erc20Resource;
18
+ /**
19
+ * Creates a native token resource declaration.
20
+ *
21
+ * @param chainId - The EVM chain ID the native token belongs to.
22
+ * @returns A {@link NativeResource} for use in flow input schemas.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const builder = sdk.flow(1, {
27
+ * inputs: { eth: native(1) },
28
+ * });
29
+ * ```
30
+ */
31
+ export declare const native: (chainId: number) => NativeResource;
32
+ /**
33
+ * Creates an ERC-20 token resource declaration.
34
+ *
35
+ * @param token - The `0x`-prefixed contract address of the ERC-20 token.
36
+ * @param chainId - The EVM chain ID the token is deployed on.
37
+ * @returns An {@link Erc20Resource} for use in flow input schemas.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
42
+ * const builder = sdk.flow(1, {
43
+ * inputs: { usdc: erc20(USDC, 1) },
44
+ * });
45
+ * ```
46
+ */
47
+ export declare const erc20: (token: Address, chainId: number) => Erc20Resource;
48
+ //#endregion
49
+ export { resources_d_exports };
50
+ //# sourceMappingURL=resources.d.cts.map
@@ -1,3 +1,50 @@
1
- import './types.js';
2
- export { E as Erc20Resource, N as NativeResource, R as Resource, e as erc20, n as native } from './resources-CYis1_DS.js';
3
- import '@lifi/compose-spec';
1
+ import { Address } from "./types.js";
2
+ declare namespace resources_d_exports {
3
+ export { Erc20Resource, NativeResource, Resource, erc20, native };
4
+ }
5
+ /** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */
6
+ export interface NativeResource {
7
+ readonly kind: "native";
8
+ readonly chainId: number;
9
+ }
10
+ /** A resource declaration representing an ERC-20 token at a specific address. */
11
+ export interface Erc20Resource {
12
+ readonly kind: "erc20";
13
+ readonly token: Address;
14
+ readonly chainId: number;
15
+ }
16
+ /** A token resource — either the chain's native token or an ERC-20. */
17
+ export type Resource = NativeResource | Erc20Resource;
18
+ /**
19
+ * Creates a native token resource declaration.
20
+ *
21
+ * @param chainId - The EVM chain ID the native token belongs to.
22
+ * @returns A {@link NativeResource} for use in flow input schemas.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const builder = sdk.flow(1, {
27
+ * inputs: { eth: native(1) },
28
+ * });
29
+ * ```
30
+ */
31
+ export declare const native: (chainId: number) => NativeResource;
32
+ /**
33
+ * Creates an ERC-20 token resource declaration.
34
+ *
35
+ * @param token - The `0x`-prefixed contract address of the ERC-20 token.
36
+ * @param chainId - The EVM chain ID the token is deployed on.
37
+ * @returns An {@link Erc20Resource} for use in flow input schemas.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
42
+ * const builder = sdk.flow(1, {
43
+ * inputs: { usdc: erc20(USDC, 1) },
44
+ * });
45
+ * ```
46
+ */
47
+ export declare const erc20: (token: Address, chainId: number) => Erc20Resource;
48
+ //#endregion
49
+ export { resources_d_exports };
50
+ //# sourceMappingURL=resources.d.ts.map
package/dist/resources.js CHANGED
@@ -1,14 +1,47 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ //#region src/resources.ts
3
+ var resources_exports = /* @__PURE__ */ __exportAll({
4
+ erc20: () => erc20,
5
+ native: () => native
6
+ });
7
+ /**
8
+ * Creates a native token resource declaration.
9
+ *
10
+ * @param chainId - The EVM chain ID the native token belongs to.
11
+ * @returns A {@link NativeResource} for use in flow input schemas.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const builder = sdk.flow(1, {
16
+ * inputs: { eth: native(1) },
17
+ * });
18
+ * ```
19
+ */
1
20
  const native = (chainId) => ({
2
- kind: "native",
3
- chainId
21
+ kind: "native",
22
+ chainId
4
23
  });
24
+ /**
25
+ * Creates an ERC-20 token resource declaration.
26
+ *
27
+ * @param token - The `0x`-prefixed contract address of the ERC-20 token.
28
+ * @param chainId - The EVM chain ID the token is deployed on.
29
+ * @returns An {@link Erc20Resource} for use in flow input schemas.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
34
+ * const builder = sdk.flow(1, {
35
+ * inputs: { usdc: erc20(USDC, 1) },
36
+ * });
37
+ * ```
38
+ */
5
39
  const erc20 = (token, chainId) => ({
6
- kind: "erc20",
7
- token,
8
- chainId
40
+ kind: "erc20",
41
+ token,
42
+ chainId
9
43
  });
10
- export {
11
- erc20,
12
- native
13
- };
44
+ //#endregion
45
+ export { erc20, native, resources_exports };
46
+
14
47
  //# sourceMappingURL=resources.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resources.ts"],"sourcesContent":["import type { Address } from './types.js';\n\n// These resource types are SDK-local declarations that mirror the shape of\n// `Resource` from `@lifi/compose-spec`. They exist so the SDK can be used\n// without directly depending on `@lifi/compose-spec` at the call site.\n// The types are structurally compatible, so they are assignable to each other.\n\n/** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */\nexport interface NativeResource {\n readonly kind: 'native';\n readonly chainId: number;\n}\n\n/** A resource declaration representing an ERC-20 token at a specific address. */\nexport interface Erc20Resource {\n readonly kind: 'erc20';\n readonly token: Address;\n readonly chainId: number;\n}\n\n/** A token resource — either the chain's native token or an ERC-20. */\nexport type Resource = NativeResource | Erc20Resource;\n\n/**\n * Creates a native token resource declaration.\n *\n * @param chainId - The EVM chain ID the native token belongs to.\n * @returns A {@link NativeResource} for use in flow input schemas.\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: { eth: native(1) },\n * });\n * ```\n */\nexport const native = (chainId: number): NativeResource => ({\n kind: 'native',\n chainId,\n});\n\n/**\n * Creates an ERC-20 token resource declaration.\n *\n * @param token - The `0x`-prefixed contract address of the ERC-20 token.\n * @param chainId - The EVM chain ID the token is deployed on.\n * @returns An {@link Erc20Resource} for use in flow input schemas.\n *\n * @example\n * ```ts\n * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';\n * const builder = sdk.flow(1, {\n * inputs: { usdc: erc20(USDC, 1) },\n * });\n * ```\n */\nexport const erc20 = (token: Address, chainId: number): Erc20Resource => ({\n kind: 'erc20',\n token,\n chainId,\n});\n"],"mappings":"AAoCO,MAAM,SAAS,CAAC,aAAqC;AAAA,EAC1D,MAAM;AAAA,EACN;AACF;AAiBO,MAAM,QAAQ,CAAC,OAAgB,aAAoC;AAAA,EACxE,MAAM;AAAA,EACN;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"file":"resources.js","names":[],"sources":["../src/resources.ts"],"sourcesContent":["import type { Address } from './types.js';\n\n// These resource types are SDK-local declarations that mirror the shape of\n// `Resource` from `@lifi/compose-spec`. They exist so the SDK can be used\n// without directly depending on `@lifi/compose-spec` at the call site.\n// The types are structurally compatible, so they are assignable to each other.\n\n/** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */\nexport interface NativeResource {\n readonly kind: 'native';\n readonly chainId: number;\n}\n\n/** A resource declaration representing an ERC-20 token at a specific address. */\nexport interface Erc20Resource {\n readonly kind: 'erc20';\n readonly token: Address;\n readonly chainId: number;\n}\n\n/** A token resource — either the chain's native token or an ERC-20. */\nexport type Resource = NativeResource | Erc20Resource;\n\n/**\n * Creates a native token resource declaration.\n *\n * @param chainId - The EVM chain ID the native token belongs to.\n * @returns A {@link NativeResource} for use in flow input schemas.\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: { eth: native(1) },\n * });\n * ```\n */\nexport const native = (chainId: number): NativeResource => ({\n kind: 'native',\n chainId,\n});\n\n/**\n * Creates an ERC-20 token resource declaration.\n *\n * @param token - The `0x`-prefixed contract address of the ERC-20 token.\n * @param chainId - The EVM chain ID the token is deployed on.\n * @returns An {@link Erc20Resource} for use in flow input schemas.\n *\n * @example\n * ```ts\n * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';\n * const builder = sdk.flow(1, {\n * inputs: { usdc: erc20(USDC, 1) },\n * });\n * ```\n */\nexport const erc20 = (token: Address, chainId: number): Erc20Resource => ({\n kind: 'erc20',\n token,\n chainId,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,MAAa,UAAU,aAAqC;CAC1D,MAAM;CACN;AACF;;;;;;;;;;;;;;;;AAiBA,MAAa,SAAS,OAAgB,aAAoC;CACxE,MAAM;CACN;CACA;AACF"}
@@ -1,126 +1,114 @@
1
- "use strict";
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 __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var responseSchemas_exports = {};
30
- __export(responseSchemas_exports, {
31
- parseCompilePartialEnvelope: () => parseCompilePartialEnvelope,
32
- parseServerErrorBody: () => parseServerErrorBody,
33
- parseSimulateResult: () => parseSimulateResult
34
- });
35
- module.exports = __toCommonJS(responseSchemas_exports);
36
- var import_zod = __toESM(require("zod"), 1);
37
- const balanceEntrySchema = import_zod.default.object({
38
- token: import_zod.default.string(),
39
- owner: import_zod.default.string(),
40
- amount: import_zod.default.string()
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
3
+ let zod = require("zod");
4
+ zod = require_runtime.__toESM(zod, 1);
5
+ //#region src/responseSchemas.ts
6
+ /**
7
+ * Zod-backed parsers for Compose API response bodies.
8
+ *
9
+ * Server responses are untrusted input crossing into the SDK, so the shapes the
10
+ * client reads back are validated here rather than asserted with `as` casts. The
11
+ * schemas are module-private (the package builds with `--isolatedDeclarations`,
12
+ * which forbids exporting un-annotated complex values); the public surface is
13
+ * the typed `parse*` helpers, whose explicit return types double as the contract.
14
+ *
15
+ * The simulate union is the one response the SDK fully owns and parses itself
16
+ * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in
17
+ * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the
18
+ * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for
19
+ * its server-side simulate schema, so the two cannot silently drift.
20
+ */
21
+ const balanceEntrySchema = zod.default.object({
22
+ token: zod.default.string(),
23
+ owner: zod.default.string(),
24
+ amount: zod.default.string()
41
25
  });
42
- const simulateOkSchema = import_zod.default.object({
43
- status: import_zod.default.literal("ok"),
44
- block: import_zod.default.number(),
45
- timestamp: import_zod.default.number(),
46
- balancesBefore: import_zod.default.array(balanceEntrySchema),
47
- balancesAfter: import_zod.default.array(balanceEntrySchema),
48
- deltas: import_zod.default.array(balanceEntrySchema),
49
- gasUsed: import_zod.default.string()
26
+ const simulateOkSchema = zod.default.object({
27
+ status: zod.default.literal("ok"),
28
+ block: zod.default.number(),
29
+ timestamp: zod.default.number(),
30
+ balancesBefore: zod.default.array(balanceEntrySchema),
31
+ balancesAfter: zod.default.array(balanceEntrySchema),
32
+ deltas: zod.default.array(balanceEntrySchema),
33
+ gasUsed: zod.default.string()
50
34
  });
51
- const simulateRevertDecodeResultSchema = import_zod.default.object({
52
- errorCandidates: import_zod.default.array(
53
- import_zod.default.object({
54
- decodedErrorSignature: import_zod.default.string(),
55
- decodedParams: import_zod.default.array(import_zod.default.string())
56
- })
57
- ).optional(),
58
- error: import_zod.default.string().optional()
35
+ const simulateRevertDecodeResultSchema = zod.default.object({
36
+ errorCandidates: zod.default.array(zod.default.object({
37
+ decodedErrorSignature: zod.default.string(),
38
+ decodedParams: zod.default.array(zod.default.string())
39
+ })).optional(),
40
+ error: zod.default.string().optional()
59
41
  });
60
- const simulateRevertSchema = import_zod.default.object({
61
- status: import_zod.default.literal("revert"),
62
- block: import_zod.default.number(),
63
- timestamp: import_zod.default.number(),
64
- revertReason: import_zod.default.string().optional(),
65
- code: import_zod.default.number().optional(),
66
- rawErrorBytes: import_zod.default.string().optional(),
67
- decodeResult: simulateRevertDecodeResultSchema.optional()
42
+ const simulateRevertSchema = zod.default.object({
43
+ status: zod.default.literal("revert"),
44
+ block: zod.default.number(),
45
+ timestamp: zod.default.number(),
46
+ revertReason: zod.default.string().optional(),
47
+ code: zod.default.number().optional(),
48
+ rawErrorBytes: zod.default.string().optional(),
49
+ decodeResult: simulateRevertDecodeResultSchema.optional()
68
50
  });
69
- const simulateSetupErrorSchema = import_zod.default.object({
70
- status: import_zod.default.literal("error"),
71
- message: import_zod.default.string()
51
+ const simulateSetupErrorSchema = zod.default.object({
52
+ status: zod.default.literal("error"),
53
+ message: zod.default.string()
72
54
  });
73
- const simulateResultSchema = import_zod.default.discriminatedUnion("status", [
74
- simulateOkSchema,
75
- simulateRevertSchema,
76
- simulateSetupErrorSchema
55
+ const simulateResultSchema = zod.default.discriminatedUnion("status", [
56
+ simulateOkSchema,
57
+ simulateRevertSchema,
58
+ simulateSetupErrorSchema
77
59
  ]);
60
+ /**
61
+ * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`
62
+ * when the body does not match the `ok`/`revert`/`error` union, letting the
63
+ * caller raise a transport-level error.
64
+ */
78
65
  const parseSimulateResult = (body) => {
79
- const parsed = simulateResultSchema.safeParse(body);
80
- if (!parsed.success) return null;
81
- const result = parsed.data;
82
- return result;
66
+ const parsed = simulateResultSchema.safeParse(body);
67
+ if (!parsed.success) return null;
68
+ return parsed.data;
83
69
  };
84
- const compilePartialEnvelopeSchema = import_zod.default.object({
85
- data: import_zod.default.record(import_zod.default.string(), import_zod.default.unknown()),
86
- error: import_zod.default.object({ kind: import_zod.default.string(), message: import_zod.default.string() })
70
+ const compilePartialEnvelopeSchema = zod.default.object({
71
+ data: zod.default.record(zod.default.string(), zod.default.unknown()),
72
+ error: zod.default.object({
73
+ kind: zod.default.string(),
74
+ message: zod.default.string()
75
+ })
87
76
  });
77
+ /** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */
88
78
  const parseCompilePartialEnvelope = (body) => {
89
- const parsed = compilePartialEnvelopeSchema.safeParse(body);
90
- return parsed.success ? parsed.data : null;
79
+ const parsed = compilePartialEnvelopeSchema.safeParse(body);
80
+ return parsed.success ? parsed.data : null;
91
81
  };
92
- const failedPreparedOpSchema = import_zod.default.object({
93
- callId: import_zod.default.string(),
94
- op: import_zod.default.string(),
95
- kind: import_zod.default.string(),
96
- message: import_zod.default.string(),
97
- path: import_zod.default.string().optional(),
98
- port: import_zod.default.string().optional(),
99
- fix: import_zod.default.string().optional()
100
- });
101
- const serverErrorBodySchema = import_zod.default.object({
102
- error: import_zod.default.object({
103
- kind: import_zod.default.string().optional(),
104
- message: import_zod.default.string().optional(),
105
- path: import_zod.default.string().optional(),
106
- port: import_zod.default.string().optional(),
107
- fix: import_zod.default.string().optional(),
108
- sdkVersion: import_zod.default.string().optional(),
109
- serverVersion: import_zod.default.string().optional(),
110
- minimumSdkVersion: import_zod.default.string().optional(),
111
- details: import_zod.default.custom().optional(),
112
- failedOps: import_zod.default.array(failedPreparedOpSchema).readonly().optional(),
113
- succeededOps: import_zod.default.array(import_zod.default.string()).readonly().optional()
114
- }).optional()
82
+ const failedPreparedOpSchema = zod.default.object({
83
+ callId: zod.default.string(),
84
+ op: zod.default.string(),
85
+ kind: zod.default.string(),
86
+ message: zod.default.string(),
87
+ path: zod.default.string().optional(),
88
+ port: zod.default.string().optional(),
89
+ fix: zod.default.string().optional()
115
90
  });
91
+ const serverErrorBodySchema = zod.default.object({ error: zod.default.object({
92
+ kind: zod.default.string().optional(),
93
+ message: zod.default.string().optional(),
94
+ path: zod.default.string().optional(),
95
+ port: zod.default.string().optional(),
96
+ fix: zod.default.string().optional(),
97
+ sdkVersion: zod.default.string().optional(),
98
+ serverVersion: zod.default.string().optional(),
99
+ minimumSdkVersion: zod.default.string().optional(),
100
+ details: zod.default.custom().optional(),
101
+ failedOps: zod.default.array(failedPreparedOpSchema).readonly().optional(),
102
+ succeededOps: zod.default.array(zod.default.string()).readonly().optional()
103
+ }).optional() });
104
+ /** Validates an already-parsed error envelope; `null` when it does not match. */
116
105
  const parseServerErrorBody = (json) => {
117
- const parsed = serverErrorBodySchema.safeParse(json);
118
- return parsed.success ? parsed.data : null;
106
+ const parsed = serverErrorBodySchema.safeParse(json);
107
+ return parsed.success ? parsed.data : null;
119
108
  };
120
- // Annotate the CommonJS export names for ESM import in node:
121
- 0 && (module.exports = {
122
- parseCompilePartialEnvelope,
123
- parseServerErrorBody,
124
- parseSimulateResult
125
- });
109
+ //#endregion
110
+ exports.parseCompilePartialEnvelope = parseCompilePartialEnvelope;
111
+ exports.parseServerErrorBody = parseServerErrorBody;
112
+ exports.parseSimulateResult = parseSimulateResult;
113
+
126
114
  //# sourceMappingURL=responseSchemas.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/responseSchemas.ts"],"sourcesContent":["import type { SimulateResult, SimulationRevert } from '@lifi/compose-spec';\nimport z from 'zod';\n\n/**\n * Zod-backed parsers for Compose API response bodies.\n *\n * Server responses are untrusted input crossing into the SDK, so the shapes the\n * client reads back are validated here rather than asserted with `as` casts. The\n * schemas are module-private (the package builds with `--isolatedDeclarations`,\n * which forbids exporting un-annotated complex values); the public surface is\n * the typed `parse*` helpers, whose explicit return types double as the contract.\n *\n * The simulate union is the one response the SDK fully owns and parses itself\n * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in\n * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the\n * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for\n * its server-side simulate schema, so the two cannot silently drift.\n */\n\nconst balanceEntrySchema = z.object({\n token: z.string(),\n owner: z.string(),\n amount: z.string(),\n});\n\nconst simulateOkSchema = z.object({\n status: z.literal('ok'),\n block: z.number(),\n timestamp: z.number(),\n balancesBefore: z.array(balanceEntrySchema),\n balancesAfter: z.array(balanceEntrySchema),\n deltas: z.array(balanceEntrySchema),\n gasUsed: z.string(),\n});\n\nconst simulateRevertDecodeResultSchema = z.object({\n errorCandidates: z\n .array(\n z.object({\n decodedErrorSignature: z.string(),\n decodedParams: z.array(z.string()),\n }),\n )\n .optional(),\n error: z.string().optional(),\n});\n\nconst simulateRevertSchema = z.object({\n status: z.literal('revert'),\n block: z.number(),\n timestamp: z.number(),\n revertReason: z.string().optional(),\n code: z.number().optional(),\n rawErrorBytes: z.string().optional(),\n decodeResult: simulateRevertDecodeResultSchema.optional(),\n});\n\nconst simulateSetupErrorSchema = z.object({\n status: z.literal('error'),\n message: z.string(),\n});\n\nconst simulateResultSchema = z.discriminatedUnion('status', [\n simulateOkSchema,\n simulateRevertSchema,\n simulateSetupErrorSchema,\n]);\n\n// The type the schema actually parses out. Kept private (referencing it from an\n// exported declaration would break `--isolatedDeclarations`) and pinned to the\n// canonical `SimulateResult` inside `parseSimulateResult` below.\ntype SimulateResultWire = z.infer<typeof simulateResultSchema>;\n\n/**\n * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`\n * when the body does not match the `ok`/`revert`/`error` union, letting the\n * caller raise a transport-level error.\n */\nexport const parseSimulateResult = (body: unknown): SimulateResult | null => {\n const parsed = simulateResultSchema.safeParse(body);\n if (!parsed.success) return null;\n // Pin the schema to the canonical contract in both directions, so it cannot\n // silently drift (mirroring the conformance assertion `@lifi/api-schemas` runs\n // on its server-side simulate schema). Assigning the inferred wire value to a\n // `SimulateResult` checks wire→spec; `satisfies SimulateResultWire` checks\n // spec→wire. A missing or mistyped field on either side fails to compile.\n const result: SimulateResult = parsed.data;\n return result satisfies SimulateResultWire;\n};\n\n/**\n * The validated members of an HTTP 206 partial compile envelope. `data` is\n * verified to be an object at runtime but left `unknown` here — compose-spec\n * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so\n * the caller narrows it in one step. `error` is fully validated.\n */\nexport interface CompilePartialEnvelope {\n readonly data: unknown;\n readonly error: { readonly kind: string; readonly message: string };\n}\n\nconst compilePartialEnvelopeSchema = z.object({\n data: z.record(z.string(), z.unknown()),\n error: z.object({ kind: z.string(), message: z.string() }),\n});\n\n/** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */\nexport const parseCompilePartialEnvelope = (\n body: unknown,\n): CompilePartialEnvelope | null => {\n const parsed = compilePartialEnvelopeSchema.safeParse(body);\n return parsed.success ? parsed.data : null;\n};\n\n/**\n * A single prepared-op failure inside a `preparation_error` envelope. `kind` is\n * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in\n * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.\n */\nexport interface ServerFailedPreparedOp {\n readonly callId: string;\n readonly op: string;\n readonly kind: string;\n readonly message: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n}\n\n/** Error envelope returned on non-2xx responses. */\nexport interface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n readonly sdkVersion?: string;\n readonly serverVersion?: string;\n readonly minimumSdkVersion?: string;\n readonly details?: SimulationRevert;\n readonly failedOps?: readonly ServerFailedPreparedOp[];\n readonly succeededOps?: readonly string[];\n };\n}\n\nconst failedPreparedOpSchema = z.object({\n callId: z.string(),\n op: z.string(),\n kind: z.string(),\n message: z.string(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n});\n\n// `details` is passed through (`z.custom`) rather than parsed: the SDK does not\n// own the `SimulationRevert` schema and forwards the field verbatim onto\n// `ComposeError`.\n//\n// `failedOps`/`succeededOps` are optional here because every error kind shares\n// this envelope; they are only populated for `preparation_error` (422). Zod\n// strips undeclared keys, so omitting them would silently drop them — which is\n// also why `port` and `fix`, set on every author-caused `validation_error`,\n// have to be declared here to reach the caller.\nconst serverErrorBodySchema = z.object({\n error: z\n .object({\n kind: z.string().optional(),\n message: z.string().optional(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n sdkVersion: z.string().optional(),\n serverVersion: z.string().optional(),\n minimumSdkVersion: z.string().optional(),\n details: z.custom<SimulationRevert>().optional(),\n failedOps: z.array(failedPreparedOpSchema).readonly().optional(),\n succeededOps: z.array(z.string()).readonly().optional(),\n })\n .optional(),\n});\n\n/** Validates an already-parsed error envelope; `null` when it does not match. */\nexport const parseServerErrorBody = (json: unknown): ServerErrorBody | null => {\n const parsed = serverErrorBodySchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAc;AAkBd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M,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,KAAK,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IACzB,YAAY,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IAChC,eAAe,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IACnC,mBAAmB,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,IACvC,SAAS,WAAAA,QAAE,OAAyB,EAAE,SAAS;AAAA,IAC/C,WAAW,WAAAA,QAAE,MAAM,sBAAsB,EAAE,SAAS,EAAE,SAAS;AAAA,IAC/D,cAAc,WAAAA,QAAE,MAAM,WAAAA,QAAE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACxD,CAAC,EACA,SAAS;AACd,CAAC;AAGM,MAAM,uBAAuB,CAAC,SAA0C;AAC7E,QAAM,SAAS,sBAAsB,UAAU,IAAI;AACnD,SAAO,OAAO,UAAU,OAAO,OAAO;AACxC;","names":["z"]}
1
+ {"version":3,"file":"responseSchemas.cjs","names":["z"],"sources":["../src/responseSchemas.ts"],"sourcesContent":["import type { SimulateResult, SimulationRevert } from '@lifi/compose-spec';\nimport z from 'zod';\n\n/**\n * Zod-backed parsers for Compose API response bodies.\n *\n * Server responses are untrusted input crossing into the SDK, so the shapes the\n * client reads back are validated here rather than asserted with `as` casts. The\n * schemas are module-private (the package builds with `--isolatedDeclarations`,\n * which forbids exporting un-annotated complex values); the public surface is\n * the typed `parse*` helpers, whose explicit return types double as the contract.\n *\n * The simulate union is the one response the SDK fully owns and parses itself\n * (it is un-enveloped, unlike `/compose`), so it gets a complete schema kept in\n * lockstep with the canonical `SimulateResult` in `@lifi/compose-spec` by the\n * compile-time assertion below — the same anchoring `@lifi/api-schemas` uses for\n * its server-side simulate schema, so the two cannot silently drift.\n */\n\nconst balanceEntrySchema = z.object({\n token: z.string(),\n owner: z.string(),\n amount: z.string(),\n});\n\nconst simulateOkSchema = z.object({\n status: z.literal('ok'),\n block: z.number(),\n timestamp: z.number(),\n balancesBefore: z.array(balanceEntrySchema),\n balancesAfter: z.array(balanceEntrySchema),\n deltas: z.array(balanceEntrySchema),\n gasUsed: z.string(),\n});\n\nconst simulateRevertDecodeResultSchema = z.object({\n errorCandidates: z\n .array(\n z.object({\n decodedErrorSignature: z.string(),\n decodedParams: z.array(z.string()),\n }),\n )\n .optional(),\n error: z.string().optional(),\n});\n\nconst simulateRevertSchema = z.object({\n status: z.literal('revert'),\n block: z.number(),\n timestamp: z.number(),\n revertReason: z.string().optional(),\n code: z.number().optional(),\n rawErrorBytes: z.string().optional(),\n decodeResult: simulateRevertDecodeResultSchema.optional(),\n});\n\nconst simulateSetupErrorSchema = z.object({\n status: z.literal('error'),\n message: z.string(),\n});\n\nconst simulateResultSchema = z.discriminatedUnion('status', [\n simulateOkSchema,\n simulateRevertSchema,\n simulateSetupErrorSchema,\n]);\n\n// The type the schema actually parses out. Kept private (referencing it from an\n// exported declaration would break `--isolatedDeclarations`) and pinned to the\n// canonical `SimulateResult` inside `parseSimulateResult` below.\ntype SimulateResultWire = z.infer<typeof simulateResultSchema>;\n\n/**\n * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`\n * when the body does not match the `ok`/`revert`/`error` union, letting the\n * caller raise a transport-level error.\n */\nexport const parseSimulateResult = (body: unknown): SimulateResult | null => {\n const parsed = simulateResultSchema.safeParse(body);\n if (!parsed.success) return null;\n // Pin the schema to the canonical contract in both directions, so it cannot\n // silently drift (mirroring the conformance assertion `@lifi/api-schemas` runs\n // on its server-side simulate schema). Assigning the inferred wire value to a\n // `SimulateResult` checks wire→spec; `satisfies SimulateResultWire` checks\n // spec→wire. A missing or mistyped field on either side fails to compile.\n const result: SimulateResult = parsed.data;\n return result satisfies SimulateResultWire;\n};\n\n/**\n * The validated members of an HTTP 206 partial compile envelope. `data` is\n * verified to be an object at runtime but left `unknown` here — compose-spec\n * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so\n * the caller narrows it in one step. `error` is fully validated.\n */\nexport interface CompilePartialEnvelope {\n readonly data: unknown;\n readonly error: { readonly kind: string; readonly message: string };\n}\n\nconst compilePartialEnvelopeSchema = z.object({\n data: z.record(z.string(), z.unknown()),\n error: z.object({ kind: z.string(), message: z.string() }),\n});\n\n/** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */\nexport const parseCompilePartialEnvelope = (\n body: unknown,\n): CompilePartialEnvelope | null => {\n const parsed = compilePartialEnvelopeSchema.safeParse(body);\n return parsed.success ? parsed.data : null;\n};\n\n/**\n * A single prepared-op failure inside a `preparation_error` envelope. `kind` is\n * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in\n * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.\n */\nexport interface ServerFailedPreparedOp {\n readonly callId: string;\n readonly op: string;\n readonly kind: string;\n readonly message: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n}\n\n/** Error envelope returned on non-2xx responses. */\nexport interface ServerErrorBody {\n readonly error?: {\n readonly kind?: string;\n readonly message?: string;\n readonly path?: string;\n readonly port?: string;\n readonly fix?: string;\n readonly sdkVersion?: string;\n readonly serverVersion?: string;\n readonly minimumSdkVersion?: string;\n readonly details?: SimulationRevert;\n readonly failedOps?: readonly ServerFailedPreparedOp[];\n readonly succeededOps?: readonly string[];\n };\n}\n\nconst failedPreparedOpSchema = z.object({\n callId: z.string(),\n op: z.string(),\n kind: z.string(),\n message: z.string(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n});\n\n// `details` is passed through (`z.custom`) rather than parsed: the SDK does not\n// own the `SimulationRevert` schema and forwards the field verbatim onto\n// `ComposeError`.\n//\n// `failedOps`/`succeededOps` are optional here because every error kind shares\n// this envelope; they are only populated for `preparation_error` (422). Zod\n// strips undeclared keys, so omitting them would silently drop them — which is\n// also why `port` and `fix`, set on every author-caused `validation_error`,\n// have to be declared here to reach the caller.\nconst serverErrorBodySchema = z.object({\n error: z\n .object({\n kind: z.string().optional(),\n message: z.string().optional(),\n path: z.string().optional(),\n port: z.string().optional(),\n fix: z.string().optional(),\n sdkVersion: z.string().optional(),\n serverVersion: z.string().optional(),\n minimumSdkVersion: z.string().optional(),\n details: z.custom<SimulationRevert>().optional(),\n failedOps: z.array(failedPreparedOpSchema).readonly().optional(),\n succeededOps: z.array(z.string()).readonly().optional(),\n })\n .optional(),\n});\n\n/** Validates an already-parsed error envelope; `null` when it does not match. */\nexport const parseServerErrorBody = (json: unknown): ServerErrorBody | null => {\n const parsed = serverErrorBodySchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,qBAAqBA,IAAAA,QAAE,OAAO;CAClC,OAAOA,IAAAA,QAAE,OAAO;CAChB,OAAOA,IAAAA,QAAE,OAAO;CAChB,QAAQA,IAAAA,QAAE,OAAO;AACnB,CAAC;AAED,MAAM,mBAAmBA,IAAAA,QAAE,OAAO;CAChC,QAAQA,IAAAA,QAAE,QAAQ,IAAI;CACtB,OAAOA,IAAAA,QAAE,OAAO;CAChB,WAAWA,IAAAA,QAAE,OAAO;CACpB,gBAAgBA,IAAAA,QAAE,MAAM,kBAAkB;CAC1C,eAAeA,IAAAA,QAAE,MAAM,kBAAkB;CACzC,QAAQA,IAAAA,QAAE,MAAM,kBAAkB;CAClC,SAASA,IAAAA,QAAE,OAAO;AACpB,CAAC;AAED,MAAM,mCAAmCA,IAAAA,QAAE,OAAO;CAChD,iBAAiBA,IAAAA,QACd,MACCA,IAAAA,QAAE,OAAO;EACP,uBAAuBA,IAAAA,QAAE,OAAO;EAChC,eAAeA,IAAAA,QAAE,MAAMA,IAAAA,QAAE,OAAO,CAAC;CACnC,CAAC,CACH,CAAC,CACA,SAAS;CACZ,OAAOA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;AAC7B,CAAC;AAED,MAAM,uBAAuBA,IAAAA,QAAE,OAAO;CACp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E,OAAO,CAAC,CAAC,SAAS;CAC1B,KAAKA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;AAC3B,CAAC;AAWD,MAAM,wBAAwBA,IAAAA,QAAE,OAAO,EACrC,OAAOA,IAAAA,QACJ,OAAO;CACN,MAAMA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,SAASA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,MAAMA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAMA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,KAAKA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CACzB,YAAYA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CAChC,eAAeA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CACnC,mBAAmBA,IAAAA,QAAE,OAAO,CAAC,CAAC,SAAS;CACvC,SAASA,IAAAA,QAAE,OAAyB,CAAC,CAAC,SAAS;CAC/C,WAAWA,IAAAA,QAAE,MAAM,sBAAsB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC/D,cAAcA,IAAAA,QAAE,MAAMA,IAAAA,QAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AACxD,CAAC,CAAC,CACD,SAAS,EACd,CAAC;;AAGD,MAAa,wBAAwB,SAA0C;CAC7E,MAAM,SAAS,sBAAsB,UAAU,IAAI;CACnD,OAAO,OAAO,UAAU,OAAO,OAAO;AACxC"}
@@ -1,57 +1,57 @@
1
- import { SimulationRevert, SimulateResult } from '@lifi/compose-spec';
2
-
1
+ import { SimulateResult, SimulationRevert } from "@lifi/compose-spec";
2
+ //#region src/responseSchemas.d.ts
3
3
  /**
4
4
  * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null`
5
5
  * when the body does not match the `ok`/`revert`/`error` union, letting the
6
6
  * caller raise a transport-level error.
7
7
  */
8
- declare const parseSimulateResult: (body: unknown) => SimulateResult | null;
8
+ export declare const parseSimulateResult: (body: unknown) => SimulateResult | null;
9
9
  /**
10
10
  * The validated members of an HTTP 206 partial compile envelope. `data` is
11
11
  * verified to be an object at runtime but left `unknown` here — compose-spec
12
12
  * owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so
13
13
  * the caller narrows it in one step. `error` is fully validated.
14
14
  */
15
- interface CompilePartialEnvelope {
16
- readonly data: unknown;
17
- readonly error: {
18
- readonly kind: string;
19
- readonly message: string;
20
- };
15
+ export interface CompilePartialEnvelope {
16
+ readonly data: unknown;
17
+ readonly error: {
18
+ readonly kind: string;
19
+ readonly message: string;
20
+ };
21
21
  }
22
22
  /** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */
23
- declare const parseCompilePartialEnvelope: (body: unknown) => CompilePartialEnvelope | null;
23
+ export declare const parseCompilePartialEnvelope: (body: unknown) => CompilePartialEnvelope | null;
24
24
  /**
25
25
  * A single prepared-op failure inside a `preparation_error` envelope. `kind` is
26
26
  * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in
27
27
  * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`.
28
28
  */
29
- interface ServerFailedPreparedOp {
30
- readonly callId: string;
31
- readonly op: string;
32
- readonly kind: string;
33
- readonly message: string;
29
+ export interface ServerFailedPreparedOp {
30
+ readonly callId: string;
31
+ readonly op: string;
32
+ readonly kind: string;
33
+ readonly message: string;
34
+ readonly path?: string;
35
+ readonly port?: string;
36
+ readonly fix?: string;
37
+ }
38
+ /** Error envelope returned on non-2xx responses. */
39
+ export interface ServerErrorBody {
40
+ readonly error?: {
41
+ readonly kind?: string;
42
+ readonly message?: string;
34
43
  readonly path?: string;
35
44
  readonly port?: string;
36
45
  readonly fix?: string;
37
- }
38
- /** Error envelope returned on non-2xx responses. */
39
- interface ServerErrorBody {
40
- readonly error?: {
41
- readonly kind?: string;
42
- readonly message?: string;
43
- readonly path?: string;
44
- readonly port?: string;
45
- readonly fix?: string;
46
- readonly sdkVersion?: string;
47
- readonly serverVersion?: string;
48
- readonly minimumSdkVersion?: string;
49
- readonly details?: SimulationRevert;
50
- readonly failedOps?: readonly ServerFailedPreparedOp[];
51
- readonly succeededOps?: readonly string[];
52
- };
46
+ readonly sdkVersion?: string;
47
+ readonly serverVersion?: string;
48
+ readonly minimumSdkVersion?: string;
49
+ readonly details?: SimulationRevert;
50
+ readonly failedOps?: readonly ServerFailedPreparedOp[];
51
+ readonly succeededOps?: readonly string[];
52
+ };
53
53
  }
54
54
  /** Validates an already-parsed error envelope; `null` when it does not match. */
55
- declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
56
-
57
- export { type CompilePartialEnvelope, type ServerErrorBody, type ServerFailedPreparedOp, parseCompilePartialEnvelope, parseServerErrorBody, parseSimulateResult };
55
+ export declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
56
+ //#endregion
57
+ //# sourceMappingURL=responseSchemas.d.cts.map