@ontemper/sdk 0.9.0-rc.3 → 0.10.0-oauth.1
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 +157 -16
- package/dist/AccessTokens.d.ts +15 -22
- package/dist/AccessTokens.d.ts.map +1 -1
- package/dist/AccessTokens.js +57 -55
- package/dist/AccessTokens.js.map +1 -1
- package/dist/As2Transport.d.ts +7 -2
- package/dist/As2Transport.d.ts.map +1 -1
- package/dist/As2Transport.js.map +1 -1
- package/dist/Contract/Manifest.d.ts +58 -1
- package/dist/Contract/Manifest.d.ts.map +1 -1
- package/dist/Contract/Manifest.js +53 -0
- package/dist/Contract/Manifest.js.map +1 -1
- package/dist/Contract/RuntimeApi.d.ts +35 -29
- package/dist/Contract/RuntimeApi.d.ts.map +1 -1
- package/dist/Contract/RuntimeApi.js +59 -25
- package/dist/Contract/RuntimeApi.js.map +1 -1
- package/dist/Contract/index.d.ts +2 -2
- package/dist/Contract/index.d.ts.map +1 -1
- package/dist/Contract/index.js +2 -2
- package/dist/Contract/index.js.map +1 -1
- package/dist/HttpApiClient.d.ts +30 -0
- package/dist/HttpApiClient.d.ts.map +1 -0
- package/dist/HttpApiClient.js +142 -0
- package/dist/HttpApiClient.js.map +1 -0
- package/dist/HttpApiResource.d.ts +133 -0
- package/dist/HttpApiResource.d.ts.map +1 -1
- package/dist/HttpApiResource.js +31 -3
- package/dist/HttpApiResource.js.map +1 -1
- package/dist/Kafka.d.ts.map +1 -1
- package/dist/Kafka.js +6 -73
- package/dist/Kafka.js.map +1 -1
- package/dist/LogContext.d.ts +2 -0
- package/dist/LogContext.d.ts.map +1 -1
- package/dist/LogContext.js +7 -4
- package/dist/LogContext.js.map +1 -1
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +16 -3
- package/dist/Logger.js.map +1 -1
- package/dist/Manifest.d.ts +14 -3
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js +98 -6
- package/dist/Manifest.js.map +1 -1
- package/dist/Middleware.d.ts.map +1 -1
- package/dist/Middleware.js +4 -1
- package/dist/Middleware.js.map +1 -1
- package/dist/OAuthToken.d.ts +46 -0
- package/dist/OAuthToken.d.ts.map +1 -0
- package/dist/OAuthToken.js +132 -0
- package/dist/OAuthToken.js.map +1 -0
- package/dist/Redaction.d.ts.map +1 -1
- package/dist/Redaction.js +1 -0
- package/dist/Redaction.js.map +1 -1
- package/dist/Resource.d.ts +3 -1
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/RuntimeResources.d.ts +9 -23
- package/dist/RuntimeResources.d.ts.map +1 -1
- package/dist/RuntimeResources.js +43 -25
- package/dist/RuntimeResources.js.map +1 -1
- package/dist/Step.d.ts +63 -0
- package/dist/Step.d.ts.map +1 -0
- package/dist/Step.js +106 -0
- package/dist/Step.js.map +1 -0
- package/dist/StepCatalog.d.ts +9 -0
- package/dist/StepCatalog.d.ts.map +1 -0
- package/dist/StepCatalog.js +16 -0
- package/dist/StepCatalog.js.map +1 -0
- package/dist/StepRuns.d.ts +33 -0
- package/dist/StepRuns.d.ts.map +1 -0
- package/dist/StepRuns.js +65 -0
- package/dist/StepRuns.js.map +1 -0
- package/dist/Workflow.d.ts +7 -7
- package/dist/Workflow.d.ts.map +1 -1
- package/dist/Workflow.js +10 -11
- package/dist/Workflow.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +9 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +9 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +64 -19
- package/dist/testing.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -150,11 +150,12 @@ const partners = yield * PartnerApis;
|
|
|
150
150
|
const { key, value } = yield * partners.select({ tenantKey }); // ResourceNotFoundError when no record matches
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
- `HttpApiResource` reads the `http_api` type at catalog revision
|
|
153
|
+
- `HttpApiResource` reads the `http_api` type at catalog revision 3. `auth` is one of `none`, `basic`,
|
|
154
154
|
`bearer`, `api_key`, `oauth2_client_credentials`, `oauth2_password`, `oauth2_jwt_bearer`, `oauth1_tba`,
|
|
155
155
|
or `aws_sigv4`. The two token-grant variants hold the client in `auth.tokenRequest`
|
|
156
156
|
(`OAuthTokenRequest`: `tokenUrl`, `clientId`, `clientAuthentication`, and `tokenRequestFormat`, `form`
|
|
157
|
-
by default
|
|
157
|
+
by default; `HttpApiOAuthTokenRequest` adds the optional token-request `headers`, and refuses a header that
|
|
158
|
+
the platform's login sets or that controls the connection, such as `Accept` or `Transfer-Encoding`). An auth `type` that a newer platform adds decodes as
|
|
158
159
|
`{ type: 'unsupported', variant, fields }`, with `fields` `Redacted`. A known type with a missing or
|
|
159
160
|
invalid field fails. The record can also carry `tls`, `proxy`, and `secondaryTenantKey`.
|
|
160
161
|
- Every `x-secret` field of a system type decodes to `Redacted`: for example `clientSecret`, `privateKey`,
|
|
@@ -206,27 +207,167 @@ const { key, value } = yield * partners.select({ tenantKey }); // ResourceNotFou
|
|
|
206
207
|
To keep a check that deploy does not run, annotate it: `Schema.isPattern(regExp, { toJsonSchema: () => ({}) })`.
|
|
207
208
|
A `Schema.makeFilter` predicate without `toJsonSchema` runs only when the workflow decodes the value.
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
## Steps
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
🟡 Proposed ([Workflow Flow](../../docs/specs/workflows/flow.md)). A step is one named unit of work. You
|
|
213
|
+
annotate the code that does the work with its step, at any depth: a client method, a service method,
|
|
214
|
+
or an effect in the orchestration. Nothing else describes the control flow. The platform reads the
|
|
215
|
+
order, nesting, loops, and parallel work of the steps from the step lines of each Run, so the code can
|
|
216
|
+
use any control flow Effect has.
|
|
217
|
+
|
|
218
|
+
Declare each step once, at module level, by convention in `src/Steps.ts`:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import { Step, Variable } from '@temper/workflow';
|
|
222
|
+
|
|
223
|
+
export class CarrierKey extends Variable<CarrierKey>()('CARRIER_KEY') {}
|
|
224
|
+
|
|
225
|
+
export const bookOrders = Step.make('bookOrders', { title: 'Book each order', kind: 'code' });
|
|
226
|
+
export const checkCustoms = Step.make('checkCustoms', { title: 'Check customs data', kind: 'code' });
|
|
227
|
+
export const bookLoad = Step.make('bookLoad', { title: 'Book the load', kind: 'http', resource: CarrierKey });
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
For a service method, use `step.fn` in place of `Effect.fn('Service.method')`. Each call is one run of
|
|
231
|
+
the step. The arguments, result, error, and requirements are the body's. `item` names the item of one
|
|
232
|
+
call from its arguments. It runs once for each call, when the step starts:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
export const book = bookLoad.fn({ item: (order: Order) => order.id })(function* (order: Order) {
|
|
236
|
+
const key = yield* CarrierKey;
|
|
237
|
+
return yield* postLoad(key, order);
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
For an effect in the orchestration, use `step.run`. A step that runs other steps encloses them:
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
const results =
|
|
245
|
+
yield * bookOrders.run(Effect.forEach(batch.orders, (order) => processOrder(order), { concurrency: 4 }));
|
|
246
|
+
// inside processOrder:
|
|
247
|
+
yield * checkCustoms.run(customsCheck(order), { item: order.id });
|
|
248
|
+
// or, in a pipe:
|
|
249
|
+
yield * customsCheck(order).pipe(checkCustoms.run({ item: order.id }));
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
An item never changes a run. When an `item` function throws, or an item is not a string, the step
|
|
253
|
+
runs without an item, and the body's result and error do not change.
|
|
254
|
+
|
|
255
|
+
Each run writes `<title> started.`, then `<title> completed.` or `<title> failed.`, in one child span.
|
|
256
|
+
Each line carries these reserved fields:
|
|
257
|
+
|
|
258
|
+
| Field | Value |
|
|
259
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
260
|
+
| `temperStep` | The step id. |
|
|
261
|
+
| `temperStepEvent` | `started`, `completed`, `failed`, or `summary`. |
|
|
262
|
+
| `temperStepPath` | The ids of the steps that enclose this run and the step id, outermost first, joined with `/`, such as `bookOrders/bookLoad`. |
|
|
263
|
+
| `temperStepItem` | The first 256 characters of the item, when the run names one. |
|
|
264
|
+
|
|
265
|
+
The enclosing steps come from the fiber context, so a step in a forked or concurrent fiber, such as an
|
|
266
|
+
item of `Effect.forEach` with `concurrency`, keeps the path of the step that started it. A path longer
|
|
267
|
+
than 256 characters keeps the innermost ids that fit and starts with `*/`. The end line carries
|
|
268
|
+
`duration` in milliseconds, and a failed line carries `err`. An interrupted step ends `failed`. A step
|
|
269
|
+
keeps the effect's result, error, and requirements, and it retries nothing. The step lines ignore
|
|
270
|
+
`LOG_LEVEL` and any minimum log level you set, so the platform always sees each state.
|
|
271
|
+
|
|
272
|
+
In one Run, the lines of a step are bounded for each path (`temperStepPath`). A Run is one event
|
|
273
|
+
request, with the work that continues after an early answer:
|
|
274
|
+
|
|
275
|
+
- The first 20 runs of a path (`STEP_DETAIL_RUNS`), in start order, write their started and end lines.
|
|
276
|
+
- A later run writes no line when it starts or completes. A later run that fails writes its failed line,
|
|
277
|
+
with `err`, `duration`, and the item, until the path wrote 20 such lines (`STEP_EXTRA_FAILED_LINES`).
|
|
278
|
+
- When the Run ends, also on a failure, an interruption, or the deadline, each path with more than 20
|
|
279
|
+
runs writes one summary line, `<title> ran <started> times.`, with `temperStepEvent: 'summary'` and
|
|
280
|
+
these numbers for all runs of the path in the Run: `temperStepStarted`, `temperStepCompleted`,
|
|
281
|
+
`temperStepFailed`, and `temperStepMaxConcurrent`. A run still open at the end counts in started only.
|
|
282
|
+
|
|
283
|
+
A later run costs almost nothing: no line, no child span, and no clock read unless it can still write a
|
|
284
|
+
failed line. A step inside it keeps its path. Outside a Run, such as an effect a unit test runs
|
|
285
|
+
directly, nothing is bounded and no summary is written. While a Run runs, the platform shows the first
|
|
286
|
+
20 runs of a path; the totals arrive with the summary. A Run that the platform kills writes no summary.
|
|
287
|
+
|
|
288
|
+
A step inside a loop keeps its lines for the first 20 runs of a Run and for up to 20 more failed runs,
|
|
289
|
+
then one summary line with the totals. When a member does not need each record, put one step around the
|
|
290
|
+
loop.
|
|
291
|
+
|
|
292
|
+
Do not set the reserved fields in your own log lines or with `Effect.annotateLogs`. A line cut to the
|
|
293
|
+
log line budget keeps each one only while its value is a string of at most 256 characters or, for the
|
|
294
|
+
summary numbers, a number.
|
|
295
|
+
|
|
296
|
+
The build writes a `steps` catalog to the manifest: every step that `Step.make` returned before the
|
|
297
|
+
build, as `{ id, title, kind, summary?, resources }`, in declaration order. A workflow without steps
|
|
298
|
+
writes the same manifest as before. The build fails, prints each problem, and names the step, when:
|
|
299
|
+
|
|
300
|
+
- two different `Step` values use one id (share one value instead);
|
|
301
|
+
- a step id does not match `^[a-z][A-Za-z0-9]{0,63}$`, or a kind, title, or summary is not one the SDK
|
|
302
|
+
accepts;
|
|
303
|
+
- a step names a `Resource`, `Variable`, or `ResourceType` that no endpoint of the workflow declares.
|
|
304
|
+
|
|
305
|
+
A step problem never stops your module from loading, so a test can import two workflows or declare
|
|
306
|
+
its own steps. `workflow()` keeps the first of two steps with one id, keeps a step without a resource
|
|
307
|
+
that no endpoint declares, leaves out a step with an invalid id or kind, and lists each problem in
|
|
308
|
+
`stepProblems` on the module. The build reads that list; the problems never enter the manifest.
|
|
309
|
+
`Step.make` never throws. `temper-workflow dev` and `invoke` print each problem once, at start, as
|
|
310
|
+
`warning: <problem>`, and run the workflow.
|
|
311
|
+
|
|
312
|
+
The first build of the process closes the catalog. A step declared after it, such as inside a
|
|
313
|
+
function, still writes its lines, also with an id or kind that the build refuses, but the catalog does not list it. A second `workflow()` in the same
|
|
314
|
+
process, as in a test, gets the same closed catalog. Keep a step's `id` when you change its title: the platform keys Run state on the id.
|
|
315
|
+
`sdk/workflow-examples/step-flow` is a complete example.
|
|
316
|
+
|
|
317
|
+
### Partner clients for `http_api` records
|
|
318
|
+
|
|
319
|
+
`HttpApiClients` gives an `HttpClient` for one `http_api` record. Each request joins the record's `baseUrl`
|
|
320
|
+
and carries its headers, authentication, TLS, and proxy settings. A header that the request sets wins over the
|
|
321
|
+
record's header. Read the service where the handler group is built, and build the client where the record is read:
|
|
213
322
|
|
|
214
323
|
```ts
|
|
215
|
-
import {
|
|
324
|
+
import { HttpApiClients } from '@temper/workflow';
|
|
216
325
|
|
|
217
|
-
const
|
|
326
|
+
const clients = yield * HttpApiClients; // in the Effect that builds the handler group
|
|
218
327
|
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
// After a 401 from the partner:
|
|
222
|
-
yield * tokens.refuse(tenant.key, token);
|
|
328
|
+
const carrier = yield * clients.client('carrier', yield * CarrierApi); // in a request
|
|
329
|
+
const response = yield * carrier.get('/v1/shipments');
|
|
223
330
|
```
|
|
224
331
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
332
|
+
The client applies `none`, `basic`, `bearer`, `api_key`, `oauth2_client_credentials`, and `oauth2_password`.
|
|
333
|
+
For the two OAuth types, workflow code holds no token, and the VM never logs in to the partner:
|
|
334
|
+
|
|
335
|
+
- The Temper API logs in with the record's `tokenRequest`, including `private_key_jwt` client authentication and
|
|
336
|
+
the token-request `headers` (for example a login API key), and keeps the token in its memory. Every VM of
|
|
337
|
+
the organization that uses the same login gets that token until 60 seconds before it expires. Each API
|
|
338
|
+
process logs in on its own, so the partner must accept tokens from several API processes at the same time.
|
|
339
|
+
The client asks for the token at `POST /api/v1/runtime/resources/access-token`, within one 20-second deadline.
|
|
340
|
+
- The key must name a stored `http_api` record in the workflow's reach: the API resolves the key itself, so a
|
|
341
|
+
record that workflow code builds gets no token. On a stack whose Temper API does not have the route yet, the
|
|
342
|
+
call fails with a message that says so; update the API first.
|
|
343
|
+
- The client names the login identity of its record: a hash of the base URL, auth type, token URL, client id,
|
|
344
|
+
username, scope, audience, `extraParams`, and token-request `headers`, without the client secret, private key,
|
|
345
|
+
or password. When the key names a record with another identity, the call fails with
|
|
346
|
+
`Resource <key> changed since this workflow read it`. After an edit of one of these fields (a login header
|
|
347
|
+
value included, also a secret one), a running workflow gets this error until it reads the record again; the SDK
|
|
348
|
+
caches a resolved record for 30 seconds.
|
|
349
|
+
- The client keeps the token in the memory of this VM until 30 seconds before it expires, per resource key and
|
|
350
|
+
login identity. Two records read under one key, such as two tenants, never share a token. A rotated secret
|
|
351
|
+
keeps the held token until it expires or the partner answers 401. Concurrent calls for one login share one
|
|
352
|
+
request to the API. A token answer without a lifetime serves one call.
|
|
353
|
+
- A failed or interrupted request keeps no token, so the next call asks again. A failed partner login fails the
|
|
354
|
+
call with an `HttpClientError` that names the key, the partner's HTTP status, and its OAuth error code.
|
|
355
|
+
- After a 401 answer, the client tells the API which token the partner refused and sends the request one more
|
|
356
|
+
time with the token the API answers. A second 401 goes to the workflow. The API logs in again only for a
|
|
357
|
+
refused token whose login is 60 seconds old or more, at most once in 5 seconds; a login the partner refused
|
|
358
|
+
with 400, 401, or 403 answers with that failure for 60 seconds. A request with a stream body is not sent
|
|
359
|
+
again: the workflow gets the 401, and the next call asks the API again.
|
|
360
|
+
|
|
361
|
+
A partner call follows redirects as `fetch` does. On a redirect to another origin, `fetch` removes
|
|
362
|
+
`Authorization` only: an API key in another header, and the record's `headers`, go to that origin. To stop
|
|
363
|
+
that for a partner that redirects, provide `FetchHttpClient.RequestInit` with `redirect: 'manual'` around the call.
|
|
364
|
+
|
|
365
|
+
The client fails with `UnsupportedHttpApiResourceError` and sends nothing for a setting it cannot apply:
|
|
366
|
+
`oauth2_jwt_bearer`, `oauth1_tba`, `aws_sigv4`, an auth type a newer platform added, and TLS or proxy settings
|
|
367
|
+
outside the Bun runtime, and, on an OAuth record, TLS or proxy settings or a token URL that is not https. The
|
|
368
|
+
message is `Resource <key> uses <setting>, which the workflow HTTP client does not support.` In tests,
|
|
369
|
+
`testPlatform({ fetch, resources })` logs in for each token in memory: it sends the record's token request through
|
|
370
|
+
`fetch`.
|
|
230
371
|
|
|
231
372
|
## Invoke in a test
|
|
232
373
|
|
package/dist/AccessTokens.d.ts
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** What a partner's token endpoint issued. */
|
|
1
|
+
import { Effect, Redacted } from 'effect';
|
|
2
|
+
/** A token the platform issued for one login. */
|
|
4
3
|
export interface IssuedAccessToken {
|
|
5
|
-
/** The credential as the workflow sends it, for example the `access_token
|
|
4
|
+
/** The credential as the workflow sends it, for example the `access_token`. */
|
|
6
5
|
readonly token: Redacted.Redacted<string>;
|
|
7
|
-
/**
|
|
8
|
-
readonly expiresIn: number;
|
|
6
|
+
/** Seconds of lifetime left when the request started. `null` means "use once"; a lifetime under 30 s is used once too. */
|
|
7
|
+
readonly expiresIn: number | null;
|
|
9
8
|
}
|
|
10
|
-
export interface
|
|
9
|
+
export interface AccessTokens {
|
|
11
10
|
/**
|
|
12
|
-
* A usable token for the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* A usable token for `login`: the one this VM holds, else a new one from `request`, which receives the token
|
|
12
|
+
* the partner last refused for this login. That refusal goes on one request only: it is cleared when the request
|
|
13
|
+
* settles, unless the request is interrupted. Concurrent calls for one login share one request, and its answer,
|
|
14
|
+
* also a use-once token. A failed or interrupted `request` keeps no token.
|
|
15
15
|
*/
|
|
16
|
-
readonly get: <E, R>(
|
|
17
|
-
/** Reports a token the partner refused (a 401): this VM
|
|
18
|
-
readonly refuse: (
|
|
16
|
+
readonly get: <E, R>(login: string, request: (refused: string | undefined) => Effect.Effect<IssuedAccessToken, E, R>) => Effect.Effect<Redacted.Redacted<string>, E, R>;
|
|
17
|
+
/** Reports a token the partner refused (a 401): this VM drops it, and the next request names it. */
|
|
18
|
+
readonly refuse: (login: string, token: Redacted.Redacted<string>) => Effect.Effect<void>;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Partner access tokens for a workflow, reused until they expire: across requests in this VM, and across the VMs
|
|
23
|
-
* and hosts of the workflow through the Temper platform. Contract: docs/specs/workflow-access-tokens.md.
|
|
24
|
-
*/
|
|
25
|
-
export declare class AccessTokens extends AccessTokens_base {
|
|
26
|
-
static readonly layer: Layer.Layer<AccessTokens, never, RuntimeAccessTokenStore>;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
20
|
+
/** Platform-issued access tokens held in the memory of this VM and reused until they expire. */
|
|
21
|
+
export declare const makeAccessTokens: () => AccessTokens;
|
|
29
22
|
//# sourceMappingURL=AccessTokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessTokens.d.ts","sourceRoot":"","sources":["../src/AccessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AccessTokens.d.ts","sourceRoot":"","sources":["../src/AccessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,MAAM,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAMhF,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,0HAA0H;IAC1H,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7E,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,oGAAoG;IACpG,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAC3F;AAeD,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,QAAO,YAyEnC,CAAC"}
|
package/dist/AccessTokens.js
CHANGED
|
@@ -1,67 +1,69 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cause, Clock, Deferred, Effect, Exit, Option, Redacted } from 'effect';
|
|
2
2
|
import { registerSecrets } from './Redaction.js';
|
|
3
|
-
|
|
4
|
-
/** A token this close to its expiry could lapse mid-request, so it counts as spent (as in legacy `unnbound-env`). */
|
|
3
|
+
// A token this close to its expiry could lapse mid-request, so it counts as spent (as in legacy `unnbound-env`).
|
|
5
4
|
const EXPIRY_MARGIN_MS = 30_000;
|
|
6
|
-
/** The platform store only saves partner requests: past this wait the workflow asks the partner itself. */
|
|
7
|
-
const STORE_BUDGET = Duration.seconds(2);
|
|
8
5
|
const usable = (expiresAt, now) => expiresAt - EXPIRY_MARGIN_MS > now;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const locks = new Map();
|
|
15
|
-
const lockOf = (resourceKey) => {
|
|
16
|
-
const existing = locks.get(resourceKey);
|
|
6
|
+
/** Platform-issued access tokens held in the memory of this VM and reused until they expire. */
|
|
7
|
+
export const makeAccessTokens = () => {
|
|
8
|
+
const logins = new Map();
|
|
9
|
+
const loginOf = (login) => {
|
|
10
|
+
const existing = logins.get(login);
|
|
17
11
|
if (existing !== undefined)
|
|
18
12
|
return existing;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
return
|
|
13
|
+
const created = { held: undefined, refused: undefined, flight: undefined };
|
|
14
|
+
logins.set(login, created);
|
|
15
|
+
return created;
|
|
22
16
|
};
|
|
23
|
-
// The
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
// The waiters of a request share its outcome; an interrupted request hands them none, and they start over.
|
|
18
|
+
const settle = (state, flight, refused, exit) => {
|
|
19
|
+
state.flight = undefined;
|
|
20
|
+
const interrupted = Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause);
|
|
21
|
+
// A refusal reported while the request ran is newer, so it stays for the next request.
|
|
22
|
+
if (!interrupted && state.refused === refused)
|
|
23
|
+
state.refused = undefined;
|
|
24
|
+
if (Exit.isSuccess(exit))
|
|
25
|
+
Deferred.doneUnsafe(flight, Exit.succeed(Option.some(exit.value)));
|
|
26
|
+
else if (interrupted)
|
|
27
|
+
Deferred.doneUnsafe(flight, Exit.succeed(Option.none()));
|
|
28
|
+
else
|
|
29
|
+
Deferred.doneUnsafe(flight, Exit.failCause(exit.cause));
|
|
30
|
+
};
|
|
31
|
+
const get = (login, request) => Effect.gen(function* () {
|
|
32
|
+
const state = loginOf(login);
|
|
33
|
+
const now = yield* Clock.currentTimeMillis;
|
|
34
|
+
if (state.held !== undefined && usable(state.held.expiresAt, now)) {
|
|
35
|
+
// A cached token may reach a request this VM serves later, so its mask registers on every hit.
|
|
36
|
+
yield* registerSecrets([state.held.token]);
|
|
37
|
+
return Redacted.make(state.held.token);
|
|
29
38
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
held.set(resourceKey, { token, expiresAt: shared.value.expiresAt });
|
|
35
|
-
return shared.value.token;
|
|
36
|
-
}
|
|
39
|
+
if (state.flight !== undefined) {
|
|
40
|
+
// SAFETY: one client builds every request of a login, so the flight fails only with that request's error type.
|
|
41
|
+
const shared = yield* Deferred.await(state.flight);
|
|
42
|
+
return Option.isSome(shared) ? Redacted.make(shared.value) : yield* get(login, request);
|
|
37
43
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
const flight = Deferred.makeUnsafe();
|
|
45
|
+
state.flight = flight;
|
|
46
|
+
const { refused } = state;
|
|
47
|
+
return yield* Effect.gen(function* () {
|
|
48
|
+
const issued = yield* request(refused);
|
|
49
|
+
const token = Redacted.value(issued.token);
|
|
50
|
+
yield* registerSecrets([token]);
|
|
51
|
+
// The lifetime counts from the start of the request: the platform's clock ran while its answer travelled.
|
|
52
|
+
const expiresAt = now + (issued.expiresIn ?? 0) * 1000;
|
|
53
|
+
state.held =
|
|
54
|
+
issued.expiresIn !== null && usable(expiresAt, yield* Clock.currentTimeMillis)
|
|
55
|
+
? { token, expiresAt }
|
|
56
|
+
: undefined;
|
|
57
|
+
return token;
|
|
58
|
+
}).pipe(Effect.onExit((exit) => Effect.sync(() => settle(state, flight, refused, exit))), Effect.map((token) => Redacted.make(token)));
|
|
59
|
+
});
|
|
60
|
+
const refuse = (login, token) => Effect.sync(() => {
|
|
61
|
+
const state = loginOf(login);
|
|
52
62
|
const value = Redacted.value(token);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
if (state.held?.token === value)
|
|
64
|
+
state.held = undefined;
|
|
65
|
+
state.refused = value;
|
|
56
66
|
});
|
|
57
67
|
return { get, refuse };
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Partner access tokens for a workflow, reused until they expire: across requests in this VM, and across the VMs
|
|
61
|
-
* and hosts of the workflow through the Temper platform. Contract: docs/specs/workflow-access-tokens.md.
|
|
62
|
-
*/
|
|
63
|
-
export class AccessTokens extends Context.Service()('@temper/workflow/AccessTokens') {
|
|
64
|
-
// Needs the store, which `workflow()` provides.
|
|
65
|
-
static layer = Layer.effect(AccessTokens, make);
|
|
66
|
-
}
|
|
68
|
+
};
|
|
67
69
|
//# sourceMappingURL=AccessTokens.js.map
|
package/dist/AccessTokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessTokens.js","sourceRoot":"","sources":["../src/AccessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AccessTokens.js","sourceRoot":"","sources":["../src/AccessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,iHAAiH;AACjH,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAoChC,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,GAAW,EAAE,EAAE,CAAC,SAAS,GAAG,gBAAgB,GAAG,GAAG,CAAC;AAEtF,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAiB,EAAE;IACjD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAExC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAS,EAAE;QACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAC5C,MAAM,OAAO,GAAU,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAClF,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,2GAA2G;IAC3G,MAAM,MAAM,GAAG,CACb,KAAY,EACZ,MAAoC,EACpC,OAA2B,EAC3B,IAA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AAI,CACL,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAChF,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAC5C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,MAAM,MAAM,GAA2B,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACtD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK;YAAE,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QACxD,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC,CAAC"}
|
package/dist/As2Transport.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpProxy, TlsSettings } from './HttpApiResource.js';
|
|
2
2
|
import type { BunTransport } from './HttpClient.js';
|
|
3
3
|
/** A partner's delivery connection: the Bun `fetch` options that apply its settings, or why they cannot apply. */
|
|
4
4
|
export type As2DeliveryTransport = {
|
|
@@ -9,13 +9,18 @@ export type As2DeliveryTransport = {
|
|
|
9
9
|
readonly code: string;
|
|
10
10
|
readonly message: string;
|
|
11
11
|
};
|
|
12
|
+
/** The connection settings an `as2_partner` and an `http_api` record share. */
|
|
13
|
+
export interface TransportSettings {
|
|
14
|
+
readonly tls?: TlsSettings | undefined;
|
|
15
|
+
readonly proxy?: HttpProxy | undefined;
|
|
16
|
+
}
|
|
12
17
|
/** True where the global `fetch` is Bun's, the only one that takes `tls` and `proxy`. */
|
|
13
18
|
export declare const bunFetch: () => boolean;
|
|
14
19
|
/**
|
|
15
20
|
* Legacy `@ontemper/as2` checks and connection options for one delivery URL, on Bun's `fetch`. Another runtime's
|
|
16
21
|
* `fetch` skips `tls` and `proxy` without an error, so a partner that sets either is refused there.
|
|
17
22
|
*/
|
|
18
|
-
export declare const deliveryTransport: (partner:
|
|
23
|
+
export declare const deliveryTransport: (partner: TransportSettings, url: URL, bun: boolean) => As2DeliveryTransport;
|
|
19
24
|
/** A request to the address the destination check approved, in place of the name in its URL. */
|
|
20
25
|
export interface PinnedDestination {
|
|
21
26
|
readonly url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"As2Transport.d.ts","sourceRoot":"","sources":["../src/As2Transport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"As2Transport.d.ts","sourceRoot":"","sources":["../src/As2Transport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,kHAAkH;AAClH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAIlF,+EAA+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACxC;AAeD,yFAAyF;AACzF,eAAO,MAAM,QAAQ,QAAO,OAA8B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YAAa,iBAAiB,OAAO,GAAG,OAAO,OAAO,KAAG,oBA+DtF,CAAC;AAEF,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAS,GAAG,WAAW,MAAM,KAAG,iBAO7D,CAAC"}
|
package/dist/As2Transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"As2Transport.js","sourceRoot":"","sources":["../src/As2Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"As2Transport.js","sourceRoot":"","sources":["../src/As2Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAiBlC,mHAAmH;AACnH,MAAM,WAAW,GAAG,CAAC,GAAQ,EAA2B,EAAE,CACxD,GAAG,KAAK,SAAS;IACjB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CACrG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAC/B,CAAC;AAEJ,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,O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Schema.Literals<readonly ["http", "schedule", "manual", "internal"]>;
|
|
3
3
|
export type TriggerKind = typeof TriggerKind.Type;
|
|
4
4
|
export declare const ResponsePolicy: Schema.Literals<readonly ["wait", "ack", "early"]>;
|
|
@@ -78,6 +78,53 @@ export declare const ManifestResource: Schema.Union<readonly [Schema.Struct<{
|
|
|
78
78
|
readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
79
79
|
}>]>;
|
|
80
80
|
export type ManifestResource = typeof ManifestResource.Type;
|
|
81
|
+
export declare const FlowStepKind: Schema.Literals<readonly ["query", "http", "file", "transform", "ai", "agent", "review", "notify", "code"]>;
|
|
82
|
+
export type FlowStepKind = typeof FlowStepKind.Type;
|
|
83
|
+
/** Why `id` is not a valid step id (FLOW-2), or `undefined`. The build reports it as a step problem. */
|
|
84
|
+
export declare const stepIdProblem: (id: string) => string | undefined;
|
|
85
|
+
/** One named unit of work the code runs; `id` is stable across deploys and unique in the workflow. */
|
|
86
|
+
export declare const FlowStep: Schema.Struct<{
|
|
87
|
+
readonly id: Schema.String;
|
|
88
|
+
readonly title: Schema.String;
|
|
89
|
+
readonly kind: Schema.Literals<readonly ["query", "http", "file", "transform", "ai", "agent", "review", "notify", "code"]>;
|
|
90
|
+
readonly summary: Schema.optionalKey<Schema.String>;
|
|
91
|
+
/** Identities of the configuration the step reads, as the endpoints' `resources` name them: `resource:<key>`. */
|
|
92
|
+
readonly resources: Schema.$Array<Schema.String>;
|
|
93
|
+
}>;
|
|
94
|
+
export type FlowStep = typeof FlowStep.Type;
|
|
95
|
+
/** The steps a workflow declares, in declaration order: the manifest's `steps` catalog (FLOW-2). */
|
|
96
|
+
export declare const WorkflowSteps: Schema.$Array<Schema.Struct<{
|
|
97
|
+
readonly id: Schema.String;
|
|
98
|
+
readonly title: Schema.String;
|
|
99
|
+
readonly kind: Schema.Literals<readonly ["query", "http", "file", "transform", "ai", "agent", "review", "notify", "code"]>;
|
|
100
|
+
readonly summary: Schema.optionalKey<Schema.String>;
|
|
101
|
+
/** Identities of the configuration the step reads, as the endpoints' `resources` name them: `resource:<key>`. */
|
|
102
|
+
readonly resources: Schema.$Array<Schema.String>;
|
|
103
|
+
}>>;
|
|
104
|
+
export type WorkflowSteps = typeof WorkflowSteps.Type;
|
|
105
|
+
/**
|
|
106
|
+
* Reserved fields of the log lines a step writes; the API folds them into the step states of a Run.
|
|
107
|
+
* `path` holds the ids of the enclosing steps and the step, outermost first, joined with `/`.
|
|
108
|
+
* `started`, `completed`, `failed`, and `maxConcurrent` are the numbers of a `summary` line only.
|
|
109
|
+
*/
|
|
110
|
+
export declare const STEP_LOG_FIELDS: {
|
|
111
|
+
readonly step: 'temperStep';
|
|
112
|
+
readonly event: 'temperStepEvent';
|
|
113
|
+
readonly item: 'temperStepItem';
|
|
114
|
+
readonly path: 'temperStepPath';
|
|
115
|
+
readonly started: 'temperStepStarted';
|
|
116
|
+
readonly completed: 'temperStepCompleted';
|
|
117
|
+
readonly failed: 'temperStepFailed';
|
|
118
|
+
readonly maxConcurrent: 'temperStepMaxConcurrent';
|
|
119
|
+
};
|
|
120
|
+
/** Characters of a step field value that a log line cut to its budget keeps whole. */
|
|
121
|
+
export declare const MAX_STEP_FIELD_LENGTH = 256;
|
|
122
|
+
/** Runs of one step path in one Run that write their started and end lines; a later run writes none (FLOW-3). */
|
|
123
|
+
export declare const STEP_DETAIL_RUNS = 20;
|
|
124
|
+
/** Failed lines that the later runs of one step path write in one Run, past the detailed runs (FLOW-3). */
|
|
125
|
+
export declare const STEP_EXTRA_FAILED_LINES = 20;
|
|
126
|
+
/** A `summary` line gives the totals of a path with more than `STEP_DETAIL_RUNS` runs, when the Run ends. */
|
|
127
|
+
export type StepLogEvent = 'started' | 'completed' | 'failed' | 'summary';
|
|
81
128
|
export declare const WorkflowManifestEndpoint: Schema.Struct<{
|
|
82
129
|
readonly group: Schema.String;
|
|
83
130
|
readonly name: Schema.String;
|
|
@@ -183,6 +230,16 @@ export declare const WorkflowManifest: Schema.Struct<{
|
|
|
183
230
|
readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
184
231
|
}>]>>, never>;
|
|
185
232
|
}>>;
|
|
233
|
+
readonly steps: Schema.optionalKey<Schema.Unknown>;
|
|
186
234
|
}>;
|
|
187
235
|
export type WorkflowManifest = typeof WorkflowManifest.Type;
|
|
236
|
+
/**
|
|
237
|
+
* The catalog of a manifest's `steps`, or `none` when it is absent or has a shape this reader does not
|
|
238
|
+
* know, such as a step kind of a later SDK. Readers call this instead of reading `steps`.
|
|
239
|
+
*/
|
|
240
|
+
export declare const decodeWorkflowSteps: (steps: WorkflowManifest['steps']) => Option.Option<WorkflowSteps>;
|
|
241
|
+
/** What `makeManifest` writes: `steps` passed the FLOW-2 checks, so it is a `WorkflowSteps`. */
|
|
242
|
+
export type BuiltWorkflowManifest = Omit<WorkflowManifest, 'steps'> & {
|
|
243
|
+
readonly steps?: WorkflowSteps;
|
|
244
|
+
};
|
|
188
245
|
//# sourceMappingURL=Manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/Contract/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/Contract/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErD,eAAO,MAAM,WAAW,sEAA8D,CAAC;AACvF,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,eAAO,MAAM,cAAc,oDAA4C,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAQxD,gHAAgH;AAChH,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AACvD,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