pipework 0.204.0 → 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 +4 -0
- package/dist/REFERENCE.md +472 -16
- package/dist/request/di/builder.d.ts +2 -2
- package/dist/request/http/namespace.d.ts +1 -1
- package/dist/request/http/sniff.d.ts +5 -4
- package/dist/request/http/sniff.d.ts.map +1 -1
- package/dist/request/http/sniff.js +11 -6
- package/dist/request/http/sniff.js.map +1 -1
- package/package.json +1 -1
- package/dist/infra/email/sigv4.d.ts +0 -24
- package/dist/infra/email/sigv4.d.ts.map +0 -1
- package/dist/infra/email/sigv4.js +0 -55
- package/dist/infra/email/sigv4.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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
|
+
|
|
3
7
|
## 0.204.0
|
|
4
8
|
|
|
5
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.
|
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-
|
|
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,
|
|
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)
|
|
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
|
|
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
|
-
### `
|
|
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
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
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
|
-
|
|
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
|
+
```
|
|
@@ -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
|
|
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
|
|
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:
|
|
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 =
|
|
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.
|
|
8
|
-
*
|
|
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,
|
|
1
|
+
{"version":3,"file":"sniff.d.ts","sourceRoot":"","sources":["../../../src/request/http/sniff.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,eAAO,MAAM,WAAW,OAAO,CAAA;AAuG/B,oHAAoH;AACpH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,MAAM,CAYxC,CAAA;AA6DF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAwCzE;AAMD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAerK;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAKlE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** Bytes of a file that decide its type. */
|
|
2
|
-
export const SNIFF_BYTES =
|
|
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.
|
|
171
|
-
*
|
|
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 >
|
|
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
|
-
|
|
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,CAA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AAI;YAAE,SAAQ;QACnC,IAAI,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC;YAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;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,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,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