@shipstatic/types 2.5.0-beta.13 → 2.5.0-beta.15
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/dist/index.d.ts +9 -1
- package/dist/index.js +27 -3
- package/package.json +1 -1
- package/src/index.ts +29 -3
package/dist/index.d.ts
CHANGED
|
@@ -552,7 +552,15 @@ export interface AccountOverrides {
|
|
|
552
552
|
* (`DeploymentStatus`, `DomainStatus`, `AccountPlan`, `AuthMethod`) follow.
|
|
553
553
|
*/
|
|
554
554
|
export declare const ErrorType: {
|
|
555
|
-
/**
|
|
555
|
+
/**
|
|
556
|
+
* Validation failed. Input shape is wrong.
|
|
557
|
+
*
|
|
558
|
+
* Carries 400 when an API judged it — including a client-side pre-check of a
|
|
559
|
+
* rule the server enforces too, which keeps the error identical wherever it
|
|
560
|
+
* was caught. **Statusless** when a client rejects something no API judges,
|
|
561
|
+
* such as a CLI's own command grammar: `status` is documented "(API
|
|
562
|
+
* contexts)" on `ErrorResponse`, so there is none to report.
|
|
563
|
+
*/
|
|
556
564
|
readonly Validation: "validation_failed";
|
|
557
565
|
/** Resource not found (404). */
|
|
558
566
|
readonly NotFound: "not_found";
|
package/dist/index.js
CHANGED
|
@@ -147,7 +147,15 @@ export const AccountPlan = {
|
|
|
147
147
|
* (`DeploymentStatus`, `DomainStatus`, `AccountPlan`, `AuthMethod`) follow.
|
|
148
148
|
*/
|
|
149
149
|
export const ErrorType = {
|
|
150
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Validation failed. Input shape is wrong.
|
|
152
|
+
*
|
|
153
|
+
* Carries 400 when an API judged it — including a client-side pre-check of a
|
|
154
|
+
* rule the server enforces too, which keeps the error identical wherever it
|
|
155
|
+
* was caught. **Statusless** when a client rejects something no API judges,
|
|
156
|
+
* such as a CLI's own command grammar: `status` is documented "(API
|
|
157
|
+
* contexts)" on `ErrorResponse`, so there is none to report.
|
|
158
|
+
*/
|
|
151
159
|
Validation: 'validation_failed',
|
|
152
160
|
/** Resource not found (404). */
|
|
153
161
|
NotFound: 'not_found',
|
|
@@ -214,6 +222,14 @@ const ERROR_CATEGORIES = {
|
|
|
214
222
|
* `ErrorType` is automatically picked up.
|
|
215
223
|
*/
|
|
216
224
|
const SERVER_PRODUCIBLE_ERROR_TYPES = new Set(Object.values(ErrorType).filter((t) => !CLIENT_ONLY_ERROR_TYPES.has(t)));
|
|
225
|
+
/**
|
|
226
|
+
* Ceiling on a message adopted from a **non-JSON** error body — a foreign
|
|
227
|
+
* responder's, never this platform's. Generous for the plain-text one-liners
|
|
228
|
+
* intermediaries actually send (`error code: 1015`), far below a document.
|
|
229
|
+
* Our own messages are never measured against it: a JSON body is the API's
|
|
230
|
+
* contract, and truncating a long validation message would be the bug.
|
|
231
|
+
*/
|
|
232
|
+
const MAX_FOREIGN_MESSAGE_LENGTH = 200;
|
|
217
233
|
/**
|
|
218
234
|
* Simple unified error class for both API and SDK
|
|
219
235
|
*/
|
|
@@ -285,9 +301,17 @@ export class ShipError extends Error {
|
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
303
|
else {
|
|
288
|
-
|
|
289
|
-
|
|
304
|
+
// A non-JSON body did not come from this platform — every API error
|
|
305
|
+
// is `ErrorResponse` JSON — so it is an intermediary's output, and
|
|
306
|
+
// the two kinds it produces need opposite treatment. A CDN's plain
|
|
307
|
+
// `error code: 1015` is the most useful thing there is to say. A
|
|
308
|
+
// proxy's HTML error page is a *document*, not a message: adopting it
|
|
309
|
+
// verbatim made a misconfigured `apiUrl` print 2,059 characters of
|
|
310
|
+
// markup as the error. Trust it only when it reads as a message.
|
|
311
|
+
const text = (await response.text()).trim();
|
|
312
|
+
if (text && !text.startsWith('<') && text.length <= MAX_FOREIGN_MESSAGE_LENGTH) {
|
|
290
313
|
message = text;
|
|
314
|
+
}
|
|
291
315
|
}
|
|
292
316
|
}
|
|
293
317
|
catch {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -627,7 +627,15 @@ export interface AccountOverrides {
|
|
|
627
627
|
* (`DeploymentStatus`, `DomainStatus`, `AccountPlan`, `AuthMethod`) follow.
|
|
628
628
|
*/
|
|
629
629
|
export const ErrorType = {
|
|
630
|
-
/**
|
|
630
|
+
/**
|
|
631
|
+
* Validation failed. Input shape is wrong.
|
|
632
|
+
*
|
|
633
|
+
* Carries 400 when an API judged it — including a client-side pre-check of a
|
|
634
|
+
* rule the server enforces too, which keeps the error identical wherever it
|
|
635
|
+
* was caught. **Statusless** when a client rejects something no API judges,
|
|
636
|
+
* such as a CLI's own command grammar: `status` is documented "(API
|
|
637
|
+
* contexts)" on `ErrorResponse`, so there is none to report.
|
|
638
|
+
*/
|
|
631
639
|
Validation: 'validation_failed',
|
|
632
640
|
/** Resource not found (404). */
|
|
633
641
|
NotFound: 'not_found',
|
|
@@ -702,6 +710,15 @@ const SERVER_PRODUCIBLE_ERROR_TYPES = new Set<string>(
|
|
|
702
710
|
Object.values(ErrorType).filter((t) => !CLIENT_ONLY_ERROR_TYPES.has(t)),
|
|
703
711
|
);
|
|
704
712
|
|
|
713
|
+
/**
|
|
714
|
+
* Ceiling on a message adopted from a **non-JSON** error body — a foreign
|
|
715
|
+
* responder's, never this platform's. Generous for the plain-text one-liners
|
|
716
|
+
* intermediaries actually send (`error code: 1015`), far below a document.
|
|
717
|
+
* Our own messages are never measured against it: a JSON body is the API's
|
|
718
|
+
* contract, and truncating a long validation message would be the bug.
|
|
719
|
+
*/
|
|
720
|
+
const MAX_FOREIGN_MESSAGE_LENGTH = 200;
|
|
721
|
+
|
|
705
722
|
/**
|
|
706
723
|
* Standard error response format used everywhere
|
|
707
724
|
*/
|
|
@@ -788,8 +805,17 @@ export class ShipError extends Error {
|
|
|
788
805
|
}
|
|
789
806
|
}
|
|
790
807
|
} else {
|
|
791
|
-
|
|
792
|
-
|
|
808
|
+
// A non-JSON body did not come from this platform — every API error
|
|
809
|
+
// is `ErrorResponse` JSON — so it is an intermediary's output, and
|
|
810
|
+
// the two kinds it produces need opposite treatment. A CDN's plain
|
|
811
|
+
// `error code: 1015` is the most useful thing there is to say. A
|
|
812
|
+
// proxy's HTML error page is a *document*, not a message: adopting it
|
|
813
|
+
// verbatim made a misconfigured `apiUrl` print 2,059 characters of
|
|
814
|
+
// markup as the error. Trust it only when it reads as a message.
|
|
815
|
+
const text = (await response.text()).trim();
|
|
816
|
+
if (text && !text.startsWith('<') && text.length <= MAX_FOREIGN_MESSAGE_LENGTH) {
|
|
817
|
+
message = text;
|
|
818
|
+
}
|
|
793
819
|
}
|
|
794
820
|
} catch {
|
|
795
821
|
// Body unreadable; fall through to operationName-derived message.
|