windmill-client 1.772.0 → 1.774.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/dist/client.d.ts +75 -7
- package/dist/client.mjs +97 -58
- package/dist/core/OpenAPI.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +246 -60
- package/dist/services.gen.d.ts +23 -1
- package/dist/services.gen.mjs +48 -2
- package/dist/types.gen.d.ts +234 -3
- package/dist/wacError.d.ts +24 -0
- package/dist/wacError.mjs +103 -0
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @internal
|
|
2
|
+
* Whether a caught value is the SDK's own suspend signal, which must be
|
|
3
|
+
* rethrown rather than reported as a step failure.
|
|
4
|
+
*
|
|
5
|
+
* Both halves of the check can throw on a hostile value: `instanceof` consults
|
|
6
|
+
* a proxy's `getPrototypeOf` trap, and reading `.name` its `get` trap. This
|
|
7
|
+
* runs before anything has been checkpointed, so neither may escape — a value
|
|
8
|
+
* that fights back is simply not a suspend. */
|
|
9
|
+
export declare function isSuspendSignal(e: unknown, suspendCtor: Function): boolean;
|
|
10
|
+
/** @internal
|
|
11
|
+
* Serialize a failed `step()` body into the `__wmill_error` marker that task
|
|
12
|
+
* failures also use, so it can be stored in `completed_steps`.
|
|
13
|
+
*
|
|
14
|
+
* The record's final shape is decided by the backend (`wac_failure_record`),
|
|
15
|
+
* which normalizes task failures through the same function; what is built here
|
|
16
|
+
* is the raw material plus the envelope the backend recognizes. */
|
|
17
|
+
export declare function stepErrorMarker(key: string, e: unknown): Record<string, any>;
|
|
18
|
+
/** @internal
|
|
19
|
+
* Rebuild the error a failed task or step throws. The run that produced the
|
|
20
|
+
* failure and every later replay go through here: a catch is control flow,
|
|
21
|
+
* `workflow()` re-runs its body from the top every round, so a handler that
|
|
22
|
+
* branches on the failure it caught must be handed the same thing in every
|
|
23
|
+
* round or it dispatches different tasks on the way back. */
|
|
24
|
+
export declare function taskErrorFromMarker(marker: any, fallbackMessage: string): Error;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/wacError.ts
|
|
2
|
+
/** Error properties the executors already report as named fields, so they must
|
|
3
|
+
* not be repeated inside `extra`. Kept identical to the skip-list in the
|
|
4
|
+
* generated bun/deno job wrappers. */
|
|
5
|
+
const SERIALIZED_ERROR_FIELDS = [
|
|
6
|
+
"line",
|
|
7
|
+
"name",
|
|
8
|
+
"stack",
|
|
9
|
+
"column",
|
|
10
|
+
"message",
|
|
11
|
+
"sourceURL",
|
|
12
|
+
"originalLine",
|
|
13
|
+
"originalColumn"
|
|
14
|
+
];
|
|
15
|
+
/** Read a property off a value that may fight back: a proxy `get` trap or a
|
|
16
|
+
* throwing accessor turns an ordinary field read into an exception. Callers
|
|
17
|
+
* are on the failure-reporting path, where nothing has been checkpointed yet. */
|
|
18
|
+
function safeRead(o, k) {
|
|
19
|
+
try {
|
|
20
|
+
return o?.[k];
|
|
21
|
+
} catch {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** @internal
|
|
26
|
+
* Whether a caught value is the SDK's own suspend signal, which must be
|
|
27
|
+
* rethrown rather than reported as a step failure.
|
|
28
|
+
*
|
|
29
|
+
* Both halves of the check can throw on a hostile value: `instanceof` consults
|
|
30
|
+
* a proxy's `getPrototypeOf` trap, and reading `.name` its `get` trap. This
|
|
31
|
+
* runs before anything has been checkpointed, so neither may escape — a value
|
|
32
|
+
* that fights back is simply not a suspend. */
|
|
33
|
+
function isSuspendSignal(e, suspendCtor) {
|
|
34
|
+
try {
|
|
35
|
+
if (e instanceof suspendCtor) return true;
|
|
36
|
+
} catch {}
|
|
37
|
+
return safeRead(e, "name") === "StepSuspend";
|
|
38
|
+
}
|
|
39
|
+
/** @internal
|
|
40
|
+
* Serialize a failed `step()` body into the `__wmill_error` marker that task
|
|
41
|
+
* failures also use, so it can be stored in `completed_steps`.
|
|
42
|
+
*
|
|
43
|
+
* The record's final shape is decided by the backend (`wac_failure_record`),
|
|
44
|
+
* which normalizes task failures through the same function; what is built here
|
|
45
|
+
* is the raw material plus the envelope the backend recognizes. */
|
|
46
|
+
function stepErrorMarker(key, e) {
|
|
47
|
+
const thrown = e;
|
|
48
|
+
const rawName = safeRead(thrown, "name");
|
|
49
|
+
const rawMessage = safeRead(thrown, "message");
|
|
50
|
+
const rawStack = safeRead(thrown, "stack");
|
|
51
|
+
const name = typeof rawName === "string" ? rawName : void 0;
|
|
52
|
+
const message = typeof rawMessage === "string" ? rawMessage : void 0;
|
|
53
|
+
const stack = typeof rawStack === "string" ? rawStack : void 0;
|
|
54
|
+
const error = {};
|
|
55
|
+
if (name) error.name = name;
|
|
56
|
+
if (message !== void 0) error.message = message;
|
|
57
|
+
if (stack) error.stack = stack;
|
|
58
|
+
if (thrown !== null && typeof thrown === "object") {
|
|
59
|
+
const extra = {};
|
|
60
|
+
let keys = [];
|
|
61
|
+
try {
|
|
62
|
+
keys = Object.getOwnPropertyNames(thrown);
|
|
63
|
+
} catch {
|
|
64
|
+
keys = [];
|
|
65
|
+
}
|
|
66
|
+
for (const k of keys) {
|
|
67
|
+
if (SERIALIZED_ERROR_FIELDS.includes(k)) continue;
|
|
68
|
+
try {
|
|
69
|
+
extra[k] = JSON.parse(JSON.stringify(thrown[k]));
|
|
70
|
+
} catch {}
|
|
71
|
+
}
|
|
72
|
+
if (Object.keys(extra).length > 0) error.extra = extra;
|
|
73
|
+
}
|
|
74
|
+
let fallback;
|
|
75
|
+
try {
|
|
76
|
+
fallback = String(e);
|
|
77
|
+
} catch {
|
|
78
|
+
fallback = `unrepresentable ${typeof e} thrown`;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
__wmill_error: true,
|
|
82
|
+
message: message ?? fallback,
|
|
83
|
+
step_key: key,
|
|
84
|
+
result: { error }
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** @internal
|
|
88
|
+
* Rebuild the error a failed task or step throws. The run that produced the
|
|
89
|
+
* failure and every later replay go through here: a catch is control flow,
|
|
90
|
+
* `workflow()` re-runs its body from the top every round, so a handler that
|
|
91
|
+
* branches on the failure it caught must be handed the same thing in every
|
|
92
|
+
* round or it dispatches different tasks on the way back. */
|
|
93
|
+
function taskErrorFromMarker(marker, fallbackMessage) {
|
|
94
|
+
const err = new Error(marker?.message || fallbackMessage);
|
|
95
|
+
err.name = "TaskError";
|
|
96
|
+
err.result = marker?.result;
|
|
97
|
+
err.step_key = marker?.step_key;
|
|
98
|
+
err.child_job_id = marker?.child_job_id;
|
|
99
|
+
return err;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { isSuspendSignal, stepErrorMarker, taskErrorFromMarker };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-client",
|
|
3
3
|
"description": "Windmill SDK client for browsers and Node.js",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.774.0",
|
|
5
5
|
"author": "Ruben Fiszel",
|
|
6
6
|
"license": "Apache 2.0",
|
|
7
7
|
"homepage": "https://github.com/windmill-labs/windmill/tree/main/typescript-client#readme",
|