@pipelex/sdk 0.32.0 → 0.33.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 +20 -4
- package/dist/artifacts.js +23 -9
- package/dist/artifacts.js.map +1 -1
- package/dist/client.d.ts +78 -12
- package/dist/client.js +234 -86
- package/dist/client.js.map +1 -1
- package/dist/codegen-check.d.ts +9 -0
- package/dist/codegen-check.js +12 -6
- package/dist/codegen-check.js.map +1 -1
- package/dist/error-models.d.ts +60 -2
- package/dist/error-models.js +169 -3
- package/dist/error-models.js.map +1 -1
- package/dist/error-verdicts.d.ts +34 -0
- package/dist/error-verdicts.js +69 -0
- package/dist/error-verdicts.js.map +1 -0
- package/dist/errors.d.ts +210 -46
- package/dist/errors.js +289 -62
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/prepare-inputs.js +26 -5
- package/dist/prepare-inputs.js.map +1 -1
- package/dist/upload-grant.d.ts +15 -10
- package/dist/upload-grant.js +36 -17
- package/dist/upload-grant.js.map +1 -1
- package/dist/upload.js +17 -4
- package/dist/upload.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +8 -7
- package/docs/artifact-download.md +3 -3
- package/docs/errors.md +93 -10
- package/docs/input-preparation.md +11 -7
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verdict an `ApiResponseError` falls back to when the server sent no usable member.
|
|
3
|
+
*
|
|
4
|
+
* A problem document may carry `retryable` and `error_domain`, and when it does the error takes
|
|
5
|
+
* them (see `ApiResponseError`). When it does not — the platform does not classify its own
|
|
6
|
+
* refusals yet, a gateway answers an HTML page, a bare runner answers Starlette's
|
|
7
|
+
* `{"detail": "Not Found"}` — each missing member is read off this table instead, so a consumer
|
|
8
|
+
* never has to choose its own default. The one exception is a `retryable` missing beside a sent
|
|
9
|
+
* `input` or `config` domain, which is not retryable whatever the status. The table reads only the
|
|
10
|
+
* HTTP status, the platform's native `code`, and whether the body names what it refused.
|
|
11
|
+
*
|
|
12
|
+
* It is also the platform's reference: the verdicts the platform will send on its own refusals
|
|
13
|
+
* are decided against this table, so a refusal keeps its verdict when the platform starts
|
|
14
|
+
* sending one. The Python twin, `pipelex-sdk`, must apply the same table. The case file
|
|
15
|
+
* `tests/fixtures/error-verdicts.json` holds every row, and this package's suite drives the table
|
|
16
|
+
* through it; the Python suite is to drive its own code through an identical copy, once that copy
|
|
17
|
+
* is added.
|
|
18
|
+
*/
|
|
19
|
+
import type { ErrorVerdict } from "./errors.js";
|
|
20
|
+
/**
|
|
21
|
+
* The verdict of a refused request whose problem document carried no usable member.
|
|
22
|
+
*
|
|
23
|
+
* - `status` is the HTTP status of the answer.
|
|
24
|
+
* - `code` is the platform's native code, when the body carried one.
|
|
25
|
+
* - `named` says whether the body names what it refused: a platform `code` or a runner
|
|
26
|
+
* `error_type`. It decides a `404`: a named one is a resource the caller asked for that does not
|
|
27
|
+
* exist (`input`), a bare one is a route the deployment does not serve (`config`).
|
|
28
|
+
*
|
|
29
|
+
* Every `4xx` the table does not list is the caller's request refused (`input`, not retryable),
|
|
30
|
+
* every `5xx` it does not list is a fault in the service that may pass (`runtime`, retryable),
|
|
31
|
+
* and any other status is one no refusal carries, such as the `2xx` of an answer the client could
|
|
32
|
+
* not read, so nothing says a retry helps (`runtime`, not retryable).
|
|
33
|
+
*/
|
|
34
|
+
export declare function fallbackVerdict(status: number, code: string | undefined, named: boolean): ErrorVerdict;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verdict an `ApiResponseError` falls back to when the server sent no usable member.
|
|
3
|
+
*
|
|
4
|
+
* A problem document may carry `retryable` and `error_domain`, and when it does the error takes
|
|
5
|
+
* them (see `ApiResponseError`). When it does not — the platform does not classify its own
|
|
6
|
+
* refusals yet, a gateway answers an HTML page, a bare runner answers Starlette's
|
|
7
|
+
* `{"detail": "Not Found"}` — each missing member is read off this table instead, so a consumer
|
|
8
|
+
* never has to choose its own default. The one exception is a `retryable` missing beside a sent
|
|
9
|
+
* `input` or `config` domain, which is not retryable whatever the status. The table reads only the
|
|
10
|
+
* HTTP status, the platform's native `code`, and whether the body names what it refused.
|
|
11
|
+
*
|
|
12
|
+
* It is also the platform's reference: the verdicts the platform will send on its own refusals
|
|
13
|
+
* are decided against this table, so a refusal keeps its verdict when the platform starts
|
|
14
|
+
* sending one. The Python twin, `pipelex-sdk`, must apply the same table. The case file
|
|
15
|
+
* `tests/fixtures/error-verdicts.json` holds every row, and this package's suite drives the table
|
|
16
|
+
* through it; the Python suite is to drive its own code through an identical copy, once that copy
|
|
17
|
+
* is added.
|
|
18
|
+
*/
|
|
19
|
+
const INPUT = Object.freeze({ errorDomain: "input", retryable: false });
|
|
20
|
+
const CONFIG = Object.freeze({ errorDomain: "config", retryable: false });
|
|
21
|
+
const TRANSIENT = Object.freeze({ errorDomain: "runtime", retryable: true });
|
|
22
|
+
const FAULT = Object.freeze({ errorDomain: "runtime", retryable: false });
|
|
23
|
+
/** The platform code a `409` carries when the organization holds as many API keys as it may. */
|
|
24
|
+
const API_KEY_LIMIT_CODE = "pipelex_api_key_limit_reached";
|
|
25
|
+
/**
|
|
26
|
+
* The verdict of a refused request whose problem document carried no usable member.
|
|
27
|
+
*
|
|
28
|
+
* - `status` is the HTTP status of the answer.
|
|
29
|
+
* - `code` is the platform's native code, when the body carried one.
|
|
30
|
+
* - `named` says whether the body names what it refused: a platform `code` or a runner
|
|
31
|
+
* `error_type`. It decides a `404`: a named one is a resource the caller asked for that does not
|
|
32
|
+
* exist (`input`), a bare one is a route the deployment does not serve (`config`).
|
|
33
|
+
*
|
|
34
|
+
* Every `4xx` the table does not list is the caller's request refused (`input`, not retryable),
|
|
35
|
+
* every `5xx` it does not list is a fault in the service that may pass (`runtime`, retryable),
|
|
36
|
+
* and any other status is one no refusal carries, such as the `2xx` of an answer the client could
|
|
37
|
+
* not read, so nothing says a retry helps (`runtime`, not retryable).
|
|
38
|
+
*/
|
|
39
|
+
export function fallbackVerdict(status, code, named) {
|
|
40
|
+
switch (status) {
|
|
41
|
+
case 401:
|
|
42
|
+
case 402:
|
|
43
|
+
case 403:
|
|
44
|
+
// The credential, the plan or the access must change.
|
|
45
|
+
return CONFIG;
|
|
46
|
+
case 404:
|
|
47
|
+
return named ? INPUT : CONFIG;
|
|
48
|
+
case 405:
|
|
49
|
+
// The deployment does not serve this method on the route.
|
|
50
|
+
return CONFIG;
|
|
51
|
+
case 408:
|
|
52
|
+
case 429:
|
|
53
|
+
// Refused for its timing, not its content.
|
|
54
|
+
return TRANSIENT;
|
|
55
|
+
case 409:
|
|
56
|
+
// A conflict with the stored state is the caller's, except the key limit, which someone
|
|
57
|
+
// lifts by removing a key.
|
|
58
|
+
return code === API_KEY_LIMIT_CODE ? CONFIG : INPUT;
|
|
59
|
+
case 501:
|
|
60
|
+
// The deployment does not implement it, and asking again will not change that.
|
|
61
|
+
return CONFIG;
|
|
62
|
+
}
|
|
63
|
+
if (status >= 400 && status < 500)
|
|
64
|
+
return INPUT;
|
|
65
|
+
if (status >= 500 && status < 600)
|
|
66
|
+
return TRANSIENT;
|
|
67
|
+
return FAULT;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=error-verdicts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-verdicts.js","sourceRoot":"","sources":["../src/error-verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,KAAK,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACtF,MAAM,MAAM,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACxF,MAAM,SAAS,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3F,MAAM,KAAK,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAExF,gGAAgG;AAChG,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,IAAwB,EACxB,KAAc;IAEd,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,sDAAsD;YACtD,OAAO,MAAM,CAAC;QAChB,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,KAAK,GAAG;YACN,0DAA0D;YAC1D,OAAO,MAAM,CAAC;QAChB,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,2CAA2C;YAC3C,OAAO,SAAS,CAAC;QACnB,KAAK,GAAG;YACN,wFAAwF;YACxF,2BAA2B;YAC3B,OAAO,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACtD,KAAK,GAAG;YACN,+EAA+E;YAC/E,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pipelex SDK errors — transport
|
|
3
|
-
* `PipelexApiClient
|
|
4
|
-
* (re-exported from `mthds/protocol`),
|
|
2
|
+
* Pipelex SDK errors — the argument, transport, run-lifecycle, input-preparation and artifact
|
|
3
|
+
* errors `PipelexApiClient` raises. Every one derives from `PipelexRequestError`, itself a
|
|
4
|
+
* `PipelineRequestError` (the protocol base, re-exported from `mthds/protocol`), and so carries
|
|
5
|
+
* a verdict: `retryable` and `errorDomain`, always decided. The one exported error outside the
|
|
6
|
+
* family, `CodegenLockError`, declares the same two members itself.
|
|
5
7
|
*/
|
|
6
8
|
import { PipelineRequestError } from "mthds/protocol";
|
|
7
9
|
import type { ValidationErrorItem } from "./models.js";
|
|
@@ -9,18 +11,97 @@ import type { ArtifactScope, DownloadArtifactsResult } from "./artifacts.js";
|
|
|
9
11
|
import type { FieldError, MigrationErrorBlock, ProblemDetails, ProviderErrorMetadata, RunErrorReport, UserAction } from "./error-models.js";
|
|
10
12
|
import type { RunStatus } from "./runs.js";
|
|
11
13
|
export { PipelineRequestError };
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Who can fix a failure:
|
|
16
|
+
*
|
|
17
|
+
* - `input` — the caller, by changing the request: the inputs, the method, a reference, an
|
|
18
|
+
* argument.
|
|
19
|
+
* - `config` — someone changing the environment: the base URL, the credential, the plan, the
|
|
20
|
+
* deployment.
|
|
21
|
+
* - `runtime` — nobody beforehand: a fault during execution or in the service.
|
|
22
|
+
*
|
|
23
|
+
* The set is closed: the hosted envelope spec names these three, so a fourth would be a contract
|
|
24
|
+
* change and would reach the SDK as one.
|
|
25
|
+
*/
|
|
26
|
+
export type ErrorDomain = "input" | "config" | "runtime";
|
|
27
|
+
/** Whether a value is one of the three error domains. */
|
|
28
|
+
export declare function isErrorDomain(value: unknown): value is ErrorDomain;
|
|
29
|
+
/**
|
|
30
|
+
* The verdict an error carries: whether asking again can plausibly succeed (`retryable`), and who
|
|
31
|
+
* can fix the failure (`errorDomain`). Both are always decided.
|
|
32
|
+
*
|
|
33
|
+
* "Retryable" says a retry can succeed, never that it is safe: it says nothing about whether the
|
|
34
|
+
* first attempt had an effect. A start answered with a `500` may already have created a run, so a
|
|
35
|
+
* caller that must not start a run twice decides that for itself.
|
|
36
|
+
*/
|
|
37
|
+
export interface ErrorVerdict {
|
|
38
|
+
readonly retryable: boolean;
|
|
39
|
+
readonly errorDomain: ErrorDomain;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The base of every error this SDK raises over a request, carrying the verdict as two readonly
|
|
43
|
+
* own properties: `retryable` and `errorDomain`. Each subclass passes its verdict to this
|
|
44
|
+
* constructor, so a class that forgets one does not compile, and every class says its verdict
|
|
45
|
+
* where it is defined.
|
|
46
|
+
*
|
|
47
|
+
* It refines the standard's `PipelineRequestError`, so `instanceof PipelineRequestError` still
|
|
48
|
+
* matches every SDK error. To read a verdict from anything a `catch` holds, use
|
|
49
|
+
* `errorVerdictOf`, which also reads it off an error raised by another copy of this SDK.
|
|
50
|
+
*/
|
|
51
|
+
export declare abstract class PipelexRequestError extends PipelineRequestError implements ErrorVerdict {
|
|
52
|
+
/** Whether asking again can plausibly succeed. Always decided. */
|
|
53
|
+
readonly retryable: boolean;
|
|
54
|
+
/** Who can fix the failure: `input`, `config` or `runtime`. Always decided. */
|
|
55
|
+
readonly errorDomain: ErrorDomain;
|
|
56
|
+
constructor(message: string, verdict: ErrorVerdict, options?: {
|
|
57
|
+
cause?: unknown;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The verdict of anything a `catch` holds: the pair from an `Error` carrying a boolean
|
|
62
|
+
* `retryable` and a known `errorDomain`, and `undefined` otherwise.
|
|
63
|
+
*
|
|
64
|
+
* The check is structural rather than `instanceof`, so it reads every error of this SDK, of
|
|
65
|
+
* another copy of it installed beside this one, of a consumer's own subclass, and an `mthds`
|
|
66
|
+
* `ApiResponseError` whose runner sent both members. `undefined` means the error carries no
|
|
67
|
+
* verdict: the `RangeError` or `TypeError` the SDK raises for an argument of the wrong type or
|
|
68
|
+
* range before any request is sent (a bug in the calling code), the caller's own abort, which the
|
|
69
|
+
* client rethrows untouched, or anything else a `try` block threw. An argument the client refuses
|
|
70
|
+
* for what it asks is a `RequestArgumentError`, which carries one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function errorVerdictOf(err: unknown): ErrorVerdict | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The SDK refused a call's arguments before sending any request: no run source given to
|
|
75
|
+
* `execute()` or `start()`, run sources or method selectors that exclude each other, a selector
|
|
76
|
+
* rule of `validate()`, an empty `validateFiles()`, a reserved key in `extra`, or a base URL that
|
|
77
|
+
* is not host-only. Nothing reached the API, so the message says what to change.
|
|
78
|
+
*
|
|
79
|
+
* Its verdict is `input`, not retryable — the caller must change the arguments — unless
|
|
80
|
+
* `options.verdict` declares another: the client declares `config` for a base URL that is not
|
|
81
|
+
* host-only, since it typically comes from `PIPELEX_BASE_URL`. A refusal the standard's own
|
|
82
|
+
* check raises (`assertExclusiveRunSources`) is rethrown as this class with the same message, the
|
|
83
|
+
* standard's error as `cause`.
|
|
84
|
+
*/
|
|
85
|
+
export declare class RequestArgumentError extends PipelexRequestError {
|
|
86
|
+
constructor(message: string, options?: {
|
|
87
|
+
cause?: unknown;
|
|
88
|
+
verdict?: ErrorVerdict;
|
|
89
|
+
});
|
|
14
90
|
}
|
|
15
91
|
/**
|
|
16
92
|
* Base class for every failure raised by input preparation (`uploadFile` /
|
|
17
93
|
* `prepareInputs`). Catch this to handle any preparation failure; catch a
|
|
18
94
|
* subclass to branch on the semantic category. All preparation failures are
|
|
19
95
|
* raised BEFORE any run is created — a run never triggers a hidden upload.
|
|
96
|
+
*
|
|
97
|
+
* Its verdict is `input`, not retryable — the asset, the inputs or the method selector must
|
|
98
|
+
* change — unless `options.verdict` declares another: the SDK's own subclasses do, and so can a
|
|
99
|
+
* consumer's, such as a form reporting a missing input in its own words.
|
|
20
100
|
*/
|
|
21
|
-
export declare class InputPreparationError extends
|
|
101
|
+
export declare class InputPreparationError extends PipelexRequestError {
|
|
22
102
|
constructor(message: string, options?: {
|
|
23
103
|
cause?: unknown;
|
|
104
|
+
verdict?: ErrorVerdict;
|
|
24
105
|
});
|
|
25
106
|
}
|
|
26
107
|
/**
|
|
@@ -59,12 +140,17 @@ export declare class InvalidLocalSourceError extends InputPreparationError {
|
|
|
59
140
|
* `grant_expired` — the grant's validity window has passed; `signature_mismatch` —
|
|
60
141
|
* the file's size, content type or metadata differ from what the grant signed;
|
|
61
142
|
* `unsigned_header` — the request carried a storage header the grant did not sign;
|
|
62
|
-
* `store_refused` — any other refusal from storage.
|
|
143
|
+
* `store_refused` — any other refusal from storage. Storage's `408` and `429` are no
|
|
144
|
+
* refusal of the asset: they refuse the request for its timing, and are an
|
|
145
|
+
* `UploadTransportError`.
|
|
63
146
|
*/
|
|
64
147
|
export type RejectedAssetCode = "too_large" | "grant_used" | "grant_expired" | "signature_mismatch" | "unsigned_header" | "store_refused";
|
|
65
148
|
/**
|
|
66
149
|
* The server or storage refused the asset — most commonly a `413` past the
|
|
67
|
-
* service-defined size cap, or storage refusing an upload with a grant.
|
|
150
|
+
* service-defined size cap, or storage refusing an upload with a grant. A storage
|
|
151
|
+
* `4xx` that says nothing about the file is not among them: a `408` or a `429`, which
|
|
152
|
+
* time out or throttle the request, a `400 RequestTimeout` and a `409
|
|
153
|
+
* ConditionalRequestConflict` are an `UploadTransportError`. The SDK
|
|
68
154
|
* does not impose a client-side cap; it surfaces the refusal. `filename` and
|
|
69
155
|
* `status` locate it, and `code` says why: the SDK sets it on every one it raises,
|
|
70
156
|
* so it is undefined only on one a caller constructs without it.
|
|
@@ -81,14 +167,18 @@ export declare class RejectedAssetError extends InputPreparationError {
|
|
|
81
167
|
/**
|
|
82
168
|
* The configured deployment does not support upload (no `/v1/upload` route, seen
|
|
83
169
|
* as a `404`). Upload is a hosted Pipelex-product capability even though the SDK
|
|
84
|
-
* can be pointed at other base URLs.
|
|
170
|
+
* can be pointed at other base URLs. Its verdict is `config`, not retryable: the base URL
|
|
171
|
+
* must point at a deployment that serves upload.
|
|
85
172
|
*/
|
|
86
173
|
export declare class UnsupportedUploadCapabilityError extends InputPreparationError {
|
|
87
174
|
constructor(message: string, options?: {
|
|
88
175
|
cause?: unknown;
|
|
89
176
|
});
|
|
90
177
|
}
|
|
91
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Upload was not authorized — a `401`/`403` from the upload route. Its verdict is `config`, not
|
|
180
|
+
* retryable: the credential must change.
|
|
181
|
+
*/
|
|
92
182
|
export declare class UploadAuthenticationError extends InputPreparationError {
|
|
93
183
|
readonly status: number;
|
|
94
184
|
constructor(message: string, status: number, options?: {
|
|
@@ -105,7 +195,8 @@ export declare class UploadAuthenticationError extends InputPreparationError {
|
|
|
105
195
|
* `uploadFile`. Whether the file was stored is unknown.
|
|
106
196
|
* - `unreachable` — no response reached the SDK. In a browser, a refused cross-origin
|
|
107
197
|
* request looks like this.
|
|
108
|
-
* - `server_error` — a `5xx`. Whether the file was stored is unknown
|
|
198
|
+
* - `server_error` — a `5xx`. Whether the file was stored is unknown, except after a `501`:
|
|
199
|
+
* storage does not implement the request it was sent, and stored nothing.
|
|
109
200
|
* - `storage_timeout` — storage's `400 RequestTimeout`: it stopped waiting for the
|
|
110
201
|
* file's bytes and stored nothing.
|
|
111
202
|
* - `conflict` — storage's `409 ConditionalRequestConflict`: another `PUT` with the
|
|
@@ -113,18 +204,36 @@ export declare class UploadAuthenticationError extends InputPreparationError {
|
|
|
113
204
|
* - `redirected` — storage redirected the `PUT`, and the redirect was refused.
|
|
114
205
|
* - `invalid_grant_url` — the grant's `url` is not an absolute `http(s)` URL free of
|
|
115
206
|
* user info, so nothing was sent.
|
|
116
|
-
* - `unexpected` — a status or a failure the SDK has no specific mapping for.
|
|
207
|
+
* - `unexpected` — a status or a failure the SDK has no specific mapping for. From
|
|
208
|
+
* `uploadWithGrant`, storage's `408` or `429`: it timed out or throttled the request,
|
|
209
|
+
* which a later attempt can pass.
|
|
117
210
|
*/
|
|
118
211
|
export type UploadTransportCode = "timeout" | "unreachable" | "server_error" | "storage_timeout" | "conflict" | "redirected" | "invalid_grant_url" | "unexpected";
|
|
119
212
|
/**
|
|
120
213
|
* A network or server fault reaching the upload route or storage — an unreachable
|
|
121
|
-
* host, a timeout, a `5xx`, a refused redirect, storage timing out on the body,
|
|
122
|
-
*
|
|
214
|
+
* host, a timeout, a `5xx`, a refused redirect, storage timing out on the body,
|
|
215
|
+
* storage timing out or throttling the request (a `408` or a `429`), or any other
|
|
216
|
+
* unexpected `upload()` failure. `code` says which: the SDK sets it on
|
|
123
217
|
* every one it raises, so it is undefined only on one a caller constructs without
|
|
124
218
|
* it. `status` is the HTTP status when a response produced it, and undefined when
|
|
125
219
|
* none did. From `uploadFile` the wrapped `ApiResponseError` is also reachable via
|
|
126
220
|
* `cause`; `uploadWithGrant` wraps no response, because storage's error body can
|
|
127
221
|
* echo the grant's credential.
|
|
222
|
+
*
|
|
223
|
+
* Its verdict is the wrapped error's when `cause` carries one: `uploadFile` wraps the
|
|
224
|
+
* `ApiResponseError` or `ApiUnreachableError` the client's `upload()` threw, and `code` is too
|
|
225
|
+
* coarse to judge it by (a `402` plan limit is `unexpected`, like a malformed answer). Otherwise
|
|
226
|
+
* — always the case from `uploadWithGrant`, which wraps no response — `code` decides: `timeout`,
|
|
227
|
+
* `storage_timeout` and `conflict` are `runtime` and retryable, `conflict` because storage
|
|
228
|
+
* documents its `409 ConditionalRequestConflict` as retryable and the grant is not spent by it (a
|
|
229
|
+
* spent grant is the `412` of a `RejectedAssetError` with code `grant_used`); `server_error` is
|
|
230
|
+
* `runtime`, and retryable when the fallback table a refused API request reads would call its
|
|
231
|
+
* `status` retryable — any `5xx` but a `501`, which storage answers for a request it does not
|
|
232
|
+
* implement — or when it carries no status; `unexpected` is `runtime`, and retryable when that
|
|
233
|
+
* table would call its `status` retryable — storage's `408` or `429`, refused for its timing —
|
|
234
|
+
* and not retryable for any other status or none; `unreachable` is `config` and retryable, like
|
|
235
|
+
* `ApiUnreachableError`; `redirected` is `config` and not retryable; `invalid_grant_url` and no
|
|
236
|
+
* code at all are `runtime` and not retryable.
|
|
128
237
|
*/
|
|
129
238
|
export declare class UploadTransportError extends InputPreparationError {
|
|
130
239
|
readonly status: number | undefined;
|
|
@@ -144,10 +253,16 @@ export declare class UploadTransportError extends InputPreparationError {
|
|
|
144
253
|
* operation throws only when it can produce no verdict at all. Transport
|
|
145
254
|
* failures on the resolve route (`ApiResponseError`, `ApiUnreachableError`)
|
|
146
255
|
* and the run-lifecycle errors propagate unchanged, so they are not subclasses.
|
|
256
|
+
*
|
|
257
|
+
* Its verdict is `runtime`, not retryable, unless `options.verdict` declares another: the SDK
|
|
258
|
+
* declares `input` where it refuses an argument (a `scope`, a bound, a location) and `config`
|
|
259
|
+
* where the environment refuses the download (a runtime with no filesystem, a directory that
|
|
260
|
+
* cannot be created).
|
|
147
261
|
*/
|
|
148
|
-
export declare class ArtifactOperationError extends
|
|
262
|
+
export declare class ArtifactOperationError extends PipelexRequestError {
|
|
149
263
|
constructor(message: string, options?: {
|
|
150
264
|
cause?: unknown;
|
|
265
|
+
verdict?: ErrorVerdict;
|
|
151
266
|
});
|
|
152
267
|
}
|
|
153
268
|
/**
|
|
@@ -174,6 +289,14 @@ export declare class ScopeUnavailableError extends ArtifactOperationError {
|
|
|
174
289
|
* (any other non-2xx), `too_large`, `timeout`, `network`. `status` is the
|
|
175
290
|
* store's HTTP status when one was received. `downloadArtifacts` never lets
|
|
176
291
|
* this escape: it becomes the item's `error`.
|
|
292
|
+
*
|
|
293
|
+
* Its verdict follows `code`: `invalid_storage_uri`, `forbidden`, `unsupported_url`, `not_found`
|
|
294
|
+
* and `too_large` are `input` and not retryable, since the reference or the bound must change;
|
|
295
|
+
* `plain_http_refused` is `config` and not retryable; `redirect_refused` and `store_refused` are
|
|
296
|
+
* `runtime` and not retryable; `timeout` and `network` are `runtime` and retryable; `store_error`
|
|
297
|
+
* is `runtime`, and retryable when the fallback table a refused API request reads would call its
|
|
298
|
+
* `status` retryable — a `408`, a `429` or a `5xx` other than `501` — and not retryable for any
|
|
299
|
+
* other status or none. A code this version does not know is `runtime` and not retryable.
|
|
177
300
|
*/
|
|
178
301
|
export declare class ArtifactFetchError extends ArtifactOperationError {
|
|
179
302
|
readonly uri: string;
|
|
@@ -189,7 +312,9 @@ export declare class ArtifactFetchError extends ArtifactOperationError {
|
|
|
189
312
|
* the download stops — but the files already saved are real, and `verdict`
|
|
190
313
|
* carries the result as it stood: every item saved before the refusal, and
|
|
191
314
|
* the rest marked `aborted`. `status` is the route's status; the wrapped
|
|
192
|
-
* `ApiResponseError` is reachable via `cause`.
|
|
315
|
+
* `ApiResponseError` is reachable via `cause`. (`verdict` is the download's result, not the
|
|
316
|
+
* error's own: that is `retryable` and `errorDomain`, `config` and not retryable, since the
|
|
317
|
+
* credential must change.)
|
|
193
318
|
*/
|
|
194
319
|
export declare class ArtifactAuthenticationError extends ArtifactOperationError {
|
|
195
320
|
readonly status: number;
|
|
@@ -206,8 +331,13 @@ export declare class ArtifactAuthenticationError extends ArtifactOperationError
|
|
|
206
331
|
*
|
|
207
332
|
* `code` is the underlying network error code when available
|
|
208
333
|
* (`ECONNREFUSED`, `ENOTFOUND`, `ETIMEDOUT`, `EAI_AGAIN`, `ABORT_TIMEOUT`).
|
|
334
|
+
*
|
|
335
|
+
* Its verdict is `config` and retryable: the address or the network must be checked, and a later
|
|
336
|
+
* attempt can get through. With the code `ABORT_TIMEOUT`, the SDK's own request timeout, it is
|
|
337
|
+
* `runtime` and retryable instead: the API took the request and did not answer in time, which is
|
|
338
|
+
* no fault of the base URL.
|
|
209
339
|
*/
|
|
210
|
-
export declare class ApiUnreachableError extends
|
|
340
|
+
export declare class ApiUnreachableError extends PipelexRequestError {
|
|
211
341
|
readonly apiUrl: string;
|
|
212
342
|
readonly code: string | undefined;
|
|
213
343
|
constructor(message: string, apiUrl: string, code: string | undefined, options?: {
|
|
@@ -219,8 +349,11 @@ export declare class ApiUnreachableError extends PipelineRequestError {
|
|
|
219
349
|
* hosted gateway's ~30s synchronous-request limit. The blocking path cannot
|
|
220
350
|
* run methods longer than 30s behind the hosted gateway — use the durable run
|
|
221
351
|
* lifecycle (start + poll) instead.
|
|
352
|
+
*
|
|
353
|
+
* Its verdict is `input`, not retryable: asking again meets the same limit, and the caller fixes
|
|
354
|
+
* it by starting the run and polling.
|
|
222
355
|
*/
|
|
223
|
-
export declare class PipelineExecuteTimeoutError extends
|
|
356
|
+
export declare class PipelineExecuteTimeoutError extends PipelexRequestError {
|
|
224
357
|
readonly elapsedMs: number;
|
|
225
358
|
constructor(elapsedMs: number, options?: {
|
|
226
359
|
cause?: unknown;
|
|
@@ -247,8 +380,15 @@ export declare class PipelineExecuteTimeoutError extends PipelineRequestError {
|
|
|
247
380
|
* report's message (`Run finished with status FAILED: <message>`), so printing the error
|
|
248
381
|
* already tells the reason.
|
|
249
382
|
* - `runId` locates the run, for a status read or a support request.
|
|
383
|
+
*
|
|
384
|
+
* Its verdict comes from the report. `errorDomain` is the report's `error_domain` when it is one
|
|
385
|
+
* of the three domains, and `runtime` otherwise, including a run with no report. `retryable` is
|
|
386
|
+
* true only when the report's `retryable` is `true`: a report that says nothing, and a run with
|
|
387
|
+
* none, read as not retryable, since starting the run again spends credit and nothing says it
|
|
388
|
+
* would succeed. The report keeps its own `retryable` as written, so a consumer that words the
|
|
389
|
+
* unknown differently still can.
|
|
250
390
|
*/
|
|
251
|
-
export declare class RunFailedError extends
|
|
391
|
+
export declare class RunFailedError extends PipelexRequestError {
|
|
252
392
|
readonly runId: string;
|
|
253
393
|
readonly status: RunStatus;
|
|
254
394
|
readonly error: RunErrorReport | null;
|
|
@@ -266,8 +406,10 @@ export declare class RunFailedError extends PipelineRequestError {
|
|
|
266
406
|
* `execute` response named a `main_stuff_name` whose stuff is absent from the returned working
|
|
267
407
|
* memory. `runId` locates the run. (An empty-but-present main stuff — `{ items: [] }`, `{ text:
|
|
268
408
|
* "" }` — is a valid output and does NOT throw; only a genuinely absent one does.)
|
|
409
|
+
*
|
|
410
|
+
* Its verdict is `runtime`, not retryable: the API broke its own contract on a completed run.
|
|
269
411
|
*/
|
|
270
|
-
export declare class MissingMainStuffError extends
|
|
412
|
+
export declare class MissingMainStuffError extends PipelexRequestError {
|
|
271
413
|
readonly runId: string;
|
|
272
414
|
constructor(message: string, runId: string);
|
|
273
415
|
}
|
|
@@ -275,8 +417,10 @@ export declare class MissingMainStuffError extends PipelineRequestError {
|
|
|
275
417
|
* Thrown when `waitForResult` exceeds its `timeoutMs` before the run reaches a
|
|
276
418
|
* terminal state. The run is NOT cancelled — it keeps executing server-side and
|
|
277
419
|
* can be resumed later by `runId` (the poll loop just stopped waiting).
|
|
420
|
+
*
|
|
421
|
+
* Its verdict is `runtime` and retryable: the run is still going, and waiting again can succeed.
|
|
278
422
|
*/
|
|
279
|
-
export declare class RunTimeoutError extends
|
|
423
|
+
export declare class RunTimeoutError extends PipelexRequestError {
|
|
280
424
|
readonly runId: string;
|
|
281
425
|
readonly timeoutMs: number;
|
|
282
426
|
constructor(message: string, runId: string, timeoutMs: number);
|
|
@@ -289,8 +433,10 @@ export declare class RunTimeoutError extends PipelineRequestError {
|
|
|
289
433
|
* when it cannot hold the connection open. The run keeps executing
|
|
290
434
|
* server-side — resume by `runId` (`getRunResult` / `waitForResult` on a
|
|
291
435
|
* hosted deployment, or the `location` status resource when provided).
|
|
436
|
+
*
|
|
437
|
+
* Its verdict is `runtime` and retryable: the run is still going, and is resumed by its id.
|
|
292
438
|
*/
|
|
293
|
-
export declare class RunStillRunningError extends
|
|
439
|
+
export declare class RunStillRunningError extends PipelexRequestError {
|
|
294
440
|
readonly runId: string;
|
|
295
441
|
readonly retryAfterSeconds: number | null;
|
|
296
442
|
readonly location: string | null;
|
|
@@ -307,13 +453,28 @@ export declare class RunStillRunningError extends PipelineRequestError {
|
|
|
307
453
|
* it 404s those routes; only a deployment that includes the platform block
|
|
308
454
|
* (the Pipelex Hosted API) serves status/results. Distinguished from a genuine
|
|
309
455
|
* run-not-found 404, which carries the server's structured error envelope.
|
|
456
|
+
*
|
|
457
|
+
* Its verdict is `config`, not retryable: the base URL points at a bare runner without the run
|
|
458
|
+
* lifecycle.
|
|
310
459
|
*/
|
|
311
|
-
export declare class RunLifecycleUnavailableError extends
|
|
460
|
+
export declare class RunLifecycleUnavailableError extends PipelexRequestError {
|
|
312
461
|
readonly apiUrl: string;
|
|
313
462
|
constructor(message: string, apiUrl: string, options?: {
|
|
314
463
|
cause?: unknown;
|
|
315
464
|
});
|
|
316
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* Thrown when a paged-list iterator (`iterateMethods`) refuses to keep following cursors.
|
|
468
|
+
*
|
|
469
|
+
* The ceiling, `pageLimit` pages, sits far beyond any real catalog, so reaching it is a
|
|
470
|
+
* server-side fault — an endpoint minting a fresh cursor forever — not a coverage limit the caller
|
|
471
|
+
* can raise. Throwing beats returning, because a silently truncated list is exactly the bug
|
|
472
|
+
* paging was introduced to remove. Its verdict is `runtime`, not retryable.
|
|
473
|
+
*/
|
|
474
|
+
export declare class PagingNotTerminatingError extends PipelexRequestError {
|
|
475
|
+
readonly pageLimit: number;
|
|
476
|
+
constructor(message: string, pageLimit: number);
|
|
477
|
+
}
|
|
317
478
|
/**
|
|
318
479
|
* The last constructor argument of `ApiResponseError`: the error's `cause`, the problem
|
|
319
480
|
* document's typed members, and the decoded document whole. The same shape as `mthds`'s
|
|
@@ -325,16 +486,32 @@ export interface ApiResponseErrorOptions {
|
|
|
325
486
|
problemDocument?: Record<string, unknown>;
|
|
326
487
|
}
|
|
327
488
|
/**
|
|
328
|
-
* A
|
|
489
|
+
* A response that DID come back from the API and that the SDK cannot hand back as a result: a
|
|
490
|
+
* non-2xx refusal, with its problem document parsed, or a 2xx answer the SDK could not read —
|
|
491
|
+
* a body that is not JSON, JSON that is not the object the route answers, or a stored method
|
|
492
|
+
* whose `python` field is not the serialized file list. The second carries the answer's status
|
|
493
|
+
* and raw text, no problem member, what made it unreadable as `cause` (the parse failure, or
|
|
494
|
+
* `mthds`'s refusal of the `python` field), and the verdict the fallback gives a 2xx: `runtime`,
|
|
495
|
+
* not retryable.
|
|
329
496
|
*
|
|
330
497
|
* Every error the hosted API answers is an RFC 9457 `application/problem+json` document, and
|
|
331
498
|
* this error carries its members as typed fields, each `undefined` when the document did not
|
|
332
|
-
* carry it (a member of the wrong type reads as absent rather than as a wrong value
|
|
499
|
+
* carry it (a member of the wrong type reads as absent rather than as a wrong value, and the
|
|
500
|
+
* nested members `providerMetadata`, `migration`, `validationErrors` and `errors` are checked
|
|
501
|
+
* field by field as a failed run's stored report is) — except the verdict, which is always
|
|
502
|
+
* decided:
|
|
333
503
|
*
|
|
334
|
-
* - **The
|
|
335
|
-
* `config` (a configuration change), `runtime` (nobody beforehand) — and `
|
|
336
|
-
*
|
|
337
|
-
*
|
|
504
|
+
* - **The verdict.** `errorDomain` says who can fix the failure — `input` (the caller),
|
|
505
|
+
* `config` (a configuration change), `runtime` (nobody beforehand) — and `retryable` whether
|
|
506
|
+
* asking again can succeed. Each is the document's member when the server sent a valid one,
|
|
507
|
+
* and otherwise the SDK's fallback, read from the status, the platform `code` and whether the
|
|
508
|
+
* body names what it refused. A runner often sends `error_domain` without `retryable`, and
|
|
509
|
+
* then the domain it sent decides `retryable`: `input` and `config` are not retryable, as a
|
|
510
|
+
* stored report that says nothing is not, since the caller or the environment must change,
|
|
511
|
+
* while `runtime` takes the fallback's. Nothing on the error says which a value came from:
|
|
512
|
+
* `problemDocument` keeps what the server sent.
|
|
513
|
+
* - **The branch fields.** `errorDomain`, and `type`, the stable URI naming the error class.
|
|
514
|
+
* Branch on these, never on the HTTP status or on the wording of a message.
|
|
338
515
|
* - **The native codes.** `code` is the platform's own closed code (`conflict`, `not_found`,
|
|
339
516
|
* `pipelex_api_key_limit_reached`, …) and `errorType` the runner's open exception class
|
|
340
517
|
* name. Each is finer than `errorDomain` and specific to the surface that emits it; the
|
|
@@ -352,11 +529,11 @@ export interface ApiResponseErrorOptions {
|
|
|
352
529
|
* `problemDocument` is the decoded document whole, so a member this SDK does not name stays
|
|
353
530
|
* reachable without re-parsing `responseBody`, which is the raw text; it is `undefined` when
|
|
354
531
|
* the body was not a JSON object. The members `mthds`'s own `ApiResponseError` carries have the
|
|
355
|
-
* same names and types
|
|
356
|
-
* `
|
|
357
|
-
* leaves to this SDK.
|
|
532
|
+
* same names here, and the same types except the verdict, which this SDK narrows from optional
|
|
533
|
+
* to decided; the rest (`code`, `errorCategory`, `model`, `provider`, `providerMetadata`,
|
|
534
|
+
* `migration`, `errors`) are the Pipelex members the standard's client leaves to this SDK.
|
|
358
535
|
*/
|
|
359
|
-
export declare class ApiResponseError extends
|
|
536
|
+
export declare class ApiResponseError extends PipelexRequestError {
|
|
360
537
|
readonly apiUrl: string;
|
|
361
538
|
readonly status: number;
|
|
362
539
|
readonly statusText: string;
|
|
@@ -385,24 +562,11 @@ export declare class ApiResponseError extends PipelineRequestError {
|
|
|
385
562
|
* lines for this request.
|
|
386
563
|
*/
|
|
387
564
|
readonly requestId: string | undefined;
|
|
388
|
-
/**
|
|
389
|
-
* The body's `error_domain`: who can fix the failure. `input` — the caller (a malformed
|
|
390
|
-
* bundle, a bad argument, a missing input); `config` — a configuration change (a missing
|
|
391
|
-
* secret, a model the backend does not serve); `runtime` — nobody beforehand (a provider
|
|
392
|
-
* outage during execution). Typed open, as the server owns the vocabulary; `undefined` when
|
|
393
|
-
* the server did not classify it.
|
|
394
|
-
*/
|
|
395
|
-
readonly errorDomain: string | undefined;
|
|
396
565
|
/**
|
|
397
566
|
* The body's `error_category`: the finer classification of an inference failure — known
|
|
398
567
|
* values `transient`, `configuration`, `content`, `capacity`, `ambiguous`, `unknown`.
|
|
399
568
|
*/
|
|
400
569
|
readonly errorCategory: string | undefined;
|
|
401
|
-
/**
|
|
402
|
-
* The body's `retryable`: whether retrying the same request can plausibly succeed.
|
|
403
|
-
* `undefined` means unknown, which is not the same as `false`.
|
|
404
|
-
*/
|
|
405
|
-
readonly retryable: boolean | undefined;
|
|
406
570
|
/** The body's `user_action`: what the caller should do next, when the server can say. */
|
|
407
571
|
readonly userAction: UserAction | undefined;
|
|
408
572
|
/** The body's `model`: the model an inference failure used. */
|