pipework 0.203.1 → 0.205.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.205.0
4
+
5
+ - **Fixed: a PDF with bytes before `%PDF-` was refused as not a PDF** (#781). Byte detection now names a file `application/pdf` when `%PDF-` starts anywhere in its first 1024 bytes, as PDF readers do, so an upload with a leading CRLF, BOM or mail header passes `mediaTypes: ['application/pdf']`. The search runs only when no other signature matches, so a zip or PNG that contains `%PDF-` keeps its type, and every other signature is still read from the first 512 bytes. **Behavior change:** `SNIFF_BYTES` is now 1024, so `.upload()` and inbound email attachments hold the first 1024 bytes of a file to detect its type.
6
+
7
+ ## 0.204.0
8
+
9
+ - **Fixed: a read cut off by the page leaving was reported as a client fault** (#779). A link, reload or `location.href` cuts off the page's in-flight fetches, and their rejections reached `reportClientFault` as faults. `reportClientFault` now holds a report made after `beforeunload`: it is dropped if `pagehide` follows, and sent if the page stays (10 s with no `pagehide`, `LEAVING_HOLD_MS`, or a bfcache restore). A report made after `pagehide` is dropped. This covers every kind (`request`, `error`, `rejection`, `render`). Pass `{ whileLeaving: 'send' }` as the third argument to send at once, for a failure that matters even while leaving (a save cut off by leaving). `pageLeaving()` says whether the page is leaving. A failure while the page stays is reported as before.
10
+
3
11
  ## 0.203.1
4
12
 
5
13
  - **Fixed: two `alerts.source.deadLetter` sources on different tables shared one position** (#777). The second to evaluate started from where the first had moved, so a dead letter in its table could be missed. Each table now keeps its own position, as each filter already did: state key `job-dead-letter@<table>` (with the `:only:`/`:except:` suffix as before). A source on the default `pipework_jobs` table keeps the key `job-dead-letter`, so its position carries over. A source on another table starts a new position from its first evaluation after the upgrade, so dead letters committed between its last evaluation before the upgrade and that first one are not raised. Condition keys are unchanged.
package/REFERENCE.md CHANGED
@@ -1918,7 +1918,7 @@ await ops.resolve('engine-unavailable')
1918
1918
  - 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).
1919
1919
  - 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` (or the report's from `assign`), 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.
1920
1920
 
1921
- `reportClientFault(url, report)` from `pipework/client` sends a report with `keepalive` and `credentials: 'include'`, cuts `message` and `stack` to their caps, and never throws.
1921
+ `reportClientFault(url, report)` from `pipework/client` sends a report with `keepalive` and `credentials: 'include'`, cuts `message` and `stack` to their caps, and never throws. A report made while the page is leaving (after `beforeunload`) is held: dropped if `pagehide` follows, sent if the page stays (10 s with no `pagehide`, or a bfcache restore), so a read cut off by a link or reload raises nothing. Pass `{ whileLeaving: 'send' }` as the third argument to send at once (a save cut off by leaving); `pageLeaving()` says whether the page is leaving.
1922
1922
 
1923
1923
  ```ts
1924
1924
  import { reportClientFault } from 'pipework/client'
package/dist/REFERENCE.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Pipework API Reference
2
2
 
3
3
  > Auto-generated from source JSDoc. Do not edit manually.
4
- > Generated: 2026-10-09
4
+ > Generated: 2026-10-25
5
5
 
6
6
  ## Contents
7
7
 
@@ -10,6 +10,7 @@
10
10
  - [jobs — Background Jobs](#jobs-background-jobs)
11
11
  - [pipeline — Multi-Step Pipelines](#pipeline-multi-step-pipelines)
12
12
  - [state — State Machines](#state-state-machines)
13
+ - [steps](#steps)
13
14
  - [auth — Authentication](#auth-authentication)
14
15
  - [rbac — Access Control](#rbac-access-control)
15
16
  - [tenant — Multi-Tenancy](#tenant-multi-tenancy)
@@ -30,7 +31,10 @@
30
31
  - [cache — Caching](#cache-caching)
31
32
  - [credits](#credits)
32
33
  - [mail](#mail)
34
+ - [untrustedFetch](#untrustedfetch)
35
+ - [quota](#quota)
33
36
  - [storage](#storage)
37
+ - [support](#support)
34
38
  - [webhook — Inbound & Outbound Webhooks](#webhook-inbound-outbound-webhooks)
35
39
  - [behavior — Resource Decorators](#behavior-resource-decorators)
36
40
  - [fitting — Dependency Injection](#fitting-dependency-injection)
@@ -42,6 +46,7 @@
42
46
  - [trace](#trace)
43
47
  - [data](#data)
44
48
  - [request](#request)
49
+ - [async](#async)
45
50
 
46
51
  ## Core
47
52
 
@@ -74,7 +79,7 @@ export default manifold
74
79
  ```
75
80
 
76
81
  ```typescript
77
- function createManifold<const TEnv extends EnvDefs = EnvDefs>( raw: Omit<BlueprintInput, 'env'> &
82
+ function createManifold<const TEnv extends EnvDefs = EnvDefs>( raw: AcceptReadonly<Omit<BlueprintInput, 'env'>> &
78
83
  ```
79
84
 
80
85
  ### Types
@@ -85,6 +90,24 @@ function createManifold<const TEnv extends EnvDefs = EnvDefs>( raw: Omit<Bluepri
85
90
  interface Manifold<TEnv extends EnvDefs = EnvDefs>
86
91
  ```
87
92
 
93
+ **`StopResult`** — What {@link Manifold.stop} resolves with: `forced` is true when the drain deadline fired.
94
+
95
+ ```typescript
96
+ interface StopResult
97
+ ```
98
+
99
+ **`ScriptOptions`** — Options for {@link Manifold.script}.
100
+
101
+ ```typescript
102
+ interface ScriptOptions
103
+ ```
104
+
105
+ **`StartOptions`** — Options for {@link Manifold.start}.
106
+
107
+ ```typescript
108
+ interface StartOptions
109
+ ```
110
+
88
111
  **`SeedOptions`** — ALS context the {@link Manifold.seed} callback runs under — tenant scope, auth principal, and job type.
89
112
 
90
113
  ```typescript
@@ -229,6 +252,14 @@ Creates a job queue with claim/complete/fail lifecycle, heartbeat, and dead lett
229
252
 
230
253
  Executes a fitting handler as a background job with its own Flow context.
231
254
 
255
+ ### `jobs.later`
256
+
257
+ The error to throw to end an attempt as "later": pending again after `delayMs`, no attempt counted.
258
+
259
+ ### `jobs.permanent`
260
+
261
+ The error to throw to dead-letter the job now, whatever attempts remain.
262
+
232
263
  ### `jobs.parseCron`
233
264
 
234
265
  Parses a 5-field cron expression into a CronSchedule (minute, hour, dom, month, dow).
@@ -269,6 +300,14 @@ Thrown when a transition is not allowed from the current state.
269
300
 
270
301
  Thrown when the state machine definition is internally inconsistent.
271
302
 
303
+ ## steps
304
+
305
+ Step graphs over a job queue: results recorded by their inputs, only missing steps run.
306
+
307
+ ### `steps.define`
308
+
309
+ Defines a graph of named steps over a jobs Queue. Pass it to `createWorkerSurface({ graphs })` to run its steps.
310
+
272
311
  ## auth — Authentication
273
312
 
274
313
  Authentication namespace — session management, multi-org support, auth chain resolution.
@@ -289,6 +328,14 @@ Hashes and verifies passwords with scrypt; reports when a stored hash needs reha
289
328
 
290
329
  Guarded password sign-in that slows, then refuses, repeated failures per account and per client.
291
330
 
331
+ ### `auth.guard`
332
+
333
+ Guards wrong guesses at a secret the app checks itself: counted per key set before the check, reset on a right answer, refused with retryAfterSeconds.
334
+
335
+ ### `auth.emailLinks`
336
+
337
+ Emailed single-use links that prove control of an address: password reset and address verification; the token is never stored.
338
+
292
339
  ### `auth.runChain`
293
340
 
294
341
  Executes an auth chain (strategy pipeline) to resolve auth + tenant from a request.
@@ -323,7 +370,7 @@ interface AuthContext
323
370
  interface AuthStrategy<TAuth>
324
371
  ```
325
372
 
326
- **`AuthRequest`** — Normalized request shape passed to auth strategies — headers, cookies, method, url.
373
+ **`AuthRequest`** — Normalized request shape passed to auth strategies — headers, the parsed `Cookie` header, and the upper-case HTTP method.
327
374
 
328
375
  ```typescript
329
376
  interface AuthRequest
@@ -353,6 +400,18 @@ interface TenantResolver<TAuth>
353
400
  interface AuthChainConfig<TAuth>
354
401
  ```
355
402
 
403
+ **`SessionAuth`** — What `sessions.strategy()` authenticates: the token's user and org, its roles, and where the token came from.
404
+
405
+ ```typescript
406
+ type SessionAuth = BaseAuth &
407
+ ```
408
+
409
+ **`SessionStrategyOptions`** — Options for `sessions.strategy()`.
410
+
411
+ ```typescript
412
+ interface SessionStrategyOptions
413
+ ```
414
+
356
415
  **`SessionConfig`** — Session configuration — signing keys, issuer, audience, token TTLs, refresh rotation.
357
416
 
358
417
  ```typescript
@@ -624,6 +683,18 @@ Base error class with code, statusCode, and suggestion fields.
624
683
 
625
684
  403 — authenticated but insufficient permissions.
626
685
 
686
+ ### `errors.CrossSiteRequest`
687
+
688
+ 403 `CROSS_SITE_REQUEST` — a cookie-authenticated request that did not come from the app's own site.
689
+
690
+ ### `errors.AuthConfiguration`
691
+
692
+ 500 `AUTH_CONFIGURATION` — the auth setup itself is faulty (a signing key that will not load); never a refusal of the caller.
693
+
694
+ ### `errors.AuthUnavailable`
695
+
696
+ 503 `AUTH_UNAVAILABLE` — authentication could not be decided (its database failed); never read as signed out.
697
+
627
698
  ### `errors.Validation`
628
699
 
629
700
  422 — input validation failed, carries field-level details.
@@ -644,13 +715,17 @@ Base error class with code, statusCode, and suggestion fields.
644
715
 
645
716
  415 — request body media type not accepted by the route.
646
717
 
718
+ ### `errors.MalformedMultipart`
719
+
720
+ 400 `MALFORMED_MULTIPART` — a multipart body that cannot be parsed or ends before its closing boundary.
721
+
647
722
  ## lifecycle — Startup & Shutdown
648
723
 
649
724
  Application lifecycle namespace — startup orchestration with hooks and timeouts.
650
725
 
651
726
  ### `lifecycle.orchestrate`
652
727
 
653
- Runs pre-start hooks (DB readiness checks, migrations, etc.) with a configurable timeout.
728
+ Runs pre-start hooks (DB readiness checks, migrations, etc.) with a configurable timeout. The hooks run in one trace that names the process; the trace-partition hook runs first, outside it.
654
729
 
655
730
  ## log — Structured Logging
656
731
 
@@ -690,7 +765,7 @@ Creates a worker surface — a long-running process that claims and executes job
690
765
 
691
766
  ### `surface.script`
692
767
 
693
- Creates a script surface — a one-shot process that runs and exits (migrations, seeds, CLI tools).
768
+ Creates a script surface — a one-shot process that runs and exits (migrations, seeds, CLI tools). The run is traced as a job-kind trace that names the surface.
694
769
 
695
770
  ## pipe — Database
696
771
 
@@ -700,6 +775,10 @@ Database accessor — returns a Drizzle DB instance scoped to the current reques
700
775
 
701
776
  The system channel — deliberate cross-tenant access for pre-tenant surfaces (auth membership resolution, public webhook ingress, admin tooling). Never tenant-scoped or tenant-guarded; runs on the owner-role connection outside the request transaction.
702
777
 
778
+ ### `pipe.door`
779
+
780
+ A named cross-tenant read: `pipe.door(name, db => ...)`. The door is declared under `doors` in config; the callback runs in one transaction on the platform-role connection and may SELECT from the door's table and from non-tenant tables. Needs `rls.platformRole`.
781
+
703
782
  ### `pipe.filter`
704
783
 
705
784
  Query operators and aggregates — eq, gt, lt, and, or, count, sum, etc.
@@ -757,10 +836,18 @@ Returns excluded-column references for onConflictDoUpdate set clauses.
757
836
 
758
837
  Acquires a transaction-scoped advisory lock. Released at commit/rollback.
759
838
 
839
+ ### `pipe.tryAdvisoryLock`
840
+
841
+ Non-blocking advisoryLock: true if the transaction-scoped lock was won, false if another transaction holds it.
842
+
760
843
  ### `pipe.serializable`
761
844
 
762
845
  Runs a function in a SERIALIZABLE transaction with automatic retry on serialization failures and deadlocks.
763
846
 
847
+ ### `pipe.withTimeouts`
848
+
849
+ Sets statement_timeout and/or lock_timeout for the current transaction in one statement, then runs fn; a statement cancelled for them rejects with StatementTimeoutError or LockTimeoutError.
850
+
764
851
  ### `pipe.bulkSet`
765
852
 
766
853
  Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values in a single statement.
@@ -769,6 +856,10 @@ Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values
769
856
 
770
857
  Produces a typed VALUES clause for bulk operations — the base primitive for bulkSet and bulkUpsert.
771
858
 
859
+ ### `pipe.fn`
860
+
861
+ A set-returning SQL function as a typed source for `.from()` and joins — `pipe.fn('schema.f', { args: [field.uuid()], columns: { path: field.text() } })`. Arguments are bound and cast to their declared types.
862
+
772
863
  ### `pipe.field`
773
864
 
774
865
  Field builders for domain definitions — uuid(), text(), integer(), etc.
@@ -781,13 +872,17 @@ Registers a domain definition with table, validators, and factory projections. T
781
872
 
782
873
  Returns the global registry of all domain definitions.
783
874
 
875
+ ### `pipe.external`
876
+
877
+ Declares a table or view another service owns (`pipe.external(name, fields, { schema, table? })`): typed columns and every query operator, read-only, never migrated, not tenant-scoped.
878
+
784
879
  ### `pipe.update`
785
880
 
786
881
  Pipework-owned UPDATE builder — the only consumer-facing way to update pipework-managed tables (Q8).
787
882
 
788
883
  ### `pipe.insert`
789
884
 
790
- Pipework-owned INSERT builder — the only consumer-facing way to insert into pipework-managed tables (Q8).
885
+ Pipework-owned INSERT builder — the only consumer-facing way to insert into pipework-managed tables (Q8). A list of any size is split into statements under Postgres's parameter limit, in one transaction.
791
886
 
792
887
  ### `pipe.delete`
793
888
 
@@ -795,7 +890,7 @@ Pipework-owned DELETE builder — the only consumer-facing way to delete from pi
795
890
 
796
891
  ### `pipe.upsert`
797
892
 
798
- Pipework-owned UPSERT builder — insert with conflict resolution (Q8).
893
+ Pipework-owned UPSERT builder — insert with conflict resolution (Q8). A list of any size is split into statements under Postgres's parameter limit, in one transaction; rows repeating a conflict key across statements do not fail as one statement would.
799
894
 
800
895
  ### Types
801
896
 
@@ -805,25 +900,107 @@ Pipework-owned UPSERT builder — insert with conflict resolution (Q8).
805
900
  interface WindowSpec
806
901
  ```
807
902
 
903
+ **`FrameBound`** — One end of a window frame. `{ preceding: n }` / `{ following: n }` take a non-negative integer.
904
+
905
+ ```typescript
906
+ type FrameBound = 'unboundedPreceding' | 'currentRow' | 'unboundedFollowing' |
907
+ ```
908
+
909
+ **`WindowFrame`** — A window frame: `rows|range|groups [between] start [and end]`.
910
+
911
+ ```typescript
912
+ interface WindowFrame
913
+ ```
914
+
915
+ **`Aggregate`** — An aggregate expression that can be narrowed with `FILTER (WHERE …)`; `undefined` leaves it unfiltered.
916
+
917
+ ```typescript
918
+ type Aggregate<T> = SQL<T> &
919
+ ```
920
+
921
+ **`EmptyableAggregate`** — An array or jsonb aggregate; `orEmpty()` replaces the no-rows NULL with an empty array.
922
+
923
+ ```typescript
924
+ type EmptyableAggregate<T, E> = SQL<T> &
925
+ ```
926
+
927
+ **`JsonOf`**
928
+
929
+ The type a value takes after a round trip through jsonb: Date -> string (ISO text),
930
+ bigint -> number, Buffer/Uint8Array -> string, objects and arrays mapped recursively,
931
+ null kept. Column decoders are not applied inside jsonb.
932
+
933
+ ```typescript
934
+ type JsonOf<T> =
935
+ ```
936
+
937
+ **`AggregateOptions`** — `ORDER BY` terms inside an aggregate — `asc(col)` / `desc(col)` or an array of them.
938
+
939
+ ```typescript
940
+ interface AggregateOptions
941
+ ```
942
+
808
943
  **`ValueColumnDef`** — One column of a typed `VALUES` clause: its name and the PostgreSQL type each value in that column is cast to. See {@link values}.
809
944
 
810
945
  ```typescript
811
946
  interface ValueColumnDef
812
947
  ```
813
948
 
949
+ **`JsonbElements`** — A jsonb array read as its elements' text. Produced by {@link jsonbElements}.
950
+
951
+ ```typescript
952
+ interface JsonbElements
953
+ ```
954
+
955
+ **`ArraySource`** — Something whose elements `arrayAny` / `arrayAll` can test.
956
+
957
+ ```typescript
958
+ type ArraySource =
959
+ ```
960
+
961
+ **`ElementOf`** — The element type of an {@link ArraySource}.
962
+
963
+ ```typescript
964
+ type ElementOf<S> =
965
+ ```
966
+
967
+ **`FunctionSpec`** — Declares a SQL function's argument and result-column shapes. See {@link fn}.
968
+
969
+ ```typescript
970
+ interface FunctionSpec<TArgs extends readonly AnyField[], TColumns extends Record<string, AnyField>>
971
+ ```
972
+
973
+ **`FunctionSourceFields`** — The selected fields of a function source: each result column as a typed SQL expression.
974
+
975
+ ```typescript
976
+ type FunctionSourceFields<TColumns extends Record<string, AnyField>> =
977
+ ```
978
+
979
+ **`FunctionSource`** — A function call usable in `.from()` and joins; its result columns are properties of it.
980
+
981
+ ```typescript
982
+ type FunctionSource<TAlias extends string, TColumns extends Record<string, AnyField>> =
983
+ ```
984
+
814
985
  **`SerializableOptions`** — Retry policy for {@link serializable}: how many attempts on a serialization failure / deadlock, and the base backoff between them.
815
986
 
816
987
  ```typescript
817
988
  interface SerializableOptions
818
989
  ```
819
990
 
991
+ **`TimeoutOptions`** — Which timeouts {@link withTimeouts} sets; each a positive integer number of milliseconds.
992
+
993
+ ```typescript
994
+ interface TimeoutOptions
995
+ ```
996
+
820
997
  **`ManagedConnection`** — A standalone pooled connection: the raw postgres.js client, its drizzle handle, and a `close()` that ends the pool.
821
998
 
822
999
  ```typescript
823
1000
  interface ManagedConnection
824
1001
  ```
825
1002
 
826
- **`ConnectOptions`** — Options for `tap()` — pool size (default 1) and idle timeout in seconds.
1003
+ **`ConnectOptions`** — Options for `tap()` — pool size (default 1), idle timeout in seconds, and session settings (GUCs) sent in every connection's startup packet.
827
1004
 
828
1005
  ```typescript
829
1006
  interface ConnectOptions
@@ -837,6 +1014,14 @@ JSONB query operators — typed helpers for PostgreSQL JSONB containment, key ch
837
1014
 
838
1015
  The @> containment operator — tests whether a JSONB column contains the given value.
839
1016
 
1017
+ ### `jsonb.merge`
1018
+
1019
+ Merges an object into a JSONB column in `.set()`: `coalesce(col, '{}') || value`. Top-level keys overwrite; others are kept.
1020
+
1021
+ ### `jsonb.remove`
1022
+
1023
+ Removes top-level keys from a JSONB column in `.set()`: `col - 'key'`. Composes as the column of `jsonb.merge`.
1024
+
840
1025
  ### `jsonb.containedBy`
841
1026
 
842
1027
  The <@ contained-by operator — tests whether a JSONB column is contained by the given value.
@@ -903,6 +1088,66 @@ type Schema<T = unknown> = z.ZodType<T>
903
1088
  type Infer<T extends Schema> = z.infer<T>
904
1089
  ```
905
1090
 
1091
+ **`StringSchema`** — A string validator — what check.string() returns.
1092
+
1093
+ ```typescript
1094
+ type StringSchema = z.ZodString
1095
+ ```
1096
+
1097
+ **`NumberSchema`** — A number validator — what check.number() returns.
1098
+
1099
+ ```typescript
1100
+ type NumberSchema = z.ZodNumber
1101
+ ```
1102
+
1103
+ **`BooleanSchema`** — A boolean validator — what check.boolean() returns.
1104
+
1105
+ ```typescript
1106
+ type BooleanSchema = z.ZodBoolean
1107
+ ```
1108
+
1109
+ **`EnumSchema`** — An enum validator over string literals — what check.enum([...]) returns.
1110
+
1111
+ ```typescript
1112
+ type EnumSchema<V extends string = string> = z.ZodEnum<
1113
+ ```
1114
+
1115
+ **`LiteralSchema`** — A literal validator — what check.literal(v) returns.
1116
+
1117
+ ```typescript
1118
+ type LiteralSchema<V extends string | number | boolean | null = string> = z.ZodLiteral<V>
1119
+ ```
1120
+
1121
+ **`ArraySchema`** — An array validator — what check.array(item) returns.
1122
+
1123
+ ```typescript
1124
+ type ArraySchema<Item extends z.core.SomeType = z.core.SomeType> = z.ZodArray<Item>
1125
+ ```
1126
+
1127
+ **`OptionalSchema`** — An optional validator — what check.optional(inner) and .optional() return.
1128
+
1129
+ ```typescript
1130
+ type OptionalSchema<Inner extends z.core.SomeType = z.core.SomeType> = z.ZodOptional<Inner>
1131
+ ```
1132
+
1133
+ **`NullableSchema`** — A nullable validator — what check.nullable(inner) and .nullable() return.
1134
+
1135
+ ```typescript
1136
+ type NullableSchema<Inner extends z.core.SomeType = z.core.SomeType> = z.ZodNullable<Inner>
1137
+ ```
1138
+
1139
+ **`ObjectSchema`** — An object validator — what check.object({...}) returns; keeps .extend, .pick, .omit and .partial. For a shape with fields beyond the plain kinds, annotate with ObjectSchema<{ field: Schema<T> }>.
1140
+
1141
+ ```typescript
1142
+ type ObjectSchema<S extends Shape = Shape> = z.ZodObject<S, z.core.$strip>
1143
+ ```
1144
+
1145
+ **`ObjectOps`** — The object operations of ObjectSchema.
1146
+
1147
+ ```typescript
1148
+ type ObjectOps<S extends Shape> = Pick<ObjectSchema<S>, 'extend' | 'pick' | 'omit' | 'partial'>
1149
+ ```
1150
+
906
1151
  ## temporal — Bitemporal Data
907
1152
 
908
1153
  Temporal (bitemporal) data namespace — version history with effective date ranges.
@@ -947,6 +1192,14 @@ Query all versions of temporal records (no date filter).
947
1192
 
948
1193
  Close the current version and create a new one with updated data.
949
1194
 
1195
+ ### `temporal.setVersion`
1196
+
1197
+ Append the next version of an append-only-versions definition: serialised per scope, numbered, never back-dated, audited.
1198
+
1199
+ ### `temporal.versionAt`
1200
+
1201
+ The version in force at a moment: the row with the greatest effectiveFrom at or before it.
1202
+
950
1203
  ## valve
951
1204
 
952
1205
  Valve namespace — typed, directional, gated boundaries between code silos.
@@ -1129,6 +1382,18 @@ Alerts namespace — raise and resolve keyed conditions, grouped, delivered to s
1129
1382
 
1130
1383
  Creates an alerts handle.
1131
1384
 
1385
+ ### `alerts.http`
1386
+
1387
+ Routes for an operations agent: list, get, totals, delivery health, acknowledge, resolve, link; bearer credentials.
1388
+
1389
+ ### `alerts.clientFaults`
1390
+
1391
+ One POST route that records failures reported by browser code as a trace step and an alert; answers 204, no session needed. Send with `reportClientFault` from `pipework/client`.
1392
+
1393
+ ### `alerts.requestFaults`
1394
+
1395
+ An `onInternalError` hook for the HTTP server: raises `request-fault:<METHOD> <route>` for each internal 500.
1396
+
1132
1397
  ### `alerts.webhook`
1133
1398
 
1134
1399
  A sink that POSTs the alert as signed JSON to a URL.
@@ -1137,6 +1402,26 @@ A sink that POSTs the alert as signed JSON to a URL.
1137
1402
 
1138
1403
  A sink that keeps deliveries in `.delivered`, for tests.
1139
1404
 
1405
+ ### `alerts.loopCheck`
1406
+
1407
+ A `/ready` health check named `loops`: unhealthy while a background loop (the tick included) has not run or succeeded within its allowance.
1408
+
1409
+ ### `alerts.recordFault`
1410
+
1411
+ Records a failure your code swallowed (logged and carried on) so `alerts.source.faults` can raise it; `void alerts.recordFault('my-kind', message, context?)`. Best effort, never throws, writes outside the caller's transaction. Does nothing without `alerts` in the blueprint.
1412
+
1413
+ ### `alerts.recordFaultFor`
1414
+
1415
+ `recordFault` for code that holds the manifold and may run outside any Flow: `void alerts.recordFaultFor(manifold, kind, message, context?)`.
1416
+
1417
+ ### `alerts.useFaultTarget`
1418
+
1419
+ Registers the manifold (or a `DB`, or a function returning one) that `alerts.recordFault` writes on outside any Flow; call once at boot in a process that is not a pipework surface, and keep the release for shutdown. A manifold without `alerts` registers nothing.
1420
+
1421
+ ### `alerts.recordBeat`
1422
+
1423
+ Records one iteration of a background loop of your own for `alerts.source.loopStalled`: `void alerts.recordBeat(manifold, 'my-loop', { ok, error?, everyMs })`. Works outside any Flow; does nothing without `alerts`.
1424
+
1140
1425
  ## audit — Audit Logging
1141
1426
 
1142
1427
  Audit logging namespace — structured audit trail for data changes.
@@ -1161,6 +1446,10 @@ The newest record's `{ seq, hash }` in the tenant's audit hash chain (blueprint
1161
1446
 
1162
1447
  Walks the tenant's audit hash chain and reports the first break (hash-mismatch, prev-mismatch, missing, head-mismatch, anchor-mismatch), or `{ ok: true }`.
1163
1448
 
1449
+ ### `audit.removeTenant`
1450
+
1451
+ Deletes every audit record of one tenant and its hash chain, for the closure of that tenant's account. Irreversible; returns the number of records removed. Other tenants' records and chains are untouched.
1452
+
1164
1453
  ## cache — Caching
1165
1454
 
1166
1455
  In-memory caching namespace — TTL-based with stats, preload, and tenant-aware variants.
@@ -1213,6 +1502,64 @@ Inbound source: SES receipt rule storing raw messages in S3 and notifying a sign
1213
1502
 
1214
1503
  Inbound development source: `.eml` files dropped in a folder, received by `scan()`; refused in production.
1215
1504
 
1505
+ ## untrustedFetch
1506
+
1507
+ Untrusted fetch — fetch one URL a stranger gave without letting them reach the app's private network.
1508
+
1509
+ ### `untrustedFetch.get`
1510
+
1511
+ Fetches `url` with GET and returns `{ ok: true, url, status, contentType, body, bytes }`, or `{ ok: false, reason, message }`
1512
+ naming the rule that refused: `scheme`, `address`, `redirects`, `too_large`, `timeout`, `status`, `rejected` or `network`.
1513
+ It does not throw for these.
1514
+
1515
+ Rules, none of which can be switched off: only `http:` and `https:`; the name is resolved and every address is checked
1516
+ (loopback, private, link-local including cloud metadata, CGNAT, unique-local and site-local IPv6, multicast, reserved,
1517
+ unspecified, and IPv4-mapped or NAT64 forms of these; literal IP URLs likewise) and the connection goes to a checked
1518
+ address; redirects are followed up to `maxRedirects` and each hop is checked as the first, and the app's `headers` go only to the first origin;
1519
+ the body is stopped the moment it passes `maxBytes`, whatever Content-Length says; `timeoutMs` covers the whole fetch.
1520
+ `accept({ status, contentType, firstBytes })` sees the first 1024 bytes before the body is kept: return false, or a string
1521
+ (your own message), to refuse with `rejected`. Messages never contain an address or anything a server sent.
1522
+
1523
+ `resolve` and `connect` are for tests: `resolve(hostname)` replaces DNS and `connect(target)` replaces the socket after the
1524
+ address check passed, so a test sends a fake public address to a local server. The address check always runs on what `resolve` returns.
1525
+
1526
+ The call is the trace step `pipework/fetch:get`; its child `pipework/fetch:outcome` carries host, status, bytes and reason.
1527
+ The full URL is recorded only when `urlIsSafeToTrace` is true; otherwise only the host.
1528
+
1529
+ ```ts
1530
+ const got = await untrustedFetch.get(pasted, { maxBytes: 5_000_000, timeoutMs: 10_000, maxRedirects: 3,
1531
+ accept: h => h.firstBytes[0] === 0x25 || 'That does not look like a PDF.' })
1532
+ if (!got.ok) return tell(got.message)
1533
+ ```
1534
+
1535
+ ### `connectRetry.fetch`
1536
+
1537
+ `fetch(input, init, opts)` that retries a fault in the connect phase (undici `UND_ERR_CONNECT_TIMEOUT`, `EAI_AGAIN`,
1538
+ `ENOTFOUND`, `ECONNREFUSED`, `ENETUNREACH`, `EHOSTUNREACH`), waiting `delaysMs` between tries (default 5 s, 15 s, 40 s: four
1539
+ tries over about a minute), then throws the last fault with its cause chain. A fault after the request was written
1540
+ (`ECONNRESET`, `UND_ERR_SOCKET`, a timeout, an abort) and a response of any status are never retried, because a POST may have taken effect.
1541
+ `signal` ends the waiting; `onRetry({ error, attempt, delayMs })` is called before each wait; `fetch` replaces the global fetch.
1542
+
1543
+ ```ts
1544
+ const res = await connectRetry.fetch('https://api.github.com/repos/o/r/issues', { method: 'POST', body })
1545
+ ```
1546
+
1547
+ ### `connectRetry.call`
1548
+
1549
+ Runs any `send()` with the same rule: retried only when `isUnsentFault(error)`; the last fault is thrown unchanged.
1550
+
1551
+ ### `connectRetry.isUnsentFault`
1552
+
1553
+ True when the error, its `cause` chain or an `AggregateError`'s errors show a connect-phase fault and no sent-phase one.
1554
+
1555
+ ## quota
1556
+
1557
+ Quota namespace — callers of one rate-limited upstream share its budget by class, read from the upstream's headers and kept in Postgres.
1558
+
1559
+ ### `quota.create`
1560
+
1561
+ Creates a quota handle.
1562
+
1216
1563
  ## storage
1217
1564
 
1218
1565
  Storage namespace — tenant-scoped, content-addressed file storage with signed URLs and retention.
@@ -1229,6 +1576,18 @@ S3-compatible backend (AWS S3, MinIO, R2): SigV4 over `fetch`, multipart streami
1229
1576
 
1230
1577
  Local-disk backend for development and tests; refused in production.
1231
1578
 
1579
+ ## support
1580
+
1581
+ Support namespace — tickets from email (and later chat), with replies sent only after an approval.
1582
+
1583
+ ### `support.create`
1584
+
1585
+ Creates the support handle: tickets, messages, notes, links, drafts, `approve`, `receiveEmail`, and the events job.
1586
+
1587
+ ### `support.templates`
1588
+
1589
+ The reply template to spread into `mail.create({ templates })`; it renders the approved draft verbatim.
1590
+
1232
1591
  ## webhook — Inbound & Outbound Webhooks
1233
1592
 
1234
1593
  Webhook namespace — inbound verification, outbound delivery with retries, HMAC signing.
@@ -1319,9 +1678,13 @@ Returns the current Flow or undefined — use for optional context detection.
1319
1678
 
1320
1679
  Creates a Flow for test isolation with optional auth and tenant overrides.
1321
1680
 
1681
+ ### `flow.actAs`
1682
+
1683
+ Runs `fn` as a tenant and user chosen inside a tenantless Flow (sign-up, a public sign-in): RLS, audit and trace under that tenant, on the request's transaction.
1684
+
1322
1685
  ## http — Server
1323
1686
 
1324
- HTTP namespace: `http.file()` builds a file response; the server itself is managed by manifold.start().
1687
+ HTTP namespace: `http.file()` builds a file response; `http.detectMediaType()` names bytes the way uploads do; the server itself is managed by manifold.start().
1325
1688
 
1326
1689
  ### Types
1327
1690
 
@@ -1343,6 +1706,40 @@ interface SecurityConfig
1343
1706
  interface RateLimitConfig
1344
1707
  ```
1345
1708
 
1709
+ **`RateLimitWindow`** — One fixed window: at most `max` requests per `windowSeconds`.
1710
+
1711
+ ```typescript
1712
+ interface RateLimitWindow
1713
+ ```
1714
+
1715
+ **`RateLimitClass`**
1716
+
1717
+ A named limit class: any of a per-user, per-tenant, per-address and total window, each counted on its own.
1718
+ Each key takes one window or an array of windows (distinct `windowSeconds`); a request is counted against
1719
+ all of a key's windows and refused if any is over.
1720
+
1721
+ ```typescript
1722
+ interface RateLimitClass
1723
+ ```
1724
+
1725
+ **`RateLimitRefusal`** — What `onRefused` is told about one refused window of one request.
1726
+
1727
+ ```typescript
1728
+ interface RateLimitRefusal
1729
+ ```
1730
+
1731
+ **`RateLimitClassesConfig`**
1732
+
1733
+ Named limit classes, checked after auth and counted in Postgres (`pipework_rate_limit_counts`, opted in
1734
+ with the blueprint's `rateLimits: {}`), so every server process on the same database shares one count.
1735
+ Keys are counted perUser, perTenant, perAddress, total in turn, up to the first key with a window over its max, so one user's
1736
+ refused requests don't spend the tenant's budget. The 429's Retry-After is the longest wait of the windows that refused. A route is in `signedIn` (auth required, or optional with
1737
+ a user), `public` (no auth, or optional without a user) or the class its fitting names with `.rateLimit(name)`.
1738
+
1739
+ ```typescript
1740
+ interface RateLimitClassesConfig
1741
+ ```
1742
+
1346
1743
  **`InjectOptions`** — Options for server.inject() — method, url, headers, payload for testing without HTTP.
1347
1744
 
1348
1745
  ```typescript
@@ -1361,6 +1758,12 @@ interface InjectResponse
1361
1758
  interface ServerConfig
1362
1759
  ```
1363
1760
 
1761
+ **`InternalErrorFault`** — What `onInternalError` is told about one request that ended in an internal error.
1762
+
1763
+ ```typescript
1764
+ interface InternalErrorFault
1765
+ ```
1766
+
1364
1767
  **`HandlerResponse`** — Standard handler response shape — statusCode, headers, body.
1365
1768
 
1366
1769
  ```typescript
@@ -1419,7 +1822,7 @@ Generates an OpenAPI 3.1 document from route registrations — schemas derived f
1419
1822
 
1420
1823
  ## trace
1421
1824
 
1422
- Trace namespace — hand the current trace to a process outside Node and record the steps it reports back.
1825
+ Trace namespace — hand the current trace to a process outside Node, record the steps it reports back, mark point events, and read a trace tree.
1423
1826
 
1424
1827
  ### `trace.traceparent`
1425
1828
 
@@ -1433,6 +1836,15 @@ W3C `traceparent` for the current trace and open step; `null` outside a traced f
1433
1836
 
1434
1837
  Records steps reported as JSON lines (or objects) by an outside process under the step open now. Synchronous; never throws.
1435
1838
 
1839
+ ### `trace.event`
1840
+
1841
+ Records one zero-length step `external:<name>` under the step open now, with an optional `capture` and `error`. A no-op outside a traced flow; never throws.
1842
+
1843
+ ### `trace.tree`
1844
+
1845
+ Reads every hot trace sharing `rootId` (a request's trace and the jobs it queued) with their steps. Runs on the
1846
+ given `db`, so tenant policies apply: only an unrestricted connection (table owner, tests) sees every tenant's rows.
1847
+
1436
1848
  ### Types
1437
1849
 
1438
1850
  **`FlowStepMeta`** — Trace metadata for one documented flow-step: its `path:symbol` graph node id and the per-argument capture projections.
@@ -1453,17 +1865,40 @@ type ExternalStepReport = z.infer<typeof externalStepReportSchema>
1453
1865
  interface ExternalRecordResult
1454
1866
  ```
1455
1867
 
1868
+ **`TraceStepNode`** — One step of a trace. `ref` is the flow step's `path:symbol`, or `external:<name>` for a recorded or point-event step.
1869
+
1870
+ ```typescript
1871
+ interface TraceStepNode
1872
+ ```
1873
+
1874
+ **`TraceNode`** — One trace of the tree, with its steps ordered by `seq`.
1875
+
1876
+ ```typescript
1877
+ interface TraceNode
1878
+ ```
1879
+
1880
+ **`TraceTree`** — The traces that share a root id, ordered by when they opened.
1881
+
1882
+ ```typescript
1883
+ interface TraceTree
1884
+ ```
1885
+
1456
1886
  ## data
1457
1887
 
1458
- ### `tap`
1888
+ ### `StatementTimeoutError`
1889
+
1890
+ A statement was cancelled by Postgres for running past the statement timeout a {@link withTimeouts} call set. `cause` is the driver error.
1891
+
1892
+ ```typescript
1893
+ class StatementTimeoutError extends Error constructor(readonly statementTimeoutMs: number, cause: unknown)
1894
+ ```
1459
1895
 
1460
- Opens a standalone managed connection outside the manifold's pools — the
1461
- sanctioned door for contexts where `pipe()` structurally cannot resolve:
1462
- `worker_threads`, detached monitors, one-off scripts. Callers own the
1463
- lifecycle: always `await conn.close()`.
1896
+ ### `LockTimeoutError`
1897
+
1898
+ A statement gave up waiting for a lock past the lock timeout a {@link withTimeouts} call set. `cause` is the driver error.
1464
1899
 
1465
1900
  ```typescript
1466
- function tap(url: string, options?: ConnectOptions): ManagedConnection
1901
+ class LockTimeoutError extends Error constructor(readonly lockTimeoutMs: number, cause: unknown)
1467
1902
  ```
1468
1903
 
1469
1904
  ## request
@@ -1475,3 +1910,24 @@ Creates a PipeworkServer — wraps Fastify with auto request IDs, CORS, rate lim
1475
1910
  ```typescript
1476
1911
  function createServer(instance: Manifold, config: ServerConfig = if (instance.config.environment === 'production')
1477
1912
  ```
1913
+
1914
+ ## async
1915
+
1916
+ ### `serializeError`
1917
+
1918
+ Serialize an arbitrary thrown value for durable storage in a job's `error_payload`.
1919
+
1920
+ A bare `{ message, stack }` capture is a diagnostics trap: wrapper errors hide the
1921
+ root cause. Drizzle throws `DrizzleQueryError` whose `.message` is only the failed
1922
+ SQL text; the real `PostgresError` — carrying `code`/`detail`/`constraint`/`table`
1923
+ — lives on `.cause`. This walks the full `cause` chain and copies each error's
1924
+ own-enumerable properties (where both Drizzle's `query` and Postgres' fields live),
1925
+ so a dead-lettered job records *why* it failed, not just *which query* failed.
1926
+
1927
+ Parameters are never stored (`params`, `parameters`, `args`, `types`); `query` is cut
1928
+ to 2,000 characters and any other string to 4,000, ending `…[truncated N chars]`.
1929
+ Non-Error values pass through unchanged. Circular `cause` references are broken.
1930
+
1931
+ ```typescript
1932
+ function serializeError(error: unknown): unknown
1933
+ ```
@@ -1,3 +1,3 @@
1
- export { reportClientFault, CLIENT_FAULT_MESSAGE_MAX, CLIENT_FAULT_STACK_MAX } from './report-fault.js';
2
- export type { ClientFaultReport } from './report-fault.js';
1
+ export { reportClientFault, pageLeaving, LEAVING_HOLD_MS, CLIENT_FAULT_MESSAGE_MAX, CLIENT_FAULT_STACK_MAX } from './report-fault.js';
2
+ export type { ClientFaultReport, ReportClientFaultOptions } from './report-fault.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AACvG,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AACrI,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,2 +1,2 @@
1
- export { reportClientFault, CLIENT_FAULT_MESSAGE_MAX, CLIENT_FAULT_STACK_MAX } from './report-fault.js';
1
+ export { reportClientFault, pageLeaving, LEAVING_HOLD_MS, CLIENT_FAULT_MESSAGE_MAX, CLIENT_FAULT_STACK_MAX } from './report-fault.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -24,9 +24,18 @@ export interface ClientFaultReport {
24
24
  }
25
25
  export declare const CLIENT_FAULT_MESSAGE_MAX = 500;
26
26
  export declare const CLIENT_FAULT_STACK_MAX = 4096;
27
+ /** How long a report made after `beforeunload` is held waiting for `pagehide` before the page is taken to be staying. */
28
+ export declare const LEAVING_HOLD_MS = 10000;
29
+ export interface ReportClientFaultOptions {
30
+ /** Default `hold`: a report made while the page is leaving waits, and is dropped if the page goes. `send` sends at once (a save cut off by leaving). */
31
+ whileLeaving?: 'hold' | 'send';
32
+ }
33
+ /** True from `beforeunload` until the page stays again (the hold timer ran out or a bfcache restore); stays true after `pagehide`. */
34
+ export declare function pageLeaving(): boolean;
27
35
  /**
28
36
  * Sends a failure to the intake route at `url` with `keepalive`, so it survives a page unload.
29
- * Cuts `message` and `stack` to their caps. Never throws and never rejects: a report that cannot be sent is dropped.
37
+ * Cuts `message` and `stack` to their caps. A report made while the page is leaving is held and dropped on `pagehide`,
38
+ * unless `options.whileLeaving` is `send`. Never throws and never rejects: a report that cannot be sent is dropped.
30
39
  */
31
- export declare function reportClientFault(url: string, report: ClientFaultReport): void;
40
+ export declare function reportClientFault(url: string, report: ClientFaultReport, options?: ReportClientFaultOptions): void;
32
41
  //# sourceMappingURL=report-fault.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"report-fault.d.ts","sourceRoot":"","sources":["../../src/client/report-fault.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;IAClD,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAA;IAC9B,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8GAA8G;IAC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wJAAwJ;IACxJ,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC/B;AA2CD,sIAAsI;AACtI,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI,CA6BlH"}
@@ -1,23 +1,85 @@
1
1
  // Browser-safe: no node imports, no runtime dependencies.
2
2
  export const CLIENT_FAULT_MESSAGE_MAX = 500;
3
3
  export const CLIENT_FAULT_STACK_MAX = 4096;
4
+ /** How long a report made after `beforeunload` is held waiting for `pagehide` before the page is taken to be staying. */
5
+ export const LEAVING_HOLD_MS = 10_000;
6
+ let leaving = false;
7
+ let left = false;
8
+ let timer;
9
+ let held = [];
10
+ function clearHold() {
11
+ if (timer !== undefined)
12
+ clearTimeout(timer);
13
+ timer = undefined;
14
+ held = [];
15
+ }
16
+ function stay() {
17
+ const pending = held;
18
+ leaving = false;
19
+ left = false;
20
+ if (timer !== undefined)
21
+ clearTimeout(timer);
22
+ timer = undefined;
23
+ held = [];
24
+ for (const send of pending)
25
+ send();
26
+ }
27
+ const win = globalThis;
28
+ if (typeof win.addEventListener === 'function') {
29
+ win.addEventListener('beforeunload', () => {
30
+ leaving = true;
31
+ if (timer !== undefined)
32
+ clearTimeout(timer);
33
+ timer = setTimeout(stay, LEAVING_HOLD_MS);
34
+ }, { passive: true });
35
+ win.addEventListener('pagehide', () => {
36
+ leaving = true;
37
+ left = true;
38
+ clearHold();
39
+ }, { passive: true });
40
+ win.addEventListener('pageshow', (event) => {
41
+ if (event.persisted === true)
42
+ stay();
43
+ }, { passive: true });
44
+ }
45
+ /** True from `beforeunload` until the page stays again (the hold timer ran out or a bfcache restore); stays true after `pagehide`. */
46
+ export function pageLeaving() {
47
+ return leaving;
48
+ }
4
49
  /**
5
50
  * Sends a failure to the intake route at `url` with `keepalive`, so it survives a page unload.
6
- * Cuts `message` and `stack` to their caps. Never throws and never rejects: a report that cannot be sent is dropped.
51
+ * Cuts `message` and `stack` to their caps. A report made while the page is leaving is held and dropped on `pagehide`,
52
+ * unless `options.whileLeaving` is `send`. Never throws and never rejects: a report that cannot be sent is dropped.
7
53
  */
8
- export function reportClientFault(url, report) {
54
+ export function reportClientFault(url, report, options) {
9
55
  try {
10
56
  const body = { ...report, message: report.message.slice(0, CLIENT_FAULT_MESSAGE_MAX) };
11
57
  if (body.stack !== undefined)
12
58
  body.stack = body.stack.slice(0, CLIENT_FAULT_STACK_MAX);
13
- const sent = fetch(url, {
14
- method: 'POST',
15
- keepalive: true,
16
- credentials: 'include',
17
- headers: { 'content-type': 'application/json' },
18
- body: JSON.stringify(body),
19
- });
20
- Promise.resolve(sent).catch(() => undefined);
59
+ const send = () => {
60
+ try {
61
+ const sent = fetch(url, {
62
+ method: 'POST',
63
+ keepalive: true,
64
+ credentials: 'include',
65
+ headers: { 'content-type': 'application/json' },
66
+ body: JSON.stringify(body),
67
+ });
68
+ Promise.resolve(sent).catch(() => undefined);
69
+ }
70
+ catch {
71
+ // dropped
72
+ }
73
+ };
74
+ if (options?.whileLeaving !== 'send') {
75
+ if (left)
76
+ return;
77
+ if (leaving) {
78
+ held.push(send);
79
+ return;
80
+ }
81
+ }
82
+ send();
21
83
  }
22
84
  catch {
23
85
  // dropped
@@ -1 +1 @@
1
- {"version":3,"file":"report-fault.js","sourceRoot":"","sources":["../../src/client/report-fault.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA2B1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAA;AAE1C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAAyB;IACtE,IAAI,CAAC;QACH,MAAM,IAAI,GAAsB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CA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,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,EAAE,CAAA;QACzG,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAA;QACtF,MAAM,IAAI,GAAG,GAAS,EAAE;YACtB,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE;oBACtB,MAAM,EAAE,MAAM;oBACd,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,SAAS;oBACtB,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;oBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;iBAC3B,CAAC,CAAA;gBACF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;YAC9C,CAAC;YAAC,MAAM,CAAC;gBACP,UAAU;YACZ,CAAC;QACH,CAAC,CAAA;QACD,IAAI,OAAO,EAAE,YAAY,KAAK,MAAM,EAAE,CAAC;YACrC,IAAI,IAAI;gBAAE,OAAM;YAChB,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACf,OAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAA;IACR,CAAC;IAAC,MAAM,CAAC;QACP,UAAU;IACZ,CAAC;AACH,CAAC"}
@@ -154,7 +154,7 @@ export declare class Builder<TDeps extends Record<string, unknown>, TDb extends
154
154
  * extension }`.
155
155
  *
156
156
  * `mediaTypes` is matched against `mediaType`, the type found in the file's
157
- * first 512 bytes (`detectedType`; null when no signature matches). A zip or
157
+ * first 1024 bytes (`detectedType`; null when no signature matches). A zip or
158
158
  * compound-file container takes the declared type or filename extension when
159
159
  * that names an Office, OpenDocument, epub, jar or apk file. With no
160
160
  * signature the declared type stands, except a type a signature would show
@@ -175,7 +175,7 @@ export declare class Builder<TDeps extends Record<string, unknown>, TDb extends
175
175
  * them (typed when `.params()` / `.query()` come before `.upload()`; the raw
176
176
  * values on a route with no schema; null when they fail it). A non-empty string it returns becomes the error
177
177
  * message; if it throws, the default message is sent. Nothing of the file is
178
- * kept: only its first 512 bytes are held, to detect the type.
178
+ * kept: only its first 1024 bytes are held, to detect the type.
179
179
  *
180
180
  * Multipart: text fields must come before the file part, only names listed in
181
181
  * `fields` are accepted (another name gets 422), each at most 64 KiB; fields
@@ -5,6 +5,6 @@ export declare const http: {
5
5
  readonly file: typeof file;
6
6
  readonly detectMediaType: typeof detectMediaType;
7
7
  readonly resolveMediaType: typeof resolveMediaType;
8
- readonly SNIFF_BYTES: 512;
8
+ readonly SNIFF_BYTES: 1024;
9
9
  };
10
10
  //# sourceMappingURL=namespace.d.ts.map
@@ -1,11 +1,12 @@
1
- /** Bytes of a file that decide its type. */
2
- export declare const SNIFF_BYTES = 512;
1
+ /** Bytes of a file that decide its type: PDF uses all 1024, every other signature the first 512. */
2
+ export declare const SNIFF_BYTES = 1024;
3
3
  /** Types whose files always show their signature. MP3 is left out: a file without an ID3 tag has none we detect. */
4
4
  export declare const sniffable: ReadonlySet<string>;
5
5
  /**
6
6
  * The media type the first bytes of a file say it is, or null when no signature
7
- * matches. Give it at least the first `SNIFF_BYTES` bytes; fewer may give null
8
- * (or, for a zip, plain `application/zip`).
7
+ * matches. A PDF is named when `%PDF-` starts anywhere in the first `SNIFF_BYTES`
8
+ * bytes, unless another signature matches first. Give it at least the first
9
+ * `SNIFF_BYTES` bytes; fewer may give null (or, for a zip, plain `application/zip`).
9
10
  */
10
11
  export declare function detectMediaType(bytes: Uint8Array | Buffer): string | null;
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sniff.d.ts","sourceRoot":"","sources":["../../../src/request/http/sniff.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,eAAO,MAAM,WAAW,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,GAAG,IAAI,CAKlE"}
@@ -1,5 +1,6 @@
1
- /** Bytes of a file that decide its type. */
2
- export const SNIFF_BYTES = 512;
1
+ /** Bytes of a file that decide its type: PDF uses all 1024, every other signature the first 512. */
2
+ export const SNIFF_BYTES = 1024;
3
+ const SIGNATURE_BYTES = 512;
3
4
  const ZIP = 'application/zip';
4
5
  const CFB = 'application/x-cfb';
5
6
  const MACHO = 'application/x-mach-binary';
@@ -167,12 +168,13 @@ function isPortableExecutable(h) {
167
168
  }
168
169
  /**
169
170
  * The media type the first bytes of a file say it is, or null when no signature
170
- * matches. Give it at least the first `SNIFF_BYTES` bytes; fewer may give null
171
- * (or, for a zip, plain `application/zip`).
171
+ * matches. A PDF is named when `%PDF-` starts anywhere in the first `SNIFF_BYTES`
172
+ * bytes, unless another signature matches first. Give it at least the first
173
+ * `SNIFF_BYTES` bytes; fewer may give null (or, for a zip, plain `application/zip`).
172
174
  */
173
175
  export function detectMediaType(bytes) {
174
176
  const head = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
175
- const h = head.length > SNIFF_BYTES ? head.subarray(0, SNIFF_BYTES) : head;
177
+ const h = head.length > SIGNATURE_BYTES ? head.subarray(0, SIGNATURE_BYTES) : head;
176
178
  if (h.length >= 12 && h.toString('latin1', 0, 4) === 'RIFF') {
177
179
  const form = RIFF_FORMS[h.toString('latin1', 8, 12)];
178
180
  if (form !== undefined)
@@ -217,7 +219,10 @@ export function detectMediaType(bytes) {
217
219
  return zipSubtype(h) ?? ZIP;
218
220
  return sig.type;
219
221
  }
220
- return isMpegFrame(h) ? 'audio/mpeg' : null;
222
+ if (isMpegFrame(h))
223
+ return 'audio/mpeg';
224
+ const window = head.length > SNIFF_BYTES ? head.subarray(0, SNIFF_BYTES) : head;
225
+ return window.indexOf('%PDF-', 0, 'latin1') >= 0 ? 'application/pdf' : null;
221
226
  }
222
227
  function refinedBy(refinements, declared) {
223
228
  return refinements.some((r) => (r.endsWith('.') ? declared.startsWith(r) : declared === r));
@@ -1 +1 @@
1
- {"version":3,"file":"sniff.js","sourceRoot":"","sources":["../../../src/request/http/sniff.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAE9B,MAAM,GAAG,GAAG,iBAAiB,CAAA;AAC7B,MAAM,GAAG,GAAG,mBAAmB,CAAA;AAC/B,MAAM,KAAK,GAAG,2BAA2B,CAAA;AACzC,MAAM,EAAE,GAAG,0BAA0B,CAAA;AAErC,MAAM,eAAe,GAAG;IACtB,gDAAgD;IAChD,qCAAqC;IACrC,sBAAsB;IACtB,0BAA0B;IAC1B,yCAAyC;CAC1C,CAAA;AACD,MAAM,eAAe,GAAG;IACtB,oBAAoB;IACpB,0BAA0B;IAC1B,+BAA+B;IAC/B,4BAA4B;IAC5B,mBAAmB;CACpB,CAAA;AAED,MAAM,cAAc,GAAqC;IACvD,IAAI,EAAE,yEAAyE;IAC/E,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,2EAA2E;IACjF,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,gDAAgD;IACrD,GAAG,EAAE,iDAAiD;IACtD,IAAI,EAAE,sBAAsB;IAC5B,GAAG,EAAE,0BAA0B;IAC/B,GAAG,EAAE,yCAAyC;CAC/C,CAAA;AACD,MAAM,cAAc,GAAqC;IACvD,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,0BAA0B;IAC/B,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,4BAA4B;IACjC,GAAG,EAAE,mBAAmB;CACzB,CAAA;AAID,MAAM,KAAK,GAAG,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAEzE,MAAM,UAAU,GAAyB;IACvC,EAAE,KAAK,EAAE,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A;QAClF,MAAM,WAAW,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAC1E,IAAI,WAAW,KAAK,SAAS;YAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,CAAA;IAChF,CAAC;IACD,IAAI,YAAY,KAAK,IAAI;QAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA;IAC3E,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC7E,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,QAAuB;IACjD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAClC,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACrC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAChE,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAA;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pipework",
3
- "version": "0.203.1",
3
+ "version": "0.205.0",
4
4
  "description": "TypeScript framework for multi-tenant SaaS applications. PostgreSQL-only.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,24 +0,0 @@
1
- export interface AwsCredentials {
2
- readonly accessKeyId: string;
3
- readonly secretAccessKey: string;
4
- readonly sessionToken?: string;
5
- }
6
- export interface SigV4Request {
7
- readonly method: string;
8
- readonly url: string;
9
- /** Headers to sign and send, other than host and x-amz-date, which are added. */
10
- readonly headers: Readonly<Record<string, string>>;
11
- readonly body: string | Buffer;
12
- readonly region: string;
13
- readonly service: string;
14
- readonly credentials: AwsCredentials;
15
- readonly now?: Date;
16
- }
17
- /**
18
- * Signs a request with AWS Signature Version 4 and returns the headers to send:
19
- * the given ones, `x-amz-date`, `x-amz-security-token` when the credentials carry
20
- * a session token, and `authorization`. `host` is signed but not returned; the
21
- * HTTP client sets it from the URL.
22
- */
23
- export declare function signV4(req: SigV4Request): Record<string, string>;
24
- //# sourceMappingURL=sigv4.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sigv4.d.ts","sourceRoot":"","sources":["../../../src/infra/email/sigv4.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAA;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAA;CACpB;AAkBD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwChE"}
@@ -1,55 +0,0 @@
1
- import { createHash, createHmac } from 'node:crypto';
2
- function sha256Hex(data) {
3
- return createHash('sha256').update(data).digest('hex');
4
- }
5
- function hmac(key, data) {
6
- return createHmac('sha256', key).update(data).digest();
7
- }
8
- function uriEncode(s) {
9
- return encodeURIComponent(s).replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
10
- }
11
- function amzDate(d) {
12
- return d.toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, '');
13
- }
14
- /**
15
- * Signs a request with AWS Signature Version 4 and returns the headers to send:
16
- * the given ones, `x-amz-date`, `x-amz-security-token` when the credentials carry
17
- * a session token, and `authorization`. `host` is signed but not returned; the
18
- * HTTP client sets it from the URL.
19
- */
20
- export function signV4(req) {
21
- const url = new URL(req.url);
22
- const stamp = amzDate(req.now ?? new Date());
23
- const day = stamp.slice(0, 8);
24
- const headers = {};
25
- for (const [name, value] of Object.entries(req.headers))
26
- headers[name.toLowerCase()] = value.trim().replace(/\s+/g, ' ');
27
- headers['x-amz-date'] = stamp;
28
- if (req.credentials.sessionToken !== undefined)
29
- headers['x-amz-security-token'] = req.credentials.sessionToken;
30
- const signed = { ...headers, host: url.host };
31
- const names = Object.keys(signed).sort();
32
- const canonicalHeaders = names.map(n => `${n}:${signed[n]}\n`).join('');
33
- const signedHeaders = names.join(';');
34
- const canonicalPath = url.pathname.split('/').map(uriEncode).join('/');
35
- const canonicalQuery = [...url.searchParams.entries()]
36
- .map(([k, v]) => [uriEncode(k), uriEncode(v)])
37
- .sort((a, b) => (a[0] === b[0] ? (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0) : (a[0] < b[0] ? -1 : 1)))
38
- .map(([k, v]) => `${k}=${v}`)
39
- .join('&');
40
- const canonicalRequest = [
41
- req.method.toUpperCase(), canonicalPath, canonicalQuery, canonicalHeaders, signedHeaders, sha256Hex(req.body),
42
- ].join('\n');
43
- const scope = `${day}/${req.region}/${req.service}/aws4_request`;
44
- const stringToSign = ['AWS4-HMAC-SHA256', stamp, scope, sha256Hex(canonicalRequest)].join('\n');
45
- const kDate = hmac(`AWS4${req.credentials.secretAccessKey}`, day);
46
- const kRegion = hmac(kDate, req.region);
47
- const kService = hmac(kRegion, req.service);
48
- const kSigning = hmac(kService, 'aws4_request');
49
- const signature = createHmac('sha256', kSigning).update(stringToSign).digest('hex');
50
- return {
51
- ...headers,
52
- authorization: `AWS4-HMAC-SHA256 Credential=${req.credentials.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`,
53
- };
54
- }
55
- //# sourceMappingURL=sigv4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sigv4.js","sourceRoot":"","sources":["../../../src/infra/email/sigv4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAoBpD,SAAS,SAAS,CAAC,IAAqB;IACtC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,IAAI,CAAC,GAAoB,EAAE,IAAY;IAC9C,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAA;AACxD,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACzG,CAAC;AAED,SAAS,OAAO,CAAC,CAAO;IACtB,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AACpE,CAAC;AAED;;;;;GAKG;AACH,MA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