pipework 0.178.0 → 0.180.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 +16 -0
- package/REFERENCE.md +7 -0
- package/dist/REFERENCE.md +322 -13
- package/dist/cli/commands/check.d.ts +2 -1
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +25 -8
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/shard.d.ts +13 -0
- package/dist/cli/commands/shard.d.ts.map +1 -0
- package/dist/cli/commands/shard.js +23 -0
- package/dist/cli/commands/shard.js.map +1 -0
- package/dist/cli/commands/test.d.ts +17 -0
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +48 -5
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +12 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/data/db/expressions.d.ts +49 -0
- package/dist/data/db/expressions.d.ts.map +1 -1
- package/dist/data/db/expressions.js +115 -0
- package/dist/data/db/expressions.js.map +1 -1
- package/dist/data/db/filter.d.ts +20 -1
- package/dist/data/db/filter.d.ts.map +1 -1
- package/dist/data/db/filter.js +20 -1
- package/dist/data/db/filter.js.map +1 -1
- package/dist/data/db/namespace.d.ts +19 -0
- package/dist/data/db/namespace.d.ts.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,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.180.0
|
|
4
|
+
|
|
5
|
+
- **Added: `pipe.filter.splitPart(a, delimiter, n)` and `pipe.filter.arrayAt(arr, n)`** (#726). `splitPart` is `split_part`; `arrayAt` is one array element by 1-based index. A negative `n` counts from the end in both. For `arrayAt`, an empty array, 0 or an index out of range gives NULL, and its type comes from the column (`uuid[]` gives `SQL<string | null>`).
|
|
6
|
+
- **Added: the rest of the common Postgres text and array functions,** so a package no longer falls back to `pipe.sql` for them:
|
|
7
|
+
- text: `lower`, `upper`, `trim`, `replace`, `substring`, `reverse`, `lpad`, `rpad`, `regexpReplace`, `regexpMatch` (`~`, or `~*` with `caseInsensitive`) and `stringToArray`;
|
|
8
|
+
- arrays: `cardinality`, `arrayPosition`, `arraySlice`, `arrayToString`, `arrayAppend` and `arrayRemove`.
|
|
9
|
+
- Every value a caller passes in is bound as a parameter. Positions and counts must be integers, or the call throws naming the builder.
|
|
10
|
+
|
|
11
|
+
## 0.179.0
|
|
12
|
+
|
|
13
|
+
- **Added: split one full run across CI machines with `--shard <i>/<n>`** (#724).
|
|
14
|
+
- `pipework test --full --shard 2/4` runs part 2 of 4 disjoint parts of the selected test files, using vitest's own split. The parts together run exactly what the unsharded run runs.
|
|
15
|
+
- A part whose files are all in projects that use no database skips test database setup.
|
|
16
|
+
- `pipework check --full --shard 2/4` deals modules round-robin to lint and type check, the slow steps. The quick repo-wide checks run in every part, and files outside every module are linted in part 1.
|
|
17
|
+
- Every machine must get the same scope flags. A value that is not `<i>/<n>` with `1 <= i <= n` is refused, naming `--shard`, and `--shard` cannot be combined with `--reap`.
|
|
18
|
+
|
|
3
19
|
## 0.178.0
|
|
4
20
|
|
|
5
21
|
- **Added: failures that were only logged now leave a row an alert can read** (failure-alert class, part 4 of 4). New table `pipework_faults`, which comes with the `alerts` blueprint key; run `pipework generate` and migrate.
|
package/REFERENCE.md
CHANGED
|
@@ -731,6 +731,11 @@ Expression helpers for `.set()`, `.values()` and `.where()` (a string or number
|
|
|
731
731
|
- `filter.interval(amount, unit)` — `($1::double precision * interval '1 <unit>')`, `amount` bound; a non-finite amount throws.
|
|
732
732
|
- `filter.strpos(a, b)`, `filter.textContains(a, b)`, `filter.startsWith(a, prefix)` — exact-text tests, no `%`/`_`/backslash wildcards (unlike `like`). `a`, `b`, `prefix` take a column, expression or string.
|
|
733
733
|
- `filter.left(a, n)`, `filter.right(a, n)`, `filter.length(a)` — text slices and length.
|
|
734
|
+
- `filter.splitPart(a, delimiter, n)` — `split_part($a, $delimiter, $n)`; negative `n` counts from the end (PG 14+). `filter.lower(a)`, `filter.upper(a)`, `filter.reverse(a)` — `lower`/`upper`/`reverse`.
|
|
735
|
+
- `filter.trim(a, { side?, characters? })` — `trim(both|leading|trailing [$characters] from a)`. `filter.replace(a, from, to)` — `replace`. `filter.substring(a, from, count?)` — `substring(a, from[, count])`. `filter.lpad(a, length, fill?)` / `filter.rpad(...)` — `lpad`/`rpad`.
|
|
736
|
+
- `filter.regexpReplace(a, pattern, replacement, flags?)` — `regexp_replace`; `filter.regexpMatch(a, pattern, { caseInsensitive? })` — `a ~ pattern` (`~*` when case-insensitive); `filter.stringToArray(a, delimiter)` — `string_to_array`. Pattern, replacement, flags and delimiter are always bound.
|
|
737
|
+
- `filter.arrayAt(arr, n)` — `(arr)[n]`, 1-based; negative `n` is `(arr)[cardinality(arr) + n + 1]`; NULL for 0, out of range or `'{}'`. Typed from the column (`uuid[]` gives `SQL<string | null>`); `n` must be an integer or it throws.
|
|
738
|
+
- `filter.cardinality(arr)`, `filter.arrayPosition(col, value)` (`array_position`, NULL when absent), `filter.arraySlice(col, from, to)` (`(col)[from:to]`), `filter.arrayToString(arr, delimiter)`, `filter.arrayAppend(col, value)` and `filter.arrayRemove(col, value)` (for `.set()`). Values are bound and cast to the column's element type.
|
|
734
739
|
- `filter.concat(...parts)` — `(p1 || p2 || ...)`, at least two parts, each a string, column or expression (`scalar(...)` for a subquery). A null part makes the result null; wrap it in `coalesce` if not wanted.
|
|
735
740
|
- `pipe.sql.inList(values, cast?)` — list match for a JS list: `` sql`id ${sql.inList(ids, 'uuid')}` `` renders `= ANY(...)`, so an empty list matches nothing; never build `IN (${sql.join(...)})`, which is a syntax error when the list is empty. `cast` is the element type, default `text`.
|
|
736
741
|
- `filter.arrayReplace(col, from, to)` — `array_replace`, every `from` becomes `to`; `filter.arrayHas(col, value)` — `$value = ANY(col)`. `col` must be an array column; values are cast to its element type.
|
|
@@ -2097,6 +2102,8 @@ Generates an OpenAPI 3.1 document from route registrations — schemas derived f
|
|
|
2097
2102
|
|
|
2098
2103
|
`pipework test <path>` runs only affected modules; when a path is given and no module is affected it prints "Nothing ran" naming the path and exits 1, so a reverted file cannot look green. Add `--all` to run it regardless. Bare `pipework test` with nothing affected still exits 0.
|
|
2099
2104
|
|
|
2105
|
+
`--shard <i>/<n>` (test and check) splits one run across n machines. `pipework test --full --shard 2/4` runs the second of four disjoint parts of the test files (vitest's `--shard`, so a file selected by two projects counts once per project); the four parts together run exactly what `--full` runs. Before database setup, `test` works out which projects have files in the part and provisions test databases only if one of them uses a database. `pipework check --shard i/n` deals the modules to lint and type check round-robin in sorted order, so the parts are disjoint and together cover every module; the repo-wide steps (doctrine, flow, startup, boundaries, dependencies) run in every part, and root-level lint files run in part 1. Combine it with `--full`, `--fast`, `--module` or `--suite`: every machine must be given the same scope flags. A value that is not `<i>/<n>` with `1 <= i <= n` is refused, naming `--shard`.
|
|
2106
|
+
|
|
2100
2107
|
## data
|
|
2101
2108
|
|
|
2102
2109
|
### `tap`
|
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-22
|
|
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,9 @@
|
|
|
30
31
|
- [cache — Caching](#cache-caching)
|
|
31
32
|
- [credits](#credits)
|
|
32
33
|
- [mail](#mail)
|
|
34
|
+
- [untrustedFetch](#untrustedfetch)
|
|
33
35
|
- [storage](#storage)
|
|
36
|
+
- [support](#support)
|
|
34
37
|
- [webhook — Inbound & Outbound Webhooks](#webhook-inbound-outbound-webhooks)
|
|
35
38
|
- [behavior — Resource Decorators](#behavior-resource-decorators)
|
|
36
39
|
- [fitting — Dependency Injection](#fitting-dependency-injection)
|
|
@@ -85,6 +88,18 @@ function createManifold<const TEnv extends EnvDefs = EnvDefs>( raw: Omit<Bluepri
|
|
|
85
88
|
interface Manifold<TEnv extends EnvDefs = EnvDefs>
|
|
86
89
|
```
|
|
87
90
|
|
|
91
|
+
**`ScriptOptions`** — Options for {@link Manifold.script}.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
interface ScriptOptions
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**`StartOptions`** — Options for {@link Manifold.start}.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
interface StartOptions
|
|
101
|
+
```
|
|
102
|
+
|
|
88
103
|
**`SeedOptions`** — ALS context the {@link Manifold.seed} callback runs under — tenant scope, auth principal, and job type.
|
|
89
104
|
|
|
90
105
|
```typescript
|
|
@@ -229,6 +244,14 @@ Creates a job queue with claim/complete/fail lifecycle, heartbeat, and dead lett
|
|
|
229
244
|
|
|
230
245
|
Executes a fitting handler as a background job with its own Flow context.
|
|
231
246
|
|
|
247
|
+
### `jobs.later`
|
|
248
|
+
|
|
249
|
+
The error to throw to end an attempt as "later": pending again after `delayMs`, no attempt counted.
|
|
250
|
+
|
|
251
|
+
### `jobs.permanent`
|
|
252
|
+
|
|
253
|
+
The error to throw to dead-letter the job now, whatever attempts remain.
|
|
254
|
+
|
|
232
255
|
### `jobs.parseCron`
|
|
233
256
|
|
|
234
257
|
Parses a 5-field cron expression into a CronSchedule (minute, hour, dom, month, dow).
|
|
@@ -269,6 +292,14 @@ Thrown when a transition is not allowed from the current state.
|
|
|
269
292
|
|
|
270
293
|
Thrown when the state machine definition is internally inconsistent.
|
|
271
294
|
|
|
295
|
+
## steps
|
|
296
|
+
|
|
297
|
+
Step graphs over a job queue: results recorded by their inputs, only missing steps run.
|
|
298
|
+
|
|
299
|
+
### `steps.define`
|
|
300
|
+
|
|
301
|
+
Defines a graph of named steps over a jobs Queue. Pass it to `createWorkerSurface({ graphs })` to run its steps.
|
|
302
|
+
|
|
272
303
|
## auth — Authentication
|
|
273
304
|
|
|
274
305
|
Authentication namespace — session management, multi-org support, auth chain resolution.
|
|
@@ -289,6 +320,10 @@ Hashes and verifies passwords with scrypt; reports when a stored hash needs reha
|
|
|
289
320
|
|
|
290
321
|
Guarded password sign-in that slows, then refuses, repeated failures per account and per client.
|
|
291
322
|
|
|
323
|
+
### `auth.emailLinks`
|
|
324
|
+
|
|
325
|
+
Emailed single-use links that prove control of an address: password reset and address verification; the token is never stored.
|
|
326
|
+
|
|
292
327
|
### `auth.runChain`
|
|
293
328
|
|
|
294
329
|
Executes an auth chain (strategy pipeline) to resolve auth + tenant from a request.
|
|
@@ -323,7 +358,7 @@ interface AuthContext
|
|
|
323
358
|
interface AuthStrategy<TAuth>
|
|
324
359
|
```
|
|
325
360
|
|
|
326
|
-
**`AuthRequest`** — Normalized request shape passed to auth strategies — headers,
|
|
361
|
+
**`AuthRequest`** — Normalized request shape passed to auth strategies — headers, the parsed `Cookie` header, and the upper-case HTTP method.
|
|
327
362
|
|
|
328
363
|
```typescript
|
|
329
364
|
interface AuthRequest
|
|
@@ -353,6 +388,18 @@ interface TenantResolver<TAuth>
|
|
|
353
388
|
interface AuthChainConfig<TAuth>
|
|
354
389
|
```
|
|
355
390
|
|
|
391
|
+
**`SessionAuth`** — What `sessions.strategy()` authenticates: the token's user and org, its roles, and where the token came from.
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
type SessionAuth = BaseAuth &
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**`SessionStrategyOptions`** — Options for `sessions.strategy()`.
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
interface SessionStrategyOptions
|
|
401
|
+
```
|
|
402
|
+
|
|
356
403
|
**`SessionConfig`** — Session configuration — signing keys, issuer, audience, token TTLs, refresh rotation.
|
|
357
404
|
|
|
358
405
|
```typescript
|
|
@@ -624,6 +671,10 @@ Base error class with code, statusCode, and suggestion fields.
|
|
|
624
671
|
|
|
625
672
|
403 — authenticated but insufficient permissions.
|
|
626
673
|
|
|
674
|
+
### `errors.CrossSiteRequest`
|
|
675
|
+
|
|
676
|
+
403 `CROSS_SITE_REQUEST` — a cookie-authenticated write that did not come from the app's own site.
|
|
677
|
+
|
|
627
678
|
### `errors.Validation`
|
|
628
679
|
|
|
629
680
|
422 — input validation failed, carries field-level details.
|
|
@@ -644,13 +695,17 @@ Base error class with code, statusCode, and suggestion fields.
|
|
|
644
695
|
|
|
645
696
|
415 — request body media type not accepted by the route.
|
|
646
697
|
|
|
698
|
+
### `errors.MalformedMultipart`
|
|
699
|
+
|
|
700
|
+
400 `MALFORMED_MULTIPART` — a multipart body that cannot be parsed or ends before its closing boundary.
|
|
701
|
+
|
|
647
702
|
## lifecycle — Startup & Shutdown
|
|
648
703
|
|
|
649
704
|
Application lifecycle namespace — startup orchestration with hooks and timeouts.
|
|
650
705
|
|
|
651
706
|
### `lifecycle.orchestrate`
|
|
652
707
|
|
|
653
|
-
Runs pre-start hooks (DB readiness checks, migrations, etc.) with a configurable timeout.
|
|
708
|
+
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
709
|
|
|
655
710
|
## log — Structured Logging
|
|
656
711
|
|
|
@@ -690,7 +745,7 @@ Creates a worker surface — a long-running process that claims and executes job
|
|
|
690
745
|
|
|
691
746
|
### `surface.script`
|
|
692
747
|
|
|
693
|
-
Creates a script surface — a one-shot process that runs and exits (migrations, seeds, CLI tools).
|
|
748
|
+
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
749
|
|
|
695
750
|
## pipe — Database
|
|
696
751
|
|
|
@@ -761,6 +816,10 @@ Acquires a transaction-scoped advisory lock. Released at commit/rollback.
|
|
|
761
816
|
|
|
762
817
|
Runs a function in a SERIALIZABLE transaction with automatic retry on serialization failures and deadlocks.
|
|
763
818
|
|
|
819
|
+
### `pipe.withTimeouts`
|
|
820
|
+
|
|
821
|
+
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.
|
|
822
|
+
|
|
764
823
|
### `pipe.bulkSet`
|
|
765
824
|
|
|
766
825
|
Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values in a single statement.
|
|
@@ -769,6 +828,10 @@ Bulk UPDATE ... FROM (VALUES ...) — updates multiple rows with per-row values
|
|
|
769
828
|
|
|
770
829
|
Produces a typed VALUES clause for bulk operations — the base primitive for bulkSet and bulkUpsert.
|
|
771
830
|
|
|
831
|
+
### `pipe.fn`
|
|
832
|
+
|
|
833
|
+
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.
|
|
834
|
+
|
|
772
835
|
### `pipe.field`
|
|
773
836
|
|
|
774
837
|
Field builders for domain definitions — uuid(), text(), integer(), etc.
|
|
@@ -781,13 +844,17 @@ Registers a domain definition with table, validators, and factory projections. T
|
|
|
781
844
|
|
|
782
845
|
Returns the global registry of all domain definitions.
|
|
783
846
|
|
|
847
|
+
### `pipe.external`
|
|
848
|
+
|
|
849
|
+
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.
|
|
850
|
+
|
|
784
851
|
### `pipe.update`
|
|
785
852
|
|
|
786
853
|
Pipework-owned UPDATE builder — the only consumer-facing way to update pipework-managed tables (Q8).
|
|
787
854
|
|
|
788
855
|
### `pipe.insert`
|
|
789
856
|
|
|
790
|
-
Pipework-owned INSERT builder — the only consumer-facing way to insert into pipework-managed tables (Q8).
|
|
857
|
+
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
858
|
|
|
792
859
|
### `pipe.delete`
|
|
793
860
|
|
|
@@ -795,7 +862,7 @@ Pipework-owned DELETE builder — the only consumer-facing way to delete from pi
|
|
|
795
862
|
|
|
796
863
|
### `pipe.upsert`
|
|
797
864
|
|
|
798
|
-
Pipework-owned UPSERT builder — insert with conflict resolution (Q8).
|
|
865
|
+
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
866
|
|
|
800
867
|
### Types
|
|
801
868
|
|
|
@@ -811,12 +878,54 @@ interface WindowSpec
|
|
|
811
878
|
interface ValueColumnDef
|
|
812
879
|
```
|
|
813
880
|
|
|
881
|
+
**`JsonbElements`** — A jsonb array read as its elements' text. Produced by {@link jsonbElements}.
|
|
882
|
+
|
|
883
|
+
```typescript
|
|
884
|
+
interface JsonbElements
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
**`ArraySource`** — Something whose elements `arrayAny` / `arrayAll` can test.
|
|
888
|
+
|
|
889
|
+
```typescript
|
|
890
|
+
type ArraySource =
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
**`ElementOf`** — The element type of an {@link ArraySource}.
|
|
894
|
+
|
|
895
|
+
```typescript
|
|
896
|
+
type ElementOf<S> =
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
**`FunctionSpec`** — Declares a SQL function's argument and result-column shapes. See {@link fn}.
|
|
900
|
+
|
|
901
|
+
```typescript
|
|
902
|
+
interface FunctionSpec<TArgs extends readonly AnyField[], TColumns extends Record<string, AnyField>>
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
**`FunctionSourceFields`** — The selected fields of a function source: each result column as a typed SQL expression.
|
|
906
|
+
|
|
907
|
+
```typescript
|
|
908
|
+
type FunctionSourceFields<TColumns extends Record<string, AnyField>> =
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
**`FunctionSource`** — A function call usable in `.from()` and joins; its result columns are properties of it.
|
|
912
|
+
|
|
913
|
+
```typescript
|
|
914
|
+
type FunctionSource<TAlias extends string, TColumns extends Record<string, AnyField>> =
|
|
915
|
+
```
|
|
916
|
+
|
|
814
917
|
**`SerializableOptions`** — Retry policy for {@link serializable}: how many attempts on a serialization failure / deadlock, and the base backoff between them.
|
|
815
918
|
|
|
816
919
|
```typescript
|
|
817
920
|
interface SerializableOptions
|
|
818
921
|
```
|
|
819
922
|
|
|
923
|
+
**`TimeoutOptions`** — Which timeouts {@link withTimeouts} sets; each a positive integer number of milliseconds.
|
|
924
|
+
|
|
925
|
+
```typescript
|
|
926
|
+
interface TimeoutOptions
|
|
927
|
+
```
|
|
928
|
+
|
|
820
929
|
**`ManagedConnection`** — A standalone pooled connection: the raw postgres.js client, its drizzle handle, and a `close()` that ends the pool.
|
|
821
930
|
|
|
822
931
|
```typescript
|
|
@@ -837,6 +946,10 @@ JSONB query operators — typed helpers for PostgreSQL JSONB containment, key ch
|
|
|
837
946
|
|
|
838
947
|
The @> containment operator — tests whether a JSONB column contains the given value.
|
|
839
948
|
|
|
949
|
+
### `jsonb.merge`
|
|
950
|
+
|
|
951
|
+
Merges an object into a JSONB column in `.set()`: `coalesce(col, '{}') || value`. Top-level keys overwrite; others are kept.
|
|
952
|
+
|
|
840
953
|
### `jsonb.containedBy`
|
|
841
954
|
|
|
842
955
|
The <@ contained-by operator — tests whether a JSONB column is contained by the given value.
|
|
@@ -903,6 +1016,60 @@ type Schema<T = unknown> = z.ZodType<T>
|
|
|
903
1016
|
type Infer<T extends Schema> = z.infer<T>
|
|
904
1017
|
```
|
|
905
1018
|
|
|
1019
|
+
**`StringSchema`** — A string validator — what check.string() returns, nameable without importing zod.
|
|
1020
|
+
|
|
1021
|
+
```typescript
|
|
1022
|
+
interface StringSchema extends z.ZodString
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
**`NumberSchema`** — A number validator — what check.number() returns.
|
|
1026
|
+
|
|
1027
|
+
```typescript
|
|
1028
|
+
interface NumberSchema extends z.ZodNumber
|
|
1029
|
+
```
|
|
1030
|
+
|
|
1031
|
+
**`BooleanSchema`** — A boolean validator — what check.boolean() returns.
|
|
1032
|
+
|
|
1033
|
+
```typescript
|
|
1034
|
+
interface BooleanSchema extends z.ZodBoolean
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
**`EnumSchema`** — An enum validator over string literals — what check.enum([...]) returns.
|
|
1038
|
+
|
|
1039
|
+
```typescript
|
|
1040
|
+
interface EnumSchema<V extends string = string> extends z.ZodEnum<
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
**`LiteralSchema`** — A literal validator — what check.literal(v) returns.
|
|
1044
|
+
|
|
1045
|
+
```typescript
|
|
1046
|
+
interface LiteralSchema<V extends string | number | boolean | null = string> extends z.ZodLiteral<V>
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
**`ArraySchema`** — An array validator — what check.array(item) returns.
|
|
1050
|
+
|
|
1051
|
+
```typescript
|
|
1052
|
+
interface ArraySchema<Item extends z.core.SomeType = z.core.SomeType> extends z.ZodArray<Item>
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
**`OptionalSchema`** — An optional validator — what check.optional(inner) returns.
|
|
1056
|
+
|
|
1057
|
+
```typescript
|
|
1058
|
+
interface OptionalSchema<Inner extends z.core.SomeType = z.core.SomeType> extends z.ZodOptional<Inner>
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1061
|
+
**`NullableSchema`** — A nullable validator — what check.nullable(inner) returns.
|
|
1062
|
+
|
|
1063
|
+
```typescript
|
|
1064
|
+
interface NullableSchema<Inner extends z.core.SomeType = z.core.SomeType> extends z.ZodNullable<Inner>
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
**`ObjectSchema`** — An object validator whose .extend, .pick, .omit and .partial results stay ObjectSchema — what check.object({...}) returns.
|
|
1068
|
+
|
|
1069
|
+
```typescript
|
|
1070
|
+
type ObjectSchema<S extends Shape = Shape> =
|
|
1071
|
+
```
|
|
1072
|
+
|
|
906
1073
|
## temporal — Bitemporal Data
|
|
907
1074
|
|
|
908
1075
|
Temporal (bitemporal) data namespace — version history with effective date ranges.
|
|
@@ -947,6 +1114,14 @@ Query all versions of temporal records (no date filter).
|
|
|
947
1114
|
|
|
948
1115
|
Close the current version and create a new one with updated data.
|
|
949
1116
|
|
|
1117
|
+
### `temporal.setVersion`
|
|
1118
|
+
|
|
1119
|
+
Append the next version of an append-only-versions definition: serialised per scope, numbered, never back-dated, audited.
|
|
1120
|
+
|
|
1121
|
+
### `temporal.versionAt`
|
|
1122
|
+
|
|
1123
|
+
The version in force at a moment: the row with the greatest effectiveFrom at or before it.
|
|
1124
|
+
|
|
950
1125
|
## valve
|
|
951
1126
|
|
|
952
1127
|
Valve namespace — typed, directional, gated boundaries between code silos.
|
|
@@ -1129,6 +1304,18 @@ Alerts namespace — raise and resolve keyed conditions, grouped, delivered to s
|
|
|
1129
1304
|
|
|
1130
1305
|
Creates an alerts handle.
|
|
1131
1306
|
|
|
1307
|
+
### `alerts.http`
|
|
1308
|
+
|
|
1309
|
+
Routes for an operations agent: list, get, totals, delivery health, acknowledge, resolve, link; bearer credentials.
|
|
1310
|
+
|
|
1311
|
+
### `alerts.clientFaults`
|
|
1312
|
+
|
|
1313
|
+
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`.
|
|
1314
|
+
|
|
1315
|
+
### `alerts.requestFaults`
|
|
1316
|
+
|
|
1317
|
+
An `onInternalError` hook for the HTTP server: raises `request-fault:<METHOD> <route>` for each internal 500.
|
|
1318
|
+
|
|
1132
1319
|
### `alerts.webhook`
|
|
1133
1320
|
|
|
1134
1321
|
A sink that POSTs the alert as signed JSON to a URL.
|
|
@@ -1161,6 +1348,10 @@ The newest record's `{ seq, hash }` in the tenant's audit hash chain (blueprint
|
|
|
1161
1348
|
|
|
1162
1349
|
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
1350
|
|
|
1351
|
+
### `audit.removeTenant`
|
|
1352
|
+
|
|
1353
|
+
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.
|
|
1354
|
+
|
|
1164
1355
|
## cache — Caching
|
|
1165
1356
|
|
|
1166
1357
|
In-memory caching namespace — TTL-based with stats, preload, and tenant-aware variants.
|
|
@@ -1213,6 +1404,36 @@ Inbound source: SES receipt rule storing raw messages in S3 and notifying a sign
|
|
|
1213
1404
|
|
|
1214
1405
|
Inbound development source: `.eml` files dropped in a folder, received by `scan()`; refused in production.
|
|
1215
1406
|
|
|
1407
|
+
## untrustedFetch
|
|
1408
|
+
|
|
1409
|
+
Untrusted fetch — fetch one URL a stranger gave without letting them reach the app's private network.
|
|
1410
|
+
|
|
1411
|
+
### `untrustedFetch.get`
|
|
1412
|
+
|
|
1413
|
+
Fetches `url` with GET and returns `{ ok: true, url, status, contentType, body, bytes }`, or `{ ok: false, reason, message }`
|
|
1414
|
+
naming the rule that refused: `scheme`, `address`, `redirects`, `too_large`, `timeout`, `status`, `rejected` or `network`.
|
|
1415
|
+
It does not throw for these.
|
|
1416
|
+
|
|
1417
|
+
Rules, none of which can be switched off: only `http:` and `https:`; the name is resolved and every address is checked
|
|
1418
|
+
(loopback, private, link-local including cloud metadata, CGNAT, unique-local and site-local IPv6, multicast, reserved,
|
|
1419
|
+
unspecified, and IPv4-mapped or NAT64 forms of these; literal IP URLs likewise) and the connection goes to a checked
|
|
1420
|
+
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;
|
|
1421
|
+
the body is stopped the moment it passes `maxBytes`, whatever Content-Length says; `timeoutMs` covers the whole fetch.
|
|
1422
|
+
`accept({ status, contentType, firstBytes })` sees the first 1024 bytes before the body is kept: return false, or a string
|
|
1423
|
+
(your own message), to refuse with `rejected`. Messages never contain an address or anything a server sent.
|
|
1424
|
+
|
|
1425
|
+
`resolve` and `connect` are for tests: `resolve(hostname)` replaces DNS and `connect(target)` replaces the socket after the
|
|
1426
|
+
address check passed, so a test sends a fake public address to a local server. The address check always runs on what `resolve` returns.
|
|
1427
|
+
|
|
1428
|
+
The call is the trace step `pipework/fetch:get`; its child `pipework/fetch:outcome` carries host, status, bytes and reason.
|
|
1429
|
+
The full URL is recorded only when `urlIsSafeToTrace` is true; otherwise only the host.
|
|
1430
|
+
|
|
1431
|
+
```ts
|
|
1432
|
+
const got = await untrustedFetch.get(pasted, { maxBytes: 5_000_000, timeoutMs: 10_000, maxRedirects: 3,
|
|
1433
|
+
accept: h => h.firstBytes[0] === 0x25 || 'That does not look like a PDF.' })
|
|
1434
|
+
if (!got.ok) return tell(got.message)
|
|
1435
|
+
```
|
|
1436
|
+
|
|
1216
1437
|
## storage
|
|
1217
1438
|
|
|
1218
1439
|
Storage namespace — tenant-scoped, content-addressed file storage with signed URLs and retention.
|
|
@@ -1229,6 +1450,18 @@ S3-compatible backend (AWS S3, MinIO, R2): SigV4 over `fetch`, multipart streami
|
|
|
1229
1450
|
|
|
1230
1451
|
Local-disk backend for development and tests; refused in production.
|
|
1231
1452
|
|
|
1453
|
+
## support
|
|
1454
|
+
|
|
1455
|
+
Support namespace — tickets from email (and later chat), with replies sent only after an approval.
|
|
1456
|
+
|
|
1457
|
+
### `support.create`
|
|
1458
|
+
|
|
1459
|
+
Creates the support handle: tickets, messages, notes, links, drafts, `approve`, `receiveEmail`, and the events job.
|
|
1460
|
+
|
|
1461
|
+
### `support.templates`
|
|
1462
|
+
|
|
1463
|
+
The reply template to spread into `mail.create({ templates })`; it renders the approved draft verbatim.
|
|
1464
|
+
|
|
1232
1465
|
## webhook — Inbound & Outbound Webhooks
|
|
1233
1466
|
|
|
1234
1467
|
Webhook namespace — inbound verification, outbound delivery with retries, HMAC signing.
|
|
@@ -1319,6 +1552,10 @@ Returns the current Flow or undefined — use for optional context detection.
|
|
|
1319
1552
|
|
|
1320
1553
|
Creates a Flow for test isolation with optional auth and tenant overrides.
|
|
1321
1554
|
|
|
1555
|
+
### `flow.actAs`
|
|
1556
|
+
|
|
1557
|
+
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.
|
|
1558
|
+
|
|
1322
1559
|
## http — Server
|
|
1323
1560
|
|
|
1324
1561
|
HTTP namespace: `http.file()` builds a file response; the server itself is managed by manifold.start().
|
|
@@ -1343,6 +1580,40 @@ interface SecurityConfig
|
|
|
1343
1580
|
interface RateLimitConfig
|
|
1344
1581
|
```
|
|
1345
1582
|
|
|
1583
|
+
**`RateLimitWindow`** — One fixed window: at most `max` requests per `windowSeconds`.
|
|
1584
|
+
|
|
1585
|
+
```typescript
|
|
1586
|
+
interface RateLimitWindow
|
|
1587
|
+
```
|
|
1588
|
+
|
|
1589
|
+
**`RateLimitClass`**
|
|
1590
|
+
|
|
1591
|
+
A named limit class: any of a per-user, per-tenant, per-address and total window, each counted on its own.
|
|
1592
|
+
Each key takes one window or an array of windows (distinct `windowSeconds`); a request is counted against
|
|
1593
|
+
all of a key's windows and refused if any is over.
|
|
1594
|
+
|
|
1595
|
+
```typescript
|
|
1596
|
+
interface RateLimitClass
|
|
1597
|
+
```
|
|
1598
|
+
|
|
1599
|
+
**`RateLimitRefusal`** — What `onRefused` is told about one refused window of one request.
|
|
1600
|
+
|
|
1601
|
+
```typescript
|
|
1602
|
+
interface RateLimitRefusal
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
**`RateLimitClassesConfig`**
|
|
1606
|
+
|
|
1607
|
+
Named limit classes, checked after auth and counted in Postgres (`pipework_rate_limit_counts`, opted in
|
|
1608
|
+
with the blueprint's `rateLimits: {}`), so every server process on the same database shares one count.
|
|
1609
|
+
Keys are counted perUser, perTenant, perAddress, total in turn, up to the first key with a window over its max, so one user's
|
|
1610
|
+
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
|
|
1611
|
+
a user), `public` (no auth, or optional without a user) or the class its fitting names with `.rateLimit(name)`.
|
|
1612
|
+
|
|
1613
|
+
```typescript
|
|
1614
|
+
interface RateLimitClassesConfig
|
|
1615
|
+
```
|
|
1616
|
+
|
|
1346
1617
|
**`InjectOptions`** — Options for server.inject() — method, url, headers, payload for testing without HTTP.
|
|
1347
1618
|
|
|
1348
1619
|
```typescript
|
|
@@ -1361,6 +1632,12 @@ interface InjectResponse
|
|
|
1361
1632
|
interface ServerConfig
|
|
1362
1633
|
```
|
|
1363
1634
|
|
|
1635
|
+
**`InternalErrorFault`** — What `onInternalError` is told about one request that ended in an internal error.
|
|
1636
|
+
|
|
1637
|
+
```typescript
|
|
1638
|
+
interface InternalErrorFault
|
|
1639
|
+
```
|
|
1640
|
+
|
|
1364
1641
|
**`HandlerResponse`** — Standard handler response shape — statusCode, headers, body.
|
|
1365
1642
|
|
|
1366
1643
|
```typescript
|
|
@@ -1419,7 +1696,7 @@ Generates an OpenAPI 3.1 document from route registrations — schemas derived f
|
|
|
1419
1696
|
|
|
1420
1697
|
## trace
|
|
1421
1698
|
|
|
1422
|
-
Trace namespace — hand the current trace to a process outside Node
|
|
1699
|
+
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
1700
|
|
|
1424
1701
|
### `trace.traceparent`
|
|
1425
1702
|
|
|
@@ -1433,6 +1710,15 @@ W3C `traceparent` for the current trace and open step; `null` outside a traced f
|
|
|
1433
1710
|
|
|
1434
1711
|
Records steps reported as JSON lines (or objects) by an outside process under the step open now. Synchronous; never throws.
|
|
1435
1712
|
|
|
1713
|
+
### `trace.event`
|
|
1714
|
+
|
|
1715
|
+
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.
|
|
1716
|
+
|
|
1717
|
+
### `trace.tree`
|
|
1718
|
+
|
|
1719
|
+
Reads every hot trace sharing `rootId` (a request's trace and the jobs it queued) with their steps. Runs on the
|
|
1720
|
+
given `db`, so tenant policies apply: only an unrestricted connection (table owner, tests) sees every tenant's rows.
|
|
1721
|
+
|
|
1436
1722
|
### Types
|
|
1437
1723
|
|
|
1438
1724
|
**`FlowStepMeta`** — Trace metadata for one documented flow-step: its `path:symbol` graph node id and the per-argument capture projections.
|
|
@@ -1453,17 +1739,40 @@ type ExternalStepReport = z.infer<typeof externalStepReportSchema>
|
|
|
1453
1739
|
interface ExternalRecordResult
|
|
1454
1740
|
```
|
|
1455
1741
|
|
|
1742
|
+
**`TraceStepNode`** — One step of a trace. `ref` is the flow step's `path:symbol`, or `external:<name>` for a recorded or point-event step.
|
|
1743
|
+
|
|
1744
|
+
```typescript
|
|
1745
|
+
interface TraceStepNode
|
|
1746
|
+
```
|
|
1747
|
+
|
|
1748
|
+
**`TraceNode`** — One trace of the tree, with its steps ordered by `seq`.
|
|
1749
|
+
|
|
1750
|
+
```typescript
|
|
1751
|
+
interface TraceNode
|
|
1752
|
+
```
|
|
1753
|
+
|
|
1754
|
+
**`TraceTree`** — The traces that share a root id, ordered by when they opened.
|
|
1755
|
+
|
|
1756
|
+
```typescript
|
|
1757
|
+
interface TraceTree
|
|
1758
|
+
```
|
|
1759
|
+
|
|
1456
1760
|
## data
|
|
1457
1761
|
|
|
1458
|
-
### `
|
|
1762
|
+
### `StatementTimeoutError`
|
|
1763
|
+
|
|
1764
|
+
A statement was cancelled by Postgres for running past the statement timeout a {@link withTimeouts} call set. `cause` is the driver error.
|
|
1765
|
+
|
|
1766
|
+
```typescript
|
|
1767
|
+
class StatementTimeoutError extends Error constructor(readonly statementTimeoutMs: number, cause: unknown)
|
|
1768
|
+
```
|
|
1769
|
+
|
|
1770
|
+
### `LockTimeoutError`
|
|
1459
1771
|
|
|
1460
|
-
|
|
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()`.
|
|
1772
|
+
A statement gave up waiting for a lock past the lock timeout a {@link withTimeouts} call set. `cause` is the driver error.
|
|
1464
1773
|
|
|
1465
1774
|
```typescript
|
|
1466
|
-
|
|
1775
|
+
class LockTimeoutError extends Error constructor(readonly lockTimeoutMs: number, cause: unknown)
|
|
1467
1776
|
```
|
|
1468
1777
|
|
|
1469
1778
|
## request
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ScopeMode } from '../../workspace/affected.js';
|
|
2
|
-
|
|
2
|
+
import { type Shard } from './shard.js';
|
|
3
|
+
export declare function check(cwd: string, scope?: ScopeMode, shard?: Shard): Promise<void>;
|
|
3
4
|
/** The startup checks that need no database — what `serve` would refuse before connecting. */
|
|
4
5
|
export declare function runStartupChecks(cwd: string): Promise<boolean>;
|
|
5
6
|
export interface ModuleScope {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"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"}
|