@ontemper/sdk 0.0.0 → 0.2.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.
Files changed (98) hide show
  1. package/README.md +221 -2
  2. package/dist/AxiosError.d.ts +46 -0
  3. package/dist/AxiosError.d.ts.map +1 -0
  4. package/dist/AxiosError.js +118 -0
  5. package/dist/AxiosError.js.map +1 -0
  6. package/dist/Contract/Invocation.d.ts +21 -0
  7. package/dist/Contract/Invocation.d.ts.map +1 -0
  8. package/dist/Contract/Invocation.js +2 -0
  9. package/dist/Contract/Invocation.js.map +1 -0
  10. package/dist/Contract/Manifest.d.ts +125 -0
  11. package/dist/Contract/Manifest.d.ts.map +1 -0
  12. package/dist/Contract/Manifest.js +59 -0
  13. package/dist/Contract/Manifest.js.map +1 -0
  14. package/dist/Contract/RuntimeApi.d.ts +143 -0
  15. package/dist/Contract/RuntimeApi.d.ts.map +1 -0
  16. package/dist/Contract/RuntimeApi.js +148 -0
  17. package/dist/Contract/RuntimeApi.js.map +1 -0
  18. package/dist/Contract/index.d.ts +4 -0
  19. package/dist/Contract/index.d.ts.map +1 -0
  20. package/dist/Contract/index.js +3 -0
  21. package/dist/Contract/index.js.map +1 -0
  22. package/dist/Correlation.d.ts +33 -0
  23. package/dist/Correlation.d.ts.map +1 -0
  24. package/dist/Correlation.js +57 -0
  25. package/dist/Correlation.js.map +1 -0
  26. package/dist/HttpApiResource.d.ts +32 -0
  27. package/dist/HttpApiResource.d.ts.map +1 -0
  28. package/dist/HttpApiResource.js +35 -0
  29. package/dist/HttpApiResource.js.map +1 -0
  30. package/dist/HttpClient.d.ts +10 -0
  31. package/dist/HttpClient.d.ts.map +1 -0
  32. package/dist/HttpClient.js +167 -0
  33. package/dist/HttpClient.js.map +1 -0
  34. package/dist/HttpPayload.d.ts +9 -0
  35. package/dist/HttpPayload.d.ts.map +1 -0
  36. package/dist/HttpPayload.js +32 -0
  37. package/dist/HttpPayload.js.map +1 -0
  38. package/dist/Invocation.d.ts +7 -0
  39. package/dist/Invocation.d.ts.map +1 -0
  40. package/dist/Invocation.js +4 -0
  41. package/dist/Invocation.js.map +1 -0
  42. package/dist/LogContext.d.ts +59 -0
  43. package/dist/LogContext.d.ts.map +1 -0
  44. package/dist/LogContext.js +47 -0
  45. package/dist/LogContext.js.map +1 -0
  46. package/dist/Logger.d.ts +5 -0
  47. package/dist/Logger.d.ts.map +1 -0
  48. package/dist/Logger.js +314 -0
  49. package/dist/Logger.js.map +1 -0
  50. package/dist/Manifest.d.ts +8 -0
  51. package/dist/Manifest.d.ts.map +1 -0
  52. package/dist/Manifest.js +101 -0
  53. package/dist/Manifest.js.map +1 -0
  54. package/dist/Middleware.d.ts +13 -0
  55. package/dist/Middleware.d.ts.map +1 -0
  56. package/dist/Middleware.js +287 -0
  57. package/dist/Middleware.js.map +1 -0
  58. package/dist/Redaction.d.ts +27 -0
  59. package/dist/Redaction.d.ts.map +1 -0
  60. package/dist/Redaction.js +149 -0
  61. package/dist/Redaction.js.map +1 -0
  62. package/dist/Resource.d.ts +66 -0
  63. package/dist/Resource.d.ts.map +1 -0
  64. package/dist/Resource.js +57 -0
  65. package/dist/Resource.js.map +1 -0
  66. package/dist/ResourcesErrors.d.ts +36 -0
  67. package/dist/ResourcesErrors.d.ts.map +1 -0
  68. package/dist/ResourcesErrors.js +27 -0
  69. package/dist/ResourcesErrors.js.map +1 -0
  70. package/dist/ResourcesToken.d.ts +10 -0
  71. package/dist/ResourcesToken.d.ts.map +1 -0
  72. package/dist/ResourcesToken.js +63 -0
  73. package/dist/ResourcesToken.js.map +1 -0
  74. package/dist/RuntimeResources.d.ts +26 -0
  75. package/dist/RuntimeResources.d.ts.map +1 -0
  76. package/dist/RuntimeResources.js +115 -0
  77. package/dist/RuntimeResources.js.map +1 -0
  78. package/dist/Trigger.d.ts +17 -0
  79. package/dist/Trigger.d.ts.map +1 -0
  80. package/dist/Trigger.js +4 -0
  81. package/dist/Trigger.js.map +1 -0
  82. package/dist/Workflow.d.ts +36 -0
  83. package/dist/Workflow.d.ts.map +1 -0
  84. package/dist/Workflow.js +80 -0
  85. package/dist/Workflow.js.map +1 -0
  86. package/dist/cli.d.ts +3 -0
  87. package/dist/cli.d.ts.map +1 -0
  88. package/dist/cli.js +447 -0
  89. package/dist/cli.js.map +1 -0
  90. package/dist/index.d.ts +17 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +16 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/testing.d.ts +42 -0
  95. package/dist/testing.d.ts.map +1 -0
  96. package/dist/testing.js +49 -0
  97. package/dist/testing.js.map +1 -0
  98. package/package.json +57 -5
