@w6w/sdk 0.9.8 → 0.9.12

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.
Files changed (63) hide show
  1. package/README.md +23 -3
  2. package/dist/mod.d.ts +11 -2
  3. package/dist/mod.d.ts.map +1 -1
  4. package/dist/mod.js +6 -0
  5. package/dist/mod.js.map +1 -1
  6. package/dist/src/apps.d.ts +68 -0
  7. package/dist/src/apps.d.ts.map +1 -0
  8. package/dist/src/apps.js +76 -0
  9. package/dist/src/apps.js.map +1 -0
  10. package/dist/src/client.d.ts +15 -3
  11. package/dist/src/client.d.ts.map +1 -1
  12. package/dist/src/client.js +19 -3
  13. package/dist/src/client.js.map +1 -1
  14. package/dist/src/connections.d.ts +41 -13
  15. package/dist/src/connections.d.ts.map +1 -1
  16. package/dist/src/connections.js +54 -12
  17. package/dist/src/connections.js.map +1 -1
  18. package/dist/src/console/apps.d.ts +5 -0
  19. package/dist/src/console/apps.d.ts.map +1 -1
  20. package/dist/src/console/apps.js.map +1 -1
  21. package/dist/src/console/connections.d.ts +10 -9
  22. package/dist/src/console/connections.d.ts.map +1 -1
  23. package/dist/src/console/connections.js +10 -9
  24. package/dist/src/console/connections.js.map +1 -1
  25. package/dist/src/console/tenant-oauth-apps.d.ts +26 -0
  26. package/dist/src/console/tenant-oauth-apps.d.ts.map +1 -1
  27. package/dist/src/console/tenant-oauth-apps.js +3 -1
  28. package/dist/src/console/tenant-oauth-apps.js.map +1 -1
  29. package/dist/src/dashboard.d.ts +50 -0
  30. package/dist/src/dashboard.d.ts.map +1 -0
  31. package/dist/src/dashboard.js +49 -0
  32. package/dist/src/dashboard.js.map +1 -0
  33. package/dist/src/functions.d.ts +100 -3
  34. package/dist/src/functions.d.ts.map +1 -1
  35. package/dist/src/functions.js +122 -3
  36. package/dist/src/functions.js.map +1 -1
  37. package/dist/src/projects.d.ts +49 -0
  38. package/dist/src/projects.d.ts.map +1 -0
  39. package/dist/src/projects.js +51 -0
  40. package/dist/src/projects.js.map +1 -0
  41. package/dist/src/reliability.d.ts +78 -0
  42. package/dist/src/reliability.d.ts.map +1 -0
  43. package/dist/src/reliability.js +76 -0
  44. package/dist/src/reliability.js.map +1 -0
  45. package/dist/src/server/mod.d.ts +71 -1
  46. package/dist/src/server/mod.d.ts.map +1 -1
  47. package/dist/src/server/mod.js +78 -7
  48. package/dist/src/server/mod.js.map +1 -1
  49. package/dist/src/types.d.ts +7 -0
  50. package/dist/src/types.d.ts.map +1 -1
  51. package/dist/src/types.js.map +1 -1
  52. package/dist/src/version.d.ts.map +1 -1
  53. package/dist/src/version.js +1 -1
  54. package/dist/src/version.js.map +1 -1
  55. package/dist/src/versions.d.ts +134 -0
  56. package/dist/src/versions.d.ts.map +1 -0
  57. package/dist/src/versions.js +113 -0
  58. package/dist/src/versions.js.map +1 -0
  59. package/dist/src/workflows.d.ts +82 -0
  60. package/dist/src/workflows.d.ts.map +1 -1
  61. package/dist/src/workflows.js +109 -4
  62. package/dist/src/workflows.js.map +1 -1
  63. package/package.json +1 -1
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Version history, publish/revert and enable/disable — shared by
3
+ * `client.workflows.*` and `client.functions.*`.
4
+ *
5
+ * The server serves both kinds from one route factory
6
+ * (`admin/callable-routes.ts`), so the wire is identical except for the
7
+ * collection segment and the verb a version run uses (`run` for a workflow,
8
+ * `invoke` for a Function). This module is the one place that knows that: a
9
+ * single path builder and one kind-parameterised request helper, which the two
10
+ * resource classes call thinly. A third copy per kind is where a path typo
11
+ * would hide.
12
+ *
13
+ * The types mirror the server's `bll/callable-versions.ts` response interfaces
14
+ * (`callableId`, nullable `createdBy`), not any consumer's copy of them.
15
+ */
16
+ import { type HttpResponse, type RequestOptions } from "./http.ts";
17
+ /** The two kinds that have a version surface in this SDK (Endpoints are not covered). */
18
+ export type VersionedKind = "workflows" | "functions";
19
+ /** What the version helpers need from a client: one transport call. */
20
+ export interface VersionsHost {
21
+ /** Perform one request. */
22
+ request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
23
+ }
24
+ /** One row of {@linkcode VersionList.versions} — metadata only, no definition. */
25
+ export interface VersionSummary {
26
+ /** 1-based, assigned by the server at publish time. */
27
+ versionNumber: number;
28
+ /** ISO-8601 timestamp of the publish. */
29
+ createdAt: string;
30
+ /** Who published it; `null` when the server did not record one. */
31
+ createdBy: string | null;
32
+ /** Whether this is the version runs use today. */
33
+ isCurrentPublished: boolean;
34
+ }
35
+ /** What `listVersions` returns: the server's whole body. */
36
+ export interface VersionList {
37
+ /** Whether the resource may be invoked at all. */
38
+ enabled: boolean;
39
+ /** The published version in effect; `null` before the first publish. */
40
+ currentPublishedVersion: number | null;
41
+ /** Published versions, metadata only. */
42
+ versions: VersionSummary[];
43
+ }
44
+ /** What `getVersion` returns: one version, with its (server-redacted) definition. */
45
+ export interface VersionDetail extends VersionSummary {
46
+ /** The definition as published; opaque, like `WorkflowDefinition` / `FunctionDefinition`. */
47
+ definition: unknown;
48
+ }
49
+ /** What `publish` returns: the server's whole body. */
50
+ export interface PublishResult {
51
+ version: {
52
+ kind: string;
53
+ /** The workflow's or Function's id. */
54
+ callableId: string;
55
+ versionNumber: number;
56
+ createdAt: string;
57
+ /** Who published it; `null` when the server did not record one. */
58
+ createdBy: string | null;
59
+ };
60
+ /** The version runs use after this publish. */
61
+ currentPublishedVersion: number;
62
+ }
63
+ /** What `revert` returns: the `reverted` object unwrapped from its envelope. */
64
+ export interface RevertResult {
65
+ kind: string;
66
+ /** The workflow's or Function's id. */
67
+ callableId: string;
68
+ /** The version the live definition was rewritten from. */
69
+ versionNumber: number;
70
+ }
71
+ /**
72
+ * The path of a version-scoped run: `run` for a workflow, `invoke` for a
73
+ * Function. The id and the number are percent-encoded by the `path` tag.
74
+ *
75
+ * @param kind - Which collection.
76
+ * @param id - The resource id (or key).
77
+ * @param n - The version number.
78
+ * @returns The path, e.g. `/functions/fn_1/versions/2/invoke`.
79
+ */
80
+ export declare function versionRunPath(kind: VersionedKind, id: string, n: number): string;
81
+ /**
82
+ * `GET /<kind>/{id}/versions`.
83
+ *
84
+ * @param host - The transport.
85
+ * @param kind - Which collection.
86
+ * @param id - The resource id.
87
+ * @returns The server's whole body.
88
+ * @throws {ApiError} Any non-2xx, untouched.
89
+ */
90
+ export declare function listVersions(host: VersionsHost, kind: VersionedKind, id: string): Promise<VersionList>;
91
+ /**
92
+ * `GET /<kind>/{id}/versions/{n}`.
93
+ *
94
+ * @param host - The transport.
95
+ * @param kind - Which collection.
96
+ * @param id - The resource id.
97
+ * @param n - The version number.
98
+ * @returns The `version` object, unwrapped from its envelope.
99
+ * @throws {ApiError} Any non-2xx untouched; `bad_response` when the envelope lacks `version`.
100
+ */
101
+ export declare function getVersion(host: VersionsHost, kind: VersionedKind, id: string, n: number): Promise<VersionDetail>;
102
+ /**
103
+ * `POST /<kind>/{id}/publish`.
104
+ *
105
+ * @param host - The transport.
106
+ * @param kind - Which collection.
107
+ * @param id - The resource id.
108
+ * @returns The server's whole body.
109
+ * @throws {ApiError} Any non-2xx, untouched.
110
+ */
111
+ export declare function publishVersion(host: VersionsHost, kind: VersionedKind, id: string): Promise<PublishResult>;
112
+ /**
113
+ * `POST /<kind>/{id}/versions/{n}/revert`.
114
+ *
115
+ * @param host - The transport.
116
+ * @param kind - Which collection.
117
+ * @param id - The resource id.
118
+ * @param n - The version to restore.
119
+ * @returns The `reverted` object, unwrapped from its envelope.
120
+ * @throws {ApiError} Any non-2xx untouched; `bad_response` when the envelope lacks `reverted`.
121
+ */
122
+ export declare function revertVersion(host: VersionsHost, kind: VersionedKind, id: string, n: number): Promise<RevertResult>;
123
+ /**
124
+ * `POST /<kind>/{id}/enable` or `/disable`. Returns nothing: the server's
125
+ * `{enabled}` echo carries no information the caller did not just ask for.
126
+ *
127
+ * @param host - The transport.
128
+ * @param kind - Which collection.
129
+ * @param id - The resource id.
130
+ * @param enabled - `true` hits `/enable`, `false` hits `/disable`.
131
+ * @throws {ApiError} Any non-2xx, untouched.
132
+ */
133
+ export declare function setEnabled(host: VersionsHost, kind: VersionedKind, id: string, enabled: boolean): Promise<void>;
134
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGzE,yFAAyF;AACzF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kDAAkD;IAClD,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,yCAAyC;IACzC,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,6FAA6F;IAC7F,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,uCAAuC;QACvC,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,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}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Version history, publish/revert and enable/disable — shared by
3
+ * `client.workflows.*` and `client.functions.*`.
4
+ *
5
+ * The server serves both kinds from one route factory
6
+ * (`admin/callable-routes.ts`), so the wire is identical except for the
7
+ * collection segment and the verb a version run uses (`run` for a workflow,
8
+ * `invoke` for a Function). This module is the one place that knows that: a
9
+ * single path builder and one kind-parameterised request helper, which the two
10
+ * resource classes call thinly. A third copy per kind is where a path typo
11
+ * would hide.
12
+ *
13
+ * The types mirror the server's `bll/callable-versions.ts` response interfaces
14
+ * (`callableId`, nullable `createdBy`), not any consumer's copy of them.
15
+ */
16
+ import { path } from "./http.js";
17
+ import { unwrap } from "./types.js";
18
+ /**
19
+ * The path of a version-scoped run: `run` for a workflow, `invoke` for a
20
+ * Function. The id and the number are percent-encoded by the `path` tag.
21
+ *
22
+ * @param kind - Which collection.
23
+ * @param id - The resource id (or key).
24
+ * @param n - The version number.
25
+ * @returns The path, e.g. `/functions/fn_1/versions/2/invoke`.
26
+ */
27
+ export function versionRunPath(kind, id, n) {
28
+ const verb = kind === "workflows" ? "run" : "invoke";
29
+ return `${path `/${kind}/${id}/versions/${String(n)}`}/${verb}`;
30
+ }
31
+ /**
32
+ * `GET /<kind>/{id}/versions`.
33
+ *
34
+ * @param host - The transport.
35
+ * @param kind - Which collection.
36
+ * @param id - The resource id.
37
+ * @returns The server's whole body.
38
+ * @throws {ApiError} Any non-2xx, untouched.
39
+ */
40
+ export async function listVersions(host, kind, id) {
41
+ const res = await host.request({
42
+ method: "GET",
43
+ path: path `/${kind}/${id}/versions`,
44
+ });
45
+ return res.body;
46
+ }
47
+ /**
48
+ * `GET /<kind>/{id}/versions/{n}`.
49
+ *
50
+ * @param host - The transport.
51
+ * @param kind - Which collection.
52
+ * @param id - The resource id.
53
+ * @param n - The version number.
54
+ * @returns The `version` object, unwrapped from its envelope.
55
+ * @throws {ApiError} Any non-2xx untouched; `bad_response` when the envelope lacks `version`.
56
+ */
57
+ export async function getVersion(host, kind, id, n) {
58
+ const res = await host.request({
59
+ method: "GET",
60
+ path: path `/${kind}/${id}/versions/${String(n)}`,
61
+ });
62
+ return unwrap(res, "version");
63
+ }
64
+ /**
65
+ * `POST /<kind>/{id}/publish`.
66
+ *
67
+ * @param host - The transport.
68
+ * @param kind - Which collection.
69
+ * @param id - The resource id.
70
+ * @returns The server's whole body.
71
+ * @throws {ApiError} Any non-2xx, untouched.
72
+ */
73
+ export async function publishVersion(host, kind, id) {
74
+ const res = await host.request({
75
+ method: "POST",
76
+ path: path `/${kind}/${id}/publish`,
77
+ });
78
+ return res.body;
79
+ }
80
+ /**
81
+ * `POST /<kind>/{id}/versions/{n}/revert`.
82
+ *
83
+ * @param host - The transport.
84
+ * @param kind - Which collection.
85
+ * @param id - The resource id.
86
+ * @param n - The version to restore.
87
+ * @returns The `reverted` object, unwrapped from its envelope.
88
+ * @throws {ApiError} Any non-2xx untouched; `bad_response` when the envelope lacks `reverted`.
89
+ */
90
+ export async function revertVersion(host, kind, id, n) {
91
+ const res = await host.request({
92
+ method: "POST",
93
+ path: path `/${kind}/${id}/versions/${String(n)}/revert`,
94
+ });
95
+ return unwrap(res, "reverted");
96
+ }
97
+ /**
98
+ * `POST /<kind>/{id}/enable` or `/disable`. Returns nothing: the server's
99
+ * `{enabled}` echo carries no information the caller did not just ask for.
100
+ *
101
+ * @param host - The transport.
102
+ * @param kind - Which collection.
103
+ * @param id - The resource id.
104
+ * @param enabled - `true` hits `/enable`, `false` hits `/disable`.
105
+ * @throws {ApiError} Any non-2xx, untouched.
106
+ */
107
+ export async function setEnabled(host, kind, id, enabled) {
108
+ await host.request({
109
+ method: "POST",
110
+ path: path `/${kind}/${id}/${enabled ? "enable" : "disable"}`,
111
+ });
112
+ }
113
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OA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,EAAE,IAAI,CAAA,IAAI,IAAI,IAAI,EAAE,UAAU;KACnC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAkB,EAClB,IAAmB,EACnB,EAAU,EACV,CAAS;IAET,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAU;QACtC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAA,IAAI,IAAI,IAAI,EAAE,aAAa,MAAM,CAAC,CAAC,CAAC,SAAS;KACxD,CAAC,CAAC;IACH,OAAO,MAAM,CAAe,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAkB,EAClB,IAAmB,EACnB,EAAU,EACV,OAAgB;IAEhB,MAAM,IAAI,CAAC,OAAO,CAAU;QAC1B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAA,IAAI,IAAI,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE;KAC7D,CAAC,CAAC;AACL,CAAC"}
@@ -71,6 +71,7 @@
71
71
  */
