pipework 0.114.0 → 0.116.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 (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/REFERENCE.md +4 -3
  3. package/dist/REFERENCE.md +1477 -0
  4. package/dist/async/jobs/queue.d.ts +2 -0
  5. package/dist/async/jobs/queue.d.ts.map +1 -1
  6. package/dist/async/jobs/queue.js +2 -1
  7. package/dist/async/jobs/queue.js.map +1 -1
  8. package/dist/async/steps/graph.d.ts.map +1 -1
  9. package/dist/async/steps/graph.js +13 -8
  10. package/dist/async/steps/graph.js.map +1 -1
  11. package/dist/async/steps/table.d.ts +5 -0
  12. package/dist/async/steps/table.d.ts.map +1 -1
  13. package/dist/async/steps/table.js +1 -0
  14. package/dist/async/steps/table.js.map +1 -1
  15. package/dist/async/steps/types.d.ts +2 -0
  16. package/dist/async/steps/types.d.ts.map +1 -1
  17. package/dist/client/report-fault.d.ts +3 -1
  18. package/dist/client/report-fault.d.ts.map +1 -1
  19. package/dist/client/report-fault.js.map +1 -1
  20. package/dist/infra/access-links/rate-limit.d.ts +10 -0
  21. package/dist/infra/access-links/rate-limit.d.ts.map +1 -0
  22. package/dist/infra/access-links/rate-limit.js +28 -0
  23. package/dist/infra/access-links/rate-limit.js.map +1 -0
  24. package/dist/infra/alerts/client-faults.d.ts.map +1 -1
  25. package/dist/infra/alerts/client-faults.js +2 -1
  26. package/dist/infra/alerts/client-faults.js.map +1 -1
  27. package/dist/infra/email/sigv4.d.ts +24 -0
  28. package/dist/infra/email/sigv4.d.ts.map +1 -0
  29. package/dist/infra/email/sigv4.js +55 -0
  30. package/dist/infra/email/sigv4.js.map +1 -0
  31. package/dist/request/http/server.d.ts.map +1 -1
  32. package/dist/request/http/server.js +5 -0
  33. package/dist/request/http/server.js.map +1 -1
  34. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.116.0
4
+
5
+ - **Added: a step graph run carries the requesting actor** (#601). `request()` records the requesting Flow's actor (`auth.userId`) on the run (new nullable `pipework_step_run.actor` column; run `pipework generate` for an existing database). Every step job, the `finish` job that delivers `onDone`, and `onFailed` run with `auth = { userId }`, so audited writes in them name the user who started the run. A later request by another user carries that user for the steps it queues. `RequestOptions.carryActor: false` records none.
6
+ - **Added: `EnqueueOptions.actor?: string | null`**: record this actor instead of the Flow's (`null` for none); overrides `carryActor`.
7
+ - **Fixed: `onFailed` ran with no `auth` in its Flow** (its trace had the actor, its audited writes did not).
8
+
9
+ ## 0.115.0
10
+
11
+ - **Added: every traced answer carries `x-pipework-trace-id`** (#599), the request's trace row id (`trace.id`). A browser reads it once the route's CORS `exposedHeaders` lists it, and sends it as `ClientFaultReport.traceId`, which then names a real trace. Not set with tracing off, or on an answer refused before the request's context is built (a 401 from auth, a 404 before routing). `x-request-id` is unchanged.
12
+ - **Added: `ClientFaultReport.requestId`** (#599): the `x-request-id` of the answer the page last saw (1-100 of `A-Za-z0-9._:-`), recorded in the alert context beside `traceId`.
13
+
3
14
  ## 0.114.0
4
15
 
5
16
  - **Added: `onJobEvent` reports a job this worker's attempt dead-lettered** (#596). `{ kind: 'dead-lettered', cause, error, job }`, once, after the dead-lettering transaction commits, in the job's tenant Flow and traced under the job's trace, like `reaped`. `cause` is `'failed'`, `'timeout'` (the handler's `.timeout(ms)` fired), `'permanent'` (`JobPermanentError`) or `'no-handler'`; `error` is the error as stored in `error_payload`. Never for an attempt that will be retried. `onDeadLetter` is unchanged: still inside the transaction, with no Flow.
package/REFERENCE.md CHANGED
@@ -250,7 +250,7 @@ Computes the next fire time for a CronSchedule after a given date, with optional
250
250
  - **Trace.** The job's trace is a child of the enqueuing trace: `trace.parent_id` is the enqueuing trace, `root_id` its root, `parent_step_id` the step open at enqueue. Nothing is recorded when tracing is off or the enqueuing trace is truncated.
251
251
  - **Tenant.** The job runs under the enqueuing Flow's `tenant` (the tenant string, whatever its key type), so row-level security applies as it does for a request.
252
252
  - **Actor.** Only with `carryActor: true`: the job's `auth` is `{ userId }` from the Flow's `auth.userId`, so audited writes record that `actor_id`. Otherwise the job's `auth` is `null`.
253
- - **Options on `EnqueueOptions`.** `continueFlow?: boolean` (default `true`; `false` records none of the above, so the job is a root trace with no tenant), `tenant?: string | null` (run under this tenant instead of the Flow's; `null` runs without one), `carryActor?: boolean` (default `false`).
253
+ - **Options on `EnqueueOptions`.** `continueFlow?: boolean` (default `true`; `false` records none of the above, so the job is a root trace with no tenant), `tenant?: string | null` (run under this tenant instead of the Flow's; `null` runs without one), `carryActor?: boolean` (default `false`), `actor?: string | null` (record this actor instead of the Flow's, `null` for none; overrides `carryActor`).
254
254
  - **No Flow.** Enqueued outside any Flow (a script, a schedule): the columns are null and the job runs as before. Schedule-fired jobs never continue a flow.
255
255
  - **Retries and `enqueueAndWait`** keep the recorded flow. `ClaimedJob.flow` exposes `{ traceId, rootId, stepId, tenant, actor }`.
256
256
  - **`executeJob`** takes `parent?: ParentTraceRef | null` (`{ id, rootId, stepId? }`); omitted, it continues the active Flow's trace and records the open step as `parent_step_id`.
@@ -1534,8 +1534,8 @@ await ops.resolve('engine-unavailable')
1534
1534
  `alerts.clientFaults(handle, { path, apps, key?, cors?, rateLimit? })` returns one POST route for failures that browser code reports; register it with the other handlers. It answers 204 with no body and needs no session (sign-in and public pages have none); with one, the tenant and user are used.
1535
1535
 
1536
1536
  - `apps` — `{ web: { owner?, runbook? } }`, at least one; a report's `app` must be one of its keys. `key(report)` — default `client-fault:<app>:<where>`. `cors` — the route's grant (see `Builder.cors`). `rateLimit` — a `rateLimits` class; omitted, the route's default class.
1537
- - Body, strict (an unknown field is 400, and nothing is raised): `app`, `where` (1-100 of `A-Za-z0-9._:/-`), `kind` (`error | rejection | render | request`), `severity?` (`warning | error`, default `error`), `code?` (100), `message` (1-500), `stack?` (4096), `route?` (200, starts with `/`, no `?`, `#` or `://`: a route pattern, never a page URL), `release?` (100), `traceId?` (a uuid).
1538
- - Each report is a trace step `pipework/alerts:client-fault` capturing the report, and raises the key with severity as sent, the app's `owner` and `runbook`, and context `{ app, where, kind, code?, route?, release?, traceId? }`. The stack is in the step's capture only. A raise that fails is logged; the answer is still 204.
1537
+ - Body, strict (an unknown field is 400, and nothing is raised): `app`, `where` (1-100 of `A-Za-z0-9._:/-`), `kind` (`error | rejection | render | request`), `severity?` (`warning | error`, default `error`), `code?` (100), `message` (1-500), `stack?` (4096), `route?` (200, starts with `/`, no `?`, `#` or `://`: a route pattern, never a page URL), `release?` (100), `traceId?` (a uuid: the `x-pipework-trace-id` of an answer), `requestId?` (1-100 of `A-Za-z0-9._:-`: the `x-request-id` of an answer).
1538
+ - Each report is a trace step `pipework/alerts:client-fault` capturing the report, and raises the key with severity as sent, the app's `owner` and `runbook`, and context `{ app, where, kind, code?, route?, release?, traceId?, requestId? }`. The stack is in the step's capture only. A raise that fails is logged; the answer is still 204.
1539
1539
 
1540
1540
  `reportClientFault(url, report)` from `pipework/client` sends a report with `keepalive` and `credentials: 'include'`, cuts `message` and `stack` to their caps, and never throws.
1541
1541
 
@@ -1754,6 +1754,7 @@ interface InjectResponse
1754
1754
  **`ServerConfig`** — Configuration for http.createServer() — CORS, security headers, rate limiting, transaction timeout.
1755
1755
 
1756
1756
  - `trustProxy` — which proxies to believe when reading the client address (`request.ip`) from `X-Forwarded-For`. Passed to Fastify unchanged. `false` (default): ignore forwarding headers, the address is the socket's. `true`: trust every hop, so a client can set its own address; only right when every request comes through your proxy. A string or string[] of addresses or CIDRs (e.g. `'10.0.0.0/8'`): trust only proxies at those addresses. A hop count (number) is not accepted: Fastify cannot check the immediate peer from a count alone, so it trusts no one.
1757
+ - Every traced answer carries `x-pipework-trace-id`, the request's trace row id; a browser reads it once the route's CORS `exposedHeaders` lists it.
1757
1758
  - `onInternalError(fault)` — called, and awaited, before the server sends a 5xx for a thrown error: an unhandled error, a `PipeworkError` with `httpStatus` >= 500, a failed route screen or file response. Never for a 4xx. `fault` is `{ error, method, route, requestId, tenantId, userId, traceId }` (`traceId`: the trace row id, null with tracing off); `route` is the registered pattern (`/things/:id`), the raw path where no route matched. Runs in the request's Flow with no transaction open, so `pipe.system()` works. A throw or rejection is logged (`onInternalError failed`) and the response is unchanged. `alerts.requestFaults(handle)` is such a hook.
1758
1759
 
1759
1760
  ```typescript