pipework 0.7.10 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/REFERENCE.md +778 -0
  3. package/dist/REFERENCE.md +844 -0
  4. package/dist/cli/commands/dev.js +5 -2
  5. package/dist/cli/commands/dev.js.map +1 -1
  6. package/dist/cli/commands/run.d.ts.map +1 -1
  7. package/dist/cli/commands/run.js +0 -2
  8. package/dist/cli/commands/run.js.map +1 -1
  9. package/dist/cli/commands/test.d.ts.map +1 -1
  10. package/dist/cli/commands/test.js +0 -2
  11. package/dist/cli/commands/test.js.map +1 -1
  12. package/dist/cli/index.d.ts.map +1 -1
  13. package/dist/cli/index.js +2 -0
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/config/discover.d.ts.map +1 -1
  16. package/dist/config/discover.js +14 -0
  17. package/dist/config/discover.js.map +1 -1
  18. package/dist/config/ts-register.d.ts +2 -0
  19. package/dist/config/ts-register.d.ts.map +1 -0
  20. package/dist/config/ts-register.js +3 -0
  21. package/dist/config/ts-register.js.map +1 -0
  22. package/dist/config/ts-resolve-hooks.d.ts +10 -0
  23. package/dist/config/ts-resolve-hooks.d.ts.map +1 -0
  24. package/dist/config/ts-resolve-hooks.js +14 -0
  25. package/dist/config/ts-resolve-hooks.js.map +1 -0
  26. package/dist/db/excluded.d.ts +7 -0
  27. package/dist/db/excluded.d.ts.map +1 -0
  28. package/dist/db/excluded.js +11 -0
  29. package/dist/db/excluded.js.map +1 -0
  30. package/dist/db/index.d.ts +1 -0
  31. package/dist/db/index.d.ts.map +1 -1
  32. package/dist/db/index.js +1 -0
  33. package/dist/db/index.js.map +1 -1
  34. package/dist/db/namespace.d.ts +5 -0
  35. package/dist/db/namespace.d.ts.map +1 -1
  36. package/dist/db/namespace.js +5 -0
  37. package/dist/db/namespace.js.map +1 -1
  38. package/dist/domain/field.d.ts +4 -2
  39. package/dist/domain/field.d.ts.map +1 -1
  40. package/dist/domain/field.js.map +1 -1
  41. package/dist/domain/index.d.ts +1 -1
  42. package/dist/domain/index.d.ts.map +1 -1
  43. package/dist/domain/types.d.ts +19 -6
  44. package/dist/domain/types.d.ts.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/log/namespace.d.ts +1 -1
  50. package/dist/logging/index.d.ts +1 -1
  51. package/dist/logging/index.d.ts.map +1 -1
  52. package/dist/logging/proxy.d.ts +2 -2
  53. package/dist/logging/proxy.d.ts.map +1 -1
  54. package/dist/logging/proxy.js +9 -2
  55. package/dist/logging/proxy.js.map +1 -1
  56. package/dist/logging/types.d.ts +7 -0
  57. package/dist/logging/types.d.ts.map +1 -1
  58. package/dist/temporal/definition-queries.d.ts +5 -5
  59. package/dist/temporal/definition-queries.d.ts.map +1 -1
  60. package/dist/temporal/definition-queries.js.map +1 -1
  61. package/dist/vector/query.d.ts +1 -1
  62. package/dist/vector/query.d.ts.map +1 -1
  63. package/dist/vector/query.js.map +1 -1
  64. package/package.json +3 -2
