@w6w/sdk 0.4.0 → 0.6.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 +24 -21
- package/dist/mod.d.ts +6 -2
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +4 -2
- package/dist/mod.js.map +1 -1
- package/dist/src/client.d.ts +32 -9
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +33 -8
- package/dist/src/client.js.map +1 -1
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.js +3 -3
- package/dist/src/config.js.map +1 -1
- package/dist/src/connections.d.ts +2 -2
- package/dist/src/connections.js +1 -1
- package/dist/src/console/aliases.d.ts +137 -0
- package/dist/src/console/aliases.d.ts.map +1 -0
- package/dist/src/console/aliases.js +113 -0
- package/dist/src/console/aliases.js.map +1 -0
- package/dist/src/console/api-calls.d.ts +2 -2
- package/dist/src/console/api-calls.js +1 -1
- package/dist/src/console/apps.d.ts +4 -4
- package/dist/src/console/apps.js +3 -3
- package/dist/src/console/auth.d.ts +204 -6
- package/dist/src/console/auth.d.ts.map +1 -1
- package/dist/src/console/auth.js +155 -5
- package/dist/src/console/auth.js.map +1 -1
- package/dist/src/console/connections.d.ts +2 -2
- package/dist/src/console/connections.js +1 -1
- package/dist/src/console/dashboard.d.ts +2 -2
- package/dist/src/console/dashboard.js +1 -1
- package/dist/src/console/endpoints.d.ts +25 -7
- package/dist/src/console/endpoints.d.ts.map +1 -1
- package/dist/src/console/endpoints.js +1 -1
- package/dist/src/console/endpoints.js.map +1 -1
- package/dist/src/console/functions.d.ts +2 -2
- package/dist/src/console/functions.js +1 -1
- package/dist/src/console/mod.d.ts +15 -5
- package/dist/src/console/mod.d.ts.map +1 -1
- package/dist/src/console/mod.js +12 -2
- package/dist/src/console/mod.js.map +1 -1
- package/dist/src/console/passkeys.d.ts +246 -0
- package/dist/src/console/passkeys.d.ts.map +1 -0
- package/dist/src/console/passkeys.js +192 -0
- package/dist/src/console/passkeys.js.map +1 -0
- package/dist/src/console/projects.d.ts +2 -2
- package/dist/src/console/projects.js +1 -1
- package/dist/src/console/reliability.d.ts +2 -2
- package/dist/src/console/reliability.js +1 -1
- package/dist/src/console/saved-tests.d.ts +3 -3
- package/dist/src/console/saved-tests.js +2 -2
- package/dist/src/console/schedules.d.ts +2 -2
- package/dist/src/console/schedules.js +1 -1
- package/dist/src/console/step-tests.d.ts +3 -3
- package/dist/src/console/step-tests.js +2 -2
- package/dist/src/console/subscriptions.d.ts +2 -2
- package/dist/src/console/subscriptions.js +1 -1
- package/dist/src/console/tenant-oauth-apps.d.ts +2 -2
- package/dist/src/console/tenant-oauth-apps.js +1 -1
- package/dist/src/console/tokens.d.ts +2 -2
- package/dist/src/console/tokens.js +1 -1
- package/dist/src/console/vault.d.ts +2 -2
- package/dist/src/console/vault.js +1 -1
- package/dist/src/console/workflows.d.ts +2 -2
- package/dist/src/console/workflows.js +1 -1
- package/dist/src/documents.d.ts +2 -2
- package/dist/src/documents.js +1 -1
- package/dist/src/endpoints.d.ts +75 -0
- package/dist/src/endpoints.d.ts.map +1 -0
- package/dist/src/endpoints.js +47 -0
- package/dist/src/endpoints.js.map +1 -0
- package/dist/src/functions.d.ts +88 -0
- package/dist/src/functions.d.ts.map +1 -0
- package/dist/src/functions.js +56 -0
- package/dist/src/functions.js.map +1 -0
- package/dist/src/me.d.ts +2 -2
- package/dist/src/me.js +1 -1
- package/dist/src/run.d.ts +9 -4
- package/dist/src/run.d.ts.map +1 -1
- package/dist/src/run.js +3 -2
- package/dist/src/run.js.map +1 -1
- package/dist/src/vars.d.ts +2 -2
- package/dist/src/vars.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflows.d.ts +2 -2
- package/dist/src/workflows.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,9 +33,9 @@ same set of operations in every language.
|
|
|
33
33
|
## Quick start
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
|
-
import {
|
|
36
|
+
import { isActionRun, isFunctionRun, isWorkflowRun, W6WClient } from "@w6w/sdk";
|
|
37
37
|
|
|
38
|
-
const client = new
|
|
38
|
+
const client = new W6WClient(); // reads W6W_BASE_URL and W6W_TOKEN
|
|
39
39
|
|
|
40
40
|
// Who am I, and what versions am I talking to?
|
|
41
41
|
const me = await client.me();
|
|
@@ -48,9 +48,9 @@ const workflows = await client.workflows.list();
|
|
|
48
48
|
|
|
49
49
|
### Run a connection action
|
|
50
50
|
|
|
51
|
-
A `conn_…` id resolves to an app action. `run` returns a `kind`-tagged envelope —
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
A `conn_…` id resolves to an app action. `run` returns a `kind`-tagged envelope — narrow it with
|
|
52
|
+
`isActionRun` / `isFunctionRun` / `isWorkflowRun` before reading a field, since the three arms use
|
|
53
|
+
different field names on purpose (`value` vs `output` vs `runId`+`status`):
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
const env = await client.run({
|
|
@@ -68,7 +68,10 @@ if (isActionRun(env)) console.log(env.value); // the action's return value
|
|
|
68
68
|
operation:
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
|
-
const env = await client.run({
|
|
71
|
+
const env = await client.run({
|
|
72
|
+
urn: "fn_normalize_address",
|
|
73
|
+
payload: { address: "1 Infinite Loop" },
|
|
74
|
+
});
|
|
72
75
|
if (isFunctionRun(env)) console.log(env.output);
|
|
73
76
|
```
|
|
74
77
|
|
|
@@ -110,10 +113,10 @@ await client.vars.update(v.id, { value: "c@d.e" });
|
|
|
110
113
|
|
|
111
114
|
Two environment variables, both read only at client construction:
|
|
112
115
|
|
|
113
|
-
| Variable | Meaning
|
|
114
|
-
| -------------- |
|
|
116
|
+
| Variable | Meaning | Required |
|
|
117
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
115
118
|
| `W6W_BASE_URL` | The **origin** of your w6w server, e.g. `https://api.example.com`. The API is served at the root of that host, so nothing is appended. | Yes |
|
|
116
|
-
| `W6W_TOKEN` | The bearer token, sent as `Authorization: Bearer <token>` on every request.
|
|
119
|
+
| `W6W_TOKEN` | The bearer token, sent as `Authorization: Bearer <token>` on every request. | Yes |
|
|
117
120
|
|
|
118
121
|
Explicit constructor arguments always win over the environment, and credentials are **instance
|
|
119
122
|
state**: two clients in one process can hold different tokens and point at different servers with no
|
|
@@ -121,27 +124,27 @@ interference. There is no default base URL — a client built without one and wi
|
|
|
121
124
|
raises a configuration error naming the variable.
|
|
122
125
|
|
|
123
126
|
```ts
|
|
124
|
-
import {
|
|
127
|
+
import { W6WClient } from "@w6w/sdk";
|
|
125
128
|
|
|
126
129
|
// Everything from the environment.
|
|
127
|
-
const client = new
|
|
130
|
+
const client = new W6WClient();
|
|
128
131
|
|
|
129
132
|
// Explicit arguments override W6W_BASE_URL and W6W_TOKEN.
|
|
130
|
-
const other = new
|
|
133
|
+
const other = new W6WClient({ baseUrl: "https://api.example.com", token: "…" });
|
|
131
134
|
```
|
|
132
135
|
|
|
133
136
|
### `W6W_BASE_URL` is an origin
|
|
134
137
|
|
|
135
|
-
The API is served at the **root** of its own host — `https://api.example.com/vars`, not
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
The API is served at the **root** of its own host — `https://api.example.com/vars`, not `…/api/vars`
|
|
139
|
+
— so the client appends **nothing**. Trailing slashes never matter, and any path you configure is
|
|
140
|
+
preserved verbatim, because it is indistinguishable from a real gateway prefix:
|
|
138
141
|
|
|
139
|
-
| `W6W_BASE_URL`
|
|
140
|
-
|
|
|
141
|
-
| `https://api.example.com`
|
|
142
|
-
| `https://api.example.com/`
|
|
143
|
-
| `https://api.example.com///`
|
|
144
|
-
| `https://api.example.com/gw`
|
|
142
|
+
| `W6W_BASE_URL` | Requests go to |
|
|
143
|
+
| ---------------------------- | ------------------------------ |
|
|
144
|
+
| `https://api.example.com` | `https://api.example.com/…` |
|
|
145
|
+
| `https://api.example.com/` | `https://api.example.com/…` |
|
|
146
|
+
| `https://api.example.com///` | `https://api.example.com/…` |
|
|
147
|
+
| `https://api.example.com/gw` | `https://api.example.com/gw/…` |
|
|
145
148
|
|
|
146
149
|
> **Breaking in `0.2.0`.** The client used to append `/api`. If your `W6W_BASE_URL` ends in `/api`
|
|
147
150
|
> because of that, **drop the suffix** — the path is now preserved rather than deduplicated, so a
|
package/dist/mod.d.ts
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
17
|
export { VERSION } from "./src/version.ts";
|
|
18
|
-
export {
|
|
18
|
+
export { W6WClient } from "./src/client.ts";
|
|
19
19
|
export { ApiError, ConfigError } from "./src/errors.ts";
|
|
20
|
-
export { BASE_PATH, type FetchLike, joinBaseUrl, type ResolvedConfig, type
|
|
20
|
+
export { BASE_PATH, type FetchLike, joinBaseUrl, type ResolvedConfig, type W6WClientOptions, } from "./src/config.ts";
|
|
21
21
|
export type { HttpMethod, HttpResponse, QueryParams, RequestOptions } from "./src/http.ts";
|
|
22
22
|
export { path } from "./src/http.ts";
|
|
23
23
|
export { DocumentsApi } from "./src/documents.ts";
|
|
@@ -29,6 +29,10 @@ export type { MeHost } from "./src/me.ts";
|
|
|
29
29
|
export { ConnectionsApi } from "./src/connections.ts";
|
|
30
30
|
export type { ConnectionsHost } from "./src/connections.ts";
|
|
31
31
|
export { WorkflowsApi } from "./src/workflows.ts";
|
|
32
|
+
export { FunctionsApi } from "./src/functions.ts";
|
|
33
|
+
export type { FunctionRunOptions, FunctionsHost } from "./src/functions.ts";
|
|
34
|
+
export { EndpointsApi } from "./src/endpoints.ts";
|
|
35
|
+
export type { EndpointRunOptions, EndpointsHost } from "./src/endpoints.ts";
|
|
32
36
|
export type { WorkflowListOptions, WorkflowRunOptions, WorkflowRunResult, WorkflowsHost, } from "./src/workflows.ts";
|
|
33
37
|
export { runUrn } from "./src/run.ts";
|
|
34
38
|
export type { RunHost, RunInput } from "./src/run.ts";
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|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M,sBAAsB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAOtD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEhG,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,mBAAmB,EACnB,EAAE,EACF,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,GAAG,EACH,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export { VERSION } from "./src/version.js";
|
|
18
18
|
// Transport core (T2.1.2): the client, its configuration and the error model.
|
|
19
|
-
export {
|
|
19
|
+
export { W6WClient } from "./src/client.js";
|
|
20
20
|
export { ApiError, ConfigError } from "./src/errors.js";
|
|
21
21
|
export { BASE_PATH, joinBaseUrl, } from "./src/config.js";
|
|
22
|
-
// Exported because `
|
|
22
|
+
// Exported because `W6WClient.request` is public: a host reaching an endpoint
|
|
23
23
|
// this version does not model yet must have the same encoding-at-interpolation
|
|
24
24
|
// tag the operation modules use, or it will concatenate a caller value into a
|
|
25
25
|
// path by hand — the one bug the encoding pin exists to prevent.
|
|
@@ -38,6 +38,8 @@ export { VarsApi } from "./src/vars.js";
|
|
|
38
38
|
export { fetchMe } from "./src/me.js";
|
|
39
39
|
export { ConnectionsApi } from "./src/connections.js";
|
|
40
40
|
export { WorkflowsApi } from "./src/workflows.js";
|
|
41
|
+
export { FunctionsApi } from "./src/functions.js";
|
|
42
|
+
export { EndpointsApi } from "./src/endpoints.js";
|
|
41
43
|
// Execution (T2.1.5): the URN-addressed `run`. `client.run(input)` is a method
|
|
42
44
|
// on the client, so what is exported is its host interface, its input type and
|
|
43
45
|
// the standalone function the client delegates to.
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,8EAA8E;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,SAAS,EAET,WAAW,GAGZ,MAAM,iBAAiB,CAAC;AAEzB,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,iEAAiE;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,gFAAgF;AAChF,gFAAgF;AAChF,wEAAwE;AACxE,gFAAgF;AAChF,6CAA6C;AAC7C,OAAO,EAAE,OAA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,wEAAwE;AACxE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `
|
|
2
|
+
* `W6WClient` — the object every operation hangs off.
|
|
3
3
|
*
|
|
4
4
|
* It holds three things and no behaviour of its own: the resolved
|
|
5
5
|
* configuration, the transport, and (from T2.1.3 onward) the operation
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
|
-
import { type ResolvedConfig, type
|
|
17
|
+
import { type ResolvedConfig, type W6WClientOptions } from "./config.ts";
|
|
18
18
|
import { ConnectionsApi } from "./connections.ts";
|
|
19
19
|
import { ConsoleApi } from "./console/mod.ts";
|
|
20
20
|
import { DocumentsApi } from "./documents.ts";
|
|
@@ -22,6 +22,8 @@ import { type HttpResponse, type RequestOptions } from "./http.ts";
|
|
|
22
22
|
import { type RunInput } from "./run.ts";
|
|
23
23
|
import type { Me, RunEnvelope } from "./types.ts";
|
|
24
24
|
import { VarsApi } from "./vars.ts";
|
|
25
|
+
import { EndpointsApi } from "./endpoints.ts";
|
|
26
|
+
import { FunctionsApi } from "./functions.ts";
|
|
25
27
|
import { WorkflowsApi } from "./workflows.ts";
|
|
26
28
|
/**
|
|
27
29
|
* A client for the w6w HTTP API.
|
|
@@ -34,14 +36,14 @@ import { WorkflowsApi } from "./workflows.ts";
|
|
|
34
36
|
* @example
|
|
35
37
|
* ```ts
|
|
36
38
|
* // From the environment.
|
|
37
|
-
* const client = new
|
|
39
|
+
* const client = new W6WClient();
|
|
38
40
|
*
|
|
39
41
|
* // Explicit, overriding the environment. Two clients, two credentials, one
|
|
40
42
|
* // process — no interference.
|
|
41
|
-
* const other = new
|
|
43
|
+
* const other = new W6WClient({ baseUrl: "https://api.example.com", token: "t_2" });
|
|
42
44
|
* ```
|
|
43
45
|
*/
|
|
44
|
-
export declare class
|
|
46
|
+
export declare class W6WClient {
|
|
45
47
|
#private;
|
|
46
48
|
/**
|
|
47
49
|
* The resolved base URL, credential and default project. Exposed read-only
|
|
@@ -78,9 +80,28 @@ export declare class W6wClient {
|
|
|
78
80
|
* `@w6w/trigger` step and read downstream as `steps.<triggerId>.output.<key>`.
|
|
79
81
|
*/
|
|
80
82
|
readonly workflows: WorkflowsApi;
|
|
83
|
+
/**
|
|
84
|
+
* Run a Function by the name you gave it: `functions.run("send-email", {payload})`.
|
|
85
|
+
*
|
|
86
|
+
* The name is the first argument and may be the Function's KEY or its `fn_…`
|
|
87
|
+
* id — the server takes either in one slot, because the two shapes cannot
|
|
88
|
+
* collide. Returns the Function's output directly; the kind is already
|
|
89
|
+
* settled by the method name, so there is no envelope to unwrap.
|
|
90
|
+
*/
|
|
91
|
+
readonly functions: FunctionsApi;
|
|
92
|
+
/**
|
|
93
|
+
* Run an Endpoint by the key you gave it: `endpoints.run("send-email", {payload})`.
|
|
94
|
+
*
|
|
95
|
+
* Same name-first shape as `functions.run`, but this one returns the
|
|
96
|
+
* `kind`-discriminated envelope: an Endpoint dispatches to an app action, a
|
|
97
|
+
* Function or a Workflow, and only the response says which answered.
|
|
98
|
+
*/
|
|
99
|
+
readonly endpoints: EndpointsApi;
|
|
81
100
|
/**
|
|
82
101
|
* Console-only namespaces: `console.reliability.list`, `console.auth.*`
|
|
83
|
-
* (`login`, `signup`, `checkAccountSlug`, `createAccount`
|
|
102
|
+
* (`login`, `signup`, `checkAccountSlug`, `createAccount`, `getMe`,
|
|
103
|
+
* `getProfile`, `updateProfile`, `requestContactChange`,
|
|
104
|
+
* `confirmContactChange`, `removeContact`, `promoteContact`, `setPassword`),
|
|
84
105
|
* `console.dashboard.stats`, `console.projects.*` (`list`, `create`,
|
|
85
106
|
* `delete`), `console.schedules.*` (`get`, `upsert`, `delete`),
|
|
86
107
|
* `console.apps.*` (`list`, `get`, `getAuth`, `getActions`, `getTriggers`,
|
|
@@ -96,8 +117,10 @@ export declare class W6wClient {
|
|
|
96
117
|
* `disable`, `enable`, `revoke`), `console.functions.*` (`list`, `get`,
|
|
97
118
|
* `upsert`), `console.endpoints.*` (`list`, `get`, `upsert`, `invoke`),
|
|
98
119
|
* `console.subscriptions.*` (`list`, `listForWorkflow`, `get`, `create`,
|
|
99
|
-
* `delete`, `listEvents`, `requeueEvent`), `console.apiCalls.*` (`list`)
|
|
100
|
-
* `console.tenantOAuthApps.*` (`list`, `put`, `remove`)
|
|
120
|
+
* `delete`, `listEvents`, `requeueEvent`), `console.apiCalls.*` (`list`),
|
|
121
|
+
* `console.tenantOAuthApps.*` (`list`, `put`, `remove`) and
|
|
122
|
+
* `console.passkeys.*` (`registrationOptions`, `registrationVerify`,
|
|
123
|
+
* `authenticationOptions`, `authenticationVerify`, `list`, `revoke`).
|
|
101
124
|
* Studio-internal and unstable — not part of the published partner
|
|
102
125
|
* contract, excluded from `endpoints.json` and from this package's root
|
|
103
126
|
* barrel (`docs/console.md`, HITL-1). Reached only through
|
|
@@ -109,7 +132,7 @@ export declare class W6wClient {
|
|
|
109
132
|
* @param options - Explicit configuration; anything omitted falls back to the environment.
|
|
110
133
|
* @throws {ConfigError} When no base URL is configured, or the host has no `fetch`.
|
|
111
134
|
*/
|
|
112
|
-
constructor(options?:
|
|
135
|
+
constructor(options?: W6WClientOptions);
|
|
113
136
|
/**
|
|
114
137
|
* Who this client's credential says you are, plus the versions of the
|
|
115
138
|
* components that answered.
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE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Client` — the object every operation hangs off.
|
|
3
3
|
*
|
|
4
4
|
* It holds three things and no behaviour of its own: the resolved
|
|
5
5
|
* configuration, the transport, and (from T2.1.3 onward) the operation
|
|
@@ -23,6 +23,8 @@ import { request } from "./http.js";
|
|
|
23
23
|
import { fetchMe } from "./me.js";
|
|
24
24
|
import { runUrn } from "./run.js";
|
|
25
25
|
import { VarsApi } from "./vars.js";
|
|
26
|
+
import { EndpointsApi } from "./endpoints.js";
|
|
27
|
+
import { FunctionsApi } from "./functions.js";
|
|
26
28
|
import { WorkflowsApi } from "./workflows.js";
|
|
27
29
|
/**
|
|
28
30
|
* A client for the w6w HTTP API.
|
|
@@ -35,14 +37,14 @@ import { WorkflowsApi } from "./workflows.js";
|
|
|
35
37
|
* @example
|
|
36
38
|
* ```ts
|
|
37
39
|
* // From the environment.
|
|
38
|
-
* const client = new
|
|
40
|
+
* const client = new W6WClient();
|
|
39
41
|
*
|
|
40
42
|
* // Explicit, overriding the environment. Two clients, two credentials, one
|
|
41
43
|
* // process — no interference.
|
|
42
|
-
* const other = new
|
|
44
|
+
* const other = new W6WClient({ baseUrl: "https://api.example.com", token: "t_2" });
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
|
-
export class
|
|
47
|
+
export class W6WClient {
|
|
46
48
|
/**
|
|
47
49
|
* The resolved base URL, credential and default project. Exposed read-only
|
|
48
50
|
* so a host can log *which server* it is talking to without re-deriving the
|
|
@@ -78,9 +80,28 @@ export class W6wClient {
|
|
|
78
80
|
* `@w6w/trigger` step and read downstream as `steps.<triggerId>.output.<key>`.
|
|
79
81
|
*/
|
|
80
82
|
workflows;
|
|
83
|
+
/**
|
|
84
|
+
* Run a Function by the name you gave it: `functions.run("send-email", {payload})`.
|
|
85
|
+
*
|
|
86
|
+
* The name is the first argument and may be the Function's KEY or its `fn_…`
|
|
87
|
+
* id — the server takes either in one slot, because the two shapes cannot
|
|
88
|
+
* collide. Returns the Function's output directly; the kind is already
|
|
89
|
+
* settled by the method name, so there is no envelope to unwrap.
|
|
90
|
+
*/
|
|
91
|
+
functions;
|
|
92
|
+
/**
|
|
93
|
+
* Run an Endpoint by the key you gave it: `endpoints.run("send-email", {payload})`.
|
|
94
|
+
*
|
|
95
|
+
* Same name-first shape as `functions.run`, but this one returns the
|
|
96
|
+
* `kind`-discriminated envelope: an Endpoint dispatches to an app action, a
|
|
97
|
+
* Function or a Workflow, and only the response says which answered.
|
|
98
|
+
*/
|
|
99
|
+
endpoints;
|
|
81
100
|
/**
|
|
82
101
|
* Console-only namespaces: `console.reliability.list`, `console.auth.*`
|
|
83
|
-
* (`login`, `signup`, `checkAccountSlug`, `createAccount`
|
|
102
|
+
* (`login`, `signup`, `checkAccountSlug`, `createAccount`, `getMe`,
|
|
103
|
+
* `getProfile`, `updateProfile`, `requestContactChange`,
|
|
104
|
+
* `confirmContactChange`, `removeContact`, `promoteContact`, `setPassword`),
|
|
84
105
|
* `console.dashboard.stats`, `console.projects.*` (`list`, `create`,
|
|
85
106
|
* `delete`), `console.schedules.*` (`get`, `upsert`, `delete`),
|
|
86
107
|
* `console.apps.*` (`list`, `get`, `getAuth`, `getActions`, `getTriggers`,
|
|
@@ -96,8 +117,10 @@ export class W6wClient {
|
|
|
96
117
|
* `disable`, `enable`, `revoke`), `console.functions.*` (`list`, `get`,
|
|
97
118
|
* `upsert`), `console.endpoints.*` (`list`, `get`, `upsert`, `invoke`),
|
|
98
119
|
* `console.subscriptions.*` (`list`, `listForWorkflow`, `get`, `create`,
|
|
99
|
-
* `delete`, `listEvents`, `requeueEvent`), `console.apiCalls.*` (`list`)
|
|
100
|
-
* `console.tenantOAuthApps.*` (`list`, `put`, `remove`)
|
|
120
|
+
* `delete`, `listEvents`, `requeueEvent`), `console.apiCalls.*` (`list`),
|
|
121
|
+
* `console.tenantOAuthApps.*` (`list`, `put`, `remove`) and
|
|
122
|
+
* `console.passkeys.*` (`registrationOptions`, `registrationVerify`,
|
|
123
|
+
* `authenticationOptions`, `authenticationVerify`, `list`, `revoke`).
|
|
101
124
|
* Studio-internal and unstable — not part of the published partner
|
|
102
125
|
* contract, excluded from `endpoints.json` and from this package's root
|
|
103
126
|
* barrel (`docs/console.md`, HITL-1). Reached only through
|
|
@@ -119,7 +142,7 @@ export class W6wClient {
|
|
|
119
142
|
const global = globalThis.fetch;
|
|
120
143
|
if (typeof global !== "function") {
|
|
121
144
|
throw new ConfigError("This runtime has no global fetch. Pass an implementation " +
|
|
122
|
-
"(new
|
|
145
|
+
"(new W6WClient({ fetch })) or run on Node 18+, Deno or Bun.");
|
|
123
146
|
}
|
|
124
147
|
// Bound, so the default keeps working when it is called as a bare
|
|
125
148
|
// function reference rather than as a method of the global object.
|
|
@@ -134,6 +157,8 @@ export class W6wClient {
|
|
|
134
157
|
this.vars = new VarsApi(this);
|
|
135
158
|
this.connections = new ConnectionsApi(this);
|
|
136
159
|
this.workflows = new WorkflowsApi(this);
|
|
160
|
+
this.functions = new FunctionsApi(this);
|
|
161
|
+
this.endpoints = new EndpointsApi(this);
|
|
137
162
|
this.console = new ConsoleApi(this);
|
|
138
163
|
}
|
|
139
164
|
/**
|
package/dist/src/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAEL,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAqB,OAAO,EAAuB,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAiB,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjD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,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,EAAE;QACA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,GAAG,CAAC,KAAe;QACjB,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAI,OAAuB;QAChC,OAAO,OAAO,CAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const BASE_PATH = "";
|
|
|
32
32
|
*/
|
|
33
33
|
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
34
34
|
/** Constructor options for a client. Every field is optional. */
|
|
35
|
-
export interface
|
|
35
|
+
export interface W6WClientOptions {
|
|
36
36
|
/**
|
|
37
37
|
* The **origin** of the w6w server, e.g. `https://api.example.com`. The API
|
|
38
38
|
* is served at its root, so no path is appended. It must be an absolute
|
|
@@ -137,7 +137,7 @@ export declare function joinBaseUrl(origin: string): string;
|
|
|
137
137
|
* @returns The resolved configuration.
|
|
138
138
|
* @throws {ConfigError} When no usable base URL was supplied, naming `W6W_BASE_URL`.
|
|
139
139
|
*/
|
|
140
|
-
export declare function resolveConfig(options?:
|
|
140
|
+
export declare function resolveConfig(options?: W6WClientOptions): ResolvedConfig;
|
|
141
141
|
/**
|
|
142
142
|
* The token, or a {@linkcode ConfigError} naming `W6W_TOKEN`.
|
|
143
143
|
*
|
package/dist/src/config.js
CHANGED
|
@@ -84,9 +84,9 @@ export function joinBaseUrl(origin) {
|
|
|
84
84
|
const trimmed = origin.trim().replace(/\/+$/, "");
|
|
85
85
|
if (trimmed.length === 0) {
|
|
86
86
|
throw new ConfigError("No w6w base URL is configured. Pass one to the client " +
|
|
87
|
-
'(new
|
|
87
|
+
'(new W6WClient({ baseUrl: "https://api.example.com" })) or set the ' +
|
|
88
88
|
`${ENV_BASE_URL} environment variable. It holds the server's origin, ` +
|
|
89
|
-
|
|
89
|
+
'e.g. "https://api.example.com" — the API is served at its root, so no ' +
|
|
90
90
|
"path is appended.");
|
|
91
91
|
}
|
|
92
92
|
if (!ABSOLUTE_HTTP_ORIGIN.test(trimmed) || !parses(trimmed)) {
|
|
@@ -161,7 +161,7 @@ export function resolveConfig(options = {}) {
|
|
|
161
161
|
export function requireToken(config) {
|
|
162
162
|
if (config.token === null || config.token.trim().length === 0) {
|
|
163
163
|
throw new ConfigError("No w6w API token is configured. Pass one to the client " +
|
|
164
|
-
'(new
|
|
164
|
+
'(new W6WClient({ token: "…" })) or set the ' +
|
|
165
165
|
`${ENV_TOKEN} environment variable. Every w6w API operation is authenticated.`);
|
|
166
166
|
}
|
|
167
167
|
return config.token;
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AA4D5B;;;;;;;;;;GAUG;AACH,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,0EAA0E;IAC1E,8EAA8E;IAC9E,4DAA4D;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAA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AAC,MAAM,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAAC,UAA4B,EAAE;IAC1D,OAAO;QACL,6EAA6E;QAC7E,2EAA2E;QAC3E,+CAA+C;QAC/C,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QACpE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,IAAI;QAClD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;KACjC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB;IACjD,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,WAAW,CACnB,yDAAyD;YACvD,6CAA6C;YAC7C,GAAG,SAAS,kEAAkE,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import type { HttpResponse, RequestOptions } from "./http.ts";
|
|
23
23
|
import { type ConnectionSummary } from "./types.ts";
|
|
24
24
|
/**
|
|
25
|
-
* The slice of `
|
|
25
|
+
* The slice of `W6WClient` this namespace needs: the transport, and nothing
|
|
26
26
|
* else. Connections carry no `?project=` — the server scopes them by
|
|
27
27
|
* tenant/account from the credential — so, as with `vars`, this host cannot
|
|
28
28
|
* reach the client's configuration to send a scope even by accident.
|
|
@@ -32,7 +32,7 @@ export interface ConnectionsHost {
|
|
|
32
32
|
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* The `connections` namespace on a `
|
|
35
|
+
* The `connections` namespace on a `W6WClient`.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```ts
|
package/dist/src/connections.js
CHANGED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `client.console.aliases.*` — account-scoped alias management
|
|
3
|
+
* (`list`/`get`/`upsert`/`delete`) for the names `run`'s URN dispatch
|
|
4
|
+
* resolves alongside its four `conn_…`/`wf_…`/`fn_…`/`ep_…` arms
|
|
5
|
+
* (`src/run.ts`).
|
|
6
|
+
*
|
|
7
|
+
* **Studio-internal, not the published partner contract.** This namespace
|
|
8
|
+
* lives under the `console` subpath export (`@w6w/sdk/console`), excluded
|
|
9
|
+
* from `endpoints.json` and from the root barrel (`mod.ts`) — see
|
|
10
|
+
* `docs/console.md` and HITL-2 in this project's contract. This surface is
|
|
11
|
+
* **new**: unlike `console.functions`/`console.endpoints`, there is no
|
|
12
|
+
* pre-existing `studio/src/api/client.ts` alias code being relocated here —
|
|
13
|
+
* Studio never had alias CRUD before this project. `@w6w/sdk`'s
|
|
14
|
+
* instance-state mechanism pin still applies here exactly as it does to
|
|
15
|
+
* every other namespace (`docs/implementation.md` §MECHANISM PIN — instance
|
|
16
|
+
* state, never globals): this class holds no state of its own beyond the
|
|
17
|
+
* injected host, so two clients in one process never share a credential.
|
|
18
|
+
*
|
|
19
|
+
* **`invoke`/`run` is deliberately NOT modeled here.** The base
|
|
20
|
+
* `client.run({urn: aliasName, payload})` (already-published surface,
|
|
21
|
+
* `endpoints.json`-named, exported from the root `mod.ts`) already reaches
|
|
22
|
+
* an alias's target — an alias name is one of `run`'s runnable `urn` arms,
|
|
23
|
+
* alongside `conn_…`/`wf_…`/`fn_…`/`ep_…` (`src/run.ts`). Adding a duplicate
|
|
24
|
+
* `console.aliases.invoke` would give a caller two ways to reach the same
|
|
25
|
+
* route — the exact anti-duplication defect `console/functions.ts:15-26`
|
|
26
|
+
* flags for Functions, applied here with alias/`run` substituted for
|
|
27
|
+
* function/`run`; `console.endpoints`/`console.workflows` follow the same
|
|
28
|
+
* precedent. No invoke method lives here, and none should be added later
|
|
29
|
+
* without re-litigating this reasoning.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
import { type HttpResponse, type RequestOptions } from "../http.ts";
|
|
34
|
+
import type { EndpointTarget } from "./endpoints.ts";
|
|
35
|
+
/**
|
|
36
|
+
* The slice of `W6WClient` this namespace needs: the transport, and nothing
|
|
37
|
+
* else. Structural rather than a concrete client type, so the namespace
|
|
38
|
+
* stays independently constructible in a test and this module never
|
|
39
|
+
* imports the client back — mirrors `FunctionsHost` in `./functions.ts`.
|
|
40
|
+
*/
|
|
41
|
+
export interface AliasesHost {
|
|
42
|
+
/** Perform one request. */
|
|
43
|
+
request<T>(options: RequestOptions): Promise<HttpResponse<T>>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An alias definition — an account-scoped name bound to one runnable
|
|
47
|
+
* target, typed with the same {@linkcode EndpointTarget} union
|
|
48
|
+
* `console.endpoints` dispatches to. Unlike `EndpointDef.target`, an
|
|
49
|
+
* alias's `target` may also carry the `endpoint` arm
|
|
50
|
+
* ({@linkcode EndpointRefTarget}) — dispatching to another Endpoint by id is
|
|
51
|
+
* legal for an alias only, so `run`'s URN dispatch can resolve it by name
|
|
52
|
+
* instead of by id.
|
|
53
|
+
*
|
|
54
|
+
* `name` is **immutable after first save** (HITL-3): a save that changes
|
|
55
|
+
* `name` on an already-stored alias answers `409 alias_name_immutable`.
|
|
56
|
+
*/
|
|
57
|
+
export interface AliasDef {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
displayName?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
target: EndpointTarget;
|
|
63
|
+
}
|
|
64
|
+
/** One row of `list`'s result — an alias's summary, not its full definition. */
|
|
65
|
+
export interface AliasSummary {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
displayName: string;
|
|
69
|
+
description: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
target: EndpointTarget;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The `console.aliases` namespace on a `W6WClient`.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const aliases = await client.console.aliases.list();
|
|
79
|
+
* const alias = await client.console.aliases.get(aliases[0].id);
|
|
80
|
+
* await client.console.aliases.upsert({ ...alias, description: "Send email" });
|
|
81
|
+
* await client.console.aliases.delete(alias.id);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare class AliasesApi {
|
|
85
|
+
#private;
|
|
86
|
+
/**
|
|
87
|
+
* @param host - The client this namespace issues requests through.
|
|
88
|
+
*/
|
|
89
|
+
constructor(host: AliasesHost);
|
|
90
|
+
/**
|
|
91
|
+
* List the caller's aliases.
|
|
92
|
+
*
|
|
93
|
+
* @returns The aliases, unwrapped from the `aliases` envelope.
|
|
94
|
+
*/
|
|
95
|
+
list(): Promise<AliasSummary[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch one alias's stored definition.
|
|
98
|
+
*
|
|
99
|
+
* No server-computed field to splice in — unlike
|
|
100
|
+
* {@linkcode FunctionsApi.get}'s `valid` merge, this returns
|
|
101
|
+
* `unwrap<AliasDef>(res, "alias")` plainly.
|
|
102
|
+
*
|
|
103
|
+
* @param id - The alias's `id`.
|
|
104
|
+
* @returns The alias definition, unwrapped from the `alias` envelope.
|
|
105
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
106
|
+
*/
|
|
107
|
+
get(id: string): Promise<AliasDef>;
|
|
108
|
+
/**
|
|
109
|
+
* Register (create or overwrite) an alias definition.
|
|
110
|
+
*
|
|
111
|
+
* `definition` is the whole definition, sent verbatim as the request body
|
|
112
|
+
* — not wrapped in an envelope key.
|
|
113
|
+
*
|
|
114
|
+
* @param definition - The whole alias definition, forwarded verbatim.
|
|
115
|
+
* @returns The new/updated alias's id and name.
|
|
116
|
+
* @throws {ApiError} `400 invalid_alias` — structurally invalid body.
|
|
117
|
+
* @throws {ApiError} `409 alias_conflict` — another `(tenant,subject)` owns this id.
|
|
118
|
+
* @throws {ApiError} `409 alias_name_conflict` — another alias already owns this name.
|
|
119
|
+
* @throws {ApiError} `409 alias_name_immutable` — `name` changed on an already-stored alias (HITL-3).
|
|
120
|
+
*/
|
|
121
|
+
upsert(definition: AliasDef): Promise<{
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Delete an alias.
|
|
127
|
+
*
|
|
128
|
+
* Returns nothing: the server's `{ok: true}` carries no information a
|
|
129
|
+
* caller can use, mirroring `console.vault.delete`/`console.projects.delete`
|
|
130
|
+
* in this same package.
|
|
131
|
+
*
|
|
132
|
+
* @param id - The alias's `id`.
|
|
133
|
+
* @throws {ApiError} `404 unknown_alias` when there is no such id.
|
|
134
|
+
*/
|
|
135
|
+
delete(id: string): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../../src/console/aliases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAQ,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;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