72
72
  import type { ResolvedConfig } from "./config.ts";
73
73
  import { type CallOptions, type HttpResponse, type RequestOptions } from "./http.ts";
74
+ import { type PublishResult, type RevertResult, type VersionDetail, type VersionList } from "./versions.ts";
74
75
  import { type RunResult, type RunStatus, type WorkflowSummary } from "./types.ts";
75
76
  /**
76
77
  * The slice of `W6WClient` this namespace needs: the transport, plus the
@@ -136,7 +137,20 @@ export interface WorkflowRunOptions {
136
137
  * the run's variable scope (`vars.*`) instead.
137
138
  */
138
139
  input?: Record<string, unknown>;
140
+ /**
141
+ * Run the **stored** definition even though it was never published — the draft
142
+ * run. A disabled one is still refused.
143
+ *
144
+ * It executes the row exactly as last saved, never a body you submit here, so
145
+ * save first. Sent as `allowUnpublished: true` in the body **only when
146
+ * `true`** (same rule as {@linkcode wait}); `false` is the same as omitting it.
147
+ * Not accepted by {@linkcode WorkflowsApi.runVersion}: a version is published
148
+ * by definition.
149
+ */
150
+ allowUnpublished?: boolean;
139
151
  }
152
+ /** Per-call options for `workflows.runVersion`: everything `run` takes except the draft flag. */
153
+ export type WorkflowRunVersionOptions = Omit<WorkflowRunOptions, "allowUnpublished">;
140
154
  /**
141
155
  * What `workflows.run` returns: the server's flat body, plus two signals derived
142
156
  * locally.
@@ -414,6 +428,74 @@ export declare class WorkflowsApi {
414
428
  * @throws {ApiError} `404 unknown_workflow` when there is no such id.
415
429
  */
