@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/workflows.js
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
|
|
@@ -45,7 +71,15 @@
|
|
|
45
71
|
*/
|
|
46
72
|
import { ApiError } from "./errors.js";
|
|
47
73
|
import { path } from "./http.js";
|
|
48
|
-
import { isTerminalRunStatus, unwrap, } from "./types.js";
|
|
74
|
+
import { isTerminalRunStatus, mintId, unwrap, } from "./types.js";
|
|
75
|
+
/**
|
|
76
|
+
* The precondition header the write path sends when `ifUnmodifiedSince` is given.
|
|
77
|
+
*
|
|
78
|
+
* Deliberately not the standard `If-Unmodified-Since`: that header's HTTP-date
|
|
79
|
+
* format has one-second granularity, and two saves inside one second is the
|
|
80
|
+
* exact case this guards (`admin/workflows.ts`).
|
|
81
|
+
*/
|
|
82
|
+
const PRECONDITION_HEADER = "x-w6w-if-unmodified-since";
|
|
49
83
|
/**
|
|
50
84
|
* The `workflows` namespace on a `W6WClient`.
|
|
51
85
|
*
|
|
@@ -55,6 +89,21 @@ import { isTerminalRunStatus, unwrap, } from "./types.js";
|
|
|
55
89
|
*
|
|
56
90
|
* const run = await client.workflows.run(active[0].id, { wait: true });
|
|
57
91
|
* if (run.status === "failed") console.error(run.error); // data, not an exception
|
|
92
|
+
*
|
|
93
|
+
* // The definition lifecycle: create, read-modify-write, then retire.
|
|
94
|
+
* const { workflow } = await client.workflows.create({
|
|
95
|
+
* manifestVersion: "2",
|
|
96
|
+
* name: "Nightly sync",
|
|
97
|
+
* steps: [],
|
|
98
|
+
* });
|
|
99
|
+
* const current = await client.workflows.get(workflow.id);
|
|
100
|
+
* await client.workflows.update(
|
|
101
|
+
* workflow.id,
|
|
102
|
+
* { ...current.workflow, name: "Nightly sync (EU)" },
|
|
103
|
+
* { ifUnmodifiedSince: current.updatedAt },
|
|
104
|
+
* );
|
|
105
|
+
* await client.workflows.archive(workflow.id);
|
|
106
|
+
* await client.workflows.delete(workflow.id);
|
|
58
107
|
* ```
|
|
59
108
|
*/
|
|
60
109
|
export class WorkflowsApi {
|
|
@@ -73,7 +122,7 @@ export class WorkflowsApi {
|
|
|
73
122
|
* `?project=`", which is how the caller asks for every project the credential
|
|
74
123
|
* can see.
|
|
75
124
|
*
|
|
76
|
-
* @param options - Optional per-call project scope.
|
|
125
|
+
* @param options - Optional per-call project scope and/or `signal` to abort.
|
|
77
126
|
* @returns The workflows, unwrapped from the `workflows` envelope.
|
|
78
127
|
* @throws {ApiError} On any non-2xx.
|
|
79
128
|
*/
|
|
@@ -82,6 +131,7 @@ export class WorkflowsApi {
|
|
|
82
131
|
method: "GET",
|
|
83
132
|
path: "/workflows",
|
|
84
133
|
query: { project: options?.project ?? this.#host.config.project ?? undefined },
|
|
134
|
+
signal: options?.signal,
|
|
85
135
|
});
|
|
86
136
|
return unwrap(res, "workflows");
|
|
87
137
|
}
|
|
@@ -101,7 +151,7 @@ export class WorkflowsApi {
|
|
|
101
151
|
* raises only when the *request* failed — `404 unknown_workflow`, a rejected
|
|
102
152
|
* token, a transport failure.
|
|
103
153
|
*
|
|
104
|
-
* @param id - The `wf_…` id,
|
|
154
|
+
* @param id - The `wf_…` id, or the Workflow's `key`. Percent-encoded into the path.
|
|
105
155
|
* @param options - `wait`, plus the `variables`, `trigger` and `input` that go in the body.
|
|
106
156
|
* @returns The run handle, its status, and the result when the run has one.
|
|
107
157
|
* @throws {ApiError} `404 unknown_workflow` when there is no such workflow.
|
|
@@ -156,5 +206,194 @@ export class WorkflowsApi {
|
|
|
156
206
|
httpStatus: res.status,
|
|
157
207
|
};
|
|
158
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Cancel a queued or running workflow run.
|
|
211
|
+
*
|
|
212
|
+
* **Addressed by the RUN id, not the workflow id** — the path root is
|
|
213
|
+
* `/runs/…`, the one deliberate exception to this class's otherwise
|
|
214
|
+
* `/workflows/…`-rooted paths, because a workflow can have many runs and
|
|
215
|
+
* only the run id picks one out.
|
|
216
|
+
*
|
|
217
|
+
* **A `202` means the cancellation was requested, not that the run has
|
|
218
|
+
* stopped.** The server does not wait for the transition, so the returned
|
|
219
|
+
* {@linkcode WorkflowCancelResult.status} is the run's status as it is
|
|
220
|
+
* right now — still `queued` or `running` — and this method never reports
|
|
221
|
+
* it as `"canceled"`. Idempotent: cancelling a run that is already marked
|
|
222
|
+
* but not yet terminal answers `202` again rather than erroring.
|
|
223
|
+
*
|
|
224
|
+
* @param runId - The `run_…` id, percent-encoded into the path.
|
|
225
|
+
* @returns The run's id, its status as of this request, and when the cancellation was requested.
|
|
226
|
+
* @throws {ApiError} `404 unknown_run` — no such run, or it is not this caller's (indistinguishable on purpose).
|
|
227
|
+
* @throws {ApiError} `409 run_not_cancelable` — the run has already reached a terminal state.
|
|
228
|
+
*/
|
|
229
|
+
async cancel(runId) {
|
|
230
|
+
const res = await this.#host.request({
|
|
231
|
+
method: "POST",
|
|
232
|
+
path: path `/runs/${runId}/cancel`,
|
|
233
|
+
});
|
|
234
|
+
return unwrap(res, "run");
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Fetch one workflow's stored definition.
|
|
238
|
+
*
|
|
239
|
+
* `workflow` is the definition the server has, overlaid with the
|
|
240
|
+
* authoritative `status` and `tags` columns — so a freshly created workflow
|
|
241
|
+
* that carries neither inline still reports its real lifecycle state.
|
|
242
|
+
*
|
|
243
|
+
* **`updatedAt` is a TOP-LEVEL SIBLING of `workflow`, never a field inside
|
|
244
|
+
* it**, and that placement is load-bearing rather than incidental: the
|
|
245
|
+
* definition is the portable document (it can be exported, re-imported, or
|
|
246
|
+
* committed to a repo) and a server timestamp must not enter it. It is also
|
|
247
|
+
* the optimistic-concurrency token — hand it straight back to
|
|
248
|
+
* {@linkcode update} as `ifUnmodifiedSince` and a save that would clobber
|
|
249
|
+
* someone else's is refused instead.
|
|
250
|
+
*
|
|
251
|
+
* @param id - The `wf_…` id, percent-encoded into the path.
|
|
252
|
+
* @param options - Optional per-call transport options (`signal` to abort).
|
|
253
|
+
* @returns The definition, its source ref, and the concurrency token.
|
|
254
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
255
|
+
*/
|
|
256
|
+
async get(id, options) {
|
|
257
|
+
const res = await this.#host.request({
|
|
258
|
+
method: "GET",
|
|
259
|
+
path: path `/workflows/${id}`,
|
|
260
|
+
signal: options?.signal,
|
|
261
|
+
});
|
|
262
|
+
// No envelope key to peel — this route's body IS the payload, all three
|
|
263
|
+
// fields of it. `unwrap` would be wrong here, not merely unnecessary:
|
|
264
|
+
// there is no key it could name.
|
|
265
|
+
return res.body;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Create a workflow.
|
|
269
|
+
*
|
|
270
|
+
* **The id is minted client-side when the definition does not carry one.**
|
|
271
|
+
* The server requires an `id` in the body and never generates one
|
|
272
|
+
* (`admin/workflows.ts`'s `validateDefinition`), so a `create` that simply
|
|
273
|
+
* forwarded the caller's object would answer `400 invalid_workflow` for the
|
|
274
|
+
* most natural call there is — `create({name, steps})`. A caller that wants
|
|
275
|
+
* to choose its own id still can: an `id` already present is forwarded
|
|
276
|
+
* untouched, which is what makes this method usable for a seeded or
|
|
277
|
+
* imported definition.
|
|
278
|
+
*
|
|
279
|
+
* `create` and {@linkcode update} reach the SAME upsert route, and the
|
|
280
|
+
* server does not distinguish them — the distinction is in what each one
|
|
281
|
+
* does to the body, and it is a real one: `create` mints an id, `update`
|
|
282
|
+
* pins the one you addressed. Posting a definition whose id already exists
|
|
283
|
+
* therefore OVERWRITES it; this method does not pre-check, because a
|
|
284
|
+
* check-then-write is two round trips that still race.
|
|
285
|
+
*
|
|
286
|
+
* @param definition - The whole workflow definition, forwarded verbatim apart from a minted `id`.
|
|
287
|
+
* @param options - `project` scopes the write to one project.
|
|
288
|
+
* @returns The new workflow's id and name, whether a schedule was applied, and the first `updatedAt`.
|
|
289
|
+
* @throws {ApiError} `400 invalid_workflow` — missing `name`/`steps`, or a wrong `manifestVersion`.
|
|
290
|
+
* @throws {ApiError} `400 unknown_project` — `project` names a project this account does not own.
|
|
291
|
+
* @throws {ApiError} `409 workflow_conflict` — another `(tenant, subject)` already owns that id.
|
|
292
|
+
*/
|
|
293
|
+
async create(definition, options) {
|
|
294
|
+
const body = typeof definition.id === "string" && definition.id.length > 0
|
|
295
|
+
? definition
|
|
296
|
+
: { ...definition, id: mintId("wf") };
|
|
297
|
+
return await this.#save(body, options);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Overwrite a workflow's stored definition.
|
|
301
|
+
*
|
|
302
|
+
* **This is a full replacement, not a patch.** The server has one write
|
|
303
|
+
* route for workflows and it stores what it is given, so a field left out of
|
|
304
|
+
* `definition` is a field removed from the workflow — the same semantics as
|
|
305
|
+
* the studio's own save. Read with {@linkcode get}, change what you mean to
|
|
306
|
+
* change, and send the whole thing back.
|
|
307
|
+
*
|
|
308
|
+
* `id` is taken from the FIRST ARGUMENT and pinned into the body, overriding
|
|
309
|
+
* any `id` the definition carries. The alternative — trusting the body —
|
|
310
|
+
* makes `update("wf_a", defOfB)` silently write to B while reading as a
|
|
311
|
+
* write to A.
|
|
312
|
+
*
|
|
313
|
+
* Pass `options.ifUnmodifiedSince` (the `updatedAt` from {@linkcode get} or
|
|
314
|
+
* from a previous save) to make the write conditional. Without it the save
|
|
315
|
+
* is last-write-wins.
|
|
316
|
+
*
|
|
317
|
+
* @param id - The `wf_…` id to write to.
|
|
318
|
+
* @param definition - The whole replacement definition.
|
|
319
|
+
* @param options - `project` scopes the write; `ifUnmodifiedSince` is the concurrency precondition.
|
|
320
|
+
* @returns The workflow's id and name, whether a schedule was (re)applied, and the new `updatedAt`.
|
|
321
|
+
* @throws {ApiError} `400 invalid_workflow` / `400 invalid_precondition`.
|
|
322
|
+
* @throws {ApiError} `409 workflow_conflict` — another `(tenant, subject)` owns this id. NOT recoverable by reloading.
|
|
323
|
+
* @throws {ApiError} `409 workflow_stale` — the precondition did not match the stored `updatedAt`. IS recoverable by reloading and re-saving.
|
|
324
|
+
*/
|
|
325
|
+
async update(id, definition, options) {
|
|
326
|
+
return await this.#save({ ...definition, id }, options);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Archive a workflow.
|
|
330
|
+
*
|
|
331
|
+
* One-way: there is no unarchive route on this domain. Idempotent —
|
|
332
|
+
* archiving an already-archived workflow re-returns it unchanged rather than
|
|
333
|
+
* erroring.
|
|
334
|
+
*
|
|
335
|
+
* This is a required step, not a convenience: {@linkcode delete} refuses a
|
|
336
|
+
* workflow that is still `draft` or `active`.
|
|
337
|
+
*
|
|
338
|
+
* @param id - The `wf_…` id.
|
|
339
|
+
* @returns The archived definition, with `status` and `tags` merged in as {@linkcode get} returns them.
|
|
340
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
341
|
+
*/
|
|
342
|
+
async archive(id) {
|
|
343
|
+
const res = await this.#host.request({
|
|
344
|
+
method: "POST",
|
|
345
|
+
path: path `/workflows/${id}/archive`,
|
|
346
|
+
});
|
|
347
|
+
return unwrap(res, "workflow");
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Delete an archived workflow, and everything that hangs off it.
|
|
351
|
+
*
|
|
352
|
+
* The workflow's runs, schedules and subscriptions cascade-delete server-side
|
|
353
|
+
* — there is nothing for the caller to clean up, and nothing to undo.
|
|
354
|
+
*
|
|
355
|
+
* **Archive first.** Deleting a workflow whose status is not `archived` is
|
|
356
|
+
* `409 workflow_not_archived`, which this method deliberately does NOT catch
|
|
357
|
+
* and retry through {@linkcode archive}: a two-step destructive path that an
|
|
358
|
+
* SDK silently completes for you is how a caller deletes something they only
|
|
359
|
+
* meant to look at.
|
|
360
|
+
*
|
|
361
|
+
* Returns nothing. The server's `{ok: true}` carries no information a caller
|
|
362
|
+
* can use, and `Ok` is not a public type of this package
|
|
363
|
+
* (`docs/implementation.md` §5).
|
|
364
|
+
*
|
|
365
|
+
* @param id - The `wf_…` id.
|
|
366
|
+
* @throws {ApiError} `404 unknown_workflow` when there is no such id.
|
|
367
|
+
* @throws {ApiError} `409 workflow_not_archived` when it exists but has not been archived yet.
|
|
368
|
+
*/
|
|
369
|
+
async delete(id) {
|
|
370
|
+
await this.#host.request({ method: "DELETE", path: path `/workflows/${id}` });
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The one POST both {@linkcode create} and {@linkcode update} go through.
|
|
374
|
+
*
|
|
375
|
+
* Private, and shared rather than duplicated, because the precondition
|
|
376
|
+
* header has a rule that is easy to get subtly wrong twice: it is sent only
|
|
377
|
+
* when a value was actually given, NEVER as an empty or `"null"` string. The
|
|
378
|
+
* server parses whatever arrives and answers `400 invalid_precondition` for
|
|
379
|
+
* a value it cannot read, so a stray header turns a fine save into an error
|
|
380
|
+
* that names something the caller never asked for.
|
|
381
|
+
*
|
|
382
|
+
* @param body - The complete definition, id already resolved.
|
|
383
|
+
* @param options - The write options as given by the public method.
|
|
384
|
+
* @returns The server's save result, verbatim.
|
|
385
|
+
*/
|
|
386
|
+
async #save(body, options) {
|
|
387
|
+
const res = await this.#host.request({
|
|
388
|
+
method: "POST",
|
|
389
|
+
path: "/workflows",
|
|
390
|
+
query: { project: options?.project ?? this.#host.config.project ?? undefined },
|
|
391
|
+
body,
|
|
392
|
+
...(options?.ifUnmodifiedSince
|
|
393
|
+
? { headers: { [PRECONDITION_HEADER]: options.ifUnmodifiedSince } }
|
|
394
|
+
: {}),
|
|
395
|
+
});
|
|
396
|
+
return res.body;
|
|
397
|
+
}
|
|
159
398
|
}
|
|
160
399
|
//# sourceMappingURL=workflows.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/workflows.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/workflows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAuC,IAAI,EAAuB,MAAM,WAAW,CAAC;AAC3F,OAAO,EACL,mBAAmB,EACnB,MAAM,EAGN,MAAM,GAEP,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AA2KxD;;;;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AC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAA,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,KAAK,CACT,IAAwB,EACxB,OAA8B;QAE9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAqB;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,SAAS,EAAE;YAC9E,IAAI;YACJ,GAAG,CAAC,OAAO,EAAE,iBAAiB;gBAC5B,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBACnE,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w6w/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Typed client for the w6w HTTP API. Thin transport, auth and error mapping — nothing else.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"./console": {
|
|
23
23
|
"types": "./dist/src/console/mod.d.ts",
|
|
24
24
|
"import": "./dist/src/console/mod.js"
|
|
25
|
+
},
|
|
26
|
+
"./server": {
|
|
27
|
+
"types": "./dist/src/server/mod.d.ts",
|
|
28
|
+
"import": "./dist/src/server/mod.js"
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
"files": ["dist"],
|