@substrat-run/contracts 0.78.0 → 0.80.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.
@@ -0,0 +1,304 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The ONE error model for every surface on the platform (`docs/rfc/error-model.md`,
4
+ * issue #113): RFC 9457 `application/problem+json`, a CLOSED code taxonomy, and one
5
+ * mapper — replacing the seven hand-rolled `onError` handlers that today choose a
6
+ * status by matching on error message TEXT.
7
+ *
8
+ * Three properties this is built for:
9
+ *
10
+ * - **Machine-readable.** `validation_failed on field 'email'` is recoverable by a
11
+ * client — or by a build agent — without a person reading a log. `500 Something
12
+ * went wrong` is not.
13
+ * - **Documentable.** The same schema that validates a problem body is emitted into
14
+ * `/openapi.json` (`openapi.ts`), so the API surface finally describes how it can
15
+ * FAIL and not only how it succeeds. Decision 22 cashed in again.
16
+ * - **Additive to adopt.** `toProblem` maps an unrecognised throw to `internal` exactly
17
+ * as the hand-rolled handlers do, so each layer could adopt this without a flag day.
18
+ *
19
+ * ## Where the rollout stands
20
+ *
21
+ * Phases 1–3 are in: the taxonomy and `toProblem` (contracts), the kernel's own error
22
+ * classes joined to it, and `wireFailure` — the value an error becomes when it has to
23
+ * cross the ScopeDO boundary, because a throw cannot carry structure across it. What
24
+ * remains is phase 4: the transports reading `code` instead of matching messages, and
25
+ * the deprecated `error` duplicate coming back out of the body.
26
+ */
27
+ /**
28
+ * The base for `type` URIs.
29
+ *
30
+ * DERIVED from the code rather than written per entry, deliberately: whether we
31
+ * actually serve a page at each of these URLs is still open (RFC §6 Q2), and nothing
32
+ * throws a problem yet, so no `type` value has reached a client. Flipping the
33
+ * decision stays a one-line change here for exactly as long as that holds.
34
+ */
35
+ export declare const PROBLEM_TYPE_BASE = "https://substrat.net/errors";
36
+ /**
37
+ * The taxonomy. CLOSED — an open one is a suggestion.
38
+ *
39
+ * A module never invents a code. It narrows an existing one with a `reason` slug it
40
+ * owns (`conflict` + `reason: 'already_exported'`), which is the star topology
41
+ * applied to failure: a vertical branches on an engine's reason without importing
42
+ * the engine's types.
43
+ */
44
+ export declare const errorCode: z.ZodEnum<{
45
+ conflict: "conflict";
46
+ forbidden: "forbidden";
47
+ internal: "internal";
48
+ not_found: "not_found";
49
+ permission_denied: "permission_denied";
50
+ precondition_failed: "precondition_failed";
51
+ rate_limited: "rate_limited";
52
+ unauthenticated: "unauthenticated";
53
+ unavailable: "unavailable";
54
+ validation_failed: "validation_failed";
55
+ }>;
56
+ export type ErrorCode = z.infer<typeof errorCode>;
57
+ /** `permission_denied` → `https://substrat.net/errors/permission-denied`. */
58
+ export declare function problemTypeFor(code: ErrorCode): string;
59
+ /**
60
+ * Status and human title per code. `Record<ErrorCode, …>` on purpose: adding a code
61
+ * without deciding what it means to HTTP is then a compile error, not a 500 found in
62
+ * production.
63
+ */
64
+ export declare const PROBLEM_CATALOG: {
65
+ readonly unauthenticated: {
66
+ readonly status: 401;
67
+ readonly title: 'Unauthenticated';
68
+ };
69
+ readonly permission_denied: {
70
+ readonly status: 403;
71
+ readonly title: 'Permission denied';
72
+ };
73
+ readonly forbidden: {
74
+ readonly status: 403;
75
+ readonly title: 'Forbidden';
76
+ };
77
+ readonly not_found: {
78
+ readonly status: 404;
79
+ readonly title: 'Not found';
80
+ };
81
+ readonly conflict: {
82
+ readonly status: 409;
83
+ readonly title: 'Conflict';
84
+ };
85
+ readonly validation_failed: {
86
+ readonly status: 400;
87
+ readonly title: 'Validation failed';
88
+ };
89
+ readonly precondition_failed: {
90
+ readonly status: 412;
91
+ readonly title: 'Precondition failed';
92
+ };
93
+ readonly rate_limited: {
94
+ readonly status: 429;
95
+ readonly title: 'Rate limited';
96
+ };
97
+ readonly unavailable: {
98
+ readonly status: 503;
99
+ readonly title: 'Service unavailable';
100
+ };
101
+ readonly internal: {
102
+ readonly status: 500;
103
+ readonly title: 'Internal error';
104
+ };
105
+ };
106
+ /** One field-level complaint, mapped from a Zod issue. */
107
+ export declare const validationIssue: z.ZodObject<{
108
+ path: z.ZodString;
109
+ message: z.ZodString;
110
+ }, z.core.$strip>;
111
+ export type ValidationIssue = z.infer<typeof validationIssue>;
112
+ /**
113
+ * The extension members each code may carry — declared per entry, never free-form.
114
+ *
115
+ * These are enforced where it matters: at the THROW site, by `substratError`, which
116
+ * both types and parses them. The wire schema below is one flat object rather than a
117
+ * ten-way discriminated union, because a `oneOf` of ten variants documents worse than
118
+ * one object does and buys a narrowing no client asked for. Per-code narrowing of the
119
+ * emitted document is RFC §6 Q1, deferred with the model layer that would own it.
120
+ */
121
+ export declare const PROBLEM_EXTENSIONS: {
122
+ readonly unauthenticated: z.ZodObject<{}, z.core.$strict>;
123
+ readonly permission_denied: z.ZodObject<{
124
+ permission: z.ZodOptional<z.ZodString>;
125
+ entity: z.ZodOptional<z.ZodObject<{
126
+ entityType: z.ZodString;
127
+ entityId: z.ZodString;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>;
130
+ readonly forbidden: z.ZodObject<{
131
+ reason: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>;
133
+ readonly not_found: z.ZodObject<{}, z.core.$strict>;
134
+ readonly conflict: z.ZodObject<{
135
+ reason: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strip>;
137
+ readonly validation_failed: z.ZodObject<{
138
+ errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
139
+ path: z.ZodString;
140
+ message: z.ZodString;
141
+ }, z.core.$strip>>>;
142
+ }, z.core.$strip>;
143
+ readonly precondition_failed: z.ZodObject<{}, z.core.$strict>;
144
+ readonly rate_limited: z.ZodObject<{
145
+ retryAfter: z.ZodOptional<z.ZodNumber>;
146
+ }, z.core.$strip>;
147
+ readonly unavailable: z.ZodObject<{}, z.core.$strict>;
148
+ readonly internal: z.ZodObject<{}, z.core.$strict>;
149
+ };
150
+ /** The extensions legal on one code, as a type — what `substratError` accepts. */
151
+ export type ExtensionsFor<C extends ErrorCode> = z.infer<(typeof PROBLEM_EXTENSIONS)[C]>;
152
+ /**
153
+ * The wire body. RFC 9457 members, plus `code`, plus every declared extension.
154
+ *
155
+ * `errors.test.ts` asserts this object carries every field any entry of
156
+ * `PROBLEM_EXTENSIONS` declares — the join between the two is checked in CI rather
157
+ * than by remembering to edit both.
158
+ */
159
+ export declare const problem: z.ZodObject<{
160
+ type: z.ZodString;
161
+ title: z.ZodString;
162
+ status: z.ZodNumber;
163
+ detail: z.ZodOptional<z.ZodString>;
164
+ instance: z.ZodOptional<z.ZodString>;
165
+ error: z.ZodOptional<z.ZodString>;
166
+ code: z.ZodEnum<{
167
+ conflict: "conflict";
168
+ forbidden: "forbidden";
169
+ internal: "internal";
170
+ not_found: "not_found";
171
+ permission_denied: "permission_denied";
172
+ precondition_failed: "precondition_failed";
173
+ rate_limited: "rate_limited";
174
+ unauthenticated: "unauthenticated";
175
+ unavailable: "unavailable";
176
+ validation_failed: "validation_failed";
177
+ }>;
178
+ permission: z.ZodOptional<z.ZodString>;
179
+ entity: z.ZodOptional<z.ZodObject<{
180
+ entityType: z.ZodString;
181
+ entityId: z.ZodString;
182
+ }, z.core.$strip>>;
183
+ reason: z.ZodOptional<z.ZodString>;
184
+ errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
185
+ path: z.ZodString;
186
+ message: z.ZodString;
187
+ }, z.core.$strip>>>;
188
+ retryAfter: z.ZodOptional<z.ZodNumber>;
189
+ }, z.core.$strip>;
190
+ export type Problem = z.infer<typeof problem>;
191
+ /**
192
+ * Where a `SubstratError` keeps its code when the class itself is unavailable.
193
+ *
194
+ * `name` is a SECOND reading of the code, not a transport for it. Phase 2 proposed it
195
+ * as the way to cross the `ScopeDO` hop and that was wrong — measured against workerd,
196
+ * a thrown error arrives carrying its message and nothing else, with `name` folded into
197
+ * the message and reset. **Errors cross that boundary as a value now** (`wireFailure`,
198
+ * below), not as a throw.
199
+ *
200
+ * What this prefix still earns: a duplicate copy of a package in one build, a structured
201
+ * clone, or any other place the prototype is gone but the object survives — `errorCodeOf`
202
+ * reads the name and still answers correctly. Cheap, and it costs nothing to keep.
203
+ */
204
+ export declare const ERROR_NAME_PREFIX = "Substrat.";
205
+ /**
206
+ * A throw that already knows what it means.
207
+ *
208
+ * `message` stays the human sentence and nothing more, so logs, stack traces and the
209
+ * contract suite's message assertions all read exactly as they do today. The code
210
+ * rides in `name`, which is what lets it survive the hop.
211
+ */
212
+ export declare class SubstratError extends Error {
213
+ readonly code: ErrorCode;
214
+ readonly status: number;
215
+ readonly extensions: Readonly<Record<string, unknown>>;
216
+ constructor(code: ErrorCode, message: string, extensions?: Record<string, unknown>);
217
+ }
218
+ /**
219
+ * The code a throw carries, however little of it survived.
220
+ *
221
+ * Three readings, in order of fidelity: the live `code` property (same isolate), the
222
+ * `Substrat.<code>` name (crossed a boundary), and the legacy class names above. A
223
+ * throw this cannot classify is not ours, and `toProblem` answers `internal` for it.
224
+ */
225
+ export declare function errorCodeOf(err: unknown): ErrorCode | undefined;
226
+ /**
227
+ * Build a typed error. The extensions are checked against the code at COMPILE time
228
+ * and parsed at runtime, so a `retryAfter` on a `not_found` is caught at the throw
229
+ * site rather than discovered in a response body.
230
+ */
231
+ export declare function substratError<C extends ErrorCode>(code: C, message: string, extensions?: ExtensionsFor<C>): SubstratError;
232
+ /**
233
+ * Recognise one of ours — by shape, never by `instanceof` alone.
234
+ *
235
+ * Two copies of a package in one build already make `instanceof` a coin toss; a
236
+ * serialising boundary makes it a certainty in the wrong direction.
237
+ */
238
+ export declare function isSubstratError(err: unknown): err is SubstratError;
239
+ /** Zod's issue list, flattened to the wire shape. */
240
+ export declare function validationIssuesFrom(error: z.ZodError): ValidationIssue[];
241
+ /**
242
+ * Map any throw onto a problem body and its status — the one function replacing every
243
+ * hand-rolled `onError` and the control plane's regex table.
244
+ *
245
+ * **`internal` never carries `detail`.** An unrecognised throw is by definition one
246
+ * whose message nobody reviewed for what it discloses, and these surfaces have
247
+ * cross-tenant reach. The existing posture is right; this preserves it rather than
248
+ * quietly widening it in the name of better errors.
249
+ */
250
+ export declare function toProblem(err: unknown, instance?: string): Problem;
251
+ /**
252
+ * The statuses an operation can actually answer with today, for the emitted document.
253
+ *
254
+ * `precondition_failed` (412) and `rate_limited` (429) are declared in the taxonomy
255
+ * so that `If-Match` (#129) and rate limiting (#130) add no vocabulary when they
256
+ * land — but nothing raises them yet, and documenting a failure that cannot occur is
257
+ * worse than documenting none. They join this list with the features that raise them.
258
+ *
259
+ * This narrows the RFC's §6 Q1 leaning ("emit the full set") on the same reasoning
260
+ * that motivated the question.
261
+ */
262
+ export declare const DOCUMENTED_ERROR_CODES: readonly ErrorCode[];
263
+ /**
264
+ * An error flattened for a boundary that carries only data — the DO↔coordinator wire
265
+ * (#113 phase 3, `docs/rfc/error-model.md` §3).
266
+ *
267
+ * This exists because a THROW cannot carry structure across the ScopeDO hop: workerd
268
+ * delivers a thrown error's message and nothing else, folding `name` into it and
269
+ * dropping every own property (measured — `adapter-cloudflare`'s contract suite pins
270
+ * it). So the error stops being thrown across the boundary and starts being returned
271
+ * across it, as a value, which is the one shape that survives intact.
272
+ */
273
+ export declare const wireFailure: z.ZodObject<{
274
+ name: z.ZodString;
275
+ message: z.ZodString;
276
+ code: z.ZodOptional<z.ZodEnum<{
277
+ conflict: "conflict";
278
+ forbidden: "forbidden";
279
+ internal: "internal";
280
+ not_found: "not_found";
281
+ permission_denied: "permission_denied";
282
+ precondition_failed: "precondition_failed";
283
+ rate_limited: "rate_limited";
284
+ unauthenticated: "unauthenticated";
285
+ unavailable: "unavailable";
286
+ validation_failed: "validation_failed";
287
+ }>>;
288
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
289
+ }, z.core.$strip>;
290
+ export type WireFailure = z.infer<typeof wireFailure>;
291
+ /** Flatten a throw for the wire, losing nothing this side of the boundary knows. */
292
+ export declare function toWireFailure(err: unknown): WireFailure;
293
+ /**
294
+ * Rebuild a throw from the wire.
295
+ *
296
+ * The rebuilt error is a `SubstratError` carrying the original `name`, NOT an instance
297
+ * of the original class — contracts cannot import the kernel, and reviving arbitrary
298
+ * classes over a wire is a capability nobody should want. That is enough for every
299
+ * consumer in the repo, because they all read the code or the name, never the
300
+ * constructor. `instanceof PermissionDenied` stays false here and always will; it is
301
+ * the wrong question, and `errorCodeOf` is the right one.
302
+ */
303
+ export declare function fromWireFailure(failure: WireFailure): Error;
304
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,gCAAgC,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;EAWpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe;;iBACP,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,iBAAiB;;;iBACnC,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,mBAAmB;;;iBAC/C,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,WAAW;;;iBAC/B,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,WAAW;;;iBAChC,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,UAAU;;;iBACrB,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,mBAAmB;;;iBACrC,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,qBAAqB;;;iBAChD,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,cAAc;;;iBACnC,MAAM,EAAE,GAAG;iBAAE,KAAK,EAAE,qBAAqB;;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ACf,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAC5B,aAAa,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAElE;AAED,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,eAAe,EAAE,CAKzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAelE;AAoBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,SAAS,EAStD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;iBAOtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAUvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,KAAK,CAO3D"}
package/dist/errors.js ADDED
@@ -0,0 +1,352 @@
1
+ import { z } from 'zod';
2
+ import { entityRef } from './events.js';
3
+ /**
4
+ * The ONE error model for every surface on the platform (`docs/rfc/error-model.md`,
5
+ * issue #113): RFC 9457 `application/problem+json`, a CLOSED code taxonomy, and one
6
+ * mapper — replacing the seven hand-rolled `onError` handlers that today choose a
7
+ * status by matching on error message TEXT.
8
+ *
9
+ * Three properties this is built for:
10
+ *
11
+ * - **Machine-readable.** `validation_failed on field 'email'` is recoverable by a
12
+ * client — or by a build agent — without a person reading a log. `500 Something
13
+ * went wrong` is not.
14
+ * - **Documentable.** The same schema that validates a problem body is emitted into
15
+ * `/openapi.json` (`openapi.ts`), so the API surface finally describes how it can
16
+ * FAIL and not only how it succeeds. Decision 22 cashed in again.
17
+ * - **Additive to adopt.** `toProblem` maps an unrecognised throw to `internal` exactly
18
+ * as the hand-rolled handlers do, so each layer could adopt this without a flag day.
19
+ *
20
+ * ## Where the rollout stands
21
+ *
22
+ * Phases 1–3 are in: the taxonomy and `toProblem` (contracts), the kernel's own error
23
+ * classes joined to it, and `wireFailure` — the value an error becomes when it has to
24
+ * cross the ScopeDO boundary, because a throw cannot carry structure across it. What
25
+ * remains is phase 4: the transports reading `code` instead of matching messages, and
26
+ * the deprecated `error` duplicate coming back out of the body.
27
+ */
28
+ /**
29
+ * The base for `type` URIs.
30
+ *
31
+ * DERIVED from the code rather than written per entry, deliberately: whether we
32
+ * actually serve a page at each of these URLs is still open (RFC §6 Q2), and nothing
33
+ * throws a problem yet, so no `type` value has reached a client. Flipping the
34
+ * decision stays a one-line change here for exactly as long as that holds.
35
+ */
36
+ export const PROBLEM_TYPE_BASE = 'https://substrat.net/errors';
37
+ /**
38
+ * The taxonomy. CLOSED — an open one is a suggestion.
39
+ *
40
+ * A module never invents a code. It narrows an existing one with a `reason` slug it
41
+ * owns (`conflict` + `reason: 'already_exported'`), which is the star topology
42
+ * applied to failure: a vertical branches on an engine's reason without importing
43
+ * the engine's types.
44
+ */
45
+ export const errorCode = z.enum([
46
+ 'unauthenticated',
47
+ 'permission_denied',
48
+ 'forbidden',
49
+ 'not_found',
50
+ 'conflict',
51
+ 'validation_failed',
52
+ 'precondition_failed',
53
+ 'rate_limited',
54
+ 'unavailable',
55
+ 'internal',
56
+ ]);
57
+ /** `permission_denied` → `https://substrat.net/errors/permission-denied`. */
58
+ export function problemTypeFor(code) {
59
+ return `${PROBLEM_TYPE_BASE}/${code.replaceAll('_', '-')}`;
60
+ }
61
+ /**
62
+ * Status and human title per code. `Record<ErrorCode, …>` on purpose: adding a code
63
+ * without deciding what it means to HTTP is then a compile error, not a 500 found in
64
+ * production.
65
+ */
66
+ export const PROBLEM_CATALOG = {
67
+ unauthenticated: { status: 401, title: 'Unauthenticated' },
68
+ permission_denied: { status: 403, title: 'Permission denied' },
69
+ forbidden: { status: 403, title: 'Forbidden' },
70
+ not_found: { status: 404, title: 'Not found' },
71
+ conflict: { status: 409, title: 'Conflict' },
72
+ validation_failed: { status: 400, title: 'Validation failed' },
73
+ precondition_failed: { status: 412, title: 'Precondition failed' },
74
+ rate_limited: { status: 429, title: 'Rate limited' },
75
+ unavailable: { status: 503, title: 'Service unavailable' },
76
+ internal: { status: 500, title: 'Internal error' },
77
+ };
78
+ /** One field-level complaint, mapped from a Zod issue. */
79
+ export const validationIssue = z.object({
80
+ /** Dotted path into the input: `lines.0.quantity`. Empty for a root-level issue. */
81
+ path: z.string(),
82
+ message: z.string(),
83
+ });
84
+ /**
85
+ * The extension members each code may carry — declared per entry, never free-form.
86
+ *
87
+ * These are enforced where it matters: at the THROW site, by `substratError`, which
88
+ * both types and parses them. The wire schema below is one flat object rather than a
89
+ * ten-way discriminated union, because a `oneOf` of ten variants documents worse than
90
+ * one object does and buys a narrowing no client asked for. Per-code narrowing of the
91
+ * emitted document is RFC §6 Q1, deferred with the model layer that would own it.
92
+ */
93
+ export const PROBLEM_EXTENSIONS = {
94
+ unauthenticated: z.strictObject({}),
95
+ permission_denied: z.object({
96
+ /** The permission key the check refused. */
97
+ permission: z.string().min(1).optional(),
98
+ /** Set when the refusal was a per-entity check rather than a node-level one. */
99
+ entity: entityRef.optional(),
100
+ }),
101
+ forbidden: z.object({ reason: z.string().min(1).optional() }),
102
+ not_found: z.strictObject({}),
103
+ conflict: z.object({ reason: z.string().min(1).optional() }),
104
+ validation_failed: z.object({ errors: z.array(validationIssue).optional() }),
105
+ precondition_failed: z.strictObject({}),
106
+ rate_limited: z.object({ retryAfter: z.number().int().nonnegative().optional() }),
107
+ unavailable: z.strictObject({}),
108
+ internal: z.strictObject({}),
109
+ };
110
+ /**
111
+ * The wire body. RFC 9457 members, plus `code`, plus every declared extension.
112
+ *
113
+ * `errors.test.ts` asserts this object carries every field any entry of
114
+ * `PROBLEM_EXTENSIONS` declares — the join between the two is checked in CI rather
115
+ * than by remembering to edit both.
116
+ */
117
+ export const problem = z.object({
118
+ /** Canonical identifier. Resolves — an error that documents itself. */
119
+ type: z.string().min(1),
120
+ /** Short, human, and STABLE per code — clients may group on it, so it does not vary. */
121
+ title: z.string().min(1),
122
+ /** Duplicated from the HTTP status line, per RFC 9457 §3.1.2. */
123
+ status: z.number().int(),
124
+ /** What went wrong THIS time. Absent on `internal`, always — see `toProblem`. */
125
+ detail: z.string().optional(),
126
+ /** The request this refers to, when a transport knows it. */
127
+ instance: z.string().optional(),
128
+ /**
129
+ * DEPRECATED duplicate of `detail`, for one migration window.
130
+ *
131
+ * Every SPA in the repo reads `{ error }` today. RFC 9457 permits extension
132
+ * members, so carrying this lets the transports adopt problem+json without
133
+ * breaking a single client — which is what makes the rollout's phase 3 a
134
+ * non-event. Removed once the clients are moved, not "eventually".
135
+ */
136
+ error: z.string().optional(),
137
+ code: errorCode,
138
+ // -- declared extensions (see PROBLEM_EXTENSIONS) ---------------------------
139
+ permission: z.string().min(1).optional(),
140
+ entity: entityRef.optional(),
141
+ reason: z.string().min(1).optional(),
142
+ errors: z.array(validationIssue).optional(),
143
+ retryAfter: z.number().int().nonnegative().optional(),
144
+ });
145
+ /**
146
+ * Where a `SubstratError` keeps its code when the class itself is unavailable.
147
+ *
148
+ * `name` is a SECOND reading of the code, not a transport for it. Phase 2 proposed it
149
+ * as the way to cross the `ScopeDO` hop and that was wrong — measured against workerd,
150
+ * a thrown error arrives carrying its message and nothing else, with `name` folded into
151
+ * the message and reset. **Errors cross that boundary as a value now** (`wireFailure`,
152
+ * below), not as a throw.
153
+ *
154
+ * What this prefix still earns: a duplicate copy of a package in one build, a structured
155
+ * clone, or any other place the prototype is gone but the object survives — `errorCodeOf`
156
+ * reads the name and still answers correctly. Cheap, and it costs nothing to keep.
157
+ */
158
+ export const ERROR_NAME_PREFIX = 'Substrat.';
159
+ /**
160
+ * Class names that predate the taxonomy and already mean a code.
161
+ *
162
+ * Keeping `PermissionDenied` named `PermissionDenied` rather than renaming it to the
163
+ * generic form is deliberate: `vertical-host`'s classifier and several verticals match
164
+ * on that exact string today, and a rename would be a silent behaviour change bundled
165
+ * into a refactor. `ZodError` earns its row because a parse failure crossing the hop
166
+ * loses its `issues` array — the code is all that is left, and `validation_failed`
167
+ * without fields still beats `internal`.
168
+ */
169
+ const CODE_BY_ERROR_NAME = {
170
+ PermissionDenied: 'permission_denied',
171
+ SecretBoxUnconfiguredError: 'unavailable',
172
+ ZodError: 'validation_failed',
173
+ };
174
+ /**
175
+ * A throw that already knows what it means.
176
+ *
177
+ * `message` stays the human sentence and nothing more, so logs, stack traces and the
178
+ * contract suite's message assertions all read exactly as they do today. The code
179
+ * rides in `name`, which is what lets it survive the hop.
180
+ */
181
+ export class SubstratError extends Error {
182
+ code;
183
+ status;
184
+ extensions;
185
+ constructor(code, message, extensions = {}) {
186
+ super(message);
187
+ this.name = `${ERROR_NAME_PREFIX}${code}`;
188
+ this.code = code;
189
+ this.status = PROBLEM_CATALOG[code].status;
190
+ this.extensions = extensions;
191
+ }
192
+ }
193
+ /**
194
+ * The code a throw carries, however little of it survived.
195
+ *
196
+ * Three readings, in order of fidelity: the live `code` property (same isolate), the
197
+ * `Substrat.<code>` name (crossed a boundary), and the legacy class names above. A
198
+ * throw this cannot classify is not ours, and `toProblem` answers `internal` for it.
199
+ */
200
+ export function errorCodeOf(err) {
201
+ if (err === null || typeof err !== 'object')
202
+ return undefined;
203
+ const own = err.code;
204
+ if (typeof own === 'string') {
205
+ const parsed = errorCode.safeParse(own);
206
+ if (parsed.success)
207
+ return parsed.data;
208
+ }
209
+ const name = err.name;
210
+ if (typeof name !== 'string')
211
+ return undefined;
212
+ if (name.startsWith(ERROR_NAME_PREFIX)) {
213
+ const parsed = errorCode.safeParse(name.slice(ERROR_NAME_PREFIX.length));
214
+ if (parsed.success)
215
+ return parsed.data;
216
+ }
217
+ return CODE_BY_ERROR_NAME[name];
218
+ }
219
+ /**
220
+ * Build a typed error. The extensions are checked against the code at COMPILE time
221
+ * and parsed at runtime, so a `retryAfter` on a `not_found` is caught at the throw
222
+ * site rather than discovered in a response body.
223
+ */
224
+ export function substratError(code, message, extensions) {
225
+ const parsed = PROBLEM_EXTENSIONS[code].parse(extensions ?? {});
226
+ return new SubstratError(code, message, parsed);
227
+ }
228
+ /**
229
+ * Recognise one of ours — by shape, never by `instanceof` alone.
230
+ *
231
+ * Two copies of a package in one build already make `instanceof` a coin toss; a
232
+ * serialising boundary makes it a certainty in the wrong direction.
233
+ */
234
+ export function isSubstratError(err) {
235
+ return err instanceof Error && errorCodeOf(err) !== undefined;
236
+ }
237
+ /** Zod's issue list, flattened to the wire shape. */
238
+ export function validationIssuesFrom(error) {
239
+ return error.issues.map((issue) => ({
240
+ path: issue.path.map(String).join('.'),
241
+ message: issue.message,
242
+ }));
243
+ }
244
+ /**
245
+ * Map any throw onto a problem body and its status — the one function replacing every
246
+ * hand-rolled `onError` and the control plane's regex table.
247
+ *
248
+ * **`internal` never carries `detail`.** An unrecognised throw is by definition one
249
+ * whose message nobody reviewed for what it discloses, and these surfaces have
250
+ * cross-tenant reach. The existing posture is right; this preserves it rather than
251
+ * quietly widening it in the name of better errors.
252
+ */
253
+ export function toProblem(err, instance) {
254
+ if (err instanceof z.ZodError) {
255
+ return build('validation_failed', 'the input did not parse', instance, {
256
+ errors: validationIssuesFrom(err),
257
+ });
258
+ }
259
+ const code = errorCodeOf(err);
260
+ if (code !== undefined && err instanceof Error) {
261
+ // `internal` is still generic even when a throw asked for it by name: the rule is
262
+ // about what reaches a client, not about who chose the code.
263
+ if (code === 'internal')
264
+ return build('internal', undefined, instance);
265
+ const extensions = err.extensions ?? {};
266
+ return build(code, err.message, instance, extensions);
267
+ }
268
+ return build('internal', undefined, instance);
269
+ }
270
+ function build(code, detail, instance, extensions = {}) {
271
+ const { status, title } = PROBLEM_CATALOG[code];
272
+ return problem.parse({
273
+ type: problemTypeFor(code),
274
+ title,
275
+ status,
276
+ ...(detail === undefined ? {} : { detail, error: detail }),
277
+ ...(instance === undefined ? {} : { instance }),
278
+ code,
279
+ ...extensions,
280
+ });
281
+ }
282
+ /**
283
+ * The statuses an operation can actually answer with today, for the emitted document.
284
+ *
285
+ * `precondition_failed` (412) and `rate_limited` (429) are declared in the taxonomy
286
+ * so that `If-Match` (#129) and rate limiting (#130) add no vocabulary when they
287
+ * land — but nothing raises them yet, and documenting a failure that cannot occur is
288
+ * worse than documenting none. They join this list with the features that raise them.
289
+ *
290
+ * This narrows the RFC's §6 Q1 leaning ("emit the full set") on the same reasoning
291
+ * that motivated the question.
292
+ */
293
+ export const DOCUMENTED_ERROR_CODES = [
294
+ 'validation_failed',
295
+ 'unauthenticated',
296
+ 'permission_denied',
297
+ 'forbidden',
298
+ 'not_found',
299
+ 'conflict',
300
+ 'unavailable',
301
+ 'internal',
302
+ ];
303
+ /**
304
+ * An error flattened for a boundary that carries only data — the DO↔coordinator wire
305
+ * (#113 phase 3, `docs/rfc/error-model.md` §3).
306
+ *
307
+ * This exists because a THROW cannot carry structure across the ScopeDO hop: workerd
308
+ * delivers a thrown error's message and nothing else, folding `name` into it and
309
+ * dropping every own property (measured — `adapter-cloudflare`'s contract suite pins
310
+ * it). So the error stops being thrown across the boundary and starts being returned
311
+ * across it, as a value, which is the one shape that survives intact.
312
+ */
313
+ export const wireFailure = z.object({
314
+ /** The original `name`, so `PermissionDenied` still reads as itself on the far side. */
315
+ name: z.string().min(1),
316
+ message: z.string(),
317
+ /** Absent when the throw was never ours — a bare `Error` stays a bare `Error`. */
318
+ code: errorCode.optional(),
319
+ extensions: z.record(z.string(), z.unknown()).optional(),
320
+ });
321
+ /** Flatten a throw for the wire, losing nothing this side of the boundary knows. */
322
+ export function toWireFailure(err) {
323
+ if (!(err instanceof Error))
324
+ return { name: 'Error', message: String(err) };
325
+ const code = errorCodeOf(err);
326
+ if (code === undefined)
327
+ return { name: err.name, message: err.message };
328
+ return {
329
+ name: err.name,
330
+ message: err.message,
331
+ code,
332
+ extensions: { ...(err.extensions ?? {}) },
333
+ };
334
+ }
335
+ /**
336
+ * Rebuild a throw from the wire.
337
+ *
338
+ * The rebuilt error is a `SubstratError` carrying the original `name`, NOT an instance
339
+ * of the original class — contracts cannot import the kernel, and reviving arbitrary
340
+ * classes over a wire is a capability nobody should want. That is enough for every
341
+ * consumer in the repo, because they all read the code or the name, never the
342
+ * constructor. `instanceof PermissionDenied` stays false here and always will; it is
343
+ * the wrong question, and `errorCodeOf` is the right one.
344
+ */
345
+ export function fromWireFailure(failure) {
346
+ const err = failure.code === undefined
347
+ ? new Error(failure.message)
348
+ : new SubstratError(failure.code, failure.message, { ...(failure.extensions ?? {}) });
349
+ err.name = failure.name;
350
+ return err;
351
+ }
352
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9B,iBAAiB;IACjB,mBAAmB;IACnB,WAAW;IACX,WAAW;IACX,UAAU;IACV,mBAAmB;IACnB,qBAAqB;IACrB,cAAc;IACd,aAAa;IACb,UAAU;CACX,CAAC,CAAC;AAGH,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,IAAe;IAC5C,OAAO,GAAG,iBAAiB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe,EAAE,EAAE,MA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G,CAAC,CAAC;IAC9B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IACxE,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI;QACJ,UAAU,EAAE,EAAE,GAAG,CAAE,GAAqB,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE;KAC7D,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,MAAM,GAAG,GACP,OAAO,CAAC,IAAI,KAAK,SAAS;QACxB,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAC5B,CAAC,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1F,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export * from './connections.js';
27
27
  export * from './control-plane.js';
28
28
  export * from './permission.js';
29
29
  export * from './events.js';
30
+ export * from './errors.js';
30
31
  export * from './platform-request.js';
31
32
  export * from './manifest.js';
32
33
  export * from './openapi.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ export * from './connections.js';
27
27
  export * from './control-plane.js';
28
28
  export * from './permission.js';
29
29
  export * from './events.js';
30
+ export * from './errors.js';
30
31
  export * from './platform-request.js';
31
32
  export * from './manifest.js';
32
33
  export * from './openapi.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
package/dist/openapi.d.ts CHANGED
@@ -43,6 +43,16 @@ export interface ApiOperationDoc {
43
43
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
44
44
  path: string;
45
45
  };
46
+ /**
47
+ * Declared by a paged read (#811). `output` then carries the ENTRY schema, and this
48
+ * builder emits the query parameters and the `{ entries, nextCursor }` envelope —
49
+ * so the wrapper is written once here rather than restated by every list operation.
50
+ */
51
+ paged?: {
52
+ sortKey: string;
53
+ order?: 'asc' | 'desc';
54
+ total?: boolean;
55
+ };
46
56
  }
47
57
  /** operation name (module-namespaced, e.g. 'hr/create-employee') → its doc. */
48
58
  export type ApiCatalog = Record<string, ApiOperationDoc>;
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mFAAmF;IACnF,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9E;AAED,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe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M,CAAA;KAAE,CAAC;IAC7E;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACtE;AAED,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA4ED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,UAAU,GAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+GzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5C,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAM,GAC3E,UAAU,CA2BZ"}
package/dist/openapi.js CHANGED
@@ -1,10 +1,63 @@
1
1
  import { z } from 'zod';
2
- const ERROR_RESPONSES = {
3
- '400': { description: 'Validation failed the input did not parse against the operation schema.' },
4
- '401': { description: 'No session sign in (or present a bearer token) first.' },
5
- '403': { description: 'Permission denied — the caller lacks the permission this operation checks.' },
6
- '404': { description: 'Unknown operation, or an entity named in the input does not exist.' },
2
+ import { LIST_PAGE_DEFAULT, LIST_PAGE_MAX, pageSchema } from './pagination.js';
3
+ import { DOCUMENTED_ERROR_CODES, PROBLEM_CATALOG, problem, } from './errors.js';
4
+ /** Where the one problem schema lives in the document, referenced from every failure. */
5
+ const PROBLEM_SCHEMA_REF = '#/components/schemas/Problem';
6
+ /**
7
+ * Prose per status. Generated descriptions would read like a type listing; these say
8
+ * what the caller should conclude, which is the half a schema cannot carry.
9
+ */
10
+ const ERROR_STATUS_PROSE = {
11
+ 400: 'Validation failed — the input did not parse against the operation schema.',
12
+ 401: 'No session — sign in (or present a bearer token) first.',
13
+ 403: 'Refused — the caller lacks the permission this operation checks, or policy forbids it.',
14
+ 404: 'Unknown operation, or an entity named in the input does not exist.',
15
+ 409: 'Conflicts with current state — an illegal transition, a name already taken, or a record that is immutable now.',
16
+ 500: 'Internal error. The body carries no `detail`, deliberately — an unreviewed message is not disclosed on a multi-tenant surface.',
17
+ 503: 'The deployment cannot serve this — a required platform facility is unconfigured.',
18
+ };
19
+ /** Component name per documented status — `403` → `#/components/responses/Forbidden`. */
20
+ const ERROR_RESPONSE_NAME = {
21
+ 400: 'ValidationFailed',
22
+ 401: 'Unauthenticated',
23
+ 403: 'Forbidden',
24
+ 404: 'NotFound',
25
+ 409: 'Conflict',
26
+ 500: 'InternalError',
27
+ 503: 'Unavailable',
7
28
  };
29
+ /**
30
+ * The failure half of every operation, derived from the error taxonomy (#113).
31
+ *
32
+ * Bodies are `application/problem+json` (RFC 9457). Both the schema AND the responses
33
+ * themselves live in `components` and are referenced, which is what keeps the
34
+ * checked-in artifact readable: a vertical with 27 operations gains three lines per
35
+ * failure rather than a fully inlined body per failure per operation. `api-diff`'s
36
+ * document is a review artifact, so its signal-to-noise is a real constraint.
37
+ *
38
+ * Every operation currently documents the same set. Narrowing it per operation — a
39
+ * `409` only where a conflict is actually reachable — wants the model layer to own
40
+ * the declaration, and is deferred with it (error-model RFC §6 Q1).
41
+ */
42
+ const DOCUMENTED_STATUSES = [
43
+ ...new Set(DOCUMENTED_ERROR_CODES.map((code) => PROBLEM_CATALOG[code].status)),
44
+ ].sort((a, b) => a - b);
45
+ const ERROR_RESPONSES = Object.fromEntries(DOCUMENTED_STATUSES.map((status) => [
46
+ String(status),
47
+ { $ref: `#/components/responses/${ERROR_RESPONSE_NAME[status]}` },
48
+ ]));
49
+ /** The definitions those references point at, written once per document. */
50
+ const ERROR_RESPONSE_COMPONENTS = Object.fromEntries(DOCUMENTED_STATUSES.map((status) => {
51
+ const codes = DOCUMENTED_ERROR_CODES.filter((code) => PROBLEM_CATALOG[code].status === status);
52
+ const codeList = codes.map((code) => `\`${code}\``).join(' or ');
53
+ return [
54
+ ERROR_RESPONSE_NAME[status],
55
+ {
56
+ description: `${ERROR_STATUS_PROSE[status]} Carries \`code\`: ${codeList}.`,
57
+ content: { 'application/problem+json': { schema: { $ref: PROBLEM_SCHEMA_REF } } },
58
+ },
59
+ ];
60
+ }));
8
61
  // The per-schema `$schema` key is dropped: OpenAPI 3.1's document-wide dialect
9
62
  // IS draft 2020-12, so repeating it on every request body is pure noise.
10
63
  const jsonSchema = (schema, io) => {
@@ -29,6 +82,30 @@ export function buildOpenApiDocument(info, catalog) {
29
82
  required: true,
30
83
  schema: { type: 'string' },
31
84
  }));
85
+ // A paged read advertises the walk itself (#811). Written here rather than by each
86
+ // operation: the convention is the platform's, so restating it twelve times per
87
+ // vertical is twelve chances to state it differently.
88
+ if (op.paged) {
89
+ params.push({
90
+ name: 'limit',
91
+ in: 'query',
92
+ required: false,
93
+ description: `Page size. Defaults to ${LIST_PAGE_DEFAULT}, capped at ${LIST_PAGE_MAX}.`,
94
+ schema: { type: 'integer', minimum: 1, maximum: LIST_PAGE_MAX, default: LIST_PAGE_DEFAULT },
95
+ }, {
96
+ name: 'cursor',
97
+ in: 'query',
98
+ required: false,
99
+ description: `The previous page's \`nextCursor\`. Keyset over \`${op.paged.sortKey}\` — exclusive, so no row is repeated.`,
100
+ schema: { type: 'string' },
101
+ }, {
102
+ name: 'order',
103
+ in: 'query',
104
+ required: false,
105
+ description: 'Walk direction.',
106
+ schema: { type: 'string', enum: ['asc', 'desc'], default: op.paged.order ?? 'asc' },
107
+ });
108
+ }
32
109
  const existing = (paths[url] ?? {});
33
110
  paths[url] = {
34
111
  ...existing,
@@ -48,9 +125,19 @@ export function buildOpenApiDocument(info, catalog) {
48
125
  : {}),
49
126
  responses: {
50
127
  '200': {
51
- description: 'The operation result.',
128
+ description: op.paged
129
+ ? op.paged.total
130
+ ? 'One page of results, with the total matching this list’s filter.'
131
+ : 'One page of results.'
132
+ : 'The operation result.',
52
133
  ...(op.output
53
- ? { content: { 'application/json': { schema: jsonSchema(op.output, 'output') } } }
134
+ ? {
135
+ content: {
136
+ 'application/json': {
137
+ schema: jsonSchema(op.paged ? pageSchema(op.output, op.paged.total === true) : op.output, 'output'),
138
+ },
139
+ },
140
+ }
54
141
  : {}),
55
142
  },
56
143
  ...ERROR_RESPONSES,
@@ -63,6 +150,11 @@ export function buildOpenApiDocument(info, catalog) {
63
150
  info,
64
151
  paths,
65
152
  components: {
153
+ // One problem schema, referenced by every failure response above — the same
154
+ // object `toProblem` builds and validates, so the documented failure shape
155
+ // cannot drift from the emitted one.
156
+ schemas: { Problem: jsonSchema(problem, 'output') },
157
+ responses: ERROR_RESPONSE_COMPONENTS,
66
158
  securitySchemes: {
67
159
  // The primary path: the vertical's own session cookie. Same-origin
68
160
  // try-it (the /api/docs page) rides it automatically — the browser
@@ -118,6 +210,9 @@ export function apiCatalogFrom(operations, prose = {}) {
118
210
  ...(op.http
119
211
  ? { http: op.http }
120
212
  : {}),
213
+ ...(op.paged
214
+ ? { paged: op.paged }
215
+ : {}),
121
216
  };
122
217
  }
123
218
  return catalog;
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwDxB,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,EAAE,WAAW,EAAE,2EAA2E,EAAE;IACnG,KAAK,EAAE,EAAE,WAAW,EAAE,yDAAyD,EAAE;IACjF,KAAK,EAAE,EAAE,WAAW,EAAE,4EAA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CAAC;YACxC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpD,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAE,EAAyC,CAAC,IAAI;gBACjD,CAAC,CAAC,EAAE,IAAI,EAAG,EAAqD,CAAC,IAAI,EAAE;gBACvE,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAE,EAA2C,CAAC,KAAK;gBACpD,CAAC,CAAC,EAAE,KAAK,EAAG,EAAuD,CAAC,KAAK,EAAE;gBAC3E,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -20,6 +20,7 @@
20
20
  * schema language would need the shape written twice, and transcription is what
21
21
  * produced 40 wrong argument names in the one app where this was measured.
22
22
  */
23
+ import type { CountedPage, Page } from './pagination.js';
23
24
  import { z } from 'zod';
24
25
  import type { EntityDef } from './model.js';
25
26
  /** `{var}` names in a literal path. */
@@ -199,6 +200,40 @@ type OperationShape<O, Entities, Engines, PermKey extends string> = {
199
200
  readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
200
201
  readonly path: CheckedPath<O>;
201
202
  };
203
+ /**
204
+ * This read returns a PAGE, not the whole table (#811, #129).
205
+ *
206
+ * A list endpoint that returns everything is a bug with a delay on it: it passes
207
+ * review, it passes tests, and then one tenant's table gets large. Declaring
208
+ * `paged` is what lets that be caught mechanically rather than noticed.
209
+ *
210
+ * When present, `output` declares the **entry** shape and the platform wraps it:
211
+ * the emitted document gains `limit` / `cursor` / `order` query parameters and a
212
+ * `{ entries, nextCursor }` envelope, and the handler returns `Page<Entry>`
213
+ * (`pageOf` builds one). Declaring the entry rather than the envelope is what
214
+ * keeps `sortKey` checkable and stops twelve operations from restating the same
215
+ * wrapper.
216
+ *
217
+ * `sortKey` names the output field the cursor walks — the same compile-checked
218
+ * join as `entityIdFrom`, and for the same reason: a cursor over a field the
219
+ * entry does not have is a page that silently skips or repeats rows, and nothing
220
+ * downstream would ever flag it. Keyset, never offset: on live data an offset
221
+ * shifts between requests, so pages drop and duplicate.
222
+ */
223
+ readonly paged?: {
224
+ readonly sortKey: OutputKeys<O>;
225
+ /** Walk direction. Defaults to `asc`; a feed reading newest-first says `desc`. */
226
+ readonly order?: 'asc' | 'desc';
227
+ /**
228
+ * Also return `total` — the count of rows matching this list's filter.
229
+ *
230
+ * Opt-in, because a keyset page cannot produce one for free: it is a second
231
+ * query per request. Say `true` where a screen renders `1–20 of 340`, which in
232
+ * business software is most tables and in a feed is none of them. The handler
233
+ * must then return `countedPageOf`, and the compiler holds it to that.
234
+ */
235
+ readonly total?: boolean;
236
+ };
202
237
  readonly emits?: {
203
238
  /**
204
239
  * The entity the event is about — one of THIS module's entities, or one of a
@@ -421,5 +456,39 @@ type PathAgainst<Op, P> = P extends string ? [PathParams<P>] extends [InputKeys<
421
456
  export declare function defineEngineRoutes<const Ops extends Record<string, object>>(operations: Ops): <const R extends { readonly [K in keyof R]: K extends keyof Ops ? EngineRouteBinding<Ops[K], R[K]> : never; }>(routes: R) => { [K in keyof R]: (K extends keyof Ops ? Ops[K] : never) & {
422
457
  http: R[K];
423
458
  }; };
459
+ /**
460
+ * The input and output a HANDLER must have, derived from its declaration.
461
+ *
462
+ * These exist so a vertical writes the `satisfies` clause once against the model
463
+ * instead of restating how a declaration maps to a handler signature — and, more to
464
+ * the point, so `paged` is understood in ONE place. A paged read declares its ENTRY
465
+ * shape and returns a `Page` of it; deriving that in each vertical's module file
466
+ * would mean each vertical could get it wrong, and one that did would typecheck
467
+ * against an envelope it never returns.
468
+ *
469
+ * `OperationHandler` itself stays in the kernel (contracts cannot import it, and does
470
+ * not need to) — these describe only the two type arguments.
471
+ *
472
+ * ```ts
473
+ * } satisfies {
474
+ * [K in keyof typeof todoOperations]: OperationHandler<
475
+ * HandlerInput<(typeof todoOperations)[K]>,
476
+ * HandlerOutput<(typeof todoOperations)[K]>
477
+ * >;
478
+ * };
479
+ * ```
480
+ */
481
+ export type HandlerInput<O> = O extends {
482
+ input: infer I;
483
+ } ? I extends z.ZodType ? z.infer<I> : undefined : undefined;
484
+ export type HandlerOutput<O> = O extends {
485
+ output: infer R;
486
+ } ? R extends z.ZodType ? O extends {
487
+ paged: {
488
+ total: true;
489
+ };
490
+ } ? CountedPage<z.infer<R>> : O extends {
491
+ paged: unknown;
492
+ } ? Page<z.infer<R>> : z.infer<R> : unknown : unknown;
424
493
  export {};
425
494
  //# sourceMappingURL=operations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,uCAAuC;AACvC,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GAC9E,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GACpB,KAAK,CAAC;AAEV,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CA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AAO,GACjB,CAAC,SAAS;IAAE,KAAK,EAAE;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,CAAA;CAAE,GAClC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GACvB,CAAC,SAAS;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAC1B,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAChB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACd,OAAO,GACT,OAAO,CAAC"}
@@ -1,25 +1,3 @@
1
- /**
2
- * The operation surface of the model (#707).
3
- *
4
- * #697 declared the entities. This declares what can be *done* to them, and
5
- * checks the joins that today are unchecked strings: which permission an
6
- * operation requires, which output field an event takes its subject from,
7
- * whether a payload carries something an erasure must be able to reach.
8
- *
9
- * ## A composer, not a second `defineModel`
10
- *
11
- * `defineOperations` sits beside `defineEntities` rather than swallowing it.
12
- * Each half stays independently adoptable — which is what let the entity half
13
- * ship and be taken up by two verticals before this existed. A vertical adopts
14
- * operations when it is ready, not as the price of adopting entities.
15
- *
16
- * ## `input`, and the transcription that is not here
17
- *
18
- * `input` is the Zod object the handler already parses — the same object, not a
19
- * description of it. That is the whole reason the model is TypeScript (#680): a
20
- * schema language would need the shape written twice, and transcription is what
21
- * produced 40 wrong argument names in the one app where this was measured.
22
- */
23
1
  import { z } from 'zod';
24
2
  // ---------------------------------------------------------------------------
25
3
  // The composer.
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsQxB,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,gBAAgB,CAI9B,SAAmB,EAAE,YAAmB,EAAE,QAAkB;IAC5D,OAAO,CA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S,CAAC,GAAG,CAAW,EAAE,CAAC,CAAC;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC;YAClC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAClF;KACF,CAAC;AACJ,CAAC;AA4BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,kBAAkB,CAA2C,UAAe;IAC1F,OAAO,CACL,MAAS,EACoE,EAAE;QAC/E,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,EAAE,GAAG,UAAU,CAAC,IAAiB,CAAC,CAAC;YACzC,2EAA2E;YAC3E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,sEAAsE;YACtE,wDAAwD;YACxD,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,KAAK,CACb,wBAAwB,IAAI,qDAAqD;oBAC/E,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjD,CAAC;YACJ,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAI,EAAa,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,GAAkF,CAAC;IAC5F,CAAC,CAAC;AACJ,CAAC"}
@@ -51,10 +51,48 @@ export interface Page<T> {
51
51
  entries: T[];
52
52
  nextCursor: string | null;
53
53
  }
54
+ /**
55
+ * A page that also knows how many rows the walk covers — `1–20 of 340`.
56
+ *
57
+ * Opt-in per operation, because it is not free: keyset paging gives no total for
58
+ * free (that is the trade for correctness under concurrent writes), so a total is a
59
+ * SECOND query on every request. Business software asks for it constantly — a list
60
+ * of work orders or invoices with no count reads as broken to an office admin — so
61
+ * the platform supports it rather than pretending nobody needs it. It just refuses
62
+ * to charge every list for it.
63
+ *
64
+ * `total` counts the FILTERED set — the same `WHERE` the page ran under, never the
65
+ * table. A count of the whole table beside a filtered page is a number that is
66
+ * wrong in a way nobody notices until a customer does.
67
+ *
68
+ * It is also a snapshot: rows may be inserted or deleted mid-walk, so a total read
69
+ * on page one can disagree with the rows eventually seen. That is inherent to
70
+ * counting a moving set, not a defect to design around.
71
+ */
72
+ export interface CountedPage<T> extends Page<T> {
73
+ total: number;
74
+ }
54
75
  /**
55
76
  * Wrap a just-read page. `nextCursor` is the last entry's sort key when the
56
77
  * page came back full (there MAY be more), null when it came back short (the
57
78
  * walk is done — no trailing empty fetch).
58
79
  */
59
80
  export declare function pageOf<T>(entries: T[], limit: number, key: (entry: T) => string): Page<T>;
81
+ /**
82
+ * Wrap a page that carries a total. `total` must come from a count over the SAME
83
+ * filter the page ran under — see `CountedPage`.
84
+ */
85
+ export declare function countedPageOf<T>(entries: T[], limit: number, key: (entry: T) => string, total: number): CountedPage<T>;
86
+ /**
87
+ * The Zod shape of a page of `entry` — what a paged operation actually returns.
88
+ *
89
+ * Built from the entry schema rather than declared beside it, so a vertical states
90
+ * the entry once and the envelope cannot drift from `pageOf`'s output. The emitted
91
+ * OpenAPI uses this same builder, which is what keeps the document and the handler
92
+ * describing one thing (D-22).
93
+ */
94
+ export declare function pageSchema<T extends z.ZodType>(entry: T, withTotal?: boolean): z.ZodObject<{
95
+ entries: z.ZodArray<T>;
96
+ nextCursor: z.ZodNullable<z.ZodString>;
97
+ }, z.core.$strip>;
60
98
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"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MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB;AAED,uDAAuD;AACvD,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,CAAC,CAAC;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAGzF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,OAAO,EAAE,CAAC,EAAE,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,EACzB,KAAK,EAAE,MAAM,GACZ,WAAW,CAAC,CAAC,CAAC,CAEhB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,UAAQ;;;kBAY1E"}
@@ -41,4 +41,32 @@ export function pageOf(entries, limit, key) {
41
41
  const last = entries.length >= limit ? entries[entries.length - 1] : undefined;
42
42
  return { entries, nextCursor: last === undefined ? null : key(last) };
43
43
  }
44
+ /**
45
+ * Wrap a page that carries a total. `total` must come from a count over the SAME
46
+ * filter the page ran under — see `CountedPage`.
47
+ */
48
+ export function countedPageOf(entries, limit, key, total) {
49
+ return { ...pageOf(entries, limit, key), total };
50
+ }
51
+ /**
52
+ * The Zod shape of a page of `entry` — what a paged operation actually returns.
53
+ *
54
+ * Built from the entry schema rather than declared beside it, so a vertical states
55
+ * the entry once and the envelope cannot drift from `pageOf`'s output. The emitted
56
+ * OpenAPI uses this same builder, which is what keeps the document and the handler
57
+ * describing one thing (D-22).
58
+ */
59
+ export function pageSchema(entry, withTotal = false) {
60
+ const base = z.object({
61
+ entries: z.array(entry),
62
+ /** The cursor to pass back for the next page, or `null` when the walk is done. */
63
+ nextCursor: z.string().nullable(),
64
+ });
65
+ return withTotal
66
+ ? base.extend({
67
+ /** Rows matching this list's filter, counted at the time of this page. */
68
+ total: z.number().int().nonnegative(),
69
+ })
70
+ : base;
71
+ }
44
72
  //# sourceMappingURL=pagination.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACvF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAoBH;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAI,O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AG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAY,EACZ,KAAa,EACb,GAAyB,EACzB,KAAa;IAEb,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAsB,KAAQ,EAAE,SAAS,GAAG,KAAK;IACzE,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QACvB,kFAAkF;QAClF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAClC,CAAC,CAAC;IACH,OAAO,SAAS;QACd,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;YACV,0EAA0E;YAC1E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/contracts",
3
- "version": "0.78.0",
3
+ "version": "0.80.0",
4
4
  "description": "Substrat kernel contract schemas — Zod is the source of truth (master plan D-22); OAS/JSON Schema are emitted artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {