@eco-foundation/api-schemas 0.1.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 +160 -0
- package/dist/build-digest.d.ts +2 -0
- package/dist/build-digest.js +10 -0
- package/dist/build-digest.js.map +1 -0
- package/dist/fixtures/index.d.ts +14 -0
- package/dist/fixtures/index.js +71 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/fixtures/v1/chains-list.response.default.json +37 -0
- package/dist/fixtures/v1/deposit-addresses-create.request.gateway-erc20.json +16 -0
- package/dist/fixtures/v1/deposit-addresses-create.response.gateway-erc20.json +20 -0
- package/dist/fixtures/v1/deposit-addresses-lookup.response.default.json +24 -0
- package/dist/fixtures/v1/deposit-addresses-submit-erc-2612.request.deposit-address-target.json +23 -0
- package/dist/fixtures/v1/deposit-addresses-submit-erc-3009.request.deposit-address-target.json +24 -0
- package/dist/fixtures/v1/intents-status.response.gasless-handoff.json +30 -0
- package/dist/fixtures/v1/intents-status.response.intent-filled.json +21 -0
- package/dist/fixtures/v1/intents-status.response.unknown.json +20 -0
- package/dist/fixtures/v1/intents-status.response.wallet-page.json +27 -0
- package/dist/fixtures/v1/intents-submit-erc-3009.response.job.json +25 -0
- package/dist/fixtures/v1/intents-submit-permit2.request.quote-target.json +25 -0
- package/dist/fixtures/v1/intents-submit-permit3.request.quote-target.json +27 -0
- package/dist/fixtures/v1/quotes-create.request.public-swap.json +25 -0
- package/dist/fixtures/v1/quotes-create.response.all-quotes.json +455 -0
- package/dist/fixtures/v1/quotes-create.response.private-swap.json +152 -0
- package/dist/fixtures/v1/quotes-create.response.public-swap.json +158 -0
- package/dist/fixtures/v1/routes-list.response.default.json +26 -0
- package/dist/fixtures/v1/tokens-list.response.default.json +24 -0
- package/dist/generated/build-digest.json +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +81 -0
- package/dist/openapi.js.map +1 -0
- package/dist/scripts/generate-build-digest.d.ts +1 -0
- package/dist/scripts/generate-build-digest.js +25 -0
- package/dist/scripts/generate-build-digest.js.map +1 -0
- package/dist/scripts/generate-openapi.d.ts +1 -0
- package/dist/scripts/generate-openapi.js +21 -0
- package/dist/scripts/generate-openapi.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +27 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/v1/endpoints/chains.d.ts +52 -0
- package/dist/v1/endpoints/chains.js +23 -0
- package/dist/v1/endpoints/chains.js.map +1 -0
- package/dist/v1/endpoints/deposit-addresses.d.ts +100 -0
- package/dist/v1/endpoints/deposit-addresses.js +61 -0
- package/dist/v1/endpoints/deposit-addresses.js.map +1 -0
- package/dist/v1/endpoints/quotes.d.ts +861 -0
- package/dist/v1/endpoints/quotes.js +297 -0
- package/dist/v1/endpoints/quotes.js.map +1 -0
- package/dist/v1/endpoints/registry.d.ts +641 -0
- package/dist/v1/endpoints/registry.js +108 -0
- package/dist/v1/endpoints/registry.js.map +1 -0
- package/dist/v1/endpoints/routes.d.ts +35 -0
- package/dist/v1/endpoints/routes.js +21 -0
- package/dist/v1/endpoints/routes.js.map +1 -0
- package/dist/v1/endpoints/status.d.ts +149 -0
- package/dist/v1/endpoints/status.js +110 -0
- package/dist/v1/endpoints/status.js.map +1 -0
- package/dist/v1/endpoints/submit.d.ts +271 -0
- package/dist/v1/endpoints/submit.js +127 -0
- package/dist/v1/endpoints/submit.js.map +1 -0
- package/dist/v1/endpoints/tokens.d.ts +59 -0
- package/dist/v1/endpoints/tokens.js +22 -0
- package/dist/v1/endpoints/tokens.js.map +1 -0
- package/dist/v1/enums.d.ts +133 -0
- package/dist/v1/enums.js +62 -0
- package/dist/v1/enums.js.map +1 -0
- package/dist/v1/errors/catalog.d.ts +247 -0
- package/dist/v1/errors/catalog.js +124 -0
- package/dist/v1/errors/catalog.js.map +1 -0
- package/dist/v1/errors/lock.d.ts +10 -0
- package/dist/v1/errors/lock.js +45 -0
- package/dist/v1/errors/lock.js.map +1 -0
- package/dist/v1/errors/problem.d.ts +50 -0
- package/dist/v1/errors/problem.js +82 -0
- package/dist/v1/errors/problem.js.map +1 -0
- package/dist/v1/index.d.ts +14 -0
- package/dist/v1/index.js +32 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/primitives.d.ts +33 -0
- package/dist/v1/primitives.js +63 -0
- package/dist/v1/primitives.js.map +1 -0
- package/dist/v1/signature.d.ts +10 -0
- package/dist/v1/signature.js +72 -0
- package/dist/v1/signature.js.map +1 -0
- package/dist/v1/tolerant.d.ts +4 -0
- package/dist/v1/tolerant.js +11 -0
- package/dist/v1/tolerant.js.map +1 -0
- package/dist/v1/types.d.ts +277 -0
- package/dist/v1/types.js +3 -0
- package/dist/v1/types.js.map +1 -0
- package/errors/catalog.lock.json +232 -0
- package/fixtures/quote-signature/vector-1.json +9 -0
- package/fixtures/quote-signature/vector-2.json +13 -0
- package/fixtures/quote-signature/vector-3.json +9 -0
- package/fixtures/signature-hash/vectors.json +58 -0
- package/openapi/v1.json +5225 -0
- package/package.json +71 -0
- package/v1/types.d.ts +7 -0
- package/v1/types.js +5 -0
package/dist/v1/enums.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STATUS_VOCABULARY = exports.GaslessSubState = exports.GASLESS_SUB_STATES = exports.GASLESS_JOB_STATUSES = exports.StatusType = exports.STATUS_TYPES = exports.STANDARDS_BY_TARGET = exports.SubmitStandard = exports.SUBMIT_STANDARDS = exports.StepKindTolerant = exports.StepKind = exports.STEP_KINDS = exports.RelatedIntentRoleTolerant = exports.RelatedIntentRole = exports.RELATED_INTENT_ROLES = exports.ChainStatus = exports.CHAIN_STATUSES = exports.ChainEncoding = exports.CHAIN_ENCODINGS = exports.ChainType = exports.CHAIN_TYPES = exports.Visibility = exports.VISIBILITIES = exports.FeeKindTolerant = exports.FeeKind = exports.FEE_KINDS = exports.GuaranteeTolerant = exports.Guarantee = exports.GUARANTEES = exports.SwapTypeTolerant = exports.SwapType = exports.SWAP_TYPES = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const primitives_1 = require("./primitives");
|
|
6
|
+
exports.SWAP_TYPES = ['exact-in', 'exact-out', 'custom'];
|
|
7
|
+
exports.SwapType = zod_1.z.enum(exports.SWAP_TYPES);
|
|
8
|
+
exports.SwapTypeTolerant = (0, primitives_1.tolerantEnum)(exports.SWAP_TYPES);
|
|
9
|
+
exports.GUARANTEES = ['atomic-or-refund', 'calls-execute-or-refund'];
|
|
10
|
+
exports.Guarantee = zod_1.z.enum(exports.GUARANTEES);
|
|
11
|
+
exports.GuaranteeTolerant = (0, primitives_1.tolerantEnum)(exports.GUARANTEES);
|
|
12
|
+
exports.FEE_KINDS = ['gas', 'proving', 'protocol', 'gateway'];
|
|
13
|
+
exports.FeeKind = zod_1.z.enum(exports.FEE_KINDS);
|
|
14
|
+
exports.FeeKindTolerant = (0, primitives_1.tolerantEnum)(exports.FEE_KINDS);
|
|
15
|
+
exports.VISIBILITIES = ['public', 'private'];
|
|
16
|
+
exports.Visibility = zod_1.z.enum(exports.VISIBILITIES);
|
|
17
|
+
exports.CHAIN_TYPES = ['evm', 'svm', 'tvm'];
|
|
18
|
+
exports.ChainType = zod_1.z.enum(exports.CHAIN_TYPES);
|
|
19
|
+
exports.CHAIN_ENCODINGS = ['abi', 'borsh'];
|
|
20
|
+
exports.ChainEncoding = zod_1.z.enum(exports.CHAIN_ENCODINGS);
|
|
21
|
+
exports.CHAIN_STATUSES = ['live', 'paused'];
|
|
22
|
+
exports.ChainStatus = zod_1.z.enum(exports.CHAIN_STATUSES);
|
|
23
|
+
exports.RELATED_INTENT_ROLES = ['local', 'bucket-candidate', 'stitched-destination'];
|
|
24
|
+
exports.RelatedIntentRole = zod_1.z.enum(exports.RELATED_INTENT_ROLES);
|
|
25
|
+
exports.RelatedIntentRoleTolerant = (0, primitives_1.tolerantEnum)(exports.RELATED_INTENT_ROLES);
|
|
26
|
+
exports.STEP_KINDS = ['swap', 'bridge', 'deposit', 'transfer'];
|
|
27
|
+
exports.StepKind = zod_1.z.enum(exports.STEP_KINDS);
|
|
28
|
+
exports.StepKindTolerant = (0, primitives_1.tolerantEnum)(exports.STEP_KINDS);
|
|
29
|
+
exports.SUBMIT_STANDARDS = ['permit3', 'permit2', 'erc-3009', 'erc-2612'];
|
|
30
|
+
exports.SubmitStandard = zod_1.z.enum(exports.SUBMIT_STANDARDS);
|
|
31
|
+
exports.STANDARDS_BY_TARGET = {
|
|
32
|
+
quote: ['permit3', 'permit2', 'erc-3009'],
|
|
33
|
+
depositAddress: ['erc-2612', 'erc-3009'],
|
|
34
|
+
};
|
|
35
|
+
exports.STATUS_TYPES = ['intent', 'quote', 'gasless', 'deposit-address'];
|
|
36
|
+
exports.StatusType = zod_1.z.enum(exports.STATUS_TYPES);
|
|
37
|
+
exports.GASLESS_JOB_STATUSES = [
|
|
38
|
+
'pending',
|
|
39
|
+
'processing',
|
|
40
|
+
'published',
|
|
41
|
+
'partial',
|
|
42
|
+
'failed',
|
|
43
|
+
'unknown',
|
|
44
|
+
];
|
|
45
|
+
exports.GASLESS_SUB_STATES = ['pending', 'submitted', 'published', 'failed'];
|
|
46
|
+
exports.GaslessSubState = zod_1.z.enum(exports.GASLESS_SUB_STATES);
|
|
47
|
+
exports.STATUS_VOCABULARY = {
|
|
48
|
+
intent: [
|
|
49
|
+
'pending',
|
|
50
|
+
'filled',
|
|
51
|
+
'settled',
|
|
52
|
+
'refunded',
|
|
53
|
+
'refundable',
|
|
54
|
+
'expired',
|
|
55
|
+
'failed',
|
|
56
|
+
'unknown',
|
|
57
|
+
],
|
|
58
|
+
quote: ['active', 'submitted', 'expired', 'unknown'],
|
|
59
|
+
gasless: exports.GASLESS_JOB_STATUSES,
|
|
60
|
+
'deposit-address': ['active', 'expired', 'unknown'],
|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C,CAAC,IAAI,CAAC,0BAAkB,CAAC,CAAC;AAQ7C,QAAA,iBAAiB,GAAG;IAE/B,MAAM,EAAE;QACN,SAAS;QACT,QAAQ;QACR,SAAS;QACT,UAAU;QACV,YAAY;QACZ,SAAS;QACT,QAAQ;QACR,SAAS;KACV;IAOD,KAAK,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;IACpD,OAAO,EAAE,4BAAoB;IAM7B,iBAAiB,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;CACkC,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
export type LegacyCodeRef = `eco-quotes:${number}` | `deposit-addresses:${number}`;
|
|
2
|
+
export interface V1ErrorDefinition {
|
|
3
|
+
code: string;
|
|
4
|
+
status: number;
|
|
5
|
+
title: string;
|
|
6
|
+
type: string;
|
|
7
|
+
audience: 'read' | 'write' | 'all';
|
|
8
|
+
legacyCodes: readonly LegacyCodeRef[];
|
|
9
|
+
}
|
|
10
|
+
export declare const V1_ERROR_CATALOG: readonly [{
|
|
11
|
+
readonly code: "invalid-request";
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly title: string;
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly audience: "read" | "write" | "all";
|
|
16
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
17
|
+
}, {
|
|
18
|
+
readonly code: "missing-parameter";
|
|
19
|
+
readonly status: number;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly type: string;
|
|
22
|
+
readonly audience: "read" | "write" | "all";
|
|
23
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
24
|
+
}, {
|
|
25
|
+
readonly code: "invalid-parameter";
|
|
26
|
+
readonly status: number;
|
|
27
|
+
readonly title: string;
|
|
28
|
+
readonly type: string;
|
|
29
|
+
readonly audience: "read" | "write" | "all";
|
|
30
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
31
|
+
}, {
|
|
32
|
+
readonly code: "slippage-out-of-bounds";
|
|
33
|
+
readonly status: number;
|
|
34
|
+
readonly title: string;
|
|
35
|
+
readonly type: string;
|
|
36
|
+
readonly audience: "read" | "write" | "all";
|
|
37
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
38
|
+
}, {
|
|
39
|
+
readonly code: "deposit-address-mismatch";
|
|
40
|
+
readonly status: number;
|
|
41
|
+
readonly title: string;
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly audience: "read" | "write" | "all";
|
|
44
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
45
|
+
}, {
|
|
46
|
+
readonly code: "invalid-signature";
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly title: string;
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly audience: "read" | "write" | "all";
|
|
51
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
52
|
+
}, {
|
|
53
|
+
readonly code: "authorization-expired";
|
|
54
|
+
readonly status: number;
|
|
55
|
+
readonly title: string;
|
|
56
|
+
readonly type: string;
|
|
57
|
+
readonly audience: "read" | "write" | "all";
|
|
58
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
59
|
+
}, {
|
|
60
|
+
readonly code: "invalid-api-key";
|
|
61
|
+
readonly status: number;
|
|
62
|
+
readonly title: string;
|
|
63
|
+
readonly type: string;
|
|
64
|
+
readonly audience: "read" | "write" | "all";
|
|
65
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
66
|
+
}, {
|
|
67
|
+
readonly code: "api-key-expired";
|
|
68
|
+
readonly status: number;
|
|
69
|
+
readonly title: string;
|
|
70
|
+
readonly type: string;
|
|
71
|
+
readonly audience: "read" | "write" | "all";
|
|
72
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
73
|
+
}, {
|
|
74
|
+
readonly code: "permission-denied";
|
|
75
|
+
readonly status: number;
|
|
76
|
+
readonly title: string;
|
|
77
|
+
readonly type: string;
|
|
78
|
+
readonly audience: "read" | "write" | "all";
|
|
79
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
80
|
+
}, {
|
|
81
|
+
readonly code: "funder-mismatch";
|
|
82
|
+
readonly status: number;
|
|
83
|
+
readonly title: string;
|
|
84
|
+
readonly type: string;
|
|
85
|
+
readonly audience: "read" | "write" | "all";
|
|
86
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
87
|
+
}, {
|
|
88
|
+
readonly code: "token-not-found";
|
|
89
|
+
readonly status: number;
|
|
90
|
+
readonly title: string;
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly audience: "read" | "write" | "all";
|
|
93
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
94
|
+
}, {
|
|
95
|
+
readonly code: "signature-already-bound";
|
|
96
|
+
readonly status: number;
|
|
97
|
+
readonly title: string;
|
|
98
|
+
readonly type: string;
|
|
99
|
+
readonly audience: "read" | "write" | "all";
|
|
100
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
101
|
+
}, {
|
|
102
|
+
readonly code: "nonce-used";
|
|
103
|
+
readonly status: number;
|
|
104
|
+
readonly title: string;
|
|
105
|
+
readonly type: string;
|
|
106
|
+
readonly audience: "read" | "write" | "all";
|
|
107
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
108
|
+
}, {
|
|
109
|
+
readonly code: "quote-expired";
|
|
110
|
+
readonly status: number;
|
|
111
|
+
readonly title: string;
|
|
112
|
+
readonly type: string;
|
|
113
|
+
readonly audience: "read" | "write" | "all";
|
|
114
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
115
|
+
}, {
|
|
116
|
+
readonly code: "no-route-found";
|
|
117
|
+
readonly status: number;
|
|
118
|
+
readonly title: string;
|
|
119
|
+
readonly type: string;
|
|
120
|
+
readonly audience: "read" | "write" | "all";
|
|
121
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
122
|
+
}, {
|
|
123
|
+
readonly code: "token-not-supported";
|
|
124
|
+
readonly status: number;
|
|
125
|
+
readonly title: string;
|
|
126
|
+
readonly type: string;
|
|
127
|
+
readonly audience: "read" | "write" | "all";
|
|
128
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
129
|
+
}, {
|
|
130
|
+
readonly code: "simulation-failed";
|
|
131
|
+
readonly status: number;
|
|
132
|
+
readonly title: string;
|
|
133
|
+
readonly type: string;
|
|
134
|
+
readonly audience: "read" | "write" | "all";
|
|
135
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
136
|
+
}, {
|
|
137
|
+
readonly code: "insufficient-funds";
|
|
138
|
+
readonly status: number;
|
|
139
|
+
readonly title: string;
|
|
140
|
+
readonly type: string;
|
|
141
|
+
readonly audience: "read" | "write" | "all";
|
|
142
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
143
|
+
}, {
|
|
144
|
+
readonly code: "chain-not-supported";
|
|
145
|
+
readonly status: number;
|
|
146
|
+
readonly title: string;
|
|
147
|
+
readonly type: string;
|
|
148
|
+
readonly audience: "read" | "write" | "all";
|
|
149
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
150
|
+
}, {
|
|
151
|
+
readonly code: "chain-pair-unsupported";
|
|
152
|
+
readonly status: number;
|
|
153
|
+
readonly title: string;
|
|
154
|
+
readonly type: string;
|
|
155
|
+
readonly audience: "read" | "write" | "all";
|
|
156
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
157
|
+
}, {
|
|
158
|
+
readonly code: "amount-too-low";
|
|
159
|
+
readonly status: number;
|
|
160
|
+
readonly title: string;
|
|
161
|
+
readonly type: string;
|
|
162
|
+
readonly audience: "read" | "write" | "all";
|
|
163
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
164
|
+
}, {
|
|
165
|
+
readonly code: "amount-too-high";
|
|
166
|
+
readonly status: number;
|
|
167
|
+
readonly title: string;
|
|
168
|
+
readonly type: string;
|
|
169
|
+
readonly audience: "read" | "write" | "all";
|
|
170
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
171
|
+
}, {
|
|
172
|
+
readonly code: "insufficient-liquidity";
|
|
173
|
+
readonly status: number;
|
|
174
|
+
readonly title: string;
|
|
175
|
+
readonly type: string;
|
|
176
|
+
readonly audience: "read" | "write" | "all";
|
|
177
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
178
|
+
}, {
|
|
179
|
+
readonly code: "insufficient-balance";
|
|
180
|
+
readonly status: number;
|
|
181
|
+
readonly title: string;
|
|
182
|
+
readonly type: string;
|
|
183
|
+
readonly audience: "read" | "write" | "all";
|
|
184
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
185
|
+
}, {
|
|
186
|
+
readonly code: "insufficient-allowance";
|
|
187
|
+
readonly status: number;
|
|
188
|
+
readonly title: string;
|
|
189
|
+
readonly type: string;
|
|
190
|
+
readonly audience: "read" | "write" | "all";
|
|
191
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
192
|
+
}, {
|
|
193
|
+
readonly code: "insufficient-gas";
|
|
194
|
+
readonly status: number;
|
|
195
|
+
readonly title: string;
|
|
196
|
+
readonly type: string;
|
|
197
|
+
readonly audience: "read" | "write" | "all";
|
|
198
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
199
|
+
}, {
|
|
200
|
+
readonly code: "unsupported-authorization";
|
|
201
|
+
readonly status: number;
|
|
202
|
+
readonly title: string;
|
|
203
|
+
readonly type: string;
|
|
204
|
+
readonly audience: "read" | "write" | "all";
|
|
205
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
206
|
+
}, {
|
|
207
|
+
readonly code: "permit2-approval-missing";
|
|
208
|
+
readonly status: number;
|
|
209
|
+
readonly title: string;
|
|
210
|
+
readonly type: string;
|
|
211
|
+
readonly audience: "read" | "write" | "all";
|
|
212
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
213
|
+
}, {
|
|
214
|
+
readonly code: "rate-limit-exceeded";
|
|
215
|
+
readonly status: number;
|
|
216
|
+
readonly title: string;
|
|
217
|
+
readonly type: string;
|
|
218
|
+
readonly audience: "read" | "write" | "all";
|
|
219
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
220
|
+
}, {
|
|
221
|
+
readonly code: "internal-error";
|
|
222
|
+
readonly status: number;
|
|
223
|
+
readonly title: string;
|
|
224
|
+
readonly type: string;
|
|
225
|
+
readonly audience: "read" | "write" | "all";
|
|
226
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
227
|
+
}, {
|
|
228
|
+
readonly code: "solver-timeout";
|
|
229
|
+
readonly status: number;
|
|
230
|
+
readonly title: string;
|
|
231
|
+
readonly type: string;
|
|
232
|
+
readonly audience: "read" | "write" | "all";
|
|
233
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
234
|
+
}, {
|
|
235
|
+
readonly code: "service-unavailable";
|
|
236
|
+
readonly status: number;
|
|
237
|
+
readonly title: string;
|
|
238
|
+
readonly type: string;
|
|
239
|
+
readonly audience: "read" | "write" | "all";
|
|
240
|
+
readonly legacyCodes: readonly LegacyCodeRef[];
|
|
241
|
+
}];
|
|
242
|
+
export type V1ErrorCode = (typeof V1_ERROR_CATALOG)[number]['code'];
|
|
243
|
+
export declare function getErrorDefinition(code: V1ErrorCode): V1ErrorDefinition;
|
|
244
|
+
export declare const UNMAPPED_LEGACY_CODES: readonly {
|
|
245
|
+
legacyCode: LegacyCodeRef;
|
|
246
|
+
reason: string;
|
|
247
|
+
}[];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNMAPPED_LEGACY_CODES = exports.V1_ERROR_CATALOG = void 0;
|
|
4
|
+
exports.getErrorDefinition = getErrorDefinition;
|
|
5
|
+
const typeUrl = (code) => `https://api.eco.com/v1/errors/${code}`;
|
|
6
|
+
const define = (code, status, title, audience, legacyCodes = []) => ({ code, status, title, type: typeUrl(code), audience, legacyCodes });
|
|
7
|
+
exports.V1_ERROR_CATALOG = [
|
|
8
|
+
define('invalid-request', 400, 'Request failed validation', 'all', ['eco-quotes:1003']),
|
|
9
|
+
define('missing-parameter', 400, 'A required parameter is missing', 'all', ['eco-quotes:1026']),
|
|
10
|
+
define('invalid-parameter', 400, 'A parameter value is invalid', 'all', [
|
|
11
|
+
'eco-quotes:1032',
|
|
12
|
+
'eco-quotes:1033',
|
|
13
|
+
'eco-quotes:1034',
|
|
14
|
+
'deposit-addresses:1017',
|
|
15
|
+
]),
|
|
16
|
+
define('slippage-out-of-bounds', 400, 'slippage is outside the valid 0-1 range; it is a decimal fraction ' +
|
|
17
|
+
'(0.005 = 0.5%), not a percent (0.5 means 50%)', 'all'),
|
|
18
|
+
define('deposit-address-mismatch', 400, 'The signed erc-3009 `to` does not equal target.depositAddress', 'write'),
|
|
19
|
+
define('invalid-signature', 401, 'Signature verification failed', 'write', [
|
|
20
|
+
'eco-quotes:1007',
|
|
21
|
+
'eco-quotes:1008',
|
|
22
|
+
'eco-quotes:1009',
|
|
23
|
+
'eco-quotes:1010',
|
|
24
|
+
'eco-quotes:1011',
|
|
25
|
+
'deposit-addresses:1000',
|
|
26
|
+
'deposit-addresses:1002',
|
|
27
|
+
]),
|
|
28
|
+
define('authorization-expired', 401, 'The signed authorization window has expired', 'write', [
|
|
29
|
+
'eco-quotes:1006',
|
|
30
|
+
'deposit-addresses:1001',
|
|
31
|
+
'deposit-addresses:1018',
|
|
32
|
+
]),
|
|
33
|
+
define('invalid-api-key', 401, 'API key is missing, unknown, or revoked', 'write'),
|
|
34
|
+
define('api-key-expired', 401, 'API key has expired', 'write'),
|
|
35
|
+
define('permission-denied', 403, 'The caller may not perform this operation', 'all', [
|
|
36
|
+
'eco-quotes:1035',
|
|
37
|
+
]),
|
|
38
|
+
define('funder-mismatch', 403, 'The quote funder does not match the recovered signer', 'write'),
|
|
39
|
+
define('token-not-found', 404, 'Token is unknown on the requested chain', 'all', [
|
|
40
|
+
'eco-quotes:1030',
|
|
41
|
+
]),
|
|
42
|
+
define('signature-already-bound', 409, 'This signature is already pinned to a different target', 'write'),
|
|
43
|
+
define('nonce-used', 409, 'The nonce is already consumed on-chain', 'write'),
|
|
44
|
+
define('quote-expired', 410, 'The quote is unknown or expired at submit time', 'write', [
|
|
45
|
+
'eco-quotes:1027',
|
|
46
|
+
]),
|
|
47
|
+
define('no-route-found', 422, 'No solver can serve the requested route', 'all', [
|
|
48
|
+
'eco-quotes:1016',
|
|
49
|
+
'eco-quotes:1017',
|
|
50
|
+
'eco-quotes:1018',
|
|
51
|
+
]),
|
|
52
|
+
define('token-not-supported', 422, 'Token is not supported for this operation', 'all', [
|
|
53
|
+
'eco-quotes:1029',
|
|
54
|
+
'deposit-addresses:1007',
|
|
55
|
+
]),
|
|
56
|
+
define('simulation-failed', 422, 'Fulfillment simulation of the call-bearing quote failed', 'all'),
|
|
57
|
+
define('insufficient-funds', 422, 'The signer balance cannot cover the transfer', 'write', [
|
|
58
|
+
'deposit-addresses:1019',
|
|
59
|
+
]),
|
|
60
|
+
define('chain-not-supported', 422, 'Chain is not supported', 'all', [
|
|
61
|
+
'deposit-addresses:1015',
|
|
62
|
+
'deposit-addresses:1016',
|
|
63
|
+
]),
|
|
64
|
+
define('chain-pair-unsupported', 422, 'This source/destination pair is not available', 'all'),
|
|
65
|
+
define('amount-too-low', 422, 'Amount is below the minimum transfer threshold', 'all'),
|
|
66
|
+
define('amount-too-high', 422, 'Amount exceeds the configured maximum order size (not a liquidity shortfall — ' +
|
|
67
|
+
'see insufficient-liquidity)', 'all'),
|
|
68
|
+
define('insufficient-liquidity', 422, 'The route cannot fill an order this size', 'all'),
|
|
69
|
+
define('insufficient-balance', 422, 'The wallet balance cannot cover the amount', 'all'),
|
|
70
|
+
define('insufficient-allowance', 422, 'The permit or approval is insufficient', 'all'),
|
|
71
|
+
define('insufficient-gas', 422, 'Not enough native token to cover gas', 'all'),
|
|
72
|
+
define('unsupported-authorization', 422, 'The token does not implement this signature standard — check /v1/tokens supports[]', 'write'),
|
|
73
|
+
define('permit2-approval-missing', 422, 'permit2 requires a prior approve() to the Permit2 contract', 'write'),
|
|
74
|
+
define('rate-limit-exceeded', 429, 'Rate limit exceeded', 'all'),
|
|
75
|
+
define('internal-error', 500, 'Internal error', 'all', [
|
|
76
|
+
'eco-quotes:1000',
|
|
77
|
+
'eco-quotes:1001',
|
|
78
|
+
'eco-quotes:1002',
|
|
79
|
+
'eco-quotes:1004',
|
|
80
|
+
'eco-quotes:1005',
|
|
81
|
+
'eco-quotes:1012',
|
|
82
|
+
'eco-quotes:1013',
|
|
83
|
+
'eco-quotes:1014',
|
|
84
|
+
'eco-quotes:1022',
|
|
85
|
+
'eco-quotes:1023',
|
|
86
|
+
'eco-quotes:1031',
|
|
87
|
+
'deposit-addresses:1003',
|
|
88
|
+
'deposit-addresses:1004',
|
|
89
|
+
'deposit-addresses:1005',
|
|
90
|
+
'deposit-addresses:1006',
|
|
91
|
+
'deposit-addresses:1008',
|
|
92
|
+
'deposit-addresses:1009',
|
|
93
|
+
'deposit-addresses:1010',
|
|
94
|
+
'deposit-addresses:1011',
|
|
95
|
+
'deposit-addresses:1012',
|
|
96
|
+
'deposit-addresses:1013',
|
|
97
|
+
'deposit-addresses:1020',
|
|
98
|
+
]),
|
|
99
|
+
define('solver-timeout', 502, 'Upstream solver quote fan-out timed out', 'all', [
|
|
100
|
+
'eco-quotes:1024',
|
|
101
|
+
'eco-quotes:1025',
|
|
102
|
+
]),
|
|
103
|
+
define('service-unavailable', 503, 'Service temporarily unavailable', 'all'),
|
|
104
|
+
];
|
|
105
|
+
const BY_CODE = new Map(exports.V1_ERROR_CATALOG.map((e) => [e.code, e]));
|
|
106
|
+
function getErrorDefinition(code) {
|
|
107
|
+
const def = BY_CODE.get(code);
|
|
108
|
+
if (!def)
|
|
109
|
+
throw new Error(`unknown v1 error code: ${code}`);
|
|
110
|
+
return def;
|
|
111
|
+
}
|
|
112
|
+
exports.UNMAPPED_LEGACY_CODES = [
|
|
113
|
+
{ legacyCode: 'eco-quotes:1015', reason: 'solver-registry admin surface is out of v1' },
|
|
114
|
+
{ legacyCode: 'eco-quotes:1019', reason: 'solver-registry admin surface is out of v1' },
|
|
115
|
+
{ legacyCode: 'eco-quotes:1020', reason: 'solver-registry admin surface is out of v1' },
|
|
116
|
+
{ legacyCode: 'eco-quotes:1021', reason: 'solver-registry admin surface is out of v1' },
|
|
117
|
+
{ legacyCode: 'eco-quotes:1036', reason: 'solver-registry admin surface is out of v1' },
|
|
118
|
+
{ legacyCode: 'eco-quotes:1028', reason: 'IntentNotFound folds into status "unknown" (D11)' },
|
|
119
|
+
{
|
|
120
|
+
legacyCode: 'deposit-addresses:1014',
|
|
121
|
+
reason: 'NoSuchDepositAddress folds into status "unknown" / empty lookup result (D11)',
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/v1/errors/catalog.ts"],"names":[],"mappings":";;;AAyLA,gDAIC;AAtKD,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,iCAAiC,IAAI,EAAE,CAAC;AAE1E,MAAM,MAAM,GAAG,CACb,IAAO,EACP,MAAc,EACd,KAAa,EACb,QAAkC,EAClC,cAAwC,EAAE,EAC1C,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAU,CAAC;AAEvE,QAAA,gBAAgB,GAAG;IAC9B,MAAM,CAAC,iBAAiB,EAAE,GAAG,EAAE,2BAA2B,EAAE,KAAK,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACvF,MAAM,CAAC,mBAAmB,EAAE,GAAG,EAAE,iCAAiC,EAAE,KAAK,EAAE,CAAC,iBAAiB,CAAC,CAAC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UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,4CAA4C,EAAE;IACvF,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,4CAA4C,EAAE;IACvF,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,kDAAkD,EAAE;IAC7F;QACE,UAAU,EAAE,wBAAwB;QACpC,MAAM,EAAE,8EAA8E;KACvF;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { V1ErrorDefinition } from './catalog';
|
|
2
|
+
export interface CatalogLockEntry {
|
|
3
|
+
code: string;
|
|
4
|
+
status: number;
|
|
5
|
+
legacyCodes: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function toLockEntries(catalog: readonly V1ErrorDefinition[]): CatalogLockEntry[];
|
|
8
|
+
export declare function serializeLock(catalog: readonly V1ErrorDefinition[]): string;
|
|
9
|
+
export declare function diffCatalogAgainstLock(catalog: readonly V1ErrorDefinition[], lock: readonly CatalogLockEntry[]): string[];
|
|
10
|
+
export declare function diffLockAgainstBaseline(baseline: readonly CatalogLockEntry[], current: readonly CatalogLockEntry[]): string[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toLockEntries = toLockEntries;
|
|
4
|
+
exports.serializeLock = serializeLock;
|
|
5
|
+
exports.diffCatalogAgainstLock = diffCatalogAgainstLock;
|
|
6
|
+
exports.diffLockAgainstBaseline = diffLockAgainstBaseline;
|
|
7
|
+
function toLockEntries(catalog) {
|
|
8
|
+
return catalog.map(({ code, status, legacyCodes }) => ({
|
|
9
|
+
code,
|
|
10
|
+
status,
|
|
11
|
+
legacyCodes: [...legacyCodes],
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function serializeLock(catalog) {
|
|
15
|
+
return `${JSON.stringify(toLockEntries(catalog), null, 2)}\n`;
|
|
16
|
+
}
|
|
17
|
+
function diffCatalogAgainstLock(catalog, lock) {
|
|
18
|
+
const expected = toLockEntries(catalog);
|
|
19
|
+
if (JSON.stringify(expected) === JSON.stringify(lock))
|
|
20
|
+
return [];
|
|
21
|
+
return ['errors/catalog.lock.json is out of sync — run: pnpm run catalog:lock'];
|
|
22
|
+
}
|
|
23
|
+
function diffLockAgainstBaseline(baseline, current) {
|
|
24
|
+
const violations = [];
|
|
25
|
+
const byCode = new Map();
|
|
26
|
+
for (const entry of current) {
|
|
27
|
+
if (byCode.has(entry.code)) {
|
|
28
|
+
violations.push(`duplicate error code in lock: ${entry.code}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
byCode.set(entry.code, entry);
|
|
32
|
+
}
|
|
33
|
+
for (const entry of baseline) {
|
|
34
|
+
const now = byCode.get(entry.code);
|
|
35
|
+
if (!now) {
|
|
36
|
+
violations.push(`error code removed: ${entry.code} — the catalog is append-only`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (JSON.stringify(now) !== JSON.stringify(entry)) {
|
|
40
|
+
violations.push(`error code mutated: ${entry.code} — status/legacyCodes freeze once published`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return violations;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../src/v1/errors/lock.ts"],"names":[],"mappings":";;AAgBA,sCAMC;AAGD,sCAEC;AAGD,wDAOC;AAOD,0DA8BC;AA1DD,SAAgB,aAAa,CAAC,OAAqC;IACjE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI;QACJ,MAAM;QACN,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC;KAC9B,CAAC,CAAC,CAAC;AACN,CAAC;AAGD,SAAgB,aAAa,CAAC,OAAqC;IACj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K,CAAC,IAAI,6CAA6C,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LegacyCodeRef, V1ErrorCode } from './catalog';
|
|
3
|
+
export declare const PROBLEM_CONTENT_TYPE = "application/problem+json";
|
|
4
|
+
export interface V1SolverError {
|
|
5
|
+
solver: string;
|
|
6
|
+
solverName?: string;
|
|
7
|
+
code?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface V1Problem {
|
|
11
|
+
type: string;
|
|
12
|
+
title: string;
|
|
13
|
+
status: number;
|
|
14
|
+
code: V1ErrorCode;
|
|
15
|
+
detail?: string;
|
|
16
|
+
instance?: string;
|
|
17
|
+
legacyCode?: LegacyCodeRef;
|
|
18
|
+
solverErrors?: V1SolverError[];
|
|
19
|
+
[extension: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare const V1SolverErrorSchema: z.ZodObject<{
|
|
22
|
+
solver: z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>]>;
|
|
23
|
+
solverName: z.ZodOptional<z.ZodString>;
|
|
24
|
+
code: z.ZodOptional<z.ZodString>;
|
|
25
|
+
message: z.ZodString;
|
|
26
|
+
}, z.core.$loose>;
|
|
27
|
+
export declare const V1ProblemSchema: z.ZodObject<{
|
|
28
|
+
type: z.ZodURL;
|
|
29
|
+
title: z.ZodString;
|
|
30
|
+
status: z.ZodNumber;
|
|
31
|
+
code: z.ZodString;
|
|
32
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
33
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
34
|
+
legacyCode: z.ZodOptional<z.ZodString>;
|
|
35
|
+
solverErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
solver: z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodString]>]>;
|
|
37
|
+
solverName: z.ZodOptional<z.ZodString>;
|
|
38
|
+
code: z.ZodOptional<z.ZodString>;
|
|
39
|
+
message: z.ZodString;
|
|
40
|
+
}, z.core.$loose>>>;
|
|
41
|
+
}, z.core.$loose>;
|
|
42
|
+
export declare const PROBLEM_RESERVED_MEMBERS: readonly ["type", "title", "status", "code", "detail", "instance", "legacyCode", "solverErrors"];
|
|
43
|
+
export interface ProblemOptions {
|
|
44
|
+
detail?: string;
|
|
45
|
+
instance?: string;
|
|
46
|
+
legacyCode?: LegacyCodeRef;
|
|
47
|
+
solverErrors?: V1SolverError[];
|
|
48
|
+
extensions?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export declare function problem(code: V1ErrorCode, opts?: ProblemOptions): V1Problem;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROBLEM_RESERVED_MEMBERS = exports.V1ProblemSchema = exports.V1SolverErrorSchema = exports.PROBLEM_CONTENT_TYPE = void 0;
|
|
4
|
+
exports.problem = problem;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const primitives_1 = require("../primitives");
|
|
7
|
+
const catalog_1 = require("./catalog");
|
|
8
|
+
exports.PROBLEM_CONTENT_TYPE = 'application/problem+json';
|
|
9
|
+
exports.V1SolverErrorSchema = zod_1.z.looseObject({
|
|
10
|
+
solver: primitives_1.AnyAddress,
|
|
11
|
+
solverName: zod_1.z.string().min(1).optional(),
|
|
12
|
+
code: zod_1.z.string().min(1).optional(),
|
|
13
|
+
message: zod_1.z.string(),
|
|
14
|
+
});
|
|
15
|
+
const CATALOG_BY_CODE = new Map(catalog_1.V1_ERROR_CATALOG.map((e) => [e.code, e]));
|
|
16
|
+
exports.V1ProblemSchema = zod_1.z
|
|
17
|
+
.looseObject({
|
|
18
|
+
type: zod_1.z.url(),
|
|
19
|
+
title: zod_1.z.string().min(1),
|
|
20
|
+
status: zod_1.z.number().int().min(400).max(599),
|
|
21
|
+
code: zod_1.z.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/),
|
|
22
|
+
detail: zod_1.z.string().optional(),
|
|
23
|
+
instance: zod_1.z.string().optional(),
|
|
24
|
+
legacyCode: zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^(eco-quotes|deposit-addresses):\d{4}$/)
|
|
27
|
+
.optional(),
|
|
28
|
+
solverErrors: zod_1.z.array(exports.V1SolverErrorSchema).optional(),
|
|
29
|
+
})
|
|
30
|
+
.superRefine((body, ctx) => {
|
|
31
|
+
const def = CATALOG_BY_CODE.get(body.code);
|
|
32
|
+
if (!def)
|
|
33
|
+
return;
|
|
34
|
+
if (body.status !== def.status) {
|
|
35
|
+
ctx.addIssue({
|
|
36
|
+
code: 'custom',
|
|
37
|
+
path: ['status'],
|
|
38
|
+
message: `status ${body.status} contradicts the catalog status ` +
|
|
39
|
+
`${def.status} for code ${body.code}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (body.type !== def.type) {
|
|
43
|
+
ctx.addIssue({
|
|
44
|
+
code: 'custom',
|
|
45
|
+
path: ['type'],
|
|
46
|
+
message: `type ${body.type} is not the catalog type ${def.type} for code ${body.code}`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
exports.PROBLEM_RESERVED_MEMBERS = [
|
|
51
|
+
'type',
|
|
52
|
+
'title',
|
|
53
|
+
'status',
|
|
54
|
+
'code',
|
|
55
|
+
'detail',
|
|
56
|
+
'instance',
|
|
57
|
+
'legacyCode',
|
|
58
|
+
'solverErrors',
|
|
59
|
+
];
|
|
60
|
+
function problem(code, opts = {}) {
|
|
61
|
+
const def = (0, catalog_1.getErrorDefinition)(code);
|
|
62
|
+
for (const key of Object.keys(opts.extensions ?? {})) {
|
|
63
|
+
if (exports.PROBLEM_RESERVED_MEMBERS.includes(key)) {
|
|
64
|
+
throw new Error(`extensions.${key} is a reserved problem member — use the named option`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (opts.legacyCode !== undefined && !def.legacyCodes.includes(opts.legacyCode)) {
|
|
68
|
+
throw new Error(`${opts.legacyCode} is not a legacy code of ${code}`);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
...opts.extensions,
|
|
72
|
+
type: def.type,
|
|
73
|
+
title: def.title,
|
|
74
|
+
status: def.status,
|
|
75
|
+
code,
|
|
76
|
+
...(opts.detail !== undefined ? { detail: opts.detail } : {}),
|
|
77
|
+
...(opts.instance !== undefined ? { instance: opts.instance } : {}),
|
|
78
|
+
...(opts.legacyCode !== undefined ? { legacyCode: opts.legacyCode } : {}),
|
|
79
|
+
...(opts.solverErrors !== undefined ? { solverErrors: opts.solverErrors } : {}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=problem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.js","sourceRoot":"","sources":["../../../src/v1/errors/problem.ts"],"names":[],"mappings":";;;AA0JA,0BAqBC;AA/KD,6BAAwB;AAExB,8CAA2C;AAC3C,uCAA6F;AA8BhF,QAAA,oBAAoB,GAAG,0BAA0B,CAAC;AA0ClD,QAAA,mBAAmB,GAAG,OAAC,CAAC,WAAW,CAAC;IAC/C,MAAM,EAAE,uBAAU;IAClB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,IAAI,GAAG,CAC7B,0BAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAA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