@w6w/sdk 0.6.0 → 0.9.8
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 +166 -16
- package/dist/mod.d.ts +7 -5
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -0
- package/dist/mod.js.map +1 -1
- package/dist/src/client.d.ts +11 -2
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +12 -2
- package/dist/src/client.js.map +1 -1
- package/dist/src/config.d.ts +83 -6
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +40 -4
- package/dist/src/config.js.map +1 -1
- package/dist/src/connections.d.ts +3 -2
- package/dist/src/connections.d.ts.map +1 -1
- package/dist/src/connections.js +7 -2
- package/dist/src/connections.js.map +1 -1
- package/dist/src/console/api-calls.d.ts +4 -3
- package/dist/src/console/api-calls.d.ts.map +1 -1
- package/dist/src/console/api-calls.js +4 -3
- package/dist/src/console/api-calls.js.map +1 -1
- package/dist/src/console/apps.d.ts +181 -8
- package/dist/src/console/apps.d.ts.map +1 -1
- package/dist/src/console/apps.js +67 -12
- package/dist/src/console/apps.js.map +1 -1
- package/dist/src/console/auth.d.ts +43 -3
- package/dist/src/console/auth.d.ts.map +1 -1
- package/dist/src/console/auth.js +23 -4
- package/dist/src/console/auth.js.map +1 -1
- package/dist/src/console/commerce.d.ts +428 -0
- package/dist/src/console/commerce.d.ts.map +1 -0
- package/dist/src/console/commerce.js +220 -0
- package/dist/src/console/commerce.js.map +1 -0
- package/dist/src/console/dashboard.d.ts +8 -0
- package/dist/src/console/dashboard.d.ts.map +1 -1
- package/dist/src/console/dashboard.js.map +1 -1
- package/dist/src/console/endpoints.d.ts +57 -2
- package/dist/src/console/endpoints.d.ts.map +1 -1
- package/dist/src/console/endpoints.js.map +1 -1
- package/dist/src/console/functions.d.ts +35 -4
- package/dist/src/console/functions.d.ts.map +1 -1
- package/dist/src/console/functions.js +13 -0
- package/dist/src/console/functions.js.map +1 -1
- package/dist/src/console/mod.d.ts +22 -7
- package/dist/src/console/mod.d.ts.map +1 -1
- package/dist/src/console/mod.js +16 -1
- package/dist/src/console/mod.js.map +1 -1
- package/dist/src/console/otp.d.ts +127 -0
- package/dist/src/console/otp.d.ts.map +1 -0
- package/dist/src/console/otp.js +118 -0
- package/dist/src/console/otp.js.map +1 -0
- package/dist/src/console/reliability.d.ts +101 -6
- package/dist/src/console/reliability.d.ts.map +1 -1
- package/dist/src/console/reliability.js +16 -5
- package/dist/src/console/reliability.js.map +1 -1
- package/dist/src/console/step-tests.d.ts +7 -1
- package/dist/src/console/step-tests.d.ts.map +1 -1
- package/dist/src/console/step-tests.js +1 -1
- package/dist/src/console/step-tests.js.map +1 -1
- package/dist/src/console/subscriptions.d.ts +38 -16
- package/dist/src/console/subscriptions.d.ts.map +1 -1
- package/dist/src/console/subscriptions.js +7 -13
- package/dist/src/console/subscriptions.js.map +1 -1
- package/dist/src/console/tenant-login-flags.d.ts +106 -0
- package/dist/src/console/tenant-login-flags.d.ts.map +1 -0
- package/dist/src/console/tenant-login-flags.js +113 -0
- package/dist/src/console/tenant-login-flags.js.map +1 -0
- package/dist/src/console/tenant-oauth-apps.d.ts +75 -14
- package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -1
- package/dist/src/console/tenant-oauth-apps.js +37 -11
- package/dist/src/console/tenant-oauth-apps.js.map +1 -1
- package/dist/src/console/tokens.d.ts +2 -0
- package/dist/src/console/tokens.d.ts.map +1 -1
- package/dist/src/console/tokens.js.map +1 -1
- package/dist/src/console/workflows.d.ts +14 -0
- package/dist/src/console/workflows.d.ts.map +1 -1
- package/dist/src/console/workflows.js +13 -0
- package/dist/src/console/workflows.js.map +1 -1
- package/dist/src/documents.d.ts +9 -5
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +6 -3
- package/dist/src/documents.js.map +1 -1
- package/dist/src/functions.d.ts +149 -1
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +145 -0
- package/dist/src/functions.js.map +1 -1
- package/dist/src/http.d.ts +58 -10
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +82 -11
- package/dist/src/http.js.map +1 -1
- package/dist/src/me.d.ts +3 -2
- package/dist/src/me.d.ts.map +1 -1
- package/dist/src/me.js +7 -2
- package/dist/src/me.js.map +1 -1
- package/dist/src/run.d.ts +11 -2
- package/dist/src/run.d.ts.map +1 -1
- package/dist/src/run.js +11 -2
- package/dist/src/run.js.map +1 -1
- package/dist/src/server/mod.d.ts +100 -0
- package/dist/src/server/mod.d.ts.map +1 -0
- package/dist/src/server/mod.js +121 -0
- package/dist/src/server/mod.js.map +1 -0
- package/dist/src/team.d.ts +204 -0
- package/dist/src/team.d.ts.map +1 -0
- package/dist/src/team.js +161 -0
- package/dist/src/team.js.map +1 -0
- package/dist/src/types.d.ts +143 -10
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +27 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/vars.d.ts +5 -3
- package/dist/src/vars.d.ts.map +1 -1
- package/dist/src/vars.js +14 -4
- package/dist/src/vars.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflows.d.ts +261 -9
- package/dist/src/workflows.d.ts.map +1 -1
- package/dist/src/workflows.js +246 -7
- package/dist/src/workflows.js.map +1 -1
- package/package.json +5 -1
package/dist/src/vars.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
|
-
import { type HttpResponse, type RequestOptions } from "./http.ts";
|
|
24
|
+
import { type CallOptions, type HttpResponse, type RequestOptions } from "./http.ts";
|
|
25
25
|
import { type Var, type VarType } from "./types.ts";
|
|
26
26
|
/**
|
|
27
27
|
* The slice of `W6WClient` this namespace needs: the transport, and nothing
|
|
@@ -86,18 +86,20 @@ export declare class VarsApi {
|
|
|
86
86
|
/**
|
|
87
87
|
* List the caller's variables.
|
|
88
88
|
*
|
|
89
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
89
90
|
* @returns The variables, unwrapped from the `vars` envelope.
|
|
90
91
|
* @throws {ApiError} On any non-2xx.
|
|
91
92
|
*/
|
|
92
|
-
list(): Promise<Var[]>;
|
|
93
|
+
list(options?: CallOptions): Promise<Var[]>;
|
|
93
94
|
/**
|
|
94
95
|
* Fetch one variable by its server-issued id.
|
|
95
96
|
*
|
|
96
97
|
* @param id - The `var_…` id.
|
|
98
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
97
99
|
* @returns The variable.
|
|
98
100
|
* @throws {ApiError} `404 unknown_var` when there is no such id.
|
|
99
101
|
*/
|
|
100
|
-
get(id: string): Promise<Var>;
|
|
102
|
+
get(id: string, options?: CallOptions): Promise<Var>;
|
|
101
103
|
/**
|
|
102
104
|
* Fetch one variable by the `name` its author chose.
|
|
103
105
|
*
|
package/dist/src/vars.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../src/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../src/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAU,KAAK,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;A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* @param options - Optional per-call transport options (`signal` to abort).
|
|
47
48
|
* @returns The variables, unwrapped from the `vars` envelope.
|
|
48
49
|
* @throws {ApiError} On any non-2xx.
|
|
49
50
|
*/
|
|
50
|
-
async list() {
|
|
51
|
-
const res = await this.#host.request({
|
|
51
|
+
async list(options) {
|
|
52
|
+
const res = await this.#host.request({
|
|
53
|
+
method: "GET",
|
|
54
|
+
path: "/vars",
|
|
55
|
+
signal: options?.signal,
|
|
56
|
+
});
|
|
52
57
|
return unwrap(res, "vars");
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Fetch one variable by its server-issued id.
|
|
56
61
|
*
|
|
57
62
|
* @param id - The `var_…` id.
|
|
63
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
58
64
|
* @returns The variable.
|
|
59
65
|
* @throws {ApiError} `404 unknown_var` when there is no such id.
|
|
60
66
|
*/
|
|
61
|
-
async get(id) {
|
|
62
|
-
const res = await this.#host.request({
|
|
67
|
+
async get(id, options) {
|
|
68
|
+
const res = await this.#host.request({
|
|
69
|
+
method: "GET",
|
|
70
|
+
path: path `/vars/${id}`,
|
|
71
|
+
signal: options?.signal,
|
|
72
|
+
});
|
|
63
73
|
// The singular envelope key is `var` — a reserved word in TypeScript, so it
|
|
64
74
|
// is read as a property and never destructured into a binding.
|
|
65
75
|
return unwrap(res, "var");
|
package/dist/src/vars.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vars.js","sourceRoot":"","sources":["../../src/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"vars.js","sourceRoot":"","sources":["../../src/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAuC,IAAI,EAAuB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,MAAM,EAA0B,MAAM,YAAY,CAAC;AAiD5D;;;;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YACb,0EAA0E;YAC1E,0EAA0E;YAC1E,0CAA0C;YAC1C,IAAI,EAAE;gBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAM,GAAG,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,KAAe;QACtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU;YAC5C,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,IAAI,CAAA,SAAS,EAAE,EAAE;YACvB,IAAI,EAAE;gBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAM,GAAG,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAA,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IACnF,CAAC;CACF"}
|
package/dist/src/version.js
CHANGED
package/dist/src/workflows.d.ts
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `client.workflows.*` — discovery and the
|
|
2
|
+
* `client.workflows.*` — discovery, the typed run, and the definition lifecycle.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Eight operations: `list` (T2.1.4) and `run` (T2.1.5), `cancel` (T1.1.4), plus
|
|
5
|
+
* `get`, `create`, `update`, `archive` and `delete`. `list` earns its place in a
|
|
6
|
+
* minimal surface for the same reason `connections.list` does (D4): it is how a
|
|
7
|
+
* caller discovers a `wf_…` id to pass to `run`.
|
|
8
|
+
*
|
|
9
|
+
* ── `cancel`, and the one thing addressed differently from its siblings ──
|
|
10
|
+
* Every other method in this class is `/workflows/…`-rooted; `cancel` alone
|
|
11
|
+
* hits `/runs/{runId}/cancel`, because it names one RUN, not the workflow that
|
|
12
|
+
* spawned it — a workflow can have many runs, and only the run id picks one
|
|
13
|
+
* out. Its `202` means the cancellation was **requested**, not that the run
|
|
14
|
+
* has stopped: the server does not wait for the transition, so the returned
|
|
15
|
+
* `status` is the run's status as it is right now (still `queued` or
|
|
16
|
+
* `running`), never `"canceled"`. Repeating the call on a run that is already
|
|
17
|
+
* marked but not yet terminal answers `202` again.
|
|
18
|
+
*
|
|
19
|
+
* ── The write path, and two things worth knowing about it ──
|
|
20
|
+
* 1. **It mints an id only when the caller sends none.** A caller-supplied
|
|
21
|
+
* `id` on create is accepted only if it matches `^wf_[A-Za-z0-9-]{1,64}$`;
|
|
22
|
+
* anything else is `400 invalid_workflow`. `create` still mints one
|
|
23
|
+
* client-side (`mintId("wf")`) when the definition has none, so what
|
|
24
|
+
* reaches the server already satisfies that grammar — every consumer that
|
|
25
|
+
* talked to this route directly had already written that themselves,
|
|
26
|
+
* studio's `newWorkflowId` is the same four lines.
|
|
27
|
+
* 2. **It does not patch.** There is ONE write route and it stores what it is
|
|
28
|
+
* given, so `update` is a full replacement. `create` and `update` are the
|
|
29
|
+
* same POST; what differs is that one mints the id and the other pins it.
|
|
30
|
+
*
|
|
31
|
+
* Deleting is two calls, `archive` then `delete`, and this module keeps it that
|
|
32
|
+
* way — see {@linkcode WorkflowsApi.delete}.
|
|
7
33
|
*
|
|
8
34
|
* ── `run`, and the three things this API gets called wrong ──
|
|
9
35
|
* 1. **`202` is success.** No `wait` → the run is queued and the server answers
|
|
@@ -44,8 +70,8 @@
|
|
|
44
70
|
* @module
|
|
45
71
|
*/
|
|
46
72
|
import type { ResolvedConfig } from "./config.ts";
|
|
47
|
-
import { type HttpResponse, type RequestOptions } from "./http.ts";
|
|
48
|
-
import { type RunResult, type WorkflowSummary } from "./types.ts";
|
|
73
|
+
import { type CallOptions, type HttpResponse, type RequestOptions } from "./http.ts";
|
|
74
|
+
import { type RunResult, type RunStatus, type WorkflowSummary } from "./types.ts";
|
|
49
75
|
/**
|
|
50
76
|
* The slice of `W6WClient` this namespace needs: the transport, plus the
|
|
51
77
|
* resolved configuration it reads the **default project** out of. Structural
|
|
@@ -63,8 +89,11 @@ export interface WorkflowsHost {
|
|
|
63
89
|
*
|
|
64
90
|
* A named interface rather than a bare `project?: string` parameter, so the
|
|
65
91
|
* operation can accept a further argument later without changing its arity.
|
|
92
|
+
*
|
|
93
|
+
* Extends {@linkcode CallOptions}, so this call also takes an optional
|
|
94
|
+
* `signal` (R-7), forwarded to the transport exactly like `project` is read.
|
|
66
95
|
*/
|
|
67
|
-
export interface WorkflowListOptions {
|
|
96
|
+
export interface WorkflowListOptions extends CallOptions {
|
|
68
97
|
/** Project id to scope this call to; overrides the client's default. */
|
|
69
98
|
project?: string;
|
|
70
99
|
}
|
|
@@ -130,6 +159,82 @@ export interface WorkflowRunResult extends RunResult {
|
|
|
130
159
|
/** The HTTP status that carried this body: `200` terminal, `202` queued or still running. */
|
|
131
160
|
httpStatus: number;
|
|
132
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* A workflow definition — the portable document, kept OPAQUE.
|
|
164
|
+
*
|
|
165
|
+
* `Record<string, unknown>` and not a modelled shape, on purpose. A workflow's
|
|
166
|
+
* body is `steps[]` of node types the engine owns and extends
|
|
167
|
+
* (`rfcs/node-types.md`); a wrapper that froze that shape would reject a
|
|
168
|
+
* workflow a newer server accepts, and would have to ship a release every time
|
|
169
|
+
* a node type gained a field. What the wrapper *does* pin is the envelope
|
|
170
|
+
* around it — {@linkcode WorkflowDetail}, {@linkcode WorkflowSaveResult} —
|
|
171
|
+
* because that is the part the wrapper is responsible for.
|
|
172
|
+
*
|
|
173
|
+
* The one field this package reads out of it is `id`, in
|
|
174
|
+
* {@linkcode WorkflowsApi.create}, to decide whether to mint one.
|
|
175
|
+
*/
|
|
176
|
+
export type WorkflowDefinition = Record<string, unknown>;
|
|
177
|
+
/** What `workflows.get` returns: the definition, plus the two things that are not in it. */
|
|
178
|
+
export interface WorkflowDetail {
|
|
179
|
+
/** The stored definition, overlaid with the authoritative `status` and `tags`. */
|
|
180
|
+
workflow: WorkflowDefinition;
|
|
181
|
+
/** Where this workflow was imported from, when it was imported at all. */
|
|
182
|
+
sourceRef: string | null;
|
|
183
|
+
/**
|
|
184
|
+
* ISO-8601. The optimistic-concurrency token — pass it back as
|
|
185
|
+
* {@linkcode WorkflowWriteOptions.ifUnmodifiedSince} to make the next save
|
|
186
|
+
* conditional.
|
|
187
|
+
*/
|
|
188
|
+
updatedAt: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* What `workflows.cancel` returns: the run, as the server's `run` envelope
|
|
192
|
+
* carries it right after the cancel request lands.
|
|
193
|
+
*
|
|
194
|
+
* **`status` is the run's status AS IT IS NOW, not the terminal outcome of the
|
|
195
|
+
* cancellation.** The server does not wait for the transition, so this is
|
|
196
|
+
* still `"queued"` or `"running"` — never `"canceled"` — and a caller that
|
|
197
|
+
* needs to know when the run actually stopped has to re-fetch it elsewhere;
|
|
198
|
+
* this operation does not poll on the caller's behalf, for the same reason
|
|
199
|
+
* {@linkcode WorkflowsApi.run}'s own `?wait=` polling stays server-side only.
|
|
200
|
+
*/
|
|
201
|
+
export interface WorkflowCancelResult {
|
|
202
|
+
/** The run's `run_…` id — the same id passed in. */
|
|
203
|
+
id: string;
|
|
204
|
+
/** The run's status as of this request; still in-flight, not yet `"canceled"`. */
|
|
205
|
+
status: RunStatus;
|
|
206
|
+
/** ISO-8601. When the server recorded this cancellation request. */
|
|
207
|
+
cancelRequestedAt: string;
|
|
208
|
+
}
|
|
209
|
+
/** What both `workflows.create` and `workflows.update` return. */
|
|
210
|
+
export interface WorkflowSaveResult {
|
|
211
|
+
/** The saved workflow's id and display name. */
|
|
212
|
+
workflow: {
|
|
213
|
+
id: string;
|
|
214
|
+
name: string;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* `true` when this save also (re)applied a schedule from the definition's
|
|
218
|
+
* `trigger.cron`. A workflow that already had one is not re-scheduled, so
|
|
219
|
+
* `false` does not mean "not scheduled" — it means "not scheduled by THIS
|
|
220
|
+
* call".
|
|
221
|
+
*/
|
|
222
|
+
scheduled: boolean;
|
|
223
|
+
/** The new concurrency token, so a caller can chain saves without a re-`get`. */
|
|
224
|
+
updatedAt: string;
|
|
225
|
+
}
|
|
226
|
+
/** Per-call options for `workflows.create` and `workflows.update`. */
|
|
227
|
+
export interface WorkflowWriteOptions {
|
|
228
|
+
/** Project id to scope this write to; overrides the client's default. */
|
|
229
|
+
project?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The exact `updatedAt` this client last saw. When given, the server refuses
|
|
232
|
+
* the write with `409 workflow_stale` if the stored row has moved on since —
|
|
233
|
+
* recoverable by re-reading and re-saving. Omitted, the save is
|
|
234
|
+
* last-write-wins.
|
|
235
|
+
*/
|
|
236
|
+
ifUnmodifiedSince?: string | null;
|
|
237
|
+
}
|
|
133
238
|
/**
|
|
134
239
|
* The `workflows` namespace on a `W6WClient`.
|
|
135
240
|
*
|
|
@@ -139,6 +244,21 @@ export interface WorkflowRunResult extends RunResult {
|
|
|
139
244
|
*
|
|
140
245
|
* const run = await client.workflows.run(active[0].id, { wait: true });
|
|
141
246
|
* if (run.status === "failed") console.error(run.error); // data, not an exception
|
|
247
|
+
*
|
|
248
|
+
* // The definition lifecycle: create, read-modify-write, then retire.
|
|
249
|
+
* const { workflow } = await client.workflows.create({
|
|
250
|
+
* manifestVersion: "2",
|
|
251
|
+
* name: "Nightly sync",
|
|
252
|
+
* steps: [],
|
|
253
|
+
* });
|
|
254
|
+
* const current = await client.workflows.get(workflow.id);
|
|
255
|
+
* await client.workflows.update(
|
|
256
|
+
* workflow.id,
|
|
257
|
+
* { ...current.workflow, name: "Nightly sync (EU)" },
|
|
258
|
+
* { ifUnmodifiedSince: current.updatedAt },
|
|
259
|
+
* );
|
|
260
|
+
* await client.workflows.archive(workflow.id);
|
|
261
|
+
* await client.workflows.delete(workflow.id);
|
|
142
262
|
* ```
|
|
143
263
|
*/
|
|
144
264
|
export declare class WorkflowsApi {
|
|
@@ -155,7 +275,7 @@ export declare class WorkflowsApi {
|
|
|
155
275
|
* `?project=`", which is how the caller asks for every project the credential
|
|
156
276
|
* can see.
|
|
157
277
|
*
|
|
158
|
-
* @param options - Optional per-call project scope.
|
|
278
|
+
* @param options - Optional per-call project scope and/or `signal` to abort.
|
|
159
279
|
* @returns The workflows, unwrapped from the `workflows` envelope.
|
|
160
280
|
* @throws {ApiError} On any non-2xx.
|
|
161
281
|
*/
|
|
@@ -176,12 +296,144 @@ export declare class WorkflowsApi {
|
|
|
176
296
|
* raises only when the *request* failed — `404 unknown_workflow`, a rejected
|
|
177
297
|
* token, a transport failure.
|
|
178
298
|
*
|
|
179
|
-
* @param id - The `wf_…` id,
|
|
299
|
+
* @param id - The `wf_…` id, or the Workflow's `key`. Percent-encoded into the path.
|
|
180
300
|
* @param options - `wait`, plus the `variables`, `trigger` and `input` that go in the body.
|
|
181
301
|
* @returns The run handle, its status, and the result when the run has one.
|
|
182
302
|
* @throws {ApiError} `404 unknown_workflow` when there is no such workflow.
|
|
183
303
|
* @throws {ApiError} `bad_response` when a success body is not a run object.
|
|
184
304
|
*/
|
|
185
305
|
run(id: string, options?: WorkflowRunOptions): Promise<WorkflowRunResult>;
|
|
306
|
+
/**
|
|
307
|
+
* Cancel a queued or running workflow run.
|
|
308
|
+
*
|
|
309
|
+
* **Addressed by the RUN id, not the workflow id** — the path root is
|
|
310
|
+
* `/runs/…`, the one deliberate exception to this class's otherwise
|
|
311
|
+
* `/workflows/…`-rooted paths, because a workflow can have many runs and
|
|
312
|
+
* only the run id picks one out.
|
|
313
|
+
*
|
|
314
|
+
* **A `202` means the cancellation was requested, not that the run has
|
|
315
|
+
* stopped.** The server does not wait for the transition, so the returned
|
|
316
|
+
* {@linkcode WorkflowCancelResult.status} is the run's status as it is
|
|
317
|
+
* right now — still `queued` or `running` — and this method never reports
|
|
318
|
+
* it as `"canceled"`. Idempotent: cancelling a run that is already marked
|
|
319
|
+
* but not yet terminal answers `202` again rather than erroring.
|
|
320
|
+
*
|
|
321
|
+
* @param runId - The `run_…` id, percent-encoded into the path.
|
|
322
|
+
* @returns The run's id, its status as of this request, and when the cancellation was requested.
|
|
323
|
+
* @throws {ApiError} `404 unknown_run` — no such run, or it is not this caller's (indistinguishable on purpose).
|
|
324
|
+
* @throws {ApiError} `409 run_not_cancelable` — the run has already reached a terminal state.
|
|
325
|
+
*/
|
|
326
|
+
cancel(runId: string): Promise<WorkflowCancelResult>;
|
|
327
|
+
/**
|
|
328
|
+
* Fetch one workflow's stored definition.
|
|
329
|
+
*
|
|
330
|
+
* `workflow` is the definition the server has, overlaid with the
|
|
331
|
+
* authoritative `status` and `tags` columns — so a freshly created workflow
|
|
332
|
+
* that carries neither inline still reports its real lifecycle state.
|
|
333
|
+
*
|
|
334
|
+
* **`updatedAt` is a TOP-LEVEL SIBLING of `workflow`, never a field inside
|
|
335
|
+
* it**, and that placement is load-bearing rather than incidental: the
|
|
336
|
+
* definition is the portable document (it can be exported, re-imported, or
|
|
337
|
+
* committed to a repo) and a server timestamp must not enter it. It is also
|
|
338
|
+
* the optimistic-concurrency token — hand it straight back to
|
|
339
|
+
* {@linkcode update} as `ifUnmodifiedSince` and a save that would clobber
|
|
340
|
+
* someone else's is refused instead.
|
|
341
|
+
*
|
|
342
|
+
* @param id - The `wf_…` id, percent-encoded into the path.
|
|
343
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
344
|
+
* @returns The definition, its source ref, and the concurrency token.
|
|
345
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
346
|
+
*/
|
|
347
|
+
get(id: string, options?: CallOptions): Promise<WorkflowDetail>;
|
|
348
|
+
/**
|
|
349
|
+
* Create a workflow.
|
|
350
|
+
*
|
|
351
|
+
* **The id is minted client-side when the definition does not carry one.**
|
|
352
|
+
* The server requires an `id` in the body and never generates one
|
|
353
|
+
* (`admin/workflows.ts`'s `validateDefinition`), so a `create` that simply
|
|
354
|
+
* forwarded the caller's object would answer `400 invalid_workflow` for the
|
|
355
|
+
* most natural call there is — `create({name, steps})`. A caller that wants
|
|
356
|
+
* to choose its own id still can: an `id` already present is forwarded
|
|
357
|
+
* untouched, which is what makes this method usable for a seeded or
|
|
358
|
+
* imported definition.
|
|
359
|
+
*
|
|
360
|
+
* `create` and {@linkcode update} reach the SAME upsert route, and the
|
|
361
|
+
* server does not distinguish them — the distinction is in what each one
|
|
362
|
+
* does to the body, and it is a real one: `create` mints an id, `update`
|
|
363
|
+
* pins the one you addressed. Posting a definition whose id already exists
|
|
364
|
+
* therefore OVERWRITES it; this method does not pre-check, because a
|
|
365
|
+
* check-then-write is two round trips that still race.
|
|
366
|
+
*
|
|
367
|
+
* @param definition - The whole workflow definition, forwarded verbatim apart from a minted `id`.
|
|
368
|
+
* @param options - `project` scopes the write to one project.
|
|
369
|
+
* @returns The new workflow's id and name, whether a schedule was applied, and the first `updatedAt`.
|
|
370
|
+
* @throws {ApiError} `400 invalid_workflow` — missing `name`/`steps`, or a wrong `manifestVersion`.
|
|
371
|
+
* @throws {ApiError} `400 unknown_project` — `project` names a project this account does not own.
|
|
372
|
+
* @throws {ApiError} `409 workflow_conflict` — another `(tenant, subject)` already owns that id.
|
|
373
|
+
*/
|
|
374
|
+
create(definition: WorkflowDefinition, options?: WorkflowWriteOptions): Promise<WorkflowSaveResult>;
|
|
375
|
+
/**
|
|
376
|
+
* Overwrite a workflow's stored definition.
|
|
377
|
+
*
|
|
378
|
+
* **This is a full replacement, not a patch.** The server has one write
|
|
379
|
+
* route for workflows and it stores what it is given, so a field left out of
|
|
380
|
+
* `definition` is a field removed from the workflow — the same semantics as
|
|
381
|
+
* the studio's own save. Read with {@linkcode get}, change what you mean to
|
|
382
|
+
* change, and send the whole thing back.
|
|
383
|
+
*
|
|
384
|
+
* `id` is taken from the FIRST ARGUMENT and pinned into the body, overriding
|
|
385
|
+
* any `id` the definition carries. The alternative — trusting the body —
|
|
386
|
+
* makes `update("wf_a", defOfB)` silently write to B while reading as a
|
|
387
|
+
* write to A.
|
|
388
|
+
*
|
|
389
|
+
* Pass `options.ifUnmodifiedSince` (the `updatedAt` from {@linkcode get} or
|
|
390
|
+
* from a previous save) to make the write conditional. Without it the save
|
|
391
|
+
* is last-write-wins.
|
|
392
|
+
*
|
|
393
|
+
* @param id - The `wf_…` id to write to.
|
|
394
|
+
* @param definition - The whole replacement definition.
|
|
395
|
+
* @param options - `project` scopes the write; `ifUnmodifiedSince` is the concurrency precondition.
|
|
396
|
+
* @returns The workflow's id and name, whether a schedule was (re)applied, and the new `updatedAt`.
|
|
397
|
+
* @throws {ApiError} `400 invalid_workflow` / `400 invalid_precondition`.
|
|
398
|
+
* @throws {ApiError} `409 workflow_conflict` — another `(tenant, subject)` owns this id. NOT recoverable by reloading.
|
|
399
|
+
* @throws {ApiError} `409 workflow_stale` — the precondition did not match the stored `updatedAt`. IS recoverable by reloading and re-saving.
|
|
400
|
+
*/
|
|
401
|
+
update(id: string, definition: WorkflowDefinition, options?: WorkflowWriteOptions): Promise<WorkflowSaveResult>;
|
|
402
|
+
/**
|
|
403
|
+
* Archive a workflow.
|
|
404
|
+
*
|
|
405
|
+
* One-way: there is no unarchive route on this domain. Idempotent —
|
|
406
|
+
* archiving an already-archived workflow re-returns it unchanged rather than
|
|
407
|
+
* erroring.
|
|
408
|
+
*
|
|
409
|
+
* This is a required step, not a convenience: {@linkcode delete} refuses a
|
|
410
|
+
* workflow that is still `draft` or `active`.
|
|
411
|
+
*
|
|
412
|
+
* @param id - The `wf_…` id.
|
|
413
|
+
* @returns The archived definition, with `status` and `tags` merged in as {@linkcode get} returns them.
|
|
414
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
415
|
+
*/
|
|
416
|
+
archive(id: string): Promise<WorkflowDefinition>;
|
|
417
|
+
/**
|
|
418
|
+
* Delete an archived workflow, and everything that hangs off it.
|
|
419
|
+
*
|
|
420
|
+
* The workflow's runs, schedules and subscriptions cascade-delete server-side
|
|
421
|
+
* — there is nothing for the caller to clean up, and nothing to undo.
|
|
422
|
+
*
|
|
423
|
+
* **Archive first.** Deleting a workflow whose status is not `archived` is
|
|
424
|
+
* `409 workflow_not_archived`, which this method deliberately does NOT catch
|
|
425
|
+
* and retry through {@linkcode archive}: a two-step destructive path that an
|
|
426
|
+
* SDK silently completes for you is how a caller deletes something they only
|
|
427
|
+
* meant to look at.
|
|
428
|
+
*
|
|
429
|
+
* Returns nothing. The server's `{ok: true}` carries no information a caller
|
|
430
|
+
* can use, and `Ok` is not a public type of this package
|
|
431
|
+
* (`docs/implementation.md` §5).
|
|
432
|
+
*
|
|
433
|
+
* @param id - The `wf_…` id.
|
|
434
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
435
|
+
* @throws {ApiError} `409 workflow_not_archived` when it exists but has not been archived yet.
|
|
436
|
+
*/
|
|
437
|
+
delete(id: string): Promise<void>;
|
|
186
438
|
}
|
|
187
439
|
//# sourceMappingURL=workflows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/workflows.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/workflows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,a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