package/README.md CHANGED
@@ -1,3 +1,222 @@
1
- # @ontemper/sdk
1
+ # `@temper/workflow`
2
2
 
3
- Placeholder. Temper publishes the workflow SDK here from CI. Pin an exact version.
3
+ Build a Temper workflow with Effect HTTP API contracts. The SDK creates a Web handler. Temper and the local CLI call the same `fetch(Request, InvocationContext)` method.
4
+
5
+ ## Define a workflow
6
+
7
+ ```ts
8
+ import { Effect, Schema } from 'effect';
9
+ import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi';
10
+ import { Invocation, Trigger, workflow } from '@temper/workflow';
11
+
12
+ const SyncResult = Schema.Struct({ executionId: Schema.String });
13
+
14
+ const SyncGroup = HttpApiGroup.make('sync').add(
15
+ HttpApiEndpoint.post('run', '/sync', {
16
+ payload: Schema.Struct({ key: Schema.String }),
17
+ success: SyncResult,
18
+ }).annotate(Trigger, { kind: 'http' }),
19
+ );
20
+
21
+ const Api = HttpApi.make('example-workflow').add(SyncGroup);
22
+
23
+ const Handlers = HttpApiBuilder.group(Api, 'sync', (handlers) =>
24
+ handlers.handle('run', ({ payload }) =>
25
+ Effect.gen(function* () {
26
+ const invocation = yield* Invocation;
27
+ return { executionId: invocation.executionId };
28
+ }),
29
+ ),
30
+ );
31
+
32
+ export default workflow({ api: Api, handlers: Handlers });
33
+ ```
34
+
35
+ Every endpoint must have a `Trigger` annotation. Supported kinds are `http`, `schedule`, `manual`, and `internal`. Module construction fails when an endpoint has no annotation or carries a default that does not belong to its kind.
36
+
37
+ Kinds accept optional defaults that deploy seeds into stored platform records when none exist; a stored record edited later always wins:
38
+
39
+ ```ts
40
+ .annotate(Trigger, { kind: 'http', response: 'ack' })
41
+ .annotate(Trigger, { kind: 'schedule', cron: '*/10 * * * *', timezone: 'UTC' })
42
+ ```
43
+
44
+ A manifest-created Schedule is disabled. Verify the deployed route and its bindings, then enable it
45
+ through the Schedule surface. Deploying source MUST NOT start external work by itself.
46
+
47
+ Customer code does not start a listener. It exports the workflow module.
48
+
49
+ ## Run locally
50
+
51
+ ```sh
52
+ temper-workflow dev --entrypoint src/index.ts --host 127.0.0.1 --port 3051
53
+ ```
54
+
55
+ The CLI rebuilds and reloads the workflow when a file in the entrypoint directory changes. It closes the old workflow after a successful reload.
56
+
57
+ Run compiled JavaScript in a trusted host:
58
+
59
+ ```sh
60
+ temper-workflow serve --entrypoint dist/index.js --host 0.0.0.0 --port 3051
61
+ ```
62
+
63
+ The `serve` command loads once. It does not rebuild or watch files.
64
+
65
+ Invoke one request without a listener:
66
+
67
+ ```sh
68
+ temper-workflow invoke --entrypoint src/index.ts --method POST --path /sync --body '{"key":"value"}'
69
+ ```
70
+
71
+ ## Invocation context
72
+
73
+ `fetch(request, context)` receives the exact object the Firecracker guest builds:
74
+
75
+ ```ts
76
+ type InvocationContext = {
77
+ workflowId: string;
78
+ deploymentId: string;
79
+ executionId: string;
80
+ runId: string; // durable Run identity
81
+ attempt: number; // 1-based
82
+ triggerKind: 'http' | 'schedule' | 'manual' | 'agent' | 'as2' | 'sftp' | 'kafka' | 'child';
83
+ deadline: number; // epoch milliseconds
84
+ token: string; // run-scoped platform token
85
+ };
86
+ ```
87
+
88
+ The SDK owns three runtime behaviours around every handler:
89
+
90
+ 1. Logs: every `Effect.log*` call becomes one JSON line on stdout with `level`, `message`, `runId`,
91
+ `executionId`, `attempt`, and `traceparent`.
92
+ 2. Deadline: two seconds before `context.deadline`, or at once when less time remains, the handler
93
+ fiber is interrupted, finalizers run, and the SDK answers `504 { _tag: 'InvocationDeadlineExceeded' }`
94
+ ahead of the host's own timer.
95
+ 3. Headers: platform `x-temper-*` request headers are removed before the handler runs.
96
+
97
+ ## Resources and variables
98
+
99
+ Declare each resource, variable, and resource type that the workflow reads once. The class is both
100
+ the endpoint middleware and the handler's value. Attach it to each endpoint that reads it:
101
+
102
+ ```ts
103
+ import { HttpApiResource, Resource, ResourceType, Trigger, Variable } from '@temper/workflow';
104
+ import { HttpApiEndpoint } from 'effect/unstable/httpapi';
105
+
106
+ export class CarrierApi extends Resource<CarrierApi>()('carrier', { type: 'http_api', schema: HttpApiResource }) {}
107
+ export class ApiToken extends Variable<ApiToken>()('CARRIER_TOKEN') {}
108
+ export class PartnerApis extends ResourceType<PartnerApis>()('http_api', { schema: HttpApiResource }) {}
109
+
110
+ HttpApiEndpoint.post('shipmentEvent', '/shipments/events', { payload: ShipmentEvent })
111
+ .middleware(CarrierApi)
112
+ .annotate(Trigger, { kind: 'http' });
113
+ ```
114
+
115
+ Read the value in the handler, or in a client method that the handler calls:
116
+
117
+ ```ts
118
+ const carrier = yield* CarrierApi; // decoded value; secret fields stay Redacted
119
+ const token = yield* ApiToken; // Redacted<string>
120
+ const partners = yield* PartnerApis;
121
+ const { key, value } = yield* partners.select({ tenantKey }); // ResourceNotFoundError when no record matches
122
+ ```
123
+
124
+ - The SDK reads a declaration on its first `yield*` in a request and keeps the value for the rest of
125
+ that request. It caches each read for 30 s, so an edit reaches a running workflow without a redeploy.
126
+ - A read that the platform cannot answer is a defect. The SDK answers `500 {"message":"Internal server error"}`
127
+ and logs the cause, never the value. `select` keeps its typed errors.
128
+ - A handler that yields a declaration that its endpoint does not declare fails to compile at
129
+ `workflow({ api, handlers })`.
130
+ - A custom `HttpApiMiddleware` that reads a declaration names it in `requires`. Add the declaration
131
+ to the endpoint after that middleware, so that it wraps the middleware.
132
+ - `makeManifest` lists the declarations of each endpoint in its `resources`. Deploy fails, with one
133
+ message for each problem, when a declaration has no binding, a bound resource has a different type,
134
+ a value breaks the declared schema, or the organization does not have a declared resource type.
135
+
136
+ ## Invoke in a test
137
+
138
+ ```ts
139
+ import { invoke, testInvocation } from '@temper/workflow/testing';
140
+ import workflowModule from '../src/index.js';
141
+
142
+ const response = await invoke(workflowModule, {
143
+ request: new Request('http://localhost/sync', {
144
+ method: 'POST',
145
+ headers: { 'content-type': 'application/json' },
146
+ body: JSON.stringify({ key: 'value' }),
147
+ }),
148
+ context: testInvocation({ runId: 'run-1' }),
149
+ });
150
+ ```
151
+
152
+ `testInvocation()` fills every field with a stable default and no deadline.
153
+
154
+ `testPlatform()` answers declarations in memory through its `resources` option:
155
+
156
+ ```ts
157
+ import { testPlatform } from '@temper/workflow/testing';
158
+
159
+ const test = testPlatform({
160
+ resources: {
161
+ values: { carrier: { baseUrl: 'https://carrier.example.invalid', auth: { type: 'bearer', token: 'token-test' } } },
162
+ variables: { CARRIER_TOKEN: 'token-test' },
163
+ select: (type, match) => (type === 'http_api' && match.tenantKey === 'tenant-1' ? 'partner-1' : undefined),
164
+ },
165
+ });
166
+ const module = workflowModule.withPlatform(test.platform);
167
+ ```
168
+
169
+ Without `resources`, declarations read through the runtime API at `UNNBOUND_API_URL`, answered by the
170
+ `fetch` option. `WorkflowPlatform.resources` replaces the reader outside tests.
171
+
172
+ ## Versions
173
+
174
+ CI publishes every version to npm as `@ontemper/sdk`; nobody publishes by hand. Workflow code keeps
175
+ importing `@temper/workflow` through an npm alias. `sdk/workflow/package.json` holds the exact
176
+ version that CI publishes. CI adds no suffix. Pin one exact version:
177
+
178
+ ```sh
179
+ npm install --save-exact @temper/workflow@npm:@ontemper/sdk@<version>
180
+ ```
181
+
182
+ A published version never changes. The workflow template and the examples pin one exact
183
+ version; `pnpm sdk:pin` moves them all together.
184
+
185
+ The package has three entry points: `@temper/workflow`, `@temper/workflow/testing`, and
186
+ `@temper/workflow/contract`. `@temper/workflow/contract` holds the runtime Resources HttpApi and the
187
+ manifest, trigger, and invocation schemas that the platform imports. Workflow code rarely needs it.
188
+
189
+ ## Develop and release
190
+
191
+ Work locally first. Then open one pull request into `stg` that carries the SDK change, its
192
+ version, and the new pins.
193
+
194
+ | Loop | Command |
195
+ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
196
+ | Unit tests | `pnpm --filter @temper/workflow test` |
197
+ | Every example against your change | `pnpm --dir sdk/workflow pack --pack-destination /tmp/sdk`, then `WORKFLOW_SDK_TARBALL=/tmp/sdk/<file>.tgz bash scripts/check-workflow-examples.sh` |
198
+ | Another workflow repository | `npm install @temper/workflow@file:/tmp/sdk/<file>.tgz` |
199
+ | A dev stack | After CI publishes your version, deploy it with `scripts/seed-example-workflow.ts --sdk-version <version>` |
200
+
201
+ Every SDK source change needs a new version. Release it in the same pull request:
202
+
203
+ 1. Set a new version in `package.json` and the same version in `SDK_VERSION` in
204
+ `src/Manifest.ts`. `scripts/check-sdk-consistency.ts` fails if they differ.
205
+ 2. Push. CI publishes that exact version under the dist-tag `pr-<N>` in about 5 minutes.
206
+ 3. Run `pnpm sdk:pin`. It waits for npm, moves the template and every example to the new
207
+ version, and regenerates their lockfiles. `--version <version>` pins another version.
208
+ 4. Commit and push the pins. The Quality Gate step "Check the workflow SDK pins against npm" passes.
209
+ 5. Get a review, then merge.
210
+
211
+ CI fails when npm already has the version from other SDK source: raise the version. A rerun with
212
+ the same SDK source publishes nothing. To retry a failed publish, choose "Re-run failed jobs".
213
+
214
+ | Change | Version |
215
+ | ------------------------------------------- | ------------------------ |
216
+ | Bug fix or any other SDK change | patch: `0.2.0` → `0.2.1` |
217
+ | New feature or breaking change (before 1.0) | minor: `0.2.1` → `0.3.0` |
218
+
219
+ Raise `RUNTIME_API_VERSION` only when the SDK needs a changed platform runtime protocol.
220
+
221
+ Nothing more happens for prod. The template pin travels with the `stg` → `prod` release pull
222
+ request, and customers get the version that the template pins on `prod`.
@@ -0,0 +1,46 @@
1
+ import { Context } from 'effect';
2
+ import type { HttpClientError } from 'effect/unstable/http';
3
+ /**
4
+ * The error axios 1.13 and later raised for a failed request, logged as legacy pino's `err`
5
+ * serializer wrote it: `type`, `message`, and `stack`, then `name`, `isAxiosError`, `code`, and
6
+ * `status`. Legacy also wrote axios's `request` and `response`, which carried credentials in plain
7
+ * text; those are left out.
8
+ */
9
+ export declare class AxiosError extends Error {
10
+ readonly isAxiosError: true;
11
+ readonly code?: string;
12
+ readonly status?: number;
13
+ constructor(message: string, fields: {
14
+ readonly name: string;
15
+ readonly code?: string | undefined;
16
+ readonly status?: number | undefined;
17
+ readonly cause?: Error | undefined;
18
+ });
19
+ }
20
+ /** Which legacy axios the SDK's failed-call lines follow: `'class'` for 1.13 and later, `'toJSON'` before. */
21
+ export type AxiosErrorFormat = 'class' | 'toJSON';
22
+ /**
23
+ * Which axios the SDK `HttpClient` follows on `Outgoing HTTP request failed.`: `'class'` logs
24
+ * `toAxiosError` and the response that axios 1.16 kept on its error, and `'toJSON'` logs
25
+ * `toAxiosErrorJson` as axios before 1.13 did. A workflow whose legacy pinned axios before 1.13
26
+ * provides `'toJSON'` to its handler layer.
27
+ */
28
+ export declare const LegacyAxiosErrorFormat: Context.Reference<AxiosErrorFormat>;
29
+ /**
30
+ * axios's message for a response body that ended before it was complete. The SDK `HttpClient` fails
31
+ * such a read with a `DecodeError` that carries it as the description.
32
+ */
33
+ export declare const STREAM_ABORTED = "stream has been aborted";
34
+ /**
35
+ * The error axios 1.13 and later raised where the SDK `HttpClient` failed: `settle`'s for a rejected
36
+ * status, the aborted-stream error for a body that ended early (with the status axios 1.16 kept on it),
37
+ * else `AxiosError.from` over the innermost error behind the failure, which keeps its name, message,
38
+ * and code, chains it as the cause, and carries the status of a response it came after.
39
+ */
40
+ export declare const toAxiosError: (error: HttpClientError.HttpClientError) => AxiosError;
41
+ /**
42
+ * The error axios before 1.13 raised where the SDK `HttpClient` failed. It logs as legacy logged it,
43
+ * as its `toJSON()`: `{ message, name, stack, code, status }` in that order, without undefined keys.
44
+ */
45
+ export declare const toAxiosErrorJson: (error: HttpClientError.HttpClientError) => AxiosError;
46
+ //# sourceMappingURL=AxiosError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AxiosError.d.ts","sourceRoot":"","sources":["../src/AxiosError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAa,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAEnC,SAAiB,YAAY,EAAE,IAAI,CAAC;IACpC,SAAiB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAiB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEjC,YACE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE;QACN,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;KACpC,EAQF;CACF;AAgBD,8GAA8G;AAC9G,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,qCAEjC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,4BAA4B,CAAC;AA2BxD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,eAAe,CAAC,eAAe,KAAG,UAiBrE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,eAAe,CAAC,eAAe,KAAG,UAuBzE,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { Context, Predicate } from 'effect';
2
+ /**
3
+ * The error axios 1.13 and later raised for a failed request, logged as legacy pino's `err`
4
+ * serializer wrote it: `type`, `message`, and `stack`, then `name`, `isAxiosError`, `code`, and
5
+ * `status`. Legacy also wrote axios's `request` and `response`, which carried credentials in plain
6
+ * text; those are left out.
7
+ */
8
+ export class AxiosError extends Error {
9
+ constructor(message, fields) {
10
+ super(message, fields.cause === undefined ? undefined : { cause: fields.cause });
11
+ // Assigned in axios's order, which is the order they log in.
12
+ this.name = fields.name;
13
+ this.isAxiosError = true;
14
+ if (fields.code !== undefined)
15
+ this.code = fields.code;
16
+ if (fields.status !== undefined)
17
+ this.status = fields.status;
18
+ }
19
+ }
20
+ /**
21
+ * An error axios before 1.13 raised. `utils.inherits` left its `toJSON` enumerable, so legacy pino's
22
+ * `err` serializer copied it like any field, and `JSON.stringify` wrote what it returned for the
23
+ * serialized error: `message` and `stack` with their causes, `name`, `code`, and `status`, and no
24
+ * `type`, `isAxiosError`, `request`, or `response`.
25
+ */
26
+ class AxiosErrorBefore113 extends AxiosError {
27
+ // axios's `toJSON` also returned keys that were never set on these errors or that pino redacted.
28
+ toJSON() {
29
+ return { message: this.message, name: this.name, stack: this.stack, code: this.code, status: this.status };
30
+ }
31
+ }
32
+ Object.defineProperty(AxiosErrorBefore113.prototype, 'toJSON', { enumerable: true });
33
+ /**
34
+ * Which axios the SDK `HttpClient` follows on `Outgoing HTTP request failed.`: `'class'` logs
35
+ * `toAxiosError` and the response that axios 1.16 kept on its error, and `'toJSON'` logs
36
+ * `toAxiosErrorJson` as axios before 1.13 did. A workflow whose legacy pinned axios before 1.13
37
+ * provides `'toJSON'` to its handler layer.
38
+ */
39
+ export const LegacyAxiosErrorFormat = Context.Reference('@temper/workflow/LegacyAxiosErrorFormat', {
40
+ defaultValue: () => 'class',
41
+ });
42
+ /**
43
+ * axios's message for a response body that ended before it was complete. The SDK `HttpClient` fails
44
+ * such a read with a `DecodeError` that carries it as the description.
45
+ */
46
+ export const STREAM_ABORTED = 'stream has been aborted';
47
+ const isAbortedBody = (reason) => reason._tag === 'DecodeError' && reason.description === STREAM_ABORTED;
48
+ /** axios 1.16 `settle`'s error for a rejected status: a 4xx is a bad request, any other a bad response. */
49
+ const statusError = (status) => new AxiosError(`Request failed with status code ${status}`, {
50
+ name: 'AxiosError',
51
+ code: status >= 400 && status < 500 ? 'ERR_BAD_REQUEST' : 'ERR_BAD_RESPONSE',
52
+ status,
53
+ });
54
+ /** The error at the bottom of a cause chain, such as the socket error behind a failed `fetch`. */
55
+ const innermost = (error) => {
56
+ const seen = new Set([error]);
57
+ let current = error;
58
+ while (current.cause instanceof Error && !seen.has(current.cause)) {
59
+ current = current.cause;
60
+ seen.add(current);
61
+ }
62
+ return current;
63
+ };
64
+ const codeOf = (error) => Predicate.hasProperty(error, 'code') && Predicate.isString(error.code) ? error.code : undefined;
65
+ /**
66
+ * The error axios 1.13 and later raised where the SDK `HttpClient` failed: `settle`'s for a rejected
67
+ * status, the aborted-stream error for a body that ended early (with the status axios 1.16 kept on it),
68
+ * else `AxiosError.from` over the innermost error behind the failure, which keeps its name, message,
69
+ * and code, chains it as the cause, and carries the status of a response it came after.
70
+ */
71
+ export const toAxiosError = (error) => {
72
+ const { reason } = error;
73
+ if (reason._tag === 'StatusCodeError')
74
+ return statusError(reason.response.status);
75
+ if (isAbortedBody(reason)) {
76
+ return new AxiosError(STREAM_ABORTED, {
77
+ name: 'AxiosError',
78
+ code: 'ERR_BAD_RESPONSE',
79
+ status: reason.response.status,
80
+ });
81
+ }
82
+ const source = innermost(error);
83
+ return new AxiosError(source.message, {
84
+ name: source.name,
85
+ code: codeOf(source),
86
+ status: error.response?.status,
87
+ cause: source,
88
+ });
89
+ };
90
+ /**
91
+ * The error axios before 1.13 raised where the SDK `HttpClient` failed. It logs as legacy logged it,
92
+ * as its `toJSON()`: `{ message, name, stack, code, status }` in that order, without undefined keys.
93
+ */
94
+ export const toAxiosErrorJson = (error) => {
95
+ const { reason } = error;
96
+ // Before 1.13, the aborted-stream error kept no response, so it has no status.
97
+ if (isAbortedBody(reason))
98
+ return new AxiosErrorBefore113(STREAM_ABORTED, { name: 'AxiosError', code: 'ERR_BAD_RESPONSE' });
99
+ if (reason._tag !== 'StatusCodeError') {
100
+ // `AxiosError.from` named an error without a name or a message `'Error'`.
101
+ const source = innermost(error);
102
+ return new AxiosErrorBefore113(source.message || 'Error', {
103
+ name: source.name || 'Error',
104
+ code: codeOf(source),
105
+ status: error.response?.status,
106
+ cause: source,
107
+ });
108
+ }
109
+ const { status } = reason.response;
110
+ // `settle` read the code at `Math.floor(status / 100) - 4`, so only a 4xx or a 5xx had one.
111
+ const hundreds = Math.floor(status / 100);
112
+ return new AxiosErrorBefore113(`Request failed with status code ${status}`, {
113
+ name: 'AxiosError',
114
+ code: hundreds === 4 ? 'ERR_BAD_REQUEST' : hundreds === 5 ? 'ERR_BAD_RESPONSE' : undefined,
115
+ status,
116
+ });
117
+ };
118
+ //# sourceMappingURL=AxiosError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AxiosError.js","sourceRoot":"","sources":["../src/AxiosError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAI5C;;;;;GAKG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAMnC,YACE,OAAe,EACf,MAKC;QAED,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACjF,6DAA6D;QAC7D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACvD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC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. */
2
+ export type InvocationTriggerKind = 'http' | 'schedule' | 'manual' | 'agent' | 'as2' | 'sftp' | 'kafka' | 'child';
3
+ /**
4
+ * The exact object the Firecracker guest passes as the second `fetch` argument.
5
+ * Fields are additive only: the platform may append, never rename or remove.
6
+ */
7
+ export interface InvocationContext {
8
+ readonly workflowId: string;
9
+ readonly deploymentId: string;
10
+ readonly executionId: string;
11
+ /** Durable Run identity. Empty when a host predates unified Run admission. */
12
+ readonly runId: string;
13
+ /** 1-based attempt counter for this Run. */
14
+ readonly attempt: number;
15
+ readonly triggerKind: InvocationTriggerKind;
16
+ /** Absolute epoch milliseconds. The SDK interrupts the request 2 s before it, ahead of the host's own timer. */
17
+ readonly deadline: number;
18
+ /** Run-scoped platform token for AS2, EDI, and Resource calls. Empty outside a platform host. */
19
+ readonly token: string;
20
+ }
21
+ //# sourceMappingURL=Invocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Invocation.d.ts","sourceRoot":"","sources":["../../src/Contract/Invocation.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAElH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAC5C,gHAAgH;IAChH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iGAAiG;IACjG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Invocation.js","sourceRoot":"","sources":["../../src/Contract/Invocation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,125 @@
1
+ import { Schema } from 'effect';
2
+ export declare const TriggerKind: Schema.Literals<readonly ["http", "schedule", "manual", "internal"]>;
3
+ export type TriggerKind = typeof TriggerKind.Type;
4
+ export declare const ResponsePolicy: Schema.Literals<readonly ["wait", "ack"]>;
5
+ export type ResponsePolicy = typeof ResponsePolicy.Type;
6
+ /**
7
+ * How the platform invokes one route. `kind` is the contract; the other fields are DEFAULTS that
8
+ * deploy seeds into the stored Trigger and Schedule records when none exist. A stored record edited
9
+ * through the product or the Temper agent always wins afterwards; deploy reports the drift.
10
+ */
11
+ export declare const TriggerMetadata: Schema.Union<readonly [Schema.Struct<{
12
+ readonly kind: Schema.Literal<"http">;
13
+ /** Default response policy for the stored Trigger: `wait` returns the handler response, `ack` returns 202. */
14
+ readonly response: Schema.optional<Schema.Literals<readonly ["wait", "ack"]>>;
15
+ }>, Schema.Struct<{
16
+ readonly kind: Schema.Literal<"schedule">;
17
+ /** Default cadence for the stored Schedule; five-field cron. Without it deploy warns until a Schedule exists. */
18
+ readonly cron: Schema.optional<Schema.String>;
19
+ /** IANA timezone for `cron`; the platform default is UTC. */
20
+ readonly timezone: Schema.optional<Schema.String>;
21
+ }>, Schema.Struct<{
22
+ readonly kind: Schema.Literal<"manual">;
23
+ }>, Schema.Struct<{
24
+ readonly kind: Schema.Literal<"internal">;
25
+ }>]>;
26
+ export type TriggerMetadata = typeof TriggerMetadata.Type;
27
+ /** A draft 2020-12 JSON Schema of a value's encoded form: the JSON the resolver must answer. */
28
+ export declare const JsonSchemaObject: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
29
+ /**
30
+ * One thing an endpoint reads from Temper configuration. Deploy fails unless each one is bound in the
31
+ * workflow's reach: a `resource` by key (and by type when it names one), a `variable` by key, and a
32
+ * `resourceType` that exists, because the handler selects its record at run time.
33
+ */
34
+ export declare const ManifestResource: Schema.Union<readonly [Schema.Struct<{
35
+ readonly kind: Schema.Literal<"resource">;
36
+ readonly key: Schema.String;
37
+ readonly type: Schema.optionalKey<Schema.String>;
38
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
39
+ }>, Schema.Struct<{
40
+ readonly kind: Schema.Literal<"variable">;
41
+ readonly key: Schema.String;
42
+ }>, Schema.Struct<{
43
+ readonly kind: Schema.Literal<"resourceType">;
44
+ readonly type: Schema.String;
45
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
46
+ }>]>;
47
+ export type ManifestResource = typeof ManifestResource.Type;
48
+ export declare const WorkflowManifestEndpoint: Schema.Struct<{
49
+ readonly group: Schema.String;
50
+ readonly name: Schema.String;
51
+ readonly method: Schema.String;
52
+ readonly path: Schema.String;
53
+ readonly trigger: Schema.Union<readonly [Schema.Struct<{
54
+ readonly kind: Schema.Literal<"http">;
55
+ /** Default response policy for the stored Trigger: `wait` returns the handler response, `ack` returns 202. */
56
+ readonly response: Schema.optional<Schema.Literals<readonly ["wait", "ack"]>>;
57
+ }>, Schema.Struct<{
58
+ readonly kind: Schema.Literal<"schedule">;
59
+ /** Default cadence for the stored Schedule; five-field cron. Without it deploy warns until a Schedule exists. */
60
+ readonly cron: Schema.optional<Schema.String>;
61
+ /** IANA timezone for `cron`; the platform default is UTC. */
62
+ readonly timezone: Schema.optional<Schema.String>;
63
+ }>, Schema.Struct<{
64
+ readonly kind: Schema.Literal<"manual">;
65
+ }>, Schema.Struct<{
66
+ readonly kind: Schema.Literal<"internal">;
67
+ }>]>;
68
+ readonly resources: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
69
+ readonly kind: Schema.Literal<"resource">;
70
+ readonly key: Schema.String;
71
+ readonly type: Schema.optionalKey<Schema.String>;
72
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
73
+ }>, Schema.Struct<{
74
+ readonly kind: Schema.Literal<"variable">;
75
+ readonly key: Schema.String;
76
+ }>, Schema.Struct<{
77
+ readonly kind: Schema.Literal<"resourceType">;
78
+ readonly type: Schema.String;
79
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
80
+ }>]>>, never>;
81
+ }>;
82
+ export type WorkflowManifestEndpoint = typeof WorkflowManifestEndpoint.Type;
83
+ /** What `makeManifest` writes next to the bundle and deploy reads to seed Triggers and check bindings. */
84
+ export declare const WorkflowManifest: Schema.Struct<{
85
+ readonly version: Schema.Literal<1>;
86
+ readonly sdkVersion: Schema.String;
87
+ readonly runtimeApiVersion: Schema.Number;
88
+ readonly apiId: Schema.String;
89
+ readonly endpoints: Schema.$Array<Schema.Struct<{
90
+ readonly group: Schema.String;
91
+ readonly name: Schema.String;
92
+ readonly method: Schema.String;
93
+ readonly path: Schema.String;
94
+ readonly trigger: Schema.Union<readonly [Schema.Struct<{
95
+ readonly kind: Schema.Literal<"http">;
96
+ /** Default response policy for the stored Trigger: `wait` returns the handler response, `ack` returns 202. */
97
+ readonly response: Schema.optional<Schema.Literals<readonly ["wait", "ack"]>>;
98
+ }>, Schema.Struct<{
99
+ readonly kind: Schema.Literal<"schedule">;
100
+ /** Default cadence for the stored Schedule; five-field cron. Without it deploy warns until a Schedule exists. */
101
+ readonly cron: Schema.optional<Schema.String>;
102
+ /** IANA timezone for `cron`; the platform default is UTC. */
103
+ readonly timezone: Schema.optional<Schema.String>;
104
+ }>, Schema.Struct<{
105
+ readonly kind: Schema.Literal<"manual">;
106
+ }>, Schema.Struct<{
107
+ readonly kind: Schema.Literal<"internal">;
108
+ }>]>;
109
+ readonly resources: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
110
+ readonly kind: Schema.Literal<"resource">;
111
+ readonly key: Schema.String;
112
+ readonly type: Schema.optionalKey<Schema.String>;
113
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
114
+ }>, Schema.Struct<{
115
+ readonly kind: Schema.Literal<"variable">;
116
+ readonly key: Schema.String;
117
+ }>, Schema.Struct<{
118
+ readonly kind: Schema.Literal<"resourceType">;
119
+ readonly type: Schema.String;
120
+ readonly schema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
121
+ }>]>>, never>;
122
+ }>>;
123
+ }>;
124
+ export type WorkflowManifest = typeof WorkflowManifest.Type;
125
+ //# sourceMappingURL=Manifest.d.ts.map
@@ -0,0 +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,2CAAmC,CAAC;AAC/D,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;IAGxB,8GAA8G;;;;IAK9G,iHAAiH;;IAEjH,6DAA6D;;;;;;IAK/D,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,qFAA4C,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;IAS3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAE5D,eAAO,MAAM,wBAAwB;;;;;;;QAnCjC,8GAA8G;;;;QAK9G,iHAAiH;;QAEjH,6DAA6D;;;;;;;;;;;;;;;;;;;;EAoC/D,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,IAAI,CAAC;AAE5E,0GAA0G;AAC1G,eAAO,MAAM,gBAAgB;;;;;;;;;;;;YA/CzB,8GAA8G;;;;YAK9G,iHAAiH;;YAEjH,6DAA6D;;;;;;;;;;;;;;;;;;;;;EA8C/D,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { Effect, Schema } from 'effect';
2
+ export const TriggerKind = Schema.Literals(['http', 'schedule', 'manual', 'internal']);
3
+ export const ResponsePolicy = Schema.Literals(['wait', 'ack']);
4
+ /**
5
+ * How the platform invokes one route. `kind` is the contract; the other fields are DEFAULTS that
6
+ * deploy seeds into the stored Trigger and Schedule records when none exist. A stored record edited
7
+ * through the product or the Temper agent always wins afterwards; deploy reports the drift.
8
+ */
9
+ export const TriggerMetadata = Schema.Union([
10
+ Schema.Struct({
11
+ kind: Schema.Literal('http'),
12
+ /** Default response policy for the stored Trigger: `wait` returns the handler response, `ack` returns 202. */
13
+ response: Schema.optional(ResponsePolicy),
14
+ }),
15
+ Schema.Struct({
16
+ kind: Schema.Literal('schedule'),
17
+ /** Default cadence for the stored Schedule; five-field cron. Without it deploy warns until a Schedule exists. */
18
+ cron: Schema.optional(Schema.String),
19
+ /** IANA timezone for `cron`; the platform default is UTC. */
20
+ timezone: Schema.optional(Schema.String),
21
+ }),
22
+ Schema.Struct({ kind: Schema.Literal('manual') }),
23
+ Schema.Struct({ kind: Schema.Literal('internal') }),
24
+ ]);
25
+ /** A draft 2020-12 JSON Schema of a value's encoded form: the JSON the resolver must answer. */
26
+ export const JsonSchemaObject = Schema.Record(Schema.String, Schema.Json);
27
+ /**
28
+ * One thing an endpoint reads from Temper configuration. Deploy fails unless each one is bound in the
29
+ * workflow's reach: a `resource` by key (and by type when it names one), a `variable` by key, and a
30
+ * `resourceType` that exists, because the handler selects its record at run time.
31
+ */
32
+ export const ManifestResource = Schema.Union([
33
+ Schema.Struct({
34
+ kind: Schema.Literal('resource'),
35
+ key: Schema.String,
36
+ type: Schema.optionalKey(Schema.String),
37
+ schema: JsonSchemaObject,
38
+ }),
39
+ Schema.Struct({ kind: Schema.Literal('variable'), key: Schema.String }),
40
+ Schema.Struct({ kind: Schema.Literal('resourceType'), type: Schema.String, schema: JsonSchemaObject }),
41
+ ]);
42
+ export const WorkflowManifestEndpoint = Schema.Struct({
43
+ group: Schema.String,
44
+ name: Schema.String,
45
+ method: Schema.String,
46
+ path: Schema.String,
47
+ trigger: TriggerMetadata,
48
+ // Manifests written before endpoints declared resources carry none.
49
+ resources: Schema.Array(ManifestResource).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
50
+ });
51
+ /** What `makeManifest` writes next to the bundle and deploy reads to seed Triggers and check bindings. */
52
+ export const WorkflowManifest = Schema.Struct({
53
+ version: Schema.Literal(1),
54
+ sdkVersion: Schema.String,
55
+ runtimeApiVersion: Schema.Number,
56
+ apiId: Schema.String,
57
+ endpoints: Schema.Array(WorkflowManifestEndpoint),
58
+ });
59
+ //# sourceMappingURL=Manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Manifest.js","sourceRoot":"","sources":["../../src/Contract/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAGvF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAG/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;IAC1C,MAAM,CAAC,M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