416
430
  archive(id: string): Promise<WorkflowDefinition>;
431
+ /**
432
+ * List a workflow's published versions (metadata only).
433
+ *
434
+ * @param id - The `wf_…` id.
435
+ * @returns `enabled`, `currentPublishedVersion` (`null` before the first publish) and `versions[]`.
436
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
437
+ */
438
+ listVersions(id: string): Promise<VersionList>;
439
+ /**
440
+ * Read one published version, with its definition.
441
+ *
442
+ * @param id - The `wf_…` id.
443
+ * @param n - The 1-based version number.
444
+ * @returns The version, unwrapped from its `version` envelope.
445
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `400 invalid_version` for a non-positive `n`.
446
+ */
447
+ getVersion(id: string, n: number): Promise<VersionDetail>;
448
+ /**
449
+ * Publish the workflow's **stored** definition as a new immutable version.
450
+ *
451
+ * It snapshots what the server has saved, not what an editor holds in memory,
452
+ * so flush any pending save first. The server takes no precondition.
453
+ *
454
+ * @param id - The `wf_…` id.
455
+ * @returns The new version and `currentPublishedVersion`, as the server sent them.
456
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
457
+ */
458
+ publish(id: string): Promise<PublishResult>;
459
+ /**
460
+ * Rewrite the live workflow from a published version. Does not publish.
461
+ *
462
+ * This rewrites the stored row, so its `updatedAt` moves: a later
463
+ * {@linkcode update} that passes `ifUnmodifiedSince` needs a freshly read
464
+ * `updatedAt` ({@linkcode get}), or it is `409 workflow_stale`.
465
+ *
466
+ * @param id - The `wf_…` id.
467
+ * @param n - The version to restore.
468
+ * @returns The `reverted` object, unwrapped from its envelope.
469
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `400 invalid_version`.
470
+ */
471
+ revert(id: string, n: number): Promise<RevertResult>;
472
+ /**
473
+ * Allow runs of this workflow. Idempotent. Returns nothing.
474
+ *
475
+ * @param id - The `wf_…` id.
476
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
477
+ */
478
+ enable(id: string): Promise<void>;
479
+ /**
480
+ * Refuse runs of this workflow (`409 workflow_disabled`). Idempotent. Returns nothing.
481
+ *
482
+ * @param id - The `wf_…` id.
483
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
484
+ */
485
+ disable(id: string): Promise<void>;
486
+ /**
487
+ * Run one published version of a workflow rather than the live row.
488
+ *
489
+ * Takes {@linkcode run}'s options (minus `allowUnpublished`) and returns the
490
+ * same {@linkcode WorkflowRunResult}, including the 202 for a run still going.
491
+ *
492
+ * @param id - The `wf_…` id, or the Workflow's `key`.
493
+ * @param n - The version to run.
494
+ * @param options - `wait`, `variables`, `trigger`, `input`.
495
+ * @returns The run handle, status and result.
496
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `409 workflow_archived` / `workflow_disabled` / `workflow_not_published`; `400 invalid_version`.
497
+ */
498
+ runVersion(id: string, n: number, options?: WorkflowRunVersionOptions): Promise<WorkflowRunResult>;
417
499
  /**
418
500
  * Delete an archived workflow, and everything that hangs off it.
419
501
  *
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/workflows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,KAAK,EAAE,cAA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;;;;;;;;;;;;;;OAyBG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,kBAAkB,CAAC;IAI9B;;;;;;;;;;;;;OAaG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQtD;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIpD;;;;;;;OAOG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI/D;;;;;;;;;OASG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIjD;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI1D;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;;;OAKG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC;;;;;;;;;;;OAWG;IACG,UAAU,CACd,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,iBAAiB,CAAC;IAS7B;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAiCxC"}
@@ -71,6 +71,7 @@
71
71
  */
