@sumrco/cli 0.3.9 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARTIFACT-MANIFEST.json +18 -0
- package/README.md +12 -0
- package/THIRD_PARTY_NOTICES.md +1119 -0
- package/ai/modules/kontract/resources/api-generation-standards.rf.md +18 -5
- package/ai/modules/kontract/resources/authoring/configuration.rf.md +568 -12
- package/ai/modules/kontract/resources/authoring/schema-reuse.rf.md +25 -4
- package/ai/modules/kontract/resources/authoring/scope-and-splitting.rf.md +8 -6
- package/ai/modules/kontract/resources/authoring/spec-layout.rf.md +4 -0
- package/ai/modules/kontract/resources/generated-output.rf.md +712 -44
- package/ai/modules/kontract/resources/nestjs-eslint.rf.md +153 -0
- package/ai/modules/kontract/resources/openapi-sdk-generator-research.rf.md +177 -0
- package/ai/modules/kontract/resources/overview.md +70 -8
- package/ai/modules/kontract/resources/performance.rf.md +11 -2
- package/ai/modules/kontract/sumr.module.yaml +15 -14
- package/ai/modules/mission/resources/flow-config.rf.md +2 -2
- package/ai/modules/mission/resources/overview.md +42 -35
- package/ai/modules/mission/resources/stage-closeout.rf.md +5 -5
- package/ai/modules/mission/resources/stage-delivery.rf.md +5 -5
- package/ai/modules/mission/resources/stage-intake.rf.md +2 -2
- package/ai/modules/mission/resources/stage-planning.rf.md +43 -4
- package/ai/modules/mission/resources/stage-pull-request.rf.md +2 -2
- package/ai/modules/mission/resources/stage-quality.rf.md +8 -8
- package/ai/modules/mission/resources/team-members/planner.tm.md +17 -5
- package/ai/modules/mission/resources/workflows/daily-triage.cmd.md +5 -1
- package/ai/modules/mission/resources/workflows/mission-cycle.cmd.md +7 -5
- package/ai/modules/mission/resources/workflows/planning-only.cmd.md +8 -3
- package/ai/modules/mission/sumr.module.yaml +20 -16
- package/ai/modules/playbook/resources/authoring/extraction.rf.md +28 -1
- package/ai/modules/playbook/resources/authoring/frontmatter.rf.md +7 -0
- package/ai/modules/playbook/resources/authoring/overview.md +33 -2
- package/ai/modules/playbook/resources/authoring/patterns.rf.md +21 -0
- package/ai/modules/playbook/resources/team-members/technical-writer.tm.md +5 -1
- package/ai/modules/playbook/sumr.module.yaml +13 -12
- package/ai/registry.json +3 -3
- package/bin/sumr +18 -3
- package/eslint/index.mjs +2 -0
- package/eslint/kontract/index.mjs +22 -0
- package/eslint/kontract/rules/typescript-nestjs/operation-contract.mjs +656 -0
- package/index.js +3060 -462
- package/package.json +26 -23
- package/sbom.cdx.json +5111 -0
|
@@ -30,16 +30,27 @@ kontract:
|
|
|
30
30
|
generator:
|
|
31
31
|
type: typescript-nestjs
|
|
32
32
|
zod: true
|
|
33
|
-
|
|
33
|
+
dto: both
|
|
34
34
|
sdk: true
|
|
35
35
|
- name: frontend
|
|
36
36
|
output: frontend/src/shared/api
|
|
37
37
|
generator:
|
|
38
38
|
type: typescript-fetch
|
|
39
|
+
zod: true
|
|
39
40
|
schemaMode: normalize
|
|
40
41
|
modelPropertyNaming: original
|
|
41
42
|
paramNaming: original
|
|
42
43
|
stringEnums: true
|
|
44
|
+
- name: frontend-query
|
|
45
|
+
output: frontend/src/shared/query-api
|
|
46
|
+
generator:
|
|
47
|
+
type: react-query-hooks
|
|
48
|
+
zod: true
|
|
49
|
+
suspense: true
|
|
50
|
+
- name: realtime-contracts
|
|
51
|
+
output: frontend/src/shared/realtime
|
|
52
|
+
generator:
|
|
53
|
+
type: asyncapi-models
|
|
43
54
|
```
|
|
44
55
|
|
|
45
56
|
## Guidance profile
|
|
@@ -99,28 +110,82 @@ Use `--target <name>` to scope generation to one target.
|
|
|
99
110
|
| Category | Type | Outputs |
|
|
100
111
|
|---|---|---|
|
|
101
112
|
| Server/framework | `typescript-nestjs` | Zod DTOs, class-validator DTOs, models, Swagger metadata, generated `ApiDoc` decorators. |
|
|
113
|
+
| Messaging contracts | `asyncapi-models` | Transport-neutral message types/Zod schemas, event/message registries, send/receive maps, parsers, and fixture validators. |
|
|
102
114
|
| Messaging | `asyncapi-nats` | NATS subjects, message schemas, server interfaces, and clients. |
|
|
103
115
|
| Client/SDK | `typescript-fetch` | TypeScript fetch SDK. |
|
|
104
116
|
| Client/SDK | `typescript-axios` | TypeScript axios SDK. |
|
|
105
117
|
| Client/SDK | `typescript-angular` | Angular SDK. |
|
|
106
118
|
| Model | `typescript-models` | Framework-model-only output. |
|
|
119
|
+
| Framework adapter/SDK | `react-query-hooks` | Validated Fetch SDK, deterministic TanStack Query keys/options, and optional direct hooks. |
|
|
107
120
|
|
|
108
121
|
Kontract is structured for more generator targets over time: runtime evidence,
|
|
109
122
|
docs-ready API schema artifacts, packaged API contracts, SDKs, mocks, contract
|
|
110
123
|
tests, and breaking-change reports.
|
|
111
124
|
|
|
125
|
+
## `asyncapi-models`
|
|
126
|
+
|
|
127
|
+
Use `asyncapi-models` when browser, mobile, worker, Socket.IO, WebSocket, or
|
|
128
|
+
another adapter needs AsyncAPI payload contracts without a generated transport:
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
generator:
|
|
132
|
+
type: asyncapi-models
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Each service emits `async/messages.ts`, `async/registry.ts`,
|
|
136
|
+
`async/fixtures.ts`, `async/enums/`, and a curated `async/index.ts`. Channel
|
|
137
|
+
addresses become runtime event names. Channel message IDs become message
|
|
138
|
+
registry names. AsyncAPI operation actions remain application-relative
|
|
139
|
+
`send`/`receive`; Kontract does not guess which side is a browser or server.
|
|
140
|
+
|
|
141
|
+
The generated consumer package requires Zod with the `zod/v4` entry point. It
|
|
142
|
+
does not require Socket.IO, NATS, NestJS, RxJS, React, or TanStack Query.
|
|
143
|
+
`parseMessage(eventName, unknown)` validates inbound values and throws the
|
|
144
|
+
generated unknown-event or message-contract-validation error. Runtime string
|
|
145
|
+
event names are accepted and validated. On duplex event addresses,
|
|
146
|
+
`parseSendMessage()` and `parseReceiveMessage()` enforce the operation-specific
|
|
147
|
+
message subsets. Channel-based replies are supported; dynamic reply addresses
|
|
148
|
+
fail explicitly because they cannot become a stable event-registry key.
|
|
149
|
+
Fixture helpers reuse the same registries.
|
|
150
|
+
|
|
151
|
+
Use `asyncapi-nats` when the consumer also needs the NATS subject,
|
|
152
|
+
request/reply, client, and server adapter artifacts. `prefix` is NATS-specific
|
|
153
|
+
and is rejected on `asyncapi-models`.
|
|
154
|
+
|
|
112
155
|
## `typescript-nestjs` options
|
|
113
156
|
|
|
114
157
|
| Option | Output |
|
|
115
158
|
|---|---|
|
|
116
|
-
| `zod: true` | Emits `http/zod/*.contract.ts`
|
|
117
|
-
| `
|
|
159
|
+
| `zod: true` | Emits framework-neutral Zod schemas and inferred types under `http/zod/*.contract.ts`. On NestJS targets, use `dto: zod` or `dto: both` when `createZodDto()` constructors are also required. |
|
|
160
|
+
| `dto: none` / `zod` / `class-validator` / `both` | Selects the NestJS DTO technology explicitly. `zod` emits Zod schemas plus `createZodDto()` constructors, `class-validator` emits `http/dto/*.dto.ts`, `both` emits both DTO flavors, and `none` emits no DTO constructors. |
|
|
118
161
|
| `swagger: true` | Emits per-service `http/swagger.ts` operation metadata and one shared `shared/http/decorators/api-doc.ts` helper for NestJS controllers. |
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
162
|
+
| `operationContract: true` | Emits one exact, machine-readable `http/operations.ts` descriptor and typed `Operation` decorator per API operation. For JSON routes the one decorator installs native nestjs-zod response metadata and preserves the exact handler-return constraint; non-JSON transports remain serializer-free. An explicit non-`none` `dto` mode supplies the authoritative response DTOs required by the runtime binding. |
|
|
163
|
+
| `foundation: true` | Emits one target-wide `shared/http/foundation.ts` with the DI-preserving global pipe, canonical filter, interceptors, guard, and `configureApp()`. Per-service `http/foundation.ts` retains source-specific Swagger configuration/cleanup. Generated test applications use the shared boundary. Requires `operationContract: true`. |
|
|
164
|
+
| `controllers: true` | Emits regeneration-safe `http/controllers.ts`, `http/ports.ts`, and `http/feature.module.ts` adapters. Controllers contain transport wiring only and delegate to the application-owned `HttpPort`. When callbacks exist, it also emits `http/callbacks.ts`; endpoint selection is explicit and signing/retry policy remains application-owned. Requires `foundation: true`. |
|
|
165
|
+
| `errors: true` | Emits typed `http/errors.ts` exceptions for documented non-success JSON responses. Requires `foundation: true`. |
|
|
166
|
+
| `mappers: true` | Emits explicit 1:1 `http/mappers.ts` projections. Generated mappers do not infer semantic transformations. Requires `operationContract: true`. |
|
|
167
|
+
| `tests: true` | Emits `http/testing.ts`, an operation manifest, example validation, OpenAPI parity helpers, and production-parity TestingModule creation. Requires `controllers: true` and `foundation: true`. |
|
|
168
|
+
| `bruno: true` | Emits `bruno/` requests and a coverage manifest keyed by the exact operation identity. Requires `operationContract: true`. |
|
|
169
|
+
| `framework: express` / `fastify` | Selects the generated NestJS HTTP adapter profile. Express is the default. Both profiles support bounded single-file, multi-file, named-file, and mixed-field multipart operations; Fastify uses a buffered `@fastify/multipart` interceptor rather than Nest's Multer interceptors. |
|
|
170
|
+
| `versioning` / `defaultVersion` | Enables explicit Nest versioning (`uri`, `header`, or `media-type`) and optionally supplies a default version. The effective operation version is emitted into the operation descriptor and lint metadata, so URI route checks understand a target-wide default without requiring redundant `@Version()` decorators and still validate explicit operation overrides. Kontract never derives an API version from `info.version`. |
|
|
171
|
+
| `envelope` | Declares a schema-owned success-envelope projection shared by the NestJS response codec and, when `sdk: true`, its validated nested SDK. `dataKey` is required; `metaKey`, literal `staticFields`, and request-derived `contextFields.path` / `contextFields.timestamp` are optional. Server context fields require `foundation: true`. |
|
|
172
|
+
| `errorEnvelope` | Declares how the canonical filter renders documented error schemas. It supports flat or nested bodies, literal outer fields, status/message/type/code/details keys, path/timestamp fields, redacted internal values, and validation values. `detailsMode` is `issues-object` (default) or `raw`. Requires `errors: true`. |
|
|
173
|
+
| `envelopeDataKey` | Deprecated compatibility spelling for `envelope.dataKey`. It cannot be combined with `envelope`. |
|
|
174
|
+
| `sdk: true` | Emits a fetch-based `http/sdk/` client that reuses the target's `http/models/` and `http/enums/` types. With `envelope`, the nested SDK also requires Zod schemas so it validates the wire response before decoding the bare payload. |
|
|
175
|
+
| `runtime: true` | Emits one shared `shared/contract-runtime.ts` helper (`toContract`) that feeds contract-shaped values into generated Zod schemas. It preserves `null`, omits only `undefined`, and never guesses date, time, or timezone conversion. |
|
|
176
|
+
|
|
177
|
+
`dto` with an explicit technology mode is the canonical spelling. Deprecated
|
|
178
|
+
Boolean `dtos` and Boolean `dto` inputs remain accepted for existing projects
|
|
179
|
+
and are normalized before generation:
|
|
180
|
+
|
|
181
|
+
| Legacy input | With `zod: true` | With `zod: false` or omitted |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `dtos: true` or `dto: true` | `dto: both` | `dto: class-validator` |
|
|
184
|
+
| `dtos: false` or `dto: false` | `dto: zod` | `dto: none` |
|
|
121
185
|
|
|
122
|
-
|
|
123
|
-
|
|
186
|
+
Do not combine a string `dto` mode with `dtos`. Conflicting legacy values fail
|
|
187
|
+
with a migration diagnostic. New and rewritten configuration must use the
|
|
188
|
+
explicit `dto` modes.
|
|
124
189
|
|
|
125
190
|
Framework-interfaces under `http/models/` and enums under `http/enums/`
|
|
126
191
|
are emitted for API schema object schemas regardless of the Zod/DTO flavor.
|
|
@@ -136,6 +201,493 @@ not per-schema code, and is independent of the Zod/DTO flavors. The flag is set
|
|
|
136
201
|
the NestJS target; NATS consumers on the same output root import the same helper
|
|
137
202
|
from `shared/`.
|
|
138
203
|
|
|
204
|
+
The adoption ring is opt-in. A complete HTTP/NestJS boundary can be enabled with:
|
|
205
|
+
|
|
206
|
+
```yaml
|
|
207
|
+
generator:
|
|
208
|
+
type: typescript-nestjs
|
|
209
|
+
zod: true
|
|
210
|
+
dto: both
|
|
211
|
+
operationContract: true
|
|
212
|
+
foundation: true
|
|
213
|
+
controllers: true
|
|
214
|
+
errors: true
|
|
215
|
+
mappers: true
|
|
216
|
+
tests: true
|
|
217
|
+
bruno: true
|
|
218
|
+
framework: fastify # or express
|
|
219
|
+
envelope:
|
|
220
|
+
dataKey: data
|
|
221
|
+
metaKey: meta
|
|
222
|
+
staticFields:
|
|
223
|
+
success: true
|
|
224
|
+
contextFields:
|
|
225
|
+
timestamp: timestamp
|
|
226
|
+
path: path
|
|
227
|
+
errorEnvelope:
|
|
228
|
+
bodyKey: error
|
|
229
|
+
statusCodeKey: statusCode
|
|
230
|
+
messageKey: message
|
|
231
|
+
typeKey: error
|
|
232
|
+
codeKey: code
|
|
233
|
+
detailsKey: errors
|
|
234
|
+
detailsMode: raw
|
|
235
|
+
timestampKey: timestamp
|
|
236
|
+
pathKey: path
|
|
237
|
+
staticFields:
|
|
238
|
+
success: false
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The default generated error policy is flat. A documented nested or otherwise
|
|
242
|
+
custom error response must configure the complete `errorEnvelope` projection;
|
|
243
|
+
for the example above, `bodyKey: error` selects the nested core and
|
|
244
|
+
`staticFields.success: false` supplies the required outer literal. Kontract
|
|
245
|
+
does not infer that policy from one application's schema.
|
|
246
|
+
|
|
247
|
+
Kontract rejects incompatible combinations before generation. In particular,
|
|
248
|
+
advanced artifacts require `operationContract`, controller and test generation
|
|
249
|
+
require the shared foundation, and the operation binding cannot be emitted with
|
|
250
|
+
Zod disabled. `sumr kontract validate` also runs the configured NestJS
|
|
251
|
+
generator's write-free compatibility preflight, so an error-envelope/schema
|
|
252
|
+
mismatch fails validation. `sumr kontract generate --clean` repeats that
|
|
253
|
+
preflight before deleting any selected output or cache.
|
|
254
|
+
|
|
255
|
+
When the generated foundation is enabled, every operation that accepts request
|
|
256
|
+
input must document a 400 (or default) error response, every fail-closed
|
|
257
|
+
operation must document 403, every operation with declared request media types
|
|
258
|
+
must document 415, and every JSON operation must document 500. Kontract will
|
|
259
|
+
not invent an undocumented validation, security, media-type, or output-failure
|
|
260
|
+
contract. The preflight prevents the canonical filter from replacing a
|
|
261
|
+
generated boundary status with a misleading 500 merely because its wire schema
|
|
262
|
+
was absent.
|
|
263
|
+
|
|
264
|
+
For generated controllers, primitive path/header parameters use OpenAPI
|
|
265
|
+
`simple` semantics, primitive/array query parameters support `form`, and query
|
|
266
|
+
arrays also support `pipeDelimited` and `spaceDelimited`. Cookie parameters
|
|
267
|
+
must be scalar `form` values. Object parameters, cookie arrays, and any other
|
|
268
|
+
style need an application-owned decoder, so controller generation rejects them
|
|
269
|
+
instead of depending on Express/Fastify parser differences. This restriction
|
|
270
|
+
does not prevent framework-neutral operation/SDK generation.
|
|
271
|
+
|
|
272
|
+
The success and error settings are projections, not replacement schemas. Every
|
|
273
|
+
generated field must exist in the selected documented response component with a
|
|
274
|
+
compatible type. A configured `metaKey` is emitted only for response schemas
|
|
275
|
+
that declare it; pagination ports return `{ data, meta }`, while ordinary ports
|
|
276
|
+
return their bare payload. Literal and request-derived fields are filled by the
|
|
277
|
+
generated boundary, so applications do not manually wrap responses.
|
|
278
|
+
|
|
279
|
+
`errorEnvelope.bodyKey` makes the error core nested; omit it for a flat error
|
|
280
|
+
body. `detailsMode: issues-object` renders validation details as
|
|
281
|
+
`{ issues: ... }`; `detailsMode: raw` assigns the generated validation detail
|
|
282
|
+
array/value directly. Unexpected failures use `internalCode` and
|
|
283
|
+
`internalMessage` when configured and never expose the rejected output or
|
|
284
|
+
exception payload.
|
|
285
|
+
|
|
286
|
+
`OPERATION_ERROR_OBSERVER` receives a redacted diagnostic only: operation
|
|
287
|
+
identity/method/path and source JSON Pointer, category and error class name,
|
|
288
|
+
status, plus response/error schema references when available. It never receives
|
|
289
|
+
the raw exception or its message. Use `DOMAIN_ERROR_MAPPER`—not the
|
|
290
|
+
observer—when application policy needs the original domain failure to select a
|
|
291
|
+
declared transport error.
|
|
292
|
+
|
|
293
|
+
There is no separate multipart generator flag. A component-backed
|
|
294
|
+
`multipart/form-data` request schema activates the adapter selected by
|
|
295
|
+
`framework`. File parts use `type: string`, `format: binary`, and a positive
|
|
296
|
+
`maxLength` byte limit. File arrays and repeated non-file arrays must also
|
|
297
|
+
declare a positive `maxItems` bound:
|
|
298
|
+
|
|
299
|
+
```yaml
|
|
300
|
+
requestBody:
|
|
301
|
+
required: true
|
|
302
|
+
content:
|
|
303
|
+
multipart/form-data:
|
|
304
|
+
schema:
|
|
305
|
+
$ref: '#/components/schemas/CreateAssetUpload'
|
|
306
|
+
encoding:
|
|
307
|
+
document:
|
|
308
|
+
contentType: application/pdf
|
|
309
|
+
metadata:
|
|
310
|
+
contentType: application/json
|
|
311
|
+
|
|
312
|
+
components:
|
|
313
|
+
schemas:
|
|
314
|
+
CreateAssetUpload:
|
|
315
|
+
type: object
|
|
316
|
+
required: [document, attachments, metadata]
|
|
317
|
+
properties:
|
|
318
|
+
document:
|
|
319
|
+
type: string
|
|
320
|
+
format: binary
|
|
321
|
+
maxLength: 10485760
|
|
322
|
+
attachments:
|
|
323
|
+
type: array
|
|
324
|
+
minItems: 1
|
|
325
|
+
maxItems: 4
|
|
326
|
+
items:
|
|
327
|
+
type: string
|
|
328
|
+
format: binary
|
|
329
|
+
maxLength: 5242880
|
|
330
|
+
metadata:
|
|
331
|
+
type: object
|
|
332
|
+
required: [title]
|
|
333
|
+
properties:
|
|
334
|
+
title:
|
|
335
|
+
type: string
|
|
336
|
+
tags:
|
|
337
|
+
type: array
|
|
338
|
+
maxItems: 8
|
|
339
|
+
items:
|
|
340
|
+
type: string
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Fastify controller consumers must install `@nestjs/platform-fastify`,
|
|
344
|
+
`fastify`, and `@fastify/multipart`. Express multipart consumers must install
|
|
345
|
+
`@nestjs/platform-express`. Dependency checks report the exact missing runtime
|
|
346
|
+
packages for the configured controller profile. `dto: class-validator` and
|
|
347
|
+
`dto: both` require `class-transformer` and `class-validator` in the
|
|
348
|
+
consuming package.
|
|
349
|
+
`tests: true` requires `@nestjs/testing` and `supertest`; those testing
|
|
350
|
+
dependencies still belong to the consumer or isolated consumer matrix, never
|
|
351
|
+
to Kontract's root package.
|
|
352
|
+
|
|
353
|
+
For a downloadable frontend response, declare the success media type and a
|
|
354
|
+
component `type: string`, `format: binary` schema. Keep JSON problem responses
|
|
355
|
+
as their own status/content contracts:
|
|
356
|
+
|
|
357
|
+
```yaml
|
|
358
|
+
responses:
|
|
359
|
+
'200':
|
|
360
|
+
description: PDF document
|
|
361
|
+
content:
|
|
362
|
+
application/pdf:
|
|
363
|
+
schema:
|
|
364
|
+
$ref: '#/components/schemas/DocumentPdf'
|
|
365
|
+
'404':
|
|
366
|
+
description: Document not found
|
|
367
|
+
content:
|
|
368
|
+
application/problem+json:
|
|
369
|
+
schema:
|
|
370
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
371
|
+
|
|
372
|
+
components:
|
|
373
|
+
schemas:
|
|
374
|
+
DocumentPdf:
|
|
375
|
+
type: string
|
|
376
|
+
format: binary
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Fetch, Axios, Angular, and React Query clients expose the success as `Blob` and
|
|
380
|
+
still validate the declared JSON error body. Do not describe one response
|
|
381
|
+
status with both binary and non-binary media representations; Kontract rejects
|
|
382
|
+
that ambiguous runtime result.
|
|
383
|
+
|
|
384
|
+
## Common TypeScript generator options
|
|
385
|
+
|
|
386
|
+
These options apply where the target emits the corresponding artifact:
|
|
387
|
+
|
|
388
|
+
| Option | Meaning |
|
|
389
|
+
|---|---|
|
|
390
|
+
| `audiences` | Acts on the `x-kontract-audiences` declared by operations. See below. |
|
|
391
|
+
| `zod` | Emits framework-neutral runtime schemas; defaults to `false`. |
|
|
392
|
+
| `envelope` | On `typescript-fetch`, `typescript-axios`, `typescript-angular`, and `react-query-hooks`, validates a documented success envelope and returns its declared payload. Requires `zod: true`. It is not supported by `typescript-models`. |
|
|
393
|
+
| `schemaMode: normalize` / `strict` | Hoists inline operation schemas in memory (default for standalone SDK/model targets) or requires reusable component refs. |
|
|
394
|
+
| `useSingleRequestParameter` | Uses one operation request object instead of positional parameters. Fetch and React Query default to one object; Axios and Angular retain their established positional default. |
|
|
395
|
+
| `paramNaming` | Local TypeScript parameter naming: `camelCase`, `PascalCase`, `snake_case`, or `original`. Wire names never change. |
|
|
396
|
+
| `modelPropertyNaming` | Model property naming using the same values. Wire serialization remains contract-owned. |
|
|
397
|
+
| `enumPropertyNaming` | Runtime enum member naming: `PascalCase`, `camelCase`, `snake_case`, `UPPERCASE`, or `original`. |
|
|
398
|
+
| `stringEnums` | Emits string literal enum types while preserving runtime values. |
|
|
399
|
+
| `enumUnknownDefaultCase` | Adds/catches the explicit `unknown_default_open_api` fallback consistently in TypeScript and Zod output. |
|
|
400
|
+
| `sortParamsByRequiredFlag` | Groups required operation inputs before optional inputs. |
|
|
401
|
+
| `sortModelPropertiesByRequiredFlag` | Groups required model fields before optional fields. |
|
|
402
|
+
|
|
403
|
+
Naming options change TypeScript identifiers only. They never rewrite HTTP
|
|
404
|
+
parameter names, JSON property keys, enum wire values, media types, or paths.
|
|
405
|
+
|
|
406
|
+
### Operation audiences
|
|
407
|
+
|
|
408
|
+
Some operations should not reach every artifact — development-only endpoints,
|
|
409
|
+
internal tooling routes, unreleased features. Declare that on the operation, so
|
|
410
|
+
every target reads the same fact:
|
|
411
|
+
|
|
412
|
+
```yaml
|
|
413
|
+
paths:
|
|
414
|
+
/preview/sessions:
|
|
415
|
+
post:
|
|
416
|
+
operationId: createPreviewSession
|
|
417
|
+
x-kontract-audiences: [nonprod]
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
An operation that declares no audiences belongs to every audience. Each target
|
|
421
|
+
then chooses what to do:
|
|
422
|
+
|
|
423
|
+
```yaml
|
|
424
|
+
- name: frontend
|
|
425
|
+
generator:
|
|
426
|
+
type: react-query-hooks
|
|
427
|
+
audiences:
|
|
428
|
+
exclude: [nonprod] # never generated for this target
|
|
429
|
+
|
|
430
|
+
- name: backend
|
|
431
|
+
generator:
|
|
432
|
+
type: typescript-nestjs
|
|
433
|
+
audiences:
|
|
434
|
+
marker: true # SUMR-standard generated annotations
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
`exclude` omits the operation and the component schemas only excluded operations
|
|
438
|
+
reach. This projection is available to every TypeScript OpenAPI generator and
|
|
439
|
+
also removes operation-only runtime schemas, models, query keys, options, hooks,
|
|
440
|
+
and barrel exports.
|
|
441
|
+
|
|
442
|
+
The exclusion list belongs to the complete source/target, not to each generated
|
|
443
|
+
service folder. Kontract validates every excluded token once against the
|
|
444
|
+
audiences declared anywhere in that selected OpenAPI source. A sibling service
|
|
445
|
+
with no matching operation generates its normal complete surface; a token that
|
|
446
|
+
matches nowhere in the complete source fails validation and `generate --clean`
|
|
447
|
+
preflight before existing output is removed.
|
|
448
|
+
|
|
449
|
+
`marker: true` is available to `typescript-nestjs`. It keeps the operation and
|
|
450
|
+
writes SUMR Kontract's fixed
|
|
451
|
+
`// sumr-kontract:audience:nonprod` annotation as the first line of exclusively
|
|
452
|
+
owned model, DTO, Zod, and enum modules. Generated
|
|
453
|
+
`// sumr-kontract:audience:nonprod:start` / `:end` blocks protect their barrel
|
|
454
|
+
exports and the matching Swagger imports, operation constants, and registry
|
|
455
|
+
entries for build pipelines that strip annotated code. The namespace and syntax
|
|
456
|
+
are owned by SUMR and are not consumer-configurable.
|
|
457
|
+
|
|
458
|
+
Each marked operation must declare exactly one audience; generation fails rather
|
|
459
|
+
than choosing one when several are declared. `exclude` continues to accept
|
|
460
|
+
several audience tokens.
|
|
461
|
+
|
|
462
|
+
A schema shared with an unscoped operation is never removed or annotated — only
|
|
463
|
+
schemas reached exclusively by one audience are scoped.
|
|
464
|
+
|
|
465
|
+
Because markers are generated from the spec, they survive regeneration and are
|
|
466
|
+
part of the exact output hash. Do not post-process generated files to add them:
|
|
467
|
+
the edit invalidates the generation manifest and is invisible to every other
|
|
468
|
+
target, which is how a client ends up shipping calls for endpoints the server
|
|
469
|
+
dropped.
|
|
470
|
+
|
|
471
|
+
## TypeScript Zod capability
|
|
472
|
+
|
|
473
|
+
`zod: true` is optional and defaults to `false` on every TypeScript OpenAPI
|
|
474
|
+
generator:
|
|
475
|
+
|
|
476
|
+
- `typescript-nestjs`
|
|
477
|
+
- `typescript-fetch`
|
|
478
|
+
- `typescript-axios`
|
|
479
|
+
- `typescript-angular`
|
|
480
|
+
- `typescript-models`
|
|
481
|
+
- `react-query-hooks`
|
|
482
|
+
|
|
483
|
+
`asyncapi-models` and `asyncapi-nats` are also TypeScript generators, but their
|
|
484
|
+
message contracts are intrinsically Zod-based rather than controlled by this
|
|
485
|
+
OpenAPI option. The transport-neutral target imports `zod/v4`.
|
|
486
|
+
|
|
487
|
+
It emits framework-neutral component schemas. Each named schema owns
|
|
488
|
+
`${Name}InputSchema`, `${Name}OutputSchema`, `${Name}Input`,
|
|
489
|
+
`${Name}Output`, and the output-compatible `${Name}Schema` / `${Name}` aliases.
|
|
490
|
+
Request input excludes `readOnly`; response output excludes `writeOnly`.
|
|
491
|
+
Required/optional and nullable/non-null are independent.
|
|
492
|
+
|
|
493
|
+
Fetch, Axios, Angular, and React Query SDKs with Zod also emit
|
|
494
|
+
`operations.ts` and `fixtures.ts`. The registry validates request locations and
|
|
495
|
+
selects response schemas by operation, status/default, and content type.
|
|
496
|
+
Generated clients serialize the parsed request value rather than the original
|
|
497
|
+
caller object, return only parsed response values, and distinguish HTTP,
|
|
498
|
+
transport, abort, and contract-validation failures. This means fields stripped
|
|
499
|
+
or normalized by the authoritative input schema cannot leak into the request
|
|
500
|
+
after validation.
|
|
501
|
+
|
|
502
|
+
Fetch, Axios, and Angular client configs expose an operation-aware
|
|
503
|
+
`authHeaders(operationId, security)` provider. Kontract calls it only when the
|
|
504
|
+
operation's effective OpenAPI security requirement is non-empty. Operations
|
|
505
|
+
with explicit `security: []` skip generated auth injection; operations without
|
|
506
|
+
an override inherit root security. The generated operation registry exposes the
|
|
507
|
+
effective requirements and `securityIsExplicit` so higher-level adapters can
|
|
508
|
+
make the same deterministic decision. When one service groups multiple
|
|
509
|
+
`.api.yml` roots, Kontract preserves each source file's root security while
|
|
510
|
+
resolving the aggregate/local-reference graph; it never replaces an inherited
|
|
511
|
+
requirement with an empty aggregate default.
|
|
512
|
+
|
|
513
|
+
Zod output uses Zod v4-compatible APIs; the consumer must provide a compatible
|
|
514
|
+
Zod version. Kontract does not add Zod, Axios, Angular, or TanStack to its own
|
|
515
|
+
runtime dependency graph. Dependency preflight reports missing packages in the
|
|
516
|
+
target consumer package.
|
|
517
|
+
|
|
518
|
+
Kontract does not coerce or transform wire values, apply schema defaults,
|
|
519
|
+
unwrap undocumented envelopes, or convert date/date-time strings, money, or
|
|
520
|
+
timezones. Recursive component cycles currently fail with an actionable lazy
|
|
521
|
+
schema limitation rather than emitting a broken eager import graph.
|
|
522
|
+
|
|
523
|
+
### Documented success-envelope decoding
|
|
524
|
+
|
|
525
|
+
Validated client generators can explicitly decode an envelope already
|
|
526
|
+
described by the selected OpenAPI success response:
|
|
527
|
+
|
|
528
|
+
```yaml
|
|
529
|
+
generator:
|
|
530
|
+
type: typescript-fetch # also axios, angular, or react-query-hooks
|
|
531
|
+
zod: true
|
|
532
|
+
envelope:
|
|
533
|
+
dataKey: data
|
|
534
|
+
metaKey: meta
|
|
535
|
+
staticFields:
|
|
536
|
+
success: true
|
|
537
|
+
contextFields:
|
|
538
|
+
timestamp: timestamp
|
|
539
|
+
path: path
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
This policy does not replace or repair the OpenAPI schema. The documented
|
|
543
|
+
response component must declare `data`, every configured static/context field,
|
|
544
|
+
and `meta` on paginated responses. Kontract validates the full wire body by
|
|
545
|
+
operation, status, and content type, then returns `data`; when that response
|
|
546
|
+
declares the configured `metaKey`, it returns `{ data, meta }`. Declared error
|
|
547
|
+
responses are validated but never projected, so typed `HttpError.body` retains
|
|
548
|
+
the documented error envelope.
|
|
549
|
+
|
|
550
|
+
Generated response fixtures remain wire fixtures. They validate and retain the
|
|
551
|
+
full envelope so MSW or another mock transport can return the same bytes as the
|
|
552
|
+
server. Client methods and React Query factories use the separate validated
|
|
553
|
+
projection path.
|
|
554
|
+
|
|
555
|
+
For a standalone client, `contextFields` only names fields expected in the
|
|
556
|
+
documented response. The application/server transport remains responsible for
|
|
557
|
+
producing them. On `typescript-nestjs`, the generated foundation derives those
|
|
558
|
+
request values and the generated codec writes them. Kontract never unwraps an
|
|
559
|
+
envelope unless this explicit policy is present.
|
|
560
|
+
|
|
561
|
+
An operation that intentionally exposes its documented response without the
|
|
562
|
+
target-wide success envelope can opt out explicitly:
|
|
563
|
+
|
|
564
|
+
```yaml
|
|
565
|
+
paths:
|
|
566
|
+
/auth/health:
|
|
567
|
+
get:
|
|
568
|
+
operationId: authHealth
|
|
569
|
+
x-response-mode: passthrough
|
|
570
|
+
responses:
|
|
571
|
+
'200':
|
|
572
|
+
description: Raw authentication health response
|
|
573
|
+
content:
|
|
574
|
+
application/json:
|
|
575
|
+
schema:
|
|
576
|
+
$ref: '#/components/schemas/AuthHealth'
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
`passthrough` is the only supported `x-response-mode` value. For generated
|
|
580
|
+
clients it disables success-envelope projection while retaining validation of
|
|
581
|
+
the raw documented success/error bodies. For NestJS it is an explicit
|
|
582
|
+
application-owned transport exemption: `Operation` emits operation and
|
|
583
|
+
Swagger metadata but does not install `ZodResponse`, and the generated response
|
|
584
|
+
interceptor, canonical error filter, and target-wide `errorEnvelope` preflight
|
|
585
|
+
do not process that operation. The controller owns status, headers, cookies,
|
|
586
|
+
body, serialization, and every documented error, so library-mode `@Res()` is
|
|
587
|
+
allowed only for this explicit response mode.
|
|
588
|
+
|
|
589
|
+
Normal operations in the same source remain fully managed and continue to use
|
|
590
|
+
the target's configured envelope, strict handler return constraint, response
|
|
591
|
+
validation, and canonical error policy. Security, request media metadata, and
|
|
592
|
+
client-side binary handling remain operation-owned. Unknown values fail
|
|
593
|
+
generation rather than silently selecting a response mode.
|
|
594
|
+
|
|
595
|
+
## `react-query-hooks` options
|
|
596
|
+
|
|
597
|
+
```yaml
|
|
598
|
+
generator:
|
|
599
|
+
type: react-query-hooks
|
|
600
|
+
zod: true
|
|
601
|
+
hooks: true # default
|
|
602
|
+
options: true # default
|
|
603
|
+
suspense: true # default false
|
|
604
|
+
operations:
|
|
605
|
+
listProducts:
|
|
606
|
+
infinite:
|
|
607
|
+
parameter: cursor
|
|
608
|
+
initialPageParam: ''
|
|
609
|
+
createProduct:
|
|
610
|
+
hooks: false
|
|
611
|
+
options: true
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
| Option | Meaning |
|
|
615
|
+
|---|---|
|
|
616
|
+
| `hooks` | Emits direct `useQuery` / `useMutation` wrappers globally. Defaults to `true`. |
|
|
617
|
+
| `options` | Exports query/mutation option factories globally. Defaults to `true`; factories remain private implementation details when disabled but hooks need them. |
|
|
618
|
+
| `suspense` | Emits suspense query hooks/options. Defaults to `false`. |
|
|
619
|
+
| `operations.<operationId>` | Per-operation overrides for `hooks`, `options`, `suspense`, and `infinite`. Unknown operation IDs fail generation. |
|
|
620
|
+
| `infinite.parameter` | Exact query parameter that receives TanStack's `pageParam`. The operation must be GET/HEAD. |
|
|
621
|
+
| `infinite.initialPageParam` | Explicit initial string, number, or null page value. Kontract never guesses pagination policy. |
|
|
622
|
+
|
|
623
|
+
The generator emits the validated fetch client plus `query-keys.ts` and
|
|
624
|
+
`react-query.ts`. Keys are hierarchical and deterministic at service,
|
|
625
|
+
operation, and request granularity; tag/surface predicates support technical
|
|
626
|
+
cache selection. TanStack forwards its query `AbortSignal` into the generated
|
|
627
|
+
client.
|
|
628
|
+
|
|
629
|
+
Hooks and options factories are separately configurable. Option factories are
|
|
630
|
+
the reusable primitive for direct hooks, `QueryClient` prefetching, SSR,
|
|
631
|
+
router loaders, tests, and imperative cache use. Consumer `select` functions
|
|
632
|
+
receive already validated values. Retry, invalidation, optimistic updates, and
|
|
633
|
+
feature business policy remain application-owned.
|
|
634
|
+
|
|
635
|
+
The generated consumer must provide `@tanstack/react-query`. Kontract core does
|
|
636
|
+
not depend on TanStack.
|
|
637
|
+
|
|
638
|
+
## Operation extensions
|
|
639
|
+
|
|
640
|
+
`x-response-mode: passthrough` is the operation-owned override for a
|
|
641
|
+
target-wide success `envelope` and the explicit NestJS application-owned
|
|
642
|
+
response transport exemption; see
|
|
643
|
+
[Documented success-envelope decoding](#documented-success-envelope-decoding).
|
|
644
|
+
It does not rewrite the documented response/error schemas. Generated clients
|
|
645
|
+
continue to validate those raw schemas, while the NestJS application must
|
|
646
|
+
produce them without the generated serializer/filter.
|
|
647
|
+
|
|
648
|
+
### `x-kontract-*` policy extensions
|
|
649
|
+
|
|
650
|
+
Policy extensions are metadata only. Applications own the guard, cache, and
|
|
651
|
+
rate-limit implementation:
|
|
652
|
+
|
|
653
|
+
```yaml
|
|
654
|
+
x-kontract-audiences: [nonprod]
|
|
655
|
+
x-kontract-handler-status: 202
|
|
656
|
+
x-kontract-version: '2'
|
|
657
|
+
x-kontract-webhook-path: /webhooks/order-created
|
|
658
|
+
x-kontract-wildcard-parameter: path
|
|
659
|
+
x-kontract-rate-limit:
|
|
660
|
+
limit: 60
|
|
661
|
+
windowMs: 60000
|
|
662
|
+
x-kontract-cache:
|
|
663
|
+
ttlMs: 5000
|
|
664
|
+
key: book-by-id
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
- `x-kontract-audiences` lists the build/delivery audiences the operation belongs
|
|
668
|
+
to, as a non-empty array of lowercase tokens. TypeScript OpenAPI targets can
|
|
669
|
+
act on it through `audiences.exclude`; `typescript-nestjs` can instead retain
|
|
670
|
+
and annotate output through `audiences.marker: true`. Unlike the other entries
|
|
671
|
+
here, this one changes generated output. An operation that declares none
|
|
672
|
+
belongs to every audience.
|
|
673
|
+
- `x-kontract-handler-status` selects one declared 2xx response as the handler
|
|
674
|
+
status when an operation has multiple successes.
|
|
675
|
+
- `x-kontract-version` assigns the NestJS operation version explicitly. URI
|
|
676
|
+
versioning may also use an explicit `/vN` path; Kontract never reads
|
|
677
|
+
`info.version` as a route version.
|
|
678
|
+
- `x-kontract-webhook-path` assigns the receiver route for a named OpenAPI 3.1
|
|
679
|
+
top-level webhook. A webhook key that already begins with `/` can be used
|
|
680
|
+
directly.
|
|
681
|
+
- `x-kontract-rate-limit` requires positive integer `limit` and `windowMs`.
|
|
682
|
+
- `x-kontract-cache` requires positive integer `ttlMs`; `key` is optional.
|
|
683
|
+
- `x-kontract-wildcard-parameter` explicitly marks one path placeholder as an
|
|
684
|
+
Express 5/path-to-regexp v8 named wildcard. Its path parameter schema must be
|
|
685
|
+
an array of strings; Kontract emits `*name`, never an unnamed wildcard.
|
|
686
|
+
|
|
687
|
+
Invalid or undeclared statuses and malformed policy values fail generation.
|
|
688
|
+
Kontract emits policy metadata but does not generate authorization, caching, or
|
|
689
|
+
rate-limiting business decisions.
|
|
690
|
+
|
|
139
691
|
## API schema schema mode
|
|
140
692
|
|
|
141
693
|
Standalone SDK and model targets default to `schemaMode: normalize`. In this
|
|
@@ -180,9 +732,11 @@ or `marketplace`.
|
|
|
180
732
|
|
|
181
733
|
Check both:
|
|
182
734
|
|
|
183
|
-
1. The target config has `generator.type: typescript-nestjs` and
|
|
184
|
-
`dto:
|
|
185
|
-
|
|
735
|
+
1. The target config has `generator.type: typescript-nestjs` and either
|
|
736
|
+
`dto: class-validator` or `dto: both`. Deprecated Boolean `dtos: true` and
|
|
737
|
+
`dto: true` remain accepted for existing projects, but new config should use
|
|
738
|
+
an explicit `dto` mode. If you use Zod without class-validator DTOs, set
|
|
739
|
+
`swagger: true` explicitly.
|
|
186
740
|
2. The installed `SUMR Kontract module` version includes Swagger/ApiDoc support.
|
|
187
741
|
|
|
188
742
|
If two configs generate identical output and both miss `dto/` + `swagger.ts`,
|
|
@@ -191,8 +745,10 @@ repo's config.
|
|
|
191
745
|
|
|
192
746
|
### `http/zod/` is missing
|
|
193
747
|
|
|
194
|
-
Check that the NestJS target has `zod: true` or
|
|
195
|
-
|
|
748
|
+
Check that the NestJS target has `zod: true`, `dto: zod`, or `dto: both`.
|
|
749
|
+
Standalone TypeScript targets emit their framework-neutral contracts under
|
|
750
|
+
`<service>/schemas/` when `zod: true`; they do not use the NestJS `http/zod/`
|
|
751
|
+
layout.
|
|
196
752
|
|
|
197
753
|
### `http/sdk/` is missing
|
|
198
754
|
|