@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.
- package/README.md +5 -2
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/authoring/FlowBuilderCore.cjs +102 -120
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
- package/dist/authoring/FlowBuilderCore.d.cts +58 -61
- package/dist/authoring/FlowBuilderCore.d.ts +58 -61
- package/dist/authoring/FlowBuilderCore.js +99 -97
- package/dist/authoring/FlowBuilderCore.js.map +1 -1
- package/dist/authoring/handles.cjs +25 -40
- package/dist/authoring/handles.cjs.map +1 -1
- package/dist/authoring/handles.d.cts +33 -34
- package/dist/authoring/handles.d.ts +33 -34
- package/dist/authoring/handles.js +21 -13
- package/dist/authoring/handles.js.map +1 -1
- package/dist/authoring/raw.cjs +85 -44
- package/dist/authoring/raw.cjs.map +1 -1
- package/dist/authoring/raw.d.cts +8 -8
- package/dist/authoring/raw.d.ts +8 -8
- package/dist/authoring/raw.js +83 -19
- package/dist/authoring/raw.js.map +1 -1
- package/dist/authoring/signatureArgs.cjs +81 -103
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.d.cts +63 -64
- package/dist/authoring/signatureArgs.d.ts +63 -64
- package/dist/authoring/signatureArgs.js +76 -75
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +172 -220
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +131 -131
- package/dist/client.d.ts +131 -131
- package/dist/client.js +165 -198
- package/dist/client.js.map +1 -1
- package/dist/discovery.cjs +0 -17
- package/dist/discovery.d.cts +57 -56
- package/dist/discovery.d.ts +57 -56
- package/dist/discovery.js +1 -1
- package/dist/errors.cjs +211 -159
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +84 -84
- package/dist/errors.d.ts +84 -84
- package/dist/errors.js +201 -120
- package/dist/errors.js.map +1 -1
- package/dist/generated/config.generated.cjs +0 -17
- package/dist/generated/config.generated.d.cts +805 -895
- package/dist/generated/config.generated.d.ts +805 -895
- package/dist/generated/config.generated.js +1 -1
- package/dist/generated/guards.generated.cjs +27 -31
- package/dist/generated/guards.generated.cjs.map +1 -1
- package/dist/generated/guards.generated.d.cts +20 -4
- package/dist/generated/guards.generated.d.ts +20 -4
- package/dist/generated/guards.generated.js +21 -8
- package/dist/generated/guards.generated.js.map +1 -1
- package/dist/generated/materialisers.generated.cjs +25 -35
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +17 -4
- package/dist/generated/materialisers.generated.d.ts +17 -4
- package/dist/generated/materialisers.generated.js +19 -11
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +236 -250
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +740 -657
- package/dist/generated/operations.generated.d.ts +740 -657
- package/dist/generated/operations.generated.js +235 -229
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/generated/preconditions.generated.cjs +25 -35
- package/dist/generated/preconditions.generated.cjs.map +1 -1
- package/dist/generated/preconditions.generated.d.cts +17 -4
- package/dist/generated/preconditions.generated.d.ts +17 -4
- package/dist/generated/preconditions.generated.js +19 -11
- package/dist/generated/preconditions.generated.js.map +1 -1
- package/dist/index.cjs +131 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -43
- package/dist/index.d.ts +29 -43
- package/dist/index.js +96 -45
- package/dist/index.js.map +1 -1
- package/dist/outputs.cjs +11 -32
- package/dist/outputs.cjs.map +1 -1
- package/dist/outputs.d.cts +5 -5
- package/dist/outputs.d.ts +5 -5
- package/dist/outputs.js +10 -8
- package/dist/outputs.js.map +1 -1
- package/dist/raw.cjs +21 -33
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.d.cts +8 -4
- package/dist/raw.d.ts +8 -4
- package/dist/raw.js +12 -7
- package/dist/raw.js.map +1 -1
- package/dist/reachability.cjs +82 -112
- package/dist/reachability.cjs.map +1 -1
- package/dist/reachability.d.cts +33 -59
- package/dist/reachability.d.ts +33 -59
- package/dist/reachability.js +81 -88
- package/dist/reachability.js.map +1 -1
- package/dist/resources.cjs +47 -32
- package/dist/resources.cjs.map +1 -1
- package/dist/resources.d.cts +50 -3
- package/dist/resources.d.ts +50 -3
- package/dist/resources.js +42 -9
- package/dist/resources.js.map +1 -1
- package/dist/responseSchemas.cjs +99 -111
- package/dist/responseSchemas.cjs.map +1 -1
- package/dist/responseSchemas.d.cts +34 -34
- package/dist/responseSchemas.d.ts +34 -34
- package/dist/responseSchemas.js +85 -66
- package/dist/responseSchemas.js.map +1 -1
- package/dist/routeAmount.cjs +61 -31
- package/dist/routeAmount.cjs.map +1 -1
- package/dist/routeAmount.d.cts +52 -2
- package/dist/routeAmount.d.ts +52 -2
- package/dist/routeAmount.js +56 -8
- package/dist/routeAmount.js.map +1 -1
- package/dist/run/inputs.cjs +56 -48
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +70 -74
- package/dist/run/inputs.d.ts +70 -74
- package/dist/run/inputs.js +54 -23
- package/dist/run/inputs.js.map +1 -1
- package/dist/run/simulate.cjs +38 -43
- package/dist/run/simulate.cjs.map +1 -1
- package/dist/run/simulate.d.cts +36 -36
- package/dist/run/simulate.d.ts +36 -36
- package/dist/run/simulate.js +37 -19
- package/dist/run/simulate.js.map +1 -1
- package/dist/sdk.cjs +55 -66
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +108 -111
- package/dist/sdk.d.ts +108 -111
- package/dist/sdk.js +52 -44
- package/dist/sdk.js.map +1 -1
- package/dist/types.cjs +0 -17
- package/dist/types.d.cts +22 -22
- package/dist/types.d.ts +22 -22
- package/dist/types.js +1 -1
- package/package.json +4 -4
- package/src/client.ts +2 -2
- package/src/examples/aaveClaimRewards.ts +2 -1
- package/src/examples/emitCustomEvent.ts +1 -2
- package/src/examples/run.ts +14 -1
- package/src/examples/transferTokens.ts +21 -17
- package/src/examples/uniswapV2AddLiquidity.ts +106 -0
- package/src/examples/uniswapV3Mint.ts +95 -0
- package/src/generated/config.generated.ts +102 -47
- package/src/generated/guards.generated.ts +9 -0
- package/src/generated/operations.generated.ts +161 -5
- package/src/index.ts +0 -3
- package/dist/discovery.cjs.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/generated/config.generated.cjs.map +0 -1
- package/dist/generated/config.generated.js.map +0 -1
- package/dist/guards.generated-BPLFwe7y.d.ts +0 -19
- package/dist/guards.generated-M3VAIevI.d.cts +0 -19
- package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
- package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
- package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
- package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
- package/dist/raw-BvRghN3r.d.ts +0 -20
- package/dist/raw-s1rer8X3.d.cts +0 -20
- package/dist/resources-BKlFxjo8.d.cts +0 -56
- package/dist/resources-CYis1_DS.d.ts +0 -56
- package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
- package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
- package/dist/types.cjs.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/resources.d.cts
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
40
|
+
kind: "erc20",
|
|
41
|
+
token,
|
|
42
|
+
chainId
|
|
9
43
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { erc20, native, resources_exports };
|
|
46
|
+
|
|
14
47
|
//# sourceMappingURL=resources.js.map
|
package/dist/resources.js.map
CHANGED
|
@@ -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":"
|
|
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"}
|
package/dist/responseSchemas.cjs
CHANGED
|
@@ -1,126 +1,114 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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 =
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
const simulateSetupErrorSchema = zod.default.object({
|
|
52
|
+
status: zod.default.literal("error"),
|
|
53
|
+
message: zod.default.string()
|
|
72
54
|
});
|
|
73
|
-
const simulateResultSchema =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return result;
|
|
66
|
+
const parsed = simulateResultSchema.safeParse(body);
|
|
67
|
+
if (!parsed.success) return null;
|
|
68
|
+
return parsed.data;
|
|
83
69
|
};
|
|
84
|
-
const compilePartialEnvelopeSchema =
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
79
|
+
const parsed = compilePartialEnvelopeSchema.safeParse(body);
|
|
80
|
+
return parsed.success ? parsed.data : null;
|
|
91
81
|
};
|
|
92
|
-
const failedPreparedOpSchema =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
118
|
-
|
|
106
|
+
const parsed = serverErrorBodySchema.safeParse(json);
|
|
107
|
+
return parsed.success ? parsed.data : null;
|
|
119
108
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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":"
|
|
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":"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"}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
readonly
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
55
|
+
export declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
|
|
56
|
+
//#endregion
|
|
57
|
+
//# sourceMappingURL=responseSchemas.d.cts.map
|