72
72
  import { ApiError } from "./errors.js";
73
73
  import { path } from "./http.js";
74
+ import { getVersion, listVersions, publishVersion, revertVersion, setEnabled, versionRunPath, } from "./versions.js";
74
75
  import { isTerminalRunStatus, mintId, unwrap, } from "./types.js";
75
76
  /**
76
77
  * The precondition header the write path sends when `ifUnmodifiedSince` is given.
@@ -158,18 +159,35 @@ export class WorkflowsApi {
158
159
  * @throws {ApiError} `bad_response` when a success body is not a run object.
159
160
  */
160
161
  async run(id, options) {
162
+ return await this.#enqueue(path `/workflows/${id}/run`, options);
163
+ }
164
+ /**
165
+ * The one POST both {@linkcode run} and {@linkcode runVersion} go through, so
166
+ * the `bad_response` guard and the derived fields cannot drift between them.
167
+ *
168
+ * @param runPath - The already-encoded path.
169
+ * @param options - The run options as given by the public method.
170
+ * @returns The run handle and derived fields.
171
+ */
172
+ async #enqueue(runPath, options) {
161
173
  const res = await this.#host.request({
162
174
  method: "POST",
163
- path: path `/workflows/${id}/run`,
175
+ path: runPath,
164
176
  // `?wait=true` or no `wait` at all — never `?wait=false`, which the server