@@ -0,0 +1,844 @@
1
+ # Pipework API Reference
2
+
3
+ > Auto-generated from source JSDoc. Do not edit manually.
4
+ > Generated: 2026-05-09
5
+
6
+ ## Contents
7
+
8
+ - **[Core](#core)** — Application setup, configuration, entry points, and infrastructure.
9
+ - [Core](#core)
10
+ - [config — Configuration](#config-configuration)
11
+ - [surface — Entry Points](#surface-entry-points)
12
+ - [lifecycle — Startup & Shutdown](#lifecycle-startup-shutdown)
13
+ - [errors — Error Classes](#errors-error-classes)
14
+ - [log — Structured Logging](#log-structured-logging)
15
+ - **[Data Layer](#data-layer)** — Database access, domain definitions, schema validation, and queries.
16
+ - [pipe — Database](#pipe-database)
17
+ - [schema — Validation & Schema](#schema-validation-schema)
18
+ - **[Request Handling](#request-handling)** — HTTP server, route builders, context, and API docs.
19
+ - [fitting — Dependency Injection](#fitting-dependency-injection)
20
+ - [http — Server](#http-server)
21
+ - [flow — Context (AsyncLocalStorage)](#flow-context-asynclocalstorage)
22
+ - [openapi — API Documentation](#openapi-api-documentation)
23
+ - **[Auth & Multi-Tenancy](#auth-multi-tenancy)** — Authentication, tenant isolation, and access control.
24
+ - [auth — Authentication](#auth-authentication)
25
+ - [tenant — Multi-Tenancy](#tenant-multi-tenancy)
26
+ - [rbac — Access Control](#rbac-access-control)
27
+ - **[Background Processing](#background-processing)** — Job queues, cron scheduling, and multi-step pipelines.
28
+ - [jobs — Background Jobs](#jobs-background-jobs)
29
+ - [pipeline — Multi-Step Pipelines](#pipeline-multi-step-pipelines)
30
+ - **[Resources & Data Patterns](#resources-data-patterns)** — REST resources, temporal data, state machines, caching, and audit trails.
31
+ - [fixture — REST Resources](#fixture-rest-resources)
32
+ - [temporal — Bitemporal Data](#temporal-bitemporal-data)
33
+ - [behavior — Resource Decorators](#behavior-resource-decorators)
34
+ - [state](#state)
35
+ - [cache — Caching](#cache-caching)
36
+ - [audit — Audit Logging](#audit-audit-logging)
37
+ - **[Extensions](#extensions)** — Vector search, webhooks, JSON operations, and idempotency.
38
+ - [vector — Vector & Full-Text Search](#vector-vector-full-text-search)
39
+ - [webhook — Inbound & Outbound Webhooks](#webhook-inbound-outbound-webhooks)
40
+ - [jsonb](#jsonb)
41
+
42
+ ## Core
43
+
44
+ Application setup, configuration, entry points, and infrastructure.
45
+
46
+ ### Core
47
+
48
+ Application instance and foundational types.
49
+
50
+ #### `createManifold`
51
+
52
+ Creates the Pipework application instance. This is the entry point for every Pipework app. Define in `pipework.config.ts` and export as default. /
53
+
54
+ ```typescript
55
+ function createManifold<const TEnv extends EnvDefs = EnvDefs>( raw: Omit<Blueprint, 'env'> &
56
+ ```
57
+
58
+ #### Types
59
+
60
+ **`Manifold`** — The application instance — holds config, connection pools, surfaces, and lifecycle.
61
+
62
+ ```typescript
63
+ interface Manifold<TEnv extends EnvDefs = EnvDefs>
64
+ ```
65
+
66
+ **`SeedOptions`**
67
+
68
+ ```typescript
69
+ interface SeedOptions
70
+ ```
71
+
72
+ **`PoolState`** — Manages database connection pools keyed by database name.
73
+
74
+ ```typescript
75
+ interface PoolState
76
+ ```
77
+
78
+ **`IsolationState`** — Tracks test isolation lifecycle — detects leaked isolation contexts.
79
+
80
+ ```typescript
81
+ interface IsolationState
82
+ ```
83
+
84
+ **`ConnectionTracker`** — Tracks active database connections for leak detection.
85
+
86
+ ```typescript
87
+ interface ConnectionTracker
88
+ ```
89
+
90
+ ### config — Configuration
91
+
92
+ Configuration namespace — loads and resolves Blueprint configs, discovers pipework.config.ts.
93
+
94
+ #### `config.load`
95
+
96
+ Parses and resolves a raw Blueprint into a ResolvedConfig with environment detection.
97
+
98
+ #### `config.discover`
99
+
100
+ Walks up from cwd to find pipework.config.ts, imports it, and returns the Manifold.
101
+
102
+ #### `config.configSchema`
103
+
104
+ The zod schema for Blueprint validation — useful for custom config tooling.
105
+
106
+ #### `config.ConfigError`
107
+
108
+ Thrown for configuration problems — includes a suggestion for how to fix.
109
+
110
+ ### surface — Entry Points
111
+
112
+ Surface namespace — declarative entry points that define how the app runs (HTTP server, background worker, one-shot script).
113
+
114
+ #### `surface.http`
115
+
116
+ Creates an HTTP surface — a Fastify server with routes, middleware, and production validation. Returns an HttpSurfaceBuilder with a .test() method for inject()-based integration tests.
117
+
118
+ #### `surface.worker`
119
+
120
+ Creates a worker surface — a long-running process that claims and executes jobs from queues.
121
+
122
+ #### `surface.script`
123
+
124
+ Creates a script surface — a one-shot process that runs and exits (migrations, seeds, CLI tools).
125
+
126
+ ### lifecycle — Startup & Shutdown
127
+
128
+ Application lifecycle namespace — startup orchestration with hooks and timeouts.
129
+
130
+ #### `lifecycle.orchestrate`
131
+
132
+ Runs pre-start hooks (DB readiness checks, migrations, etc.) with a configurable timeout.
133
+
134
+ ### errors — Error Classes
135
+
136
+ Standard error classes — all extend PipeworkError with structured error codes and actionable messages.
137
+
138
+ #### `errors.Base`
139
+
140
+ Base error class with code, statusCode, and suggestion fields.
141
+
142
+ #### `errors.NotFound`
143
+
144
+ 404 — resource not found.
145
+
146
+ #### `errors.Unauthorized`
147
+
148
+ 401 — missing or invalid authentication.
149
+
150
+ #### `errors.Forbidden`
151
+
152
+ 403 — authenticated but insufficient permissions.
153
+
154
+ #### `errors.Validation`
155
+
156
+ 422 — input validation failed, carries field-level details.
157
+
158
+ #### `errors.Conflict`
159
+
160
+ 409 — resource state conflict (duplicate, version mismatch).
161
+
162
+ ### log — Structured Logging
163
+
164
+ Structured logger (Pino) — auto-binds requestId, tenantId, userId, sessionId from ALS context on every log call.
165
+
166
+ #### `log.create`
167
+
168
+ Creates a new PipeworkLogger instance with custom config (level, redaction, transport).
169
+
170
+ #### `log.get`
171
+
172
+ Returns the context-aware logger proxy (same as the log export itself).
173
+
174
+ #### `log.getBase`
175
+
176
+ Returns the raw Pino logger without ALS context binding.
177
+
178
+ #### `log.configure`
179
+
180
+ Sets global logging config (level, redaction paths, custom context fields).
181
+
182
+ #### `log.REDACT_PATHS`
183
+
184
+ Default redaction paths — password, secret, token, authorization, cookie, etc.
185
+
186
+ ## Data Layer
187
+
188
+ Database access, domain definitions, schema validation, and queries.
189
+
190
+ ### pipe — Database
191
+
192
+ Database accessor — returns a Drizzle DB instance scoped to the current request/job/test context. Requires active AsyncLocalStorage context.
193
+
194
+ #### `pipe.filter`
195
+
196
+ Query operators and aggregates — eq, gt, lt, and, or, count, sum, etc.
197
+
198
+ #### `pipe.migrate`
199
+
200
+ Runs migrations for all configured databases.
201
+
202
+ #### `pipe.migrateOne`
203
+
204
+ Runs migrations for a single named database.
205
+
206
+ #### `pipe.excluded`
207
+
208
+ Returns excluded-column references for onConflictDoUpdate set clauses.
209
+
210
+ #### `pipe.field`
211
+
212
+ Field builders for domain definitions — uuid(), text(), integer(), etc.
213
+
214
+ #### `pipe.define`
215
+
216
+ Registers a domain definition with table, validators, and factory projections.
217
+
218
+ #### `pipe.definitions`
219
+
220
+ Returns the global registry of all domain definitions.
221
+
222
+ ### schema — Validation & Schema
223
+
224
+ Schema definition and validation namespace — wraps zod for validation, drizzle for table/column/index definitions.
225
+
226
+ #### `schema.check`
227
+
228
+ Validation sub-namespace — type constructors, combinators, formats, coerce, parse, tryParse, toJsonSchema, branded.
229
+
230
+ #### `schema.col`
231
+
232
+ Column type builders for table definitions — text, uuid, integer, timestamp, jsonb, boolean, varchar, etc.
233
+
234
+ #### `schema.idx`
235
+
236
+ Index and constraint builders — index, uniqueIndex, primaryKey, foreignKey, unique, check.
237
+
238
+ #### Types
239
+
240
+ **`Schema`** — Any validation schema — the base type accepted by .input(), .query(), .params() in the fitting builder.
241
+
242
+ ```typescript
243
+ type Schema<T = unknown> = z.ZodType<T>
244
+ ```
245
+
246
+ **`Infer`** — Extracts the TypeScript type from a Schema — Infer<typeof mySchema> gives you the validated type.
247
+
248
+ ```typescript
249
+ type Infer<T extends Schema> = z.infer<T>
250
+ ```
251
+
252
+ ## Request Handling
253
+
254
+ HTTP server, route builders, context, and API docs.
255
+
256
+ ### fitting — Dependency Injection
257
+
258
+ ### http — Server
259
+
260
+ HTTP server namespace — managed by manifold.start(), not directly accessible.
261
+
262
+ #### Types
263
+
264
+ **`CorsConfig`** — CORS configuration — origin, methods, headers, credentials, maxAge.
265
+
266
+ ```typescript
267
+ interface CorsConfig
268
+ ```
269
+
270
+ **`SecurityConfig`** — Security header configuration — passed to @fastify/helmet.
271
+
272
+ ```typescript
273
+ interface SecurityConfig
274
+ ```
275
+
276
+ **`RateLimitConfig`** — Rate limiting configuration — max requests, time window, key generator.
277
+
278
+ ```typescript
279
+ interface RateLimitConfig
280
+ ```
281
+
282
+ **`InjectOptions`** — Options for server.inject() — method, url, headers, payload for testing without HTTP.
283
+
284
+ ```typescript
285
+ interface InjectOptions
286
+ ```
287
+
288
+ **`InjectResponse`** — Response from server.inject() — statusCode, headers, body, json() helper.
289
+
290
+ ```typescript
291
+ interface InjectResponse
292
+ ```
293
+
294
+ **`ServerConfig`** — Configuration for http.createServer() — CORS, security headers, rate limiting, transaction timeout.
295
+
296
+ ```typescript
297
+ interface ServerConfig
298
+ ```
299
+
300
+ **`HandlerResponse`** — Standard handler response shape — statusCode, headers, body.
301
+
302
+ ```typescript
303
+ interface HandlerResponse
304
+ ```
305
+
306
+ **`ErrorResponse`** — Standard error response shape — { error: { code, message }, statusCode }.
307
+
308
+ ```typescript
309
+ interface ErrorResponse
310
+ ```
311
+
312
+ **`PipeworkServer`** — Fastify server wrapper with route registration, handler auto-wiring, and inject() for testing.
313
+
314
+ ```typescript
315
+ interface PipeworkServer
316
+ ```
317
+
318
+ **`HttpRequest`** — Fastify request with pipework extensions — req.id (UUID), typed headers.
319
+
320
+ ```typescript
321
+ interface HttpRequest
322
+ ```
323
+
324
+ **`HttpResponse`** — Fastify reply with pipework extensions.
325
+
326
+ ```typescript
327
+ interface HttpResponse
328
+ ```
329
+
330
+ ### flow — Context (AsyncLocalStorage)
331
+
332
+ AsyncLocalStorage context namespace — manages request/job/test contexts that carry auth, tenant, transactions.
333
+
334
+ #### `flow.run`
335
+
336
+ Executes a function within a Flow context (AsyncLocalStorage). All pipe() calls inside will use this context.
337
+
338
+ #### `flow.require`
339
+
340
+ Returns the current Flow or throws — use in code that must run inside a managed context.
341
+
342
+ #### `flow.get`
343
+
344
+ Returns the current Flow or undefined — use for optional context detection.
345
+
346
+ #### `flow.createTest`
347
+
348
+ Creates a Flow for test isolation with optional auth and tenant overrides.
349
+
350
+ ### openapi — API Documentation
351
+
352
+ OpenAPI spec generation namespace.
353
+
354
+ #### `openapi.generate`
355
+
356
+ Generates an OpenAPI 3.1 document from route registrations — schemas derived from fitting() input/output.
357
+
358
+ ## Auth & Multi-Tenancy
359
+
360
+ Authentication, tenant isolation, and access control.
361
+
362
+ ### auth — Authentication
363
+
364
+ Authentication namespace — session management, multi-org support, auth chain resolution.
365
+
366
+ #### `auth.createSessions`
367
+
368
+ Creates a Sessions manager with JWT access/refresh tokens, rotation, and reuse detection.
369
+
370
+ #### `auth.createMultiOrg`
371
+
372
+ Creates multi-org session management — org selection, switching, membership CRUD.
373
+
374
+ #### `auth.runChain`
375
+
376
+ Executes an auth chain (strategy pipeline) to resolve auth + tenant from a request.
377
+
378
+ #### `auth.resolveCookie`
379
+
380
+ Resolves CookieConfig with defaults for secure cookie-based token delivery.
381
+
382
+ #### `auth.parseCookie`
383
+
384
+ Parses a Cookie header string into key-value pairs.
385
+
386
+ #### `auth.buildSetCookie`
387
+
388
+ Builds a Set-Cookie header string from name, value, and CookieConfig.
389
+
390
+ #### `auth.buildClearCookie`
391
+
392
+ Builds a Set-Cookie header that clears (expires) a cookie.
393
+
394
+ #### Types
395
+
396
+ **`AuthContext`** — Runtime auth context passed to strategies — carries the resolved DB and request metadata.
397
+
398
+ ```typescript
399
+ interface AuthContext
400
+ ```
401
+
402
+ **`AuthStrategy`** — Pluggable auth strategy — implement authenticate() to extract auth from a request.
403
+
404
+ ```typescript
405
+ interface AuthStrategy<TAuth>
406
+ ```
407
+
408
+ **`AuthRequest`** — Normalized request shape passed to auth strategies — headers, cookies, method, url.
409
+
410
+ ```typescript
411
+ interface AuthRequest
412
+ ```
413
+
414
+ **`BaseAuth`** — Minimum auth shape — userId and tenantId. Extend for app-specific auth fields.
415
+
416
+ ```typescript
417
+ interface BaseAuth
418
+ ```
419
+
420
+ **`AuthEnricher`** — Post-authentication hook — enrich the resolved auth with additional data (roles, permissions, etc.).
421
+
422
+ ```typescript
423
+ interface AuthEnricher<TAuth>
424
+ ```
425
+
426
+ **`TenantResolver`** — Resolves tenant ID from auth context — called after authentication in the chain.
427
+
428
+ ```typescript
429
+ interface TenantResolver<TAuth>
430
+ ```
431
+
432
+ **`AuthChainConfig`** — Configuration for the auth chain — strategies, enrichers, tenant resolver.
433
+
434
+ ```typescript
435
+ interface AuthChainConfig<TAuth>
436
+ ```
437
+
438
+ **`SessionConfig`** — Session configuration — signing keys, issuer, audience, token TTLs, refresh rotation.
439
+
440
+ ```typescript
441
+ interface SessionConfig
442
+ ```
443
+
444
+ **`TokenPair`** — Access + refresh token pair returned by issueTokens().
445
+
446
+ ```typescript
447
+ interface TokenPair
448
+ ```
449
+
450
+ **`TokenPayload`** — Decoded JWT payload — userId, tenantId, roles, version.
451
+
452
+ ```typescript
453
+ interface TokenPayload
454
+ ```
455
+
456
+ **`HttpTokenResult`** — Result from HTTP token operations — the token pair plus whether cookies were set.
457
+
458
+ ```typescript
459
+ interface HttpTokenResult
460
+ ```
461
+
462
+ **`Sessions`** — Session manager with JWT issue/refresh/revoke lifecycle and cookie-based HTTP helpers.
463
+
464
+ ```typescript
465
+ interface Sessions
466
+ ```
467
+
468
+ **`CookieConfig`** — Cookie configuration for token delivery — name, domain, path, secure, sameSite, httpOnly.
469
+
470
+ ```typescript
471
+ interface CookieConfig
472
+ ```
473
+
474
+ **`MultiOrgConfig`** — Configuration for multi-org sessions — base sessions, signing keys, org-select token TTL.
475
+
476
+ ```typescript
477
+ interface MultiOrgConfig
478
+ ```
479
+
480
+ **`OrgMembership`** — A user's membership in an organization — userId, orgId, role.
481
+
482
+ ```typescript
483
+ interface OrgMembership
484
+ ```
485
+
486
+ **`OrgInfo`** — Basic organization info — id and display name.
487
+
488
+ ```typescript
489
+ interface OrgInfo
490
+ ```
491
+
492
+ **`OrgMembershipDetail`** — Organization membership with display name — extends OrgMembership with org info.
493
+
494
+ ```typescript
495
+ interface OrgMembershipDetail
496
+ ```
497
+
498
+ **`AuthenticatedResult`** — Result when user has exactly one org — direct authentication, no org selection needed.
499
+
500
+ ```typescript
501
+ interface AuthenticatedResult
502
+ ```
503
+
504
+ **`OrgSelectResult`** — Result when user has multiple orgs — returns a session token for org selection.
505
+
506
+ ```typescript
507
+ interface OrgSelectResult
508
+ ```
509
+
510
+ **`ResolveLoginResult`** — Union result from resolveLogin() — either AuthenticatedResult or OrgSelectResult.
511
+
512
+ ```typescript
513
+ type ResolveLoginResult = AuthenticatedResult | OrgSelectResult
514
+ ```
515
+
516
+ **`MultiOrgSessions`** — Multi-org session manager — login resolution, org selection, switching, membership CRUD.
517
+
518
+ ```typescript
519
+ interface MultiOrgSessions
520
+ ```
521
+
522
+ ### tenant — Multi-Tenancy
523
+
524
+ Multi-tenant isolation namespace — RLS policies, tenant extraction, Postgres-side verification.
525
+
526
+ #### `tenant.validate`
527
+
528
+ Validates a tenant ID format (non-empty string, safe characters).
529
+
530
+ #### `tenant.rls`
531
+
532
+ Enables RLS on a table and creates the tenant isolation policy in Postgres.
533
+
534
+ #### `tenant.policy`
535
+
536
+ Returns the SQL string for a tenant isolation RLS policy — use in migrations.
537
+
538
+ #### `tenant.verify`
539
+
540
+ Cross-checks ALS tenant against Postgres set_config('pipework.tenant_id') — defense-in-depth.
541
+
542
+ #### `tenant.propagate`
543
+
544
+ Sets pipework.tenant_id on the Postgres connection via set_config().
545
+
546
+ #### `tenant.extract`
547
+
548
+ Extracts tenant ID from auth context using the configured extraction strategy.
549
+
550
+ #### `tenant.isTenantScoped`
551
+
552
+ Returns true if a table has been marked as tenant-scoped (via .tenant() field metadata).
553
+
554
+ ### rbac — Access Control
555
+
556
+ Role-based access control namespace — permission checking, enforcement, scope hierarchy.
557
+
558
+ #### `rbac.create`
559
+
560
+ Creates an Rbac instance from config (roles, permissions, hierarchy).
561
+
562
+ #### `rbac.check`
563
+
564
+ Checks if a permission set includes the required resource/action/scope. Pure function, no DB.
565
+
566
+ #### `rbac.enforce`
567
+
568
+ Checks permission and throws ForbiddenError if denied. Loads permissions from DB with caching.
569
+
570
+ #### `rbac.satisfies`
571
+
572
+ Checks if a granted scope satisfies a required scope given a hierarchy (e.g. org > team > self).
573
+
574
+ #### `rbac.PermissionCache`
575
+
576
+ LRU cache for resolved permissions — avoids repeated DB lookups within a request.
577
+
578
+ ## Background Processing
579
+
580
+ Job queues, cron scheduling, and multi-step pipelines.
581
+
582
+ ### jobs — Background Jobs
583
+
584
+ Background job queue namespace — Postgres-backed with SKIP LOCKED, LISTEN/NOTIFY, cron scheduling.
585
+
586
+ #### `jobs.createQueue`
587
+
588
+ Creates a job queue with claim/complete/fail lifecycle, heartbeat, and dead letter requeue.
589
+
590
+ #### `jobs.execute`
591
+
592
+ Executes a fitting handler as a background job with its own Flow context.
593
+
594
+ #### `jobs.parseCron`
595
+
596
+ Parses a 5-field cron expression into a CronSchedule (minute, hour, dom, month, dow).
597
+
598
+ #### `jobs.nextTick`
599
+
600
+ Computes the next fire time for a CronSchedule after a given date, with optional timezone.
601
+
602
+ ### pipeline — Multi-Step Pipelines
603
+
604
+ Multi-step pipeline namespace — define, execute, pause, and resume ordered step sequences.
605
+
606
+ #### `pipeline.define`
607
+
608
+ Defines a pipeline from a config of named steps with handlers. Returns a Pipeline with execute/resume/getStatus.
609
+
610
+ #### `pipeline.PipelineStepError`
611
+
612
+ Thrown when an individual pipeline step fails.
613
+
614
+ #### `pipeline.PipelineResumeError`
615
+
616
+ Thrown when resuming a pipeline from an invalid state.
617
+
618
+ ## Resources & Data Patterns
619
+
620
+ REST resources, temporal data, state machines, caching, and audit trails.
621
+
622
+ ### fixture — REST Resources
623
+
624
+ REST resource builder namespace — declarative CRUD with cursor pagination and batch operations.
625
+
626
+ #### `fixture.toHandlers`
627
+
628
+ Converts a Resource into fitted Handler[] that go through the standard handler pipeline.
629
+
630
+ #### `fixture.build`
631
+
632
+ Builds a Resource from a name, operations map, and builder state — used internally by fitting().fixture().
633
+
634
+ #### `fixture.encodeCursor`
635
+
636
+ Encodes pagination cursor values into an opaque base64 string.
637
+
638
+ #### `fixture.decodeCursor`
639
+
640
+ Decodes an opaque pagination cursor back into its values.
641
+
642
+ #### `fixture.buildPage`
643
+
644
+ Builds a PageResult from rows, limit, and cursor extractor — handles hasMore detection.
645
+
646
+ #### `fixture.validateBatch`
647
+
648
+ Validates a batch request body (preview/execute mode, targets, actions).
649
+
650
+ #### `fixture.MethodNotAllowedError`
651
+
652
+ Thrown when a resource doesn't support the requested HTTP method.
653
+
654
+ ### temporal — Bitemporal Data
655
+
656
+ Temporal (bitemporal) data namespace — version history with effective date ranges.
657
+
658
+ #### `temporal.columns`
659
+
660
+ Returns the standard temporal column definitions (effectiveFrom, effectiveTo, version, createdBy) for table schemas.
661
+
662
+ #### `temporal.revise`
663
+
664
+ Creates a new version of a temporal record, closing the previous version's effectiveTo.
665
+
666
+ #### `temporal.close`
667
+
668
+ Closes a temporal record by setting effectiveTo to now. Returns number of rows affected.
669
+
670
+ #### `temporal.current`
671
+
672
+ Fetches the currently-effective version of a temporal record (effectiveTo IS NULL).
673
+
674
+ #### `temporal.atTime`
675
+
676
+ Returns a SQL condition for records effective at a specific point in time.
677
+
678
+ #### `temporal.between`
679
+
680
+ Returns a SQL condition for records overlapping a date range.
681
+
682
+ #### `temporal.TemporalIntegrityError`
683
+
684
+ Thrown when a temporal operation would violate version continuity.
685
+
686
+ #### `temporal.asOf`
687
+
688
+ Query records effective at a specific date, using a domain definition with .effectiveDated() trait.
689
+
690
+ #### `temporal.allVersions`
691
+
692
+ Query all versions of temporal records (no date filter).
693
+
694
+ #### `temporal.effectiveUpdate`
695
+
696
+ Close the current version and create a new one with updated data.
697
+
698
+ ### behavior — Resource Decorators
699
+
700
+ Resource behavior decorators — compose versioning, audit trails, and cache invalidation onto CRUD operations.
701
+
702
+ #### `behavior.compose`
703
+
704
+ Applies multiple behaviors to a ResourceOperations set in order.
705
+
706
+ #### `behavior.versioned`
707
+
708
+ Adds optimistic concurrency control via a version column — rejects stale updates.
709
+
710
+ #### `behavior.audited`
711
+
712
+ Wraps operations to emit audit records on create/update/delete.
713
+
714
+ #### `behavior.invalidate`
715
+
716
+ Wraps operations to invalidate a cache on mutations. Returns ops with an attached .cache handle.
717
+
718
+ ### state
719
+
720
+ State machine namespace — define valid transitions with guards and side effects.
721
+
722
+ #### `state.define`
723
+
724
+ Defines a state machine from states, transitions, guards, and effects. Returns a StateMachine with transition/canTransition.
725
+
726
+ #### `state.InvalidTransitionError`
727
+
728
+ Thrown when a transition is not allowed from the current state.
729
+
730
+ #### `state.InvalidStateMachineError`
731
+
732
+ Thrown when the state machine definition is internally inconsistent.
733
+
734
+ ### cache — Caching
735
+
736
+ In-memory caching namespace — TTL-based with stats, preload, and tenant-aware variants.
737
+
738
+ #### `cache.create`
739
+
740
+ Creates a single-key cache with TTL, a loader function, and invalidation.
741
+
742
+ #### `cache.createTenant`
743
+
744
+ Creates a per-tenant cache — each tenant gets its own TTL and loader keyed by tenant ID.
745
+
746
+ ### audit — Audit Logging
747
+
748
+ Audit logging namespace — structured audit trail for data changes.
749
+
750
+ #### `audit.create`
751
+
752
+ Creates an Audit instance that writes audit records to a Postgres table.
753
+
754
+ ## Extensions
755
+
756
+ Vector search, webhooks, JSON operations, and idempotency.
757
+
758
+ ### vector — Vector & Full-Text Search
759
+
760
+ Vector and full-text search namespace — pgvector column types, similarity queries, and FTS operators.
761
+
762
+ #### `vector.column`
763
+
764
+ Defines a vector(N) column for embeddings.
765
+
766
+ #### `vector.tsvector`
767
+
768
+ Defines a tsvector column for full-text search.
769
+
770
+ #### `vector.cosine`
771
+
772
+ Cosine distance between a column and a query vector (lower = more similar).
773
+
774
+ #### `vector.cosineSimilarity`
775
+
776
+ Cosine similarity (higher = more similar) — 1 - cosineDistance.
777
+
778
+ #### `vector.l2`
779
+
780
+ L2 (Euclidean) distance between a column and a query vector.
781
+
782
+ #### `vector.innerProduct`
783
+
784
+ Inner product between a column and a query vector.
785
+
786
+ #### `vector.toTsvector`
787
+
788
+ Converts text to a tsvector for full-text indexing.
789
+
790
+ #### `vector.toTsquery`
791
+
792
+ Converts a search query string to a tsquery using to_tsquery (supports operators like &, |, !).
793
+
794
+ #### `vector.plainToTsquery`
795
+
796
+ Converts natural language text to a tsquery using plainto_tsquery (no operator syntax required).
797
+
798
+ #### `vector.matches`
799
+
800
+ The @@ match operator — tests whether a tsvector column matches a tsquery.
801
+
802
+ #### `vector.headline`
803
+
804
+ Generates a ts_headline search snippet with highlighted matches.
805
+
806
+ #### `vector.rank`
807
+
808
+ Computes ts_rank for full-text search result ordering. Accepts a pre-built tsquery SQL or a raw query string.
809
+
810
+ #### `vector.validate`
811
+
812
+ Verifies the pgvector extension is installed and accessible.
813
+
814
+ ### webhook — Inbound & Outbound Webhooks
815
+
816
+ Webhook namespace — inbound verification, outbound delivery with retries, HMAC signing.
817
+
818
+ #### `webhook.defineInbound`
819
+
820
+ Defines an inbound webhook handler with signature verification and optional idempotency.
821
+
822
+ #### `webhook.createOutbound`
823
+
824
+ Creates an outbound webhook system — endpoint registration, payload signing, delivery with retries.
825
+
826
+ #### `webhook.sign`
827
+
828
+ Signs a payload with HMAC for outbound delivery — returns body, signature, timestamp, messageId.
829
+
830
+ ### jsonb
831
+
832
+ JSONB query operators — typed helpers for PostgreSQL JSONB containment and key checks.
833
+
834
+ #### `jsonb.contains`
835
+
836
+ The @> containment operator — tests whether a JSONB column contains the given value.
837
+
838
+ #### `jsonb.containedBy`
839
+
840
+ The <@ contained-by operator — tests whether a JSONB column is contained by the given value.
841
+
842
+ #### `jsonb.hasKey`
843
+
844
+ The ? key-existence operator — tests whether a JSONB column has the given top-level key.