@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.
Files changed (87) hide show
  1. package/README.md +157 -16
  2. package/dist/AccessTokens.d.ts +15 -22
  3. package/dist/AccessTokens.d.ts.map +1 -1
  4. package/dist/AccessTokens.js +57 -55
  5. package/dist/AccessTokens.js.map +1 -1
  6. package/dist/As2Transport.d.ts +7 -2
  7. package/dist/As2Transport.d.ts.map +1 -1
  8. package/dist/As2Transport.js.map +1 -1
  9. package/dist/Contract/Manifest.d.ts +58 -1
  10. package/dist/Contract/Manifest.d.ts.map +1 -1
  11. package/dist/Contract/Manifest.js +53 -0
  12. package/dist/Contract/Manifest.js.map +1 -1
  13. package/dist/Contract/RuntimeApi.d.ts +35 -29
  14. package/dist/Contract/RuntimeApi.d.ts.map +1 -1
  15. package/dist/Contract/RuntimeApi.js +59 -25
  16. package/dist/Contract/RuntimeApi.js.map +1 -1
  17. package/dist/Contract/index.d.ts +2 -2
  18. package/dist/Contract/index.d.ts.map +1 -1
  19. package/dist/Contract/index.js +2 -2
  20. package/dist/Contract/index.js.map +1 -1
  21. package/dist/HttpApiClient.d.ts +30 -0
  22. package/dist/HttpApiClient.d.ts.map +1 -0
  23. package/dist/HttpApiClient.js +142 -0
  24. package/dist/HttpApiClient.js.map +1 -0
  25. package/dist/HttpApiResource.d.ts +133 -0
  26. package/dist/HttpApiResource.d.ts.map +1 -1
  27. package/dist/HttpApiResource.js +31 -3
  28. package/dist/HttpApiResource.js.map +1 -1
  29. package/dist/Kafka.d.ts.map +1 -1
  30. package/dist/Kafka.js +6 -73
  31. package/dist/Kafka.js.map +1 -1
  32. package/dist/LogContext.d.ts +2 -0
  33. package/dist/LogContext.d.ts.map +1 -1
  34. package/dist/LogContext.js +7 -4
  35. package/dist/LogContext.js.map +1 -1
  36. package/dist/Logger.d.ts.map +1 -1
  37. package/dist/Logger.js +16 -3
  38. package/dist/Logger.js.map +1 -1
  39. package/dist/Manifest.d.ts +14 -3
  40. package/dist/Manifest.d.ts.map +1 -1
  41. package/dist/Manifest.js +98 -6
  42. package/dist/Manifest.js.map +1 -1
  43. package/dist/Middleware.d.ts.map +1 -1
  44. package/dist/Middleware.js +4 -1
  45. package/dist/Middleware.js.map +1 -1
  46. package/dist/OAuthToken.d.ts +46 -0
  47. package/dist/OAuthToken.d.ts.map +1 -0
  48. package/dist/OAuthToken.js +132 -0
  49. package/dist/OAuthToken.js.map +1 -0
  50. package/dist/Redaction.d.ts.map +1 -1
  51. package/dist/Redaction.js +1 -0
  52. package/dist/Redaction.js.map +1 -1
  53. package/dist/Resource.d.ts +3 -1
  54. package/dist/Resource.d.ts.map +1 -1
  55. package/dist/Resource.js.map +1 -1
  56. package/dist/RuntimeResources.d.ts +9 -23
  57. package/dist/RuntimeResources.d.ts.map +1 -1
  58. package/dist/RuntimeResources.js +43 -25
  59. package/dist/RuntimeResources.js.map +1 -1
  60. package/dist/Step.d.ts +63 -0
  61. package/dist/Step.d.ts.map +1 -0
  62. package/dist/Step.js +106 -0
  63. package/dist/Step.js.map +1 -0
  64. package/dist/StepCatalog.d.ts +9 -0
  65. package/dist/StepCatalog.d.ts.map +1 -0
  66. package/dist/StepCatalog.js +16 -0
  67. package/dist/StepCatalog.js.map +1 -0
  68. package/dist/StepRuns.d.ts +33 -0
  69. package/dist/StepRuns.d.ts.map +1 -0
  70. package/dist/StepRuns.js +65 -0
  71. package/dist/StepRuns.js.map +1 -0
  72. package/dist/Workflow.d.ts +7 -7
  73. package/dist/Workflow.d.ts.map +1 -1
  74. package/dist/Workflow.js +10 -11
  75. package/dist/Workflow.js.map +1 -1
  76. package/dist/cli.d.ts.map +1 -1
  77. package/dist/cli.js +9 -0
  78. package/dist/cli.js.map +1 -1
  79. package/dist/index.d.ts +4 -3
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -2
  82. package/dist/index.js.map +1 -1
  83. package/dist/testing.d.ts +9 -3
  84. package/dist/testing.d.ts.map +1 -1
  85. package/dist/testing.js +64 -19
  86. package/dist/testing.js.map +1 -1
  87. 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 2. `auth` is one of `none`, `basic`,
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). An auth `type` that a newer platform adds decodes as
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
- ### Partner access tokens
210
+ ## Steps
210
211
 
