@lifi/composer-sdk 0.8.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 +3 -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 +804 -936
- package/dist/generated/config.generated.d.ts +804 -936
- package/dist/generated/config.generated.js +1 -1
- package/dist/generated/guards.generated.cjs +25 -35
- 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 +19 -11
- 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 -277
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +719 -708
- package/dist/generated/operations.generated.d.ts +719 -708
- package/dist/generated/operations.generated.js +235 -256
- 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 +1 -1
- package/src/examples/transferTokens.ts +21 -17
- package/src/generated/config.generated.ts +20 -9
- package/src/generated/operations.generated.ts +28 -5
- 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-CDCgYGZo.d.cts +0 -24
- package/dist/guards.generated-CdYcs4h0.d.ts +0 -24
- 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/discovery.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/discovery.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Types for the Compose discovery API (`GET /compose/zap-packs`, `GET /chains`).
|
|
3
4
|
*
|
|
@@ -13,73 +14,73 @@
|
|
|
13
14
|
/**
|
|
14
15
|
* A chain the Compose deployment supports.
|
|
15
16
|
*/
|
|
16
|
-
interface ChainSummary {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
export interface ChainSummary {
|
|
18
|
+
/** EVM chain ID. The stable identifier — key on this. */
|
|
19
|
+
readonly chainId: number;
|
|
20
|
+
/**
|
|
21
|
+
* Human-readable label, suitable for display in a chain selector.
|
|
22
|
+
*
|
|
23
|
+
* Maintained by the deployment rather than derived from canonical chain
|
|
24
|
+
* branding, so it can differ from a chain's marketed name and can change
|
|
25
|
+
* without notice. Never treat it as an identifier, and never match on it.
|
|
26
|
+
* A chain the deployment has no configured label for reports `Chain <id>`.
|
|
27
|
+
*/
|
|
28
|
+
readonly name: string;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* A single routing edge representing a supported token-to-token path
|
|
31
32
|
* through a DeFi protocol.
|
|
32
33
|
*/
|
|
33
|
-
interface ZapPackEdge {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
export interface ZapPackEdge {
|
|
35
|
+
/** Edge type (e.g. `"enter-position"`, `"exit-position"`, `"wrap"`). */
|
|
36
|
+
readonly type: string;
|
|
37
|
+
/** Input token. */
|
|
38
|
+
readonly in: {
|
|
39
|
+
readonly address: string;
|
|
40
|
+
readonly chainId: number;
|
|
41
|
+
};
|
|
42
|
+
/** Output token. */
|
|
43
|
+
readonly out: {
|
|
44
|
+
readonly address: string;
|
|
45
|
+
readonly chainId: number;
|
|
46
|
+
};
|
|
47
|
+
/** Minimum input amount accepted (stringified integer), if constrained. */
|
|
48
|
+
readonly inAmountMin?: string;
|
|
49
|
+
/** Maximum input amount accepted (stringified integer), if constrained. */
|
|
50
|
+
readonly inAmountMax?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Recipient binding obligation. `"required"` means the zap must bind its
|
|
53
|
+
* `recipient` input. The output is externally owned, terminal, and unswept.
|
|
54
|
+
* The loose string type preserves forward compatibility with new values.
|
|
55
|
+
*/
|
|
56
|
+
readonly recipient?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Output availability. `"future"` means the output becomes available only
|
|
59
|
+
* after the initiating transaction settles; route via `lifi.zapAsync` with
|
|
60
|
+
* a bound recipient. Absent means the output is available synchronously.
|
|
61
|
+
* The loose string type preserves forward compatibility with new values.
|
|
62
|
+
*/
|
|
63
|
+
readonly availability?: string;
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* All routing edges for a single protocol.
|
|
66
67
|
*/
|
|
67
|
-
interface ZapPackOverview {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
export interface ZapPackOverview {
|
|
69
|
+
/** Protocol identifier (e.g. `"aave"`, `"morpho"`). */
|
|
70
|
+
readonly protocol: string;
|
|
71
|
+
/** Available routing edges for this protocol. */
|
|
72
|
+
readonly edges: readonly ZapPackEdge[];
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Options for {@link ComposeClient.getZapPacks}.
|
|
75
76
|
*/
|
|
76
|
-
interface GetZapPacksOptions {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
export interface GetZapPacksOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Filter to specific protocols. Pass a single string or an array.
|
|
80
|
+
* Only edges belonging to the listed protocols are returned.
|
|
81
|
+
* Omit to fetch all available protocols.
|
|
82
|
+
*/
|
|
83
|
+
readonly protocols?: string | readonly string[];
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
//# sourceMappingURL=discovery.d.cts.map
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/discovery.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Types for the Compose discovery API (`GET /compose/zap-packs`, `GET /chains`).
|
|
3
4
|
*
|
|
@@ -13,73 +14,73 @@
|
|
|
13
14
|
/**
|
|
14
15
|
* A chain the Compose deployment supports.
|
|
15
16
|
*/
|
|
16
|
-
interface ChainSummary {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
export interface ChainSummary {
|
|
18
|
+
/** EVM chain ID. The stable identifier — key on this. */
|
|
19
|
+
readonly chainId: number;
|
|
20
|
+
/**
|
|
21
|
+
* Human-readable label, suitable for display in a chain selector.
|
|
22
|
+
*
|
|
23
|
+
* Maintained by the deployment rather than derived from canonical chain
|
|
24
|
+
* branding, so it can differ from a chain's marketed name and can change
|
|
25
|
+
* without notice. Never treat it as an identifier, and never match on it.
|
|
26
|
+
* A chain the deployment has no configured label for reports `Chain <id>`.
|
|
27
|
+
*/
|
|
28
|
+
readonly name: string;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* A single routing edge representing a supported token-to-token path
|
|
31
32
|
* through a DeFi protocol.
|
|
32
33
|
*/
|
|
33
|
-
interface ZapPackEdge {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
export interface ZapPackEdge {
|
|
35
|
+
/** Edge type (e.g. `"enter-position"`, `"exit-position"`, `"wrap"`). */
|
|
36
|
+
readonly type: string;
|
|
37
|
+
/** Input token. */
|
|
38
|
+
readonly in: {
|
|
39
|
+
readonly address: string;
|
|
40
|
+
readonly chainId: number;
|
|
41
|
+
};
|
|
42
|
+
/** Output token. */
|
|
43
|
+
readonly out: {
|
|
44
|
+
readonly address: string;
|
|
45
|
+
readonly chainId: number;
|
|
46
|
+
};
|
|
47
|
+
/** Minimum input amount accepted (stringified integer), if constrained. */
|
|
48
|
+
readonly inAmountMin?: string;
|
|
49
|
+
/** Maximum input amount accepted (stringified integer), if constrained. */
|
|
50
|
+
readonly inAmountMax?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Recipient binding obligation. `"required"` means the zap must bind its
|
|
53
|
+
* `recipient` input. The output is externally owned, terminal, and unswept.
|
|
54
|
+
* The loose string type preserves forward compatibility with new values.
|
|
55
|
+
*/
|
|
56
|
+
readonly recipient?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Output availability. `"future"` means the output becomes available only
|
|
59
|
+
* after the initiating transaction settles; route via `lifi.zapAsync` with
|
|
60
|
+
* a bound recipient. Absent means the output is available synchronously.
|
|
61
|
+
* The loose string type preserves forward compatibility with new values.
|
|
62
|
+
*/
|
|
63
|
+
readonly availability?: string;
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* All routing edges for a single protocol.
|
|
66
67
|
*/
|
|
67
|
-
interface ZapPackOverview {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
export interface ZapPackOverview {
|
|
69
|
+
/** Protocol identifier (e.g. `"aave"`, `"morpho"`). */
|
|
70
|
+
readonly protocol: string;
|
|
71
|
+
/** Available routing edges for this protocol. */
|
|
72
|
+
readonly edges: readonly ZapPackEdge[];
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Options for {@link ComposeClient.getZapPacks}.
|
|
75
76
|
*/
|
|
76
|
-
interface GetZapPacksOptions {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
export interface GetZapPacksOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Filter to specific protocols. Pass a single string or an array.
|
|
80
|
+
* Only edges belonging to the listed protocols are returned.
|
|
81
|
+
* Omit to fetch all available protocols.
|
|
82
|
+
*/
|
|
83
|
+
readonly protocols?: string | readonly string[];
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/errors.cjs
CHANGED
|
@@ -1,175 +1,227 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_responseSchemas = require("./responseSchemas.cjs");
|
|
4
|
+
let zod = require("zod");
|
|
5
|
+
zod = require_runtime.__toESM(zod, 1);
|
|
6
|
+
//#region src/errors.ts
|
|
7
|
+
/**
|
|
8
|
+
* Error class for all failures originating from the Compose SDK or API.
|
|
9
|
+
*
|
|
10
|
+
* Includes structured metadata beyond the error message to support
|
|
11
|
+
* programmatic error handling.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* try {
|
|
16
|
+
* await builder.compile(run);
|
|
17
|
+
* } catch (e) {
|
|
18
|
+
* if (isComposeError(e) && e.code === 'VALIDATION_ERROR') {
|
|
19
|
+
* console.error('Invalid request:', e.message, e.path);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
var ComposeError = class extends Error {
|
|
25
|
+
name = "ComposeError";
|
|
26
|
+
/** Machine-readable error category. */
|
|
27
|
+
code;
|
|
28
|
+
/** HTTP status code, when the error originated from an HTTP response. */
|
|
29
|
+
status;
|
|
30
|
+
/** The request URL that produced the error. */
|
|
31
|
+
url;
|
|
32
|
+
/** Server-provided error kind for finer-grained classification. */
|
|
33
|
+
kind;
|
|
34
|
+
/**
|
|
35
|
+
* Where a validation error points: the node id for a rejection of an
|
|
36
|
+
* authored node, or a JSON-pointer path for a rejection of the request shape.
|
|
37
|
+
*/
|
|
38
|
+
path;
|
|
39
|
+
/**
|
|
40
|
+
* The input port of {@link ComposeError.path}'s node whose binding caused the
|
|
41
|
+
* error. Set when the rejection is about what a port binds rather than about
|
|
42
|
+
* the node's config.
|
|
43
|
+
*/
|
|
44
|
+
port;
|
|
45
|
+
/**
|
|
46
|
+
* The one edit that clears the error, written for whoever authored the flow.
|
|
47
|
+
* Set on `continuation.settle` authoring rejections; may be absent on other
|
|
48
|
+
* `validation_error`s.
|
|
49
|
+
*/
|
|
50
|
+
fix;
|
|
51
|
+
/**
|
|
52
|
+
* Simulation revert diagnostics attached to `simulation_revert` errors.
|
|
53
|
+
* Contains the raw error bytes and decoded error candidates when the
|
|
54
|
+
* backend can parse the revert reason.
|
|
55
|
+
*/
|
|
56
|
+
details;
|
|
57
|
+
/**
|
|
58
|
+
* The prepared ops that failed, attached to `preparation_error` errors.
|
|
59
|
+
* Each entry carries the `callId` of the failing node so callers can drop
|
|
60
|
+
* the unroutable legs and resubmit a smaller flow.
|
|
61
|
+
*/
|
|
62
|
+
failedOps;
|
|
63
|
+
/**
|
|
64
|
+
* The `callId`s of the prepared ops that succeeded, attached to
|
|
65
|
+
* `preparation_error` errors alongside {@link ComposeError.failedOps}.
|
|
66
|
+
*/
|
|
67
|
+
succeededOps;
|
|
68
|
+
/** Version details attached only to `sdk_outdated` errors. */
|
|
69
|
+
sdkOutdated;
|
|
70
|
+
/** Version details attached only to `server_outdated` errors. */
|
|
71
|
+
serverOutdated;
|
|
72
|
+
constructor(code, message, options) {
|
|
73
|
+
super(message, { cause: options?.cause });
|
|
74
|
+
this.code = code;
|
|
75
|
+
this.status = options?.status;
|
|
76
|
+
this.url = options?.url;
|
|
77
|
+
this.kind = options?.kind;
|
|
78
|
+
this.path = options?.path;
|
|
79
|
+
this.port = options?.port;
|
|
80
|
+
this.fix = options?.fix;
|
|
81
|
+
this.details = options?.details;
|
|
82
|
+
this.failedOps = options?.failedOps;
|
|
83
|
+
this.succeededOps = options?.succeededOps;
|
|
84
|
+
this.sdkOutdated = options?.sdkOutdated;
|
|
85
|
+
this.serverOutdated = options?.serverOutdated;
|
|
86
|
+
}
|
|
11
87
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 errors_exports = {};
|
|
30
|
-
__export(errors_exports, {
|
|
31
|
-
ComposeError: () => ComposeError,
|
|
32
|
-
errorFromHttpResponse: () => errorFromHttpResponse,
|
|
33
|
-
isComposeError: () => isComposeError,
|
|
34
|
-
isComposePreparationError: () => isComposePreparationError,
|
|
35
|
-
isComposeSdkOutdatedError: () => isComposeSdkOutdatedError,
|
|
36
|
-
isComposeServerOutdatedError: () => isComposeServerOutdatedError
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(errors_exports);
|
|
39
|
-
var import_zod = __toESM(require("zod"), 1);
|
|
40
|
-
var import_responseSchemas = require("./responseSchemas.js");
|
|
41
|
-
class ComposeError extends Error {
|
|
42
|
-
name = "ComposeError";
|
|
43
|
-
/** Machine-readable error category. */
|
|
44
|
-
code;
|
|
45
|
-
/** HTTP status code, when the error originated from an HTTP response. */
|
|
46
|
-
status;
|
|
47
|
-
/** The request URL that produced the error. */
|
|
48
|
-
url;
|
|
49
|
-
/** Server-provided error kind for finer-grained classification. */
|
|
50
|
-
kind;
|
|
51
|
-
/**
|
|
52
|
-
* Where a validation error points: the node id for a rejection of an
|
|
53
|
-
* authored node, or a JSON-pointer path for a rejection of the request shape.
|
|
54
|
-
*/
|
|
55
|
-
path;
|
|
56
|
-
/**
|
|
57
|
-
* The input port of {@link ComposeError.path}'s node whose binding caused the
|
|
58
|
-
* error. Set when the rejection is about what a port binds rather than about
|
|
59
|
-
* the node's config.
|
|
60
|
-
*/
|
|
61
|
-
port;
|
|
62
|
-
/**
|
|
63
|
-
* The one edit that clears the error, written for whoever authored the flow.
|
|
64
|
-
* Set on `continuation.settle` authoring rejections; may be absent on other
|
|
65
|
-
* `validation_error`s.
|
|
66
|
-
*/
|
|
67
|
-
fix;
|
|
68
|
-
/**
|
|
69
|
-
* Simulation revert diagnostics attached to `simulation_revert` errors.
|
|
70
|
-
* Contains the raw error bytes and decoded error candidates when the
|
|
71
|
-
* backend can parse the revert reason.
|
|
72
|
-
*/
|
|
73
|
-
details;
|
|
74
|
-
/**
|
|
75
|
-
* The prepared ops that failed, attached to `preparation_error` errors.
|
|
76
|
-
* Each entry carries the `callId` of the failing node so callers can drop
|
|
77
|
-
* the unroutable legs and resubmit a smaller flow.
|
|
78
|
-
*/
|
|
79
|
-
failedOps;
|
|
80
|
-
/**
|
|
81
|
-
* The `callId`s of the prepared ops that succeeded, attached to
|
|
82
|
-
* `preparation_error` errors alongside {@link ComposeError.failedOps}.
|
|
83
|
-
*/
|
|
84
|
-
succeededOps;
|
|
85
|
-
/** Version details attached only to `sdk_outdated` errors. */
|
|
86
|
-
sdkOutdated;
|
|
87
|
-
/** Version details attached only to `server_outdated` errors. */
|
|
88
|
-
serverOutdated;
|
|
89
|
-
constructor(code, message, options) {
|
|
90
|
-
super(message, { cause: options?.cause });
|
|
91
|
-
this.code = code;
|
|
92
|
-
this.status = options?.status;
|
|
93
|
-
this.url = options?.url;
|
|
94
|
-
this.kind = options?.kind;
|
|
95
|
-
this.path = options?.path;
|
|
96
|
-
this.port = options?.port;
|
|
97
|
-
this.fix = options?.fix;
|
|
98
|
-
this.details = options?.details;
|
|
99
|
-
this.failedOps = options?.failedOps;
|
|
100
|
-
this.succeededOps = options?.succeededOps;
|
|
101
|
-
this.sdkOutdated = options?.sdkOutdated;
|
|
102
|
-
this.serverOutdated = options?.serverOutdated;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
88
|
+
/**
|
|
89
|
+
* Type guard that narrows an unknown error to {@link ComposeError}.
|
|
90
|
+
* @param e - The value to check.
|
|
91
|
+
* @returns `true` if `e` is an instance of `ComposeError`.
|
|
92
|
+
*/
|
|
105
93
|
const isComposeError = (e) => e instanceof ComposeError || e instanceof Error && e.name === "ComposeError" && "code" in e;
|
|
94
|
+
/**
|
|
95
|
+
* Type guard for `preparation_error` failures (HTTP 422): a mixed basket where
|
|
96
|
+
* some prepared ops failed and others succeeded. Narrows both
|
|
97
|
+
* {@link ComposeError.failedOps} and {@link ComposeError.succeededOps} to
|
|
98
|
+
* present, so callers can read them without a cast or a truthiness check.
|
|
99
|
+
*
|
|
100
|
+
* @param e - The value to check.
|
|
101
|
+
* @returns `true` if `e` is a `ComposeError` carrying per-op preparation diagnostics.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* try {
|
|
106
|
+
* await builder.compile(run);
|
|
107
|
+
* } catch (e) {
|
|
108
|
+
* if (isComposePreparationError(e)) {
|
|
109
|
+
* console.error('Failed ops:', e.failedOps);
|
|
110
|
+
* console.error('Succeeded ops:', e.succeededOps);
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
106
115
|
const isComposePreparationError = (e) => isComposeError(e) && e.kind === "preparation_error" && Array.isArray(e.failedOps) && Array.isArray(e.succeededOps);
|
|
107
|
-
const sdkOutdatedSchema =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
const sdkOutdatedSchema = zod.default.object({
|
|
117
|
+
sdkVersion: zod.default.string(),
|
|
118
|
+
serverVersion: zod.default.string(),
|
|
119
|
+
minimumSdkVersion: zod.default.string()
|
|
111
120
|
});
|
|
121
|
+
/**
|
|
122
|
+
* Narrows an outdated-SDK rejection to its required version details.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* try {
|
|
127
|
+
* await builder.compile(run);
|
|
128
|
+
* } catch (e) {
|
|
129
|
+
* if (isComposeSdkOutdatedError(e)) {
|
|
130
|
+
* console.error(`Upgrade to at least ${e.sdkOutdated.minimumSdkVersion}`);
|
|
131
|
+
* return;
|
|
132
|
+
* }
|
|
133
|
+
* throw e;
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
112
137
|
const isComposeSdkOutdatedError = (e) => isComposeError(e) && e.kind === "sdk_outdated" && sdkOutdatedSchema.safeParse(e.sdkOutdated).success;
|
|
113
|
-
const serverOutdatedSchema =
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
const serverOutdatedSchema = zod.default.object({
|
|
139
|
+
sdkVersion: zod.default.string(),
|
|
140
|
+
serverVersion: zod.default.string()
|
|
116
141
|
});
|
|
142
|
+
/**
|
|
143
|
+
* Narrows a server-behind-SDK rejection to its required version details.
|
|
144
|
+
*
|
|
145
|
+
* This is the deploy-window error: the SDK on npm is ahead of the backend that
|
|
146
|
+
* answered. Pin the SDK to the server's `major.minor`, or wait for the rollout.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* try {
|
|
151
|
+
* await builder.compile(run);
|
|
152
|
+
* } catch (e) {
|
|
153
|
+
* if (isComposeServerOutdatedError(e)) {
|
|
154
|
+
* console.error(`Server serves ${e.serverOutdated.serverVersion}`);
|
|
155
|
+
* return;
|
|
156
|
+
* }
|
|
157
|
+
* throw e;
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
117
161
|
const isComposeServerOutdatedError = (e) => isComposeError(e) && e.kind === "server_outdated" && serverOutdatedSchema.safeParse(e.serverOutdated).success;
|
|
118
162
|
const STATUS_TO_CODE = /* @__PURE__ */ new Map([
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
163
|
+
[400, "VALIDATION_ERROR"],
|
|
164
|
+
[401, "UNAUTHENTICATED"],
|
|
165
|
+
[403, "FORBIDDEN"],
|
|
166
|
+
[404, "NOT_FOUND"],
|
|
167
|
+
[422, "VALIDATION_ERROR"],
|
|
168
|
+
[429, "RATE_LIMITED"]
|
|
125
169
|
]);
|
|
126
170
|
const tryParseErrorBody = (body) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
171
|
+
let json;
|
|
172
|
+
try {
|
|
173
|
+
json = JSON.parse(body);
|
|
174
|
+
} catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return require_responseSchemas.parseServerErrorBody(json);
|
|
134
178
|
};
|
|
179
|
+
/**
|
|
180
|
+
* Extracts the version triple an `sdk_outdated` or `server_outdated` envelope
|
|
181
|
+
* carries. The slots reuse the same schemas the type guards narrow with. Zod
|
|
182
|
+
* strips keys the schema does not declare, so the parsed value is exactly the
|
|
183
|
+
* triple; a partial payload fails the parse and yields `undefined` rather than
|
|
184
|
+
* a half-populated object.
|
|
185
|
+
*/
|
|
135
186
|
const readVersionSlots = (serverError) => ({
|
|
136
|
-
|
|
137
|
-
|
|
187
|
+
sdkOutdated: serverError?.kind === "sdk_outdated" ? sdkOutdatedSchema.safeParse(serverError).data : void 0,
|
|
188
|
+
serverOutdated: serverError?.kind === "server_outdated" ? serverOutdatedSchema.safeParse(serverError).data : void 0
|
|
138
189
|
});
|
|
190
|
+
/**
|
|
191
|
+
* Constructs a {@link ComposeError} from an HTTP error response, extracting
|
|
192
|
+
* structured error details from the response body when available.
|
|
193
|
+
*
|
|
194
|
+
* @param status - The HTTP status code.
|
|
195
|
+
* @param body - The raw response body text.
|
|
196
|
+
* @param url - The request URL that produced the error.
|
|
197
|
+
* @returns A `ComposeError` with the appropriate error code and metadata.
|
|
198
|
+
*/
|
|
139
199
|
const errorFromHttpResponse = (status, body, url) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
kind: op.kind
|
|
159
|
-
})),
|
|
160
|
-
succeededOps: serverError?.succeededOps,
|
|
161
|
-
sdkOutdated,
|
|
162
|
-
serverOutdated
|
|
163
|
-
}
|
|
164
|
-
);
|
|
200
|
+
const serverError = tryParseErrorBody(body)?.error;
|
|
201
|
+
const { sdkOutdated, serverOutdated } = readVersionSlots(serverError);
|
|
202
|
+
return new ComposeError(STATUS_TO_CODE.get(status) ?? (status >= 500 ? "SERVER_ERROR" : "UNKNOWN_ERROR"), (serverError?.message ?? body) || `HTTP ${status}`, {
|
|
203
|
+
status,
|
|
204
|
+
url,
|
|
205
|
+
kind: serverError?.kind,
|
|
206
|
+
path: serverError?.path,
|
|
207
|
+
port: serverError?.port,
|
|
208
|
+
fix: serverError?.fix,
|
|
209
|
+
details: serverError?.details,
|
|
210
|
+
failedOps: serverError?.failedOps?.map((op) => ({
|
|
211
|
+
...op,
|
|
212
|
+
kind: op.kind
|
|
213
|
+
})),
|
|
214
|
+
succeededOps: serverError?.succeededOps,
|
|
215
|
+
sdkOutdated,
|
|
216
|
+
serverOutdated
|
|
217
|
+
});
|
|
165
218
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
219
|
+
//#endregion
|
|
220
|
+
exports.ComposeError = ComposeError;
|
|
221
|
+
exports.errorFromHttpResponse = errorFromHttpResponse;
|
|
222
|
+
exports.isComposeError = isComposeError;
|
|
223
|
+
exports.isComposePreparationError = isComposePreparationError;
|
|
224
|
+
exports.isComposeSdkOutdatedError = isComposeSdkOutdatedError;
|
|
225
|
+
exports.isComposeServerOutdatedError = isComposeServerOutdatedError;
|
|
226
|
+
|
|
175
227
|
//# sourceMappingURL=errors.cjs.map
|