165
177
  // reads as "no wait" anyway and which would misrepresent the request in a
166
178
  // log or a proxy.
167
179
  query: { wait: options?.wait ? true : undefined },
168
180
  // Always a body, even when empty: the route parses one when the text is
169
181
  // non-empty and defaults to `{}` otherwise, so `{}` and no body are the
170
- // same request — and sending the object keeps the three optional fields at
171
- // one place instead of behind a conditional.
172
- body: { variables: options?.variables, trigger: options?.trigger, input: options?.input },
182
+ // same request — and sending the object keeps the optional fields at
183
+ // one place instead of behind a conditional. `allowUnpublished` follows
184
+ // the `wait` rule: present only when `true`.
185
+ body: {
186
+ variables: options?.variables,
187
+ trigger: options?.trigger,
188
+ input: options?.input,
189
+ allowUnpublished: options?.allowUnpublished === true ? true : undefined,
190
+ },
173
191
  });
174
192
  const body = res.body;
175
193
  // The `runId` and `status` checks are the guard, not decoration. An
@@ -346,6 +364,93 @@ export class WorkflowsApi {
346
364
  });
347
365
  return unwrap(res, "workflow");
348
366
  }
367
+ /**
368
+ * List a workflow's published versions (metadata only).
369
+ *
370
+ * @param id - The `wf_…` id.
371
+ * @returns `enabled`, `currentPublishedVersion` (`null` before the first publish) and `versions[]`.
372
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
373
+ */
374
+ async listVersions(id) {
375
+ return await listVersions(this.#host, "workflows", id);
376
+ }
377
+ /**
378
+ * Read one published version, with its definition.
379
+ *
380
+ * @param id - The `wf_…` id.
381
+ * @param n - The 1-based version number.
382
+ * @returns The version, unwrapped from its `version` envelope.
383
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `400 invalid_version` for a non-positive `n`.
384
+ */
385
+ async getVersion(id, n) {
386
+ return await getVersion(this.#host, "workflows", id, n);
387
+ }
388
+ /**
389
+ * Publish the workflow's **stored** definition as a new immutable version.
390
+ *
391
+ * It snapshots what the server has saved, not what an editor holds in memory,
392
+ * so flush any pending save first. The server takes no precondition.
393
+ *
394
+ * @param id - The `wf_…` id.
395
+ * @returns The new version and `currentPublishedVersion`, as the server sent them.
396
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
397
+ */
398
+ async publish(id) {
399
+ return await publishVersion(this.#host, "workflows", id);
400
+ }
401
+ /**
402
+ * Rewrite the live workflow from a published version. Does not publish.
403
+ *
404
+ * This rewrites the stored row, so its `updatedAt` moves: a later
405
+ * {@linkcode update} that passes `ifUnmodifiedSince` needs a freshly read
406
+ * `updatedAt` ({@linkcode get}), or it is `409 workflow_stale`.
407
+ *
408
+ * @param id - The `wf_…` id.
409
+ * @param n - The version to restore.
410
+ * @returns The `reverted` object, unwrapped from its envelope.
411
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `400 invalid_version`.
412
+ */
413
+ async revert(id, n) {
414
+ return await revertVersion(this.#host, "workflows", id, n);
415
+ }
416
+ /**
417
+ * Allow runs of this workflow. Idempotent. Returns nothing.
418
+ *
419
+ * @param id - The `wf_…` id.
420
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
421
+ */
422
+ async enable(id) {
423
+ await setEnabled(this.#host, "workflows", id, true);
424
+ }
425
+ /**
426
+ * Refuse runs of this workflow (`409 workflow_disabled`). Idempotent. Returns nothing.
427
+ *
428
+ * @param id - The `wf_…` id.
429
+ * @throws {ApiError} `404 unknown_workflow` when there is no such id.
430
+ */
431
+ async disable(id) {
432
+ await setEnabled(this.#host, "workflows", id, false);
433
+ }
434
+ /**
435
+ * Run one published version of a workflow rather than the live row.
436
+ *
437
+ * Takes {@linkcode run}'s options (minus `allowUnpublished`) and returns the
438
+ * same {@linkcode WorkflowRunResult}, including the 202 for a run still going.
439
+ *
440
+ * @param id - The `wf_…` id, or the Workflow's `key`.
441
+ * @param n - The version to run.
442
+ * @param options - `wait`, `variables`, `trigger`, `input`.
443
+ * @returns The run handle, status and result.
444
+ * @throws {ApiError} `404 unknown_version` / `404 unknown_workflow`; `409 workflow_archived` / `workflow_disabled` / `workflow_not_published`; `400 invalid_version`.
445
+ */
446
+ async runVersion(id, n, options) {
447
+ // `allowUnpublished` is stripped: a version is published by definition, and
448
+ // a JS caller passing it anyway must not put it on this route's wire.
449
+ return await this.#enqueue(versionRunPath("workflows", id, n), {
450
+ ...options,
451
+ allowUnpublished: undefined,
452
+ });
453
+ }
349
454
  /**
350
455
  * Delete an archived workflow, and everything that hangs off it.
351
456
  *
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,YAAY;IACd,KAAK,CAAgB;IAE9B;;OAEG;IACH,YAAY,IAAmB;QAC7B,IAAI,CAAC,KAAK,GAA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AAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;YAC7D,GAAG,OAAO;YACV,gBAAgB,EAAE,SAAS;SAC5B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,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.9.8",
3
+ "version": "0.9.12",
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": {