211
- `AccessTokens` keeps a partner OAuth access token for the workflow. Read the service where the client layer or the
212
- handler group is built. Pass it the key of the record that holds the login and the Effect that requests a token:
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 { AccessTokens } from '@temper/workflow';
324
+ import { HttpApiClients } from '@temper/workflow';
216
325
 
217
- const tokens = yield * AccessTokens; // in `make`, or in the Effect that builds the handler group
326
+ const clients = yield * HttpApiClients; // in the Effect that builds the handler group
218
327
 
219
- // requestToken: Effect<{ token: Redacted<string>; expiresIn: number }>
220
- const token = yield * tokens.get(tenant.key, requestToken(tenant.value));
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
- `get` returns the token this VM holds, else the one another VM of the workflow stored on the Temper platform,
226
- else a new one from the request. It reuses a token until 30 seconds before it expires; a token whose `expiresIn` is not a
227
- positive number is used once. A failed or interrupted token request keeps nothing. After `refuse`, the next `get` requests a new token. Each workflow and environment
228
- has its own token for a record. `testPlatform({ resources })` keeps tokens in memory, so two modules on one test
229
- platform share them.
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
 
@@ -1,29 +1,22 @@
1
- import { Context, Effect, Layer, Redacted } from 'effect';
2
- import { RuntimeAccessTokenStore } from './RuntimeResources.js';
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` or a whole `Authorization` value. */
4
+ /** The credential as the workflow sends it, for example the `access_token`. */
6
5
  readonly token: Redacted.Redacted<string>;
7
- /** The partner's lifetime in seconds (`expires_in`). A value that is not a positive number means "use once". */
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 AccessTokensService {
9
+ export interface AccessTokens {
11
10
  /**
12
- * A usable token for the resource record `resourceKey`: this VM's, else the one another VM of this workflow
13
- * stored on the platform, else a new one from `request`. Concurrent calls for one record share one request.
14
- * A failed or interrupted `request` keeps and shares nothing.
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>(resourceKey: string, request: Effect.Effect<IssuedAccessToken, E, R>) => Effect.Effect<Redacted.Redacted<string>, E, R>;
17
- /** Reports a token the partner refused (a 401): this VM never uses it again, and its next `get` replaces it. */
18
- readonly refuse: (resourceKey: string, token: Redacted.Redacted<string>) => Effect.Effect<void>;
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
- declare const AccessTokens_base: Context.ServiceClass<AccessTokens, "@temper/workflow/AccessTokens", AccessTokensService>;
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,EAAS,OAAO,EAAY,MAAM,EAAE,KAAK,EAAU,QAAQ,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AAM,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"}
@@ -1,67 +1,69 @@
1
- import { Clock, Context, Duration, Effect, Layer, Option, Redacted, Semaphore } from 'effect';
1
+ import { Cause, Clock, Deferred, Effect, Exit, Option, Redacted } from 'effect';
2
2
  import { registerSecrets } from './Redaction.js';
3
- import { RuntimeAccessTokenStore } from './RuntimeResources.js';
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
- const make = Effect.gen(function* () {
10
- const store = yield* RuntimeAccessTokenStore;
11
- const held = new Map();
12
- // The last token each record's partner refused: the store still holds it until the replacement is written.
13
- const refused = new Map();
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 lock = Semaphore.makeUnsafe(1);
20
- locks.set(resourceKey, lock);
21
- return lock;
13
+ const created = { held: undefined, refused: undefined, flight: undefined };
14
+ logins.set(login, created);
15
+ return created;
22
16
  };
23
- // The store never fails or delays a partner call: an error, or no answer in time, reads as no answer.
24
- const bounded = (operation) => operation.pipe(Effect.timeoutOption(STORE_BUDGET), Effect.catch(() => Effect.succeed(Option.none())));
25
- const get = (resourceKey, request) => Effect.gen(function* () {
26
- const local = held.get(resourceKey);
27
- if (local !== undefined && usable(local.expiresAt, yield* Clock.currentTimeMillis)) {
28
- return Redacted.make(local.token);
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
- const shared = Option.flatten(yield* bounded(store.read(resourceKey)));
31
- if (Option.isSome(shared)) {
32
- const token = Redacted.value(shared.value.token);
33
- if (token !== refused.get(resourceKey) && usable(shared.value.expiresAt, yield* Clock.currentTimeMillis)) {
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
- // The lifetime counts from the start of the request: the partner's clock ran while its answer travelled.
39
- const requestedAt = yield* Clock.currentTimeMillis;
40
- const issued = yield* request;
41
- const token = Redacted.value(issued.token);
42
- yield* registerSecrets([token]);
43
- const expiresAt = requestedAt + issued.expiresIn * 1000;
44
- if (!Number.isFinite(expiresAt) || !usable(expiresAt, yield* Clock.currentTimeMillis))
45
- return issued.token;
46
- held.set(resourceKey, { token, expiresAt });
47
- // Inside the lock, so the writes of this VM reach the store in the order of its token requests.
48
- yield* bounded(store.write(resourceKey, { token: issued.token, expiresAt }));
49
- return issued.token;
50
- }).pipe(Semaphore.withPermit(lockOf(resourceKey)));
51
- const refuse = (resourceKey, token) => Effect.sync(() => {
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
- refused.set(resourceKey, value);
54
- if (held.get(resourceKey)?.token === value)
55
- held.delete(resourceKey);
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
@@ -1 +1 @@
1
- {"version":3,"file":"AccessTokens.js","sourceRoot":"","sources":["../src/AccessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,qHAAqH;AACrH,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,2GAA2G;AAC3G,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AA6BzC,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,GAAW,EAAE,EAAE,CAAC,SAAS,GAAG,gBAAgB,GAAG,GAAG,CAAC;AAEtF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAgB,CAAC;IACrC,2GAA2G;IAC3G,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IAErD,MA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AACzB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { As2PartnerResource } from './As2Resource.js';
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: As2PartnerResource, url: URL, bun: boolean) => As2DeliveryTransport;
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,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,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,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} from 'effect';
1
+ import { type Option, Schema } from 'effect';
2
2
  export declare const TriggerKind: 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;AAExC,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,qGAAqG;AACrG,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,eAAe;;IAGxB;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;;;IAKH,iHAAiH;;IAEjH,6DAA6D;;IAE7D,gHAAgH;;;;;;IAKlH,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,6FAA6F;AAC7F,eAAO,MAAM,wBAAwB,YAAa,eAAe,KAAG,MAAM,GAAG,SACe,CAAC;AAE7F;;;GAGG;AACH,eAAO,MAAM,gBAAgB,YAAa,eAAe,KAAG,MAAM,GAAG,SAWpE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,YAAa,eAAe,KAAG,MAAM,GAAG,SAI9E,CAAC;AAEF,8GAA8G;AAC9G,eAAO,MAAM,kBAAkB,YAAa,eAAe,KAAG,MAAM,GAAG,SAKtE,CAAC;AAEF,gGAAgG;AAChG,eAAO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