ts-procedures 8.4.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/codegen/bin/cli.d.ts +4 -0
- package/build/codegen/bin/cli.js +16 -0
- package/build/codegen/bin/cli.js.map +1 -1
- package/build/codegen/bin/cli.test.js +18 -0
- package/build/codegen/bin/cli.test.js.map +1 -1
- package/build/codegen/bin/flag-specs.js +2 -0
- package/build/codegen/bin/flag-specs.js.map +1 -1
- package/build/codegen/bin/flag-specs.test.js +9 -0
- package/build/codegen/bin/flag-specs.test.js.map +1 -1
- package/build/codegen/collect-models.d.ts +14 -3
- package/build/codegen/collect-models.js +15 -5
- package/build/codegen/collect-models.js.map +1 -1
- package/build/codegen/collect-models.test.js +21 -2
- package/build/codegen/collect-models.test.js.map +1 -1
- package/build/codegen/emit-index.js +13 -0
- package/build/codegen/emit-index.js.map +1 -1
- package/build/codegen/emit-index.test.js +25 -0
- package/build/codegen/emit-index.test.js.map +1 -1
- package/build/codegen/emit-scope.js +45 -8
- package/build/codegen/emit-scope.js.map +1 -1
- package/build/codegen/emit-scope.test.js +86 -4
- package/build/codegen/emit-scope.test.js.map +1 -1
- package/build/codegen/index.d.ts +10 -0
- package/build/codegen/index.js +3 -0
- package/build/codegen/index.js.map +1 -1
- package/build/codegen/pipeline.d.ts +4 -0
- package/build/codegen/pipeline.js +3 -0
- package/build/codegen/pipeline.js.map +1 -1
- package/build/codegen/targets/_shared/target-run.d.ts +10 -0
- package/build/codegen/targets/ts/run.js +11 -2
- package/build/codegen/targets/ts/run.js.map +1 -1
- package/build/codegen/targets/ts/shared-models.test.js +97 -1
- package/build/codegen/targets/ts/shared-models.test.js.map +1 -1
- package/docs/client-and-codegen.md +62 -0
- package/docs/client-error-handling.md +87 -0
- package/docs/handoffs/2026-06-08-dx-round2-declines.md +45 -0
- package/docs/handoffs/shared-models-auto-resolve-response.md +181 -0
- package/docs/http-integrations.md +25 -0
- package/docs/superpowers/plans/2026-06-06-shared-models-convention-and-diagnostics.md +659 -0
- package/docs/superpowers/plans/2026-06-08-codegen-dx-surfacing.md +428 -0
- package/docs/superpowers/specs/2026-06-08-dx-feedback-round-2-design.md +376 -0
- package/package.json +1 -1
- package/src/codegen/__fixtures__/users-envelope.json +9 -0
- package/src/codegen/bin/cli.test.ts +27 -0
- package/src/codegen/bin/cli.ts +18 -0
- package/src/codegen/bin/flag-specs.test.ts +11 -0
- package/src/codegen/bin/flag-specs.ts +2 -0
- package/src/codegen/collect-models.test.ts +24 -2
- package/src/codegen/collect-models.ts +22 -5
- package/src/codegen/emit-index.test.ts +34 -0
- package/src/codegen/emit-index.ts +19 -0
- package/src/codegen/emit-scope.test.ts +94 -4
- package/src/codegen/emit-scope.ts +53 -8
- package/src/codegen/index.ts +13 -0
- package/src/codegen/pipeline.ts +7 -0
- package/src/codegen/targets/_shared/target-run.ts +10 -0
- package/src/codegen/targets/kotlin/__fixtures__/users-golden.kt +6 -0
- package/src/codegen/targets/swift/__fixtures__/users-golden.swift +6 -0
- package/src/codegen/targets/ts/run.ts +18 -1
- package/src/codegen/targets/ts/shared-models.test.ts +109 -1
|
@@ -36,6 +36,9 @@ export async function runPipeline(options) {
|
|
|
36
36
|
cleanOutDir,
|
|
37
37
|
shareModels,
|
|
38
38
|
sharedTypesImport: options.sharedTypesImport,
|
|
39
|
+
sharedModelsModule: options.sharedModelsModule,
|
|
40
|
+
strictSharedModels: options.strictSharedModels,
|
|
41
|
+
logger: options.logger,
|
|
39
42
|
};
|
|
40
43
|
switch (options.target) {
|
|
41
44
|
case 'kotlin':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/codegen/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,mBAAmB,EAAE,M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face TargetRunInput {
|
|
|
29
29
|
shareModels?: boolean;
|
|
30
30
|
/** Maps a model `$id` to an external import (re-exported instead of generated). */
|
|
31
31
|
sharedTypesImport?: SharedTypesImportMap;
|
|
32
|
+
/** Single module every $id-bearing model re-exports from (convention; map entries override). */
|
|
33
|
+
sharedModelsModule?: string;
|
|
34
|
+
/** When true, hard-fail if any $id-bearing model has no shared-type mapping (would be a local twin). */
|
|
35
|
+
strictSharedModels?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Sink for non-error progress messages (e.g. the shared-models summary).
|
|
38
|
+
* Defaults to undefined — programmatic callers stay silent; the CLI injects
|
|
39
|
+
* `console.log`. Output belongs to the caller, not the run module.
|
|
40
|
+
*/
|
|
41
|
+
logger?: (message: string) => void;
|
|
32
42
|
}
|
|
@@ -15,7 +15,7 @@ import { emitClientRuntimeFile } from '../../emit-client-runtime.js';
|
|
|
15
15
|
import { collectModels, resolveModelImports } from '../../collect-models.js';
|
|
16
16
|
import { emitModelsFile } from '../../emit-models.js';
|
|
17
17
|
export async function runTsPipeline(input) {
|
|
18
|
-
const { envelope, outDir, hash, groups, serviceName, ajsc: ajscOpts, clientImportPath, dryRun = false, namespaceTypes = false, selfContained = false, cleanOutDir = false, sharedTypesImport, } = input;
|
|
18
|
+
const { envelope, outDir, hash, groups, serviceName, ajsc: ajscOpts, clientImportPath, dryRun = false, namespaceTypes = false, selfContained = false, cleanOutDir = false, sharedTypesImport, sharedModelsModule, strictSharedModels = false, logger, } = input;
|
|
19
19
|
const shareModels = input.shareModels ?? false;
|
|
20
20
|
const hashComment = `// Source hash: ${hash}`;
|
|
21
21
|
// Error keys that will be emitted in `_errors.ts` — only those with a schema.
|
|
@@ -34,7 +34,7 @@ export async function runTsPipeline(input) {
|
|
|
34
34
|
// covers ALL models (generated AND externally-imported) since scopes always
|
|
35
35
|
// import shared types from `./_models`.
|
|
36
36
|
const models = shareModels
|
|
37
|
-
? resolveModelImports(collectModels(envelope.routes), sharedTypesImport)
|
|
37
|
+
? resolveModelImports(collectModels(envelope.routes), { sharedTypesImport, sharedModelsModule })
|
|
38
38
|
: [];
|
|
39
39
|
const idToModelName = new Map(models.map((m) => [m.id, m.name]));
|
|
40
40
|
if (shareModels) {
|
|
@@ -44,6 +44,15 @@ export async function runTsPipeline(input) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
if (shareModels && models.length > 0) {
|
|
48
|
+
const generated = models.filter((m) => m.import == null);
|
|
49
|
+
if (strictSharedModels && generated.length > 0) {
|
|
50
|
+
const list = generated.map((m) => `"${m.id}" (${m.name})`).join(', ');
|
|
51
|
+
throw new Error(`[ts-procedures-codegen] --strict-shared-models: ${generated.length} $id-bearing schema(s) have no shared-type mapping and would be generated as local structural twins: ${list}. Add a sharedTypesImport entry, set sharedModelsModule, or drop --strict-shared-models.`);
|
|
52
|
+
}
|
|
53
|
+
const reExported = models.length - generated.length;
|
|
54
|
+
logger?.(`[ts-procedures-codegen] Shared models: ${models.length} total — ${reExported} re-exported, ${generated.length} generated locally.`);
|
|
55
|
+
}
|
|
47
56
|
const files = [];
|
|
48
57
|
for (const group of groups) {
|
|
49
58
|
const rawCode = await emitScopeFile(group, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../src/codegen/targets/ts/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;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AM,qBAAqB,EAAE,CAAA;QACnD,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC7C,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAA;QACrC,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,MAAM,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;IAEjE,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { runPipeline } from '../../pipeline.js';
|
|
3
3
|
import { makeApiRoute, makeEnvelope } from '../../__fixtures__/make-envelope.js';
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
@@ -210,6 +210,102 @@ describe('shared models (TS target, ajsc x-named-type)', () => {
|
|
|
210
210
|
const messages = findFile(files, 'messages.ts');
|
|
211
211
|
expect(messages.code).toContain("import type { Message } from './_models'");
|
|
212
212
|
});
|
|
213
|
+
it('sharedModelsModule re-exports every $id model from the convention module', async () => {
|
|
214
|
+
const files = await runPipeline({
|
|
215
|
+
envelope: modelEnvelope(),
|
|
216
|
+
outDir: 'out',
|
|
217
|
+
dryRun: true,
|
|
218
|
+
shareModels: true,
|
|
219
|
+
namespaceTypes: true,
|
|
220
|
+
selfContained: false,
|
|
221
|
+
sharedModelsModule: '@app/schemas',
|
|
222
|
+
});
|
|
223
|
+
const modelsFile = findFile(files, '_models.ts');
|
|
224
|
+
// Re-exported, not generated.
|
|
225
|
+
expect(modelsFile.code).toContain("export { Message } from '@app/schemas'");
|
|
226
|
+
expect(countMatches(modelsFile.code, /export type Message =/g)).toBe(0);
|
|
227
|
+
// Scopes still import the shared name from ./_models.
|
|
228
|
+
expect(findFile(files, 'messages.ts').code).toContain("from './_models'");
|
|
229
|
+
});
|
|
230
|
+
it('explicit sharedTypesImport overrides the sharedModelsModule convention per $id', async () => {
|
|
231
|
+
const files = await runPipeline({
|
|
232
|
+
envelope: modelEnvelope(),
|
|
233
|
+
outDir: 'out',
|
|
234
|
+
dryRun: true,
|
|
235
|
+
shareModels: true,
|
|
236
|
+
namespaceTypes: true,
|
|
237
|
+
selfContained: false,
|
|
238
|
+
sharedModelsModule: '@app/schemas',
|
|
239
|
+
sharedTypesImport: { 'urn:msg': { module: '@override/pkg', name: 'Message' } },
|
|
240
|
+
});
|
|
241
|
+
expect(findFile(files, '_models.ts').code).toContain("export { Message } from '@override/pkg'");
|
|
242
|
+
});
|
|
243
|
+
it('emits a neutral summary of the re-exported / generated split via the injected logger', async () => {
|
|
244
|
+
const lines = [];
|
|
245
|
+
await runPipeline({
|
|
246
|
+
envelope: modelEnvelope(),
|
|
247
|
+
outDir: 'out',
|
|
248
|
+
dryRun: true,
|
|
249
|
+
shareModels: true,
|
|
250
|
+
namespaceTypes: true,
|
|
251
|
+
selfContained: false,
|
|
252
|
+
logger: (m) => lines.push(m),
|
|
253
|
+
});
|
|
254
|
+
expect(lines.join('\n')).toContain('Shared models: 1 total — 0 re-exported, 1 generated locally.');
|
|
255
|
+
});
|
|
256
|
+
it('does not emit a summary when there are no $id-bearing models', async () => {
|
|
257
|
+
const lines = [];
|
|
258
|
+
await runPipeline({
|
|
259
|
+
envelope: noModelEnvelope(),
|
|
260
|
+
outDir: 'out',
|
|
261
|
+
dryRun: true,
|
|
262
|
+
shareModels: true,
|
|
263
|
+
namespaceTypes: true,
|
|
264
|
+
selfContained: false,
|
|
265
|
+
logger: (m) => lines.push(m),
|
|
266
|
+
});
|
|
267
|
+
expect(lines.join('\n')).not.toContain('Shared models:');
|
|
268
|
+
});
|
|
269
|
+
it('stays silent (no console output) when no logger is injected', async () => {
|
|
270
|
+
const log = vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
271
|
+
try {
|
|
272
|
+
await runPipeline({
|
|
273
|
+
envelope: modelEnvelope(),
|
|
274
|
+
outDir: 'out',
|
|
275
|
+
dryRun: true,
|
|
276
|
+
shareModels: true,
|
|
277
|
+
namespaceTypes: true,
|
|
278
|
+
selfContained: false,
|
|
279
|
+
});
|
|
280
|
+
expect(log.mock.calls.flat().join('\n')).not.toContain('Shared models:');
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
log.mockRestore();
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
it('strictSharedModels throws listing the offending $id and derived name', async () => {
|
|
287
|
+
await expect(runPipeline({
|
|
288
|
+
envelope: modelEnvelope(),
|
|
289
|
+
outDir: 'out',
|
|
290
|
+
dryRun: true,
|
|
291
|
+
shareModels: true,
|
|
292
|
+
namespaceTypes: true,
|
|
293
|
+
selfContained: false,
|
|
294
|
+
strictSharedModels: true,
|
|
295
|
+
})).rejects.toThrow(/--strict-shared-models[\s\S]*urn:msg[\s\S]*Message/);
|
|
296
|
+
});
|
|
297
|
+
it('strictSharedModels passes once every model is covered by the convention', async () => {
|
|
298
|
+
await expect(runPipeline({
|
|
299
|
+
envelope: modelEnvelope(),
|
|
300
|
+
outDir: 'out',
|
|
301
|
+
dryRun: true,
|
|
302
|
+
shareModels: true,
|
|
303
|
+
namespaceTypes: true,
|
|
304
|
+
selfContained: false,
|
|
305
|
+
strictSharedModels: true,
|
|
306
|
+
sharedModelsModule: '@app/schemas',
|
|
307
|
+
})).resolves.toBeDefined();
|
|
308
|
+
});
|
|
213
309
|
it('fails loudly when a shared model name collides with a property-derived sub-type', async () => {
|
|
214
310
|
// `latest` references the Message model; a sibling property literally named
|
|
215
311
|
// `message` would make ajsc extract a structural sub-type ALSO named
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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;gBACb,QAAQ,EAAE,SAAS;gBACnB,UAAU,EAAE;oBACV,GAAG,EAAE;wBACH,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;4BAC/B,UAAU,EAAE;gCACV,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;oCACd,GAAG,EAAE,SAAS;oCACd,KAAK,EAAE,SAAS;oCAChB,QAAQ,EAAE,CAAC,IAAI,CAAC;oCAChB,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;iCACvC;gCACD,OAAO,EAAE;oCACP,IAAI,EAAE,QAAQ;oCACd,QAAQ,EAAE,CAAC,QAAQ,CAAC;oCACpB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;iCAC5C;6BACF;yBACF;qBACF;iBACF;aACF,CAAC;SACH,CAAC,CAAA;QAEF,MAAM,MAAM,CACV,WAAW,CAAC;YACV,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;SACrB,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"shared-models.test.js","sourceRoot":"","sources":["../../../../src/codegen/targets/ts/shared-models.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG/C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAEhF,8EAA8E;AAC9E,WAAW;AACX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EAAE;oCACP,IAAI,EAAE,QAAQ;oCACd,QAAQ,EAAE,CAAC,QAAQ,CAAC;oCACpB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;iCAC5C;6BACF;yBACF;qBACF;iBACF;aACF,CAAC;SACH,CAAC,CAAA;QAEF,MAAM,MAAM,CACV,WAAW,CAAC;YACV,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;SACrB,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -134,6 +134,9 @@ generated/
|
|
|
134
134
|
| `--uncountable-words <list>` | Comma-separated words to skip singularization (ignored with `--no-namespace-types`) | Off |
|
|
135
135
|
| `--service-name <name>` | Names the service namespace and binding factory (e.g. `Auth` → `export namespace Auth` + `createAuthBindings`). Also prefixes `${Name}Errors` and `${Name}ProcedureErrorUnion` in `_errors.ts`. | `Api` |
|
|
136
136
|
| `--clean-out-dir` / `--no-clean-out-dir` | Prune orphaned generated files from `--out <dir>` before writing — files carrying the `ts-procedures-codegen` signature that this run no longer emits (e.g. a deleted scope). Hand-written files (no signature) are never removed, and subdirectories are left untouched. Skipped under `--dry-run`. Pass `--no-clean-out-dir` to opt out. | **On** |
|
|
137
|
+
| `--share-models` / `--no-share-models` | Collect `$id`-bearing subschemas into a shared `_models.ts` hub; scopes import from there instead of inlining types. | **On** |
|
|
138
|
+
| `--shared-models-module <module>` | Convention form: re-export every `$id` model (with no explicit `sharedTypesImport` entry) from this single module. E.g. `--shared-models-module @app/schemas`. | Off |
|
|
139
|
+
| `--strict-shared-models` | Fail the build if any `$id` model would be generated locally as a structural twin (i.e., not covered by `sharedTypesImport` or `sharedModelsModule`). CI guard. | Off |
|
|
137
140
|
|
|
138
141
|
> **Note:** ajsc formatting options (`--enum-style`, `--depluralize`, `--array-item-naming`, `--uncountable-words`) only take effect in namespace mode (the default). With `--no-namespace-types`, all types are inlined and these options have no effect.
|
|
139
142
|
>
|
|
@@ -527,6 +530,65 @@ await generateClient({
|
|
|
527
530
|
})
|
|
528
531
|
```
|
|
529
532
|
|
|
533
|
+
## Shared Model Types (`_models.ts`)
|
|
534
|
+
|
|
535
|
+
When `shareModels` is on (the default), the codegen pre-pass collects every subschema with a `$id` field, deduplicates them, and emits a single `_models.ts` hub. Every scope that references one of those types imports from `./_models` instead of inlining it — so the type is defined once and shared across scopes.
|
|
536
|
+
|
|
537
|
+
### `sharedTypesImport` — per-`$id` override map
|
|
538
|
+
|
|
539
|
+
For each `$id` you'd rather import from your own package instead of generating locally, add an entry to `sharedTypesImport` in the config file:
|
|
540
|
+
|
|
541
|
+
```jsonc
|
|
542
|
+
// ts-procedures-codegen.config.json
|
|
543
|
+
{
|
|
544
|
+
"sharedTypesImport": {
|
|
545
|
+
"https://example.com/schemas/Message": { "module": "@app/schemas", "name": "Message" }
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
`_models.ts` then re-exports that type from `@app/schemas` instead of generating it — scopes still import from `./_models` (single hub, no scattered imports).
|
|
551
|
+
|
|
552
|
+
### `sharedModelsModule` — one-value convention
|
|
553
|
+
|
|
554
|
+
When ALL (or most) of your `$id`-bearing models live in a single shared package, use `sharedModelsModule` instead of listing each one in the per-`$id` map:
|
|
555
|
+
|
|
556
|
+
```jsonc
|
|
557
|
+
// ts-procedures-codegen.config.json — collapse the per-$id map to one module
|
|
558
|
+
{ "sharedModelsModule": "@app/schemas" }
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
```bash
|
|
562
|
+
npx ts-procedures-codegen --file envelope.json --out gen --shared-models-module @app/schemas
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
Every `$id` model that has no explicit `sharedTypesImport` entry is re-exported from this single module under its derived name (the convention: `$id`/`title` === the exported type name). The generated scope file then imports `Api.Users.GetUser.Response.Body` from `./_models`, which re-exports it from `@app/schemas` — one symbol, not a structural twin.
|
|
566
|
+
|
|
567
|
+
Precedence in `resolveModelImports`: explicit `sharedTypesImport[$id]` → `sharedModelsModule` → generate locally. Use the per-`$id` map only for overrides (rename, a different package per type, multi-consumer setups).
|
|
568
|
+
|
|
569
|
+
### Shared-models diagnostics
|
|
570
|
+
|
|
571
|
+
On the CLI, every codegen run that has `$id`-bearing models prints a neutral one-line summary:
|
|
572
|
+
|
|
573
|
+
```
|
|
574
|
+
[ts-procedures-codegen] Shared models: 5 total — 4 re-exported, 1 generated locally.
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
This makes a silently-generated structural twin visible — if a model you expected to re-export appears in "generated locally", check that its `$id` is covered by `sharedTypesImport` or `sharedModelsModule`.
|
|
578
|
+
|
|
579
|
+
When calling `generateClient` programmatically the run is silent by default (no stray stdout in your build scripts or tests); pass `logger: console.log` to opt into the same summary.
|
|
580
|
+
|
|
581
|
+
**CI guard — `--strict-shared-models`:** pass this flag (or set `strictSharedModels: true` in the config) to turn the silent fallback into a hard error. Codegen will list every `$id` that would be generated as a local structural twin and exit non-zero — a reliable guard against the single-source-of-truth silently degrading:
|
|
582
|
+
|
|
583
|
+
```bash
|
|
584
|
+
# CI: fail the build if any domain entity is generated as a structural twin
|
|
585
|
+
npx ts-procedures-codegen --file envelope.json --out gen --strict-shared-models
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
`strictSharedModels` is off by default so existing setups are unaffected. Enable it once you've confirmed all expected `$id` models are covered.
|
|
589
|
+
|
|
590
|
+
> **Note:** Source-tree scanning (e.g. a `--shared-types-from <dir>` flag) was deliberately not implemented. Codegen is pure-envelope: `--url` and offline `--file` codegen never depend on a local source tree, so it works identically in CI and on a developer's machine.
|
|
591
|
+
|
|
530
592
|
## Self-Contained Mode (Default)
|
|
531
593
|
|
|
532
594
|
By default, the generated output includes two additional files in the output directory:
|
|
@@ -88,6 +88,66 @@ The `else { throw err }` rethrow at the end is intentional: any error that slips
|
|
|
88
88
|
|
|
89
89
|
---
|
|
90
90
|
|
|
91
|
+
## 3a. Discoverability: where the types live and how to reach them
|
|
92
|
+
|
|
93
|
+
Two capabilities are easy to miss because they need no extra imports or wrappers — they fall out of the generated code directly. This section is purely about *finding and using* them.
|
|
94
|
+
|
|
95
|
+
### Narrowing declared errors on the throwing path
|
|
96
|
+
|
|
97
|
+
You do **not** need `.safe()` to narrow typed errors — the throwing path is fully typed. Declared route errors are **real runtime classes**, so they narrow with the same `try/catch` + `instanceof` pattern shown in §3 (`err instanceof ApiErrors.Conflict`), right alongside the framework transport classes — there's no separate API to learn.
|
|
98
|
+
|
|
99
|
+
What makes them *discoverable*: when a server route declares `errors`, codegen also emits that route's error union as a **named type you can hover and import**, so you can see which classes a call may throw without leaving your editor:
|
|
100
|
+
|
|
101
|
+
- **Namespace mode** (default): `Scope.Route.Errors` — e.g. `Api.Users.CreateUser.Errors`.
|
|
102
|
+
- **Flat mode** (`--no-namespace-types`): `RouteErrors` — e.g. `CreateUserErrors`.
|
|
103
|
+
|
|
104
|
+
The classes themselves are the `${ServiceName}Errors` namespace (default `ApiErrors`) — the same one §3 catches against — and each class name matches the taxonomy key declared on the server. The callable's JSDoc names the union inline too: hovering a declared-error route shows `@throws Declared typed errors: {@link Api.Users.CreateUser.Errors} — narrow on the throwing path (§3), or call .safe() for a Result`.
|
|
105
|
+
|
|
106
|
+
Routes that declare *no* errors omit the `Errors` type (and the `kind: 'typed'` arm on `.safe()`) entirely, so their absence is discoverable too. `.safe()` (§4) stays available whenever you'd rather branch on a returned `Result` than catch.
|
|
107
|
+
|
|
108
|
+
### Per-call options (signal, timeout, headers, basePath)
|
|
109
|
+
|
|
110
|
+
Every generated callable takes an **optional second argument**: a `ProcedureCallOptions` bag. It is the per-call seam for cancellation, deadlines, headers, and base-path overrides — no client reconfiguration required.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
export interface ProcedureCallDefaults {
|
|
114
|
+
signal?: AbortSignal // cancel this call (combines with any client-default signal)
|
|
115
|
+
timeout?: number // ms; per-call 0 disables an inherited default timeout
|
|
116
|
+
headers?: ClientHeadersInit // record or (async) () => record; merges over defaults
|
|
117
|
+
basePath?: string // override the base path for this call only
|
|
118
|
+
meta?: RequestMeta // typed per-request metadata (declaration-merged)
|
|
119
|
+
}
|
|
120
|
+
// ProcedureCallOptions = ProcedureCallDefaults + per-call hooks
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The most common case is threading an `AbortSignal` so the request cancels when the caller is torn down (component unmount, route change, a newer request superseding an in-flight one):
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
const controller = new AbortController()
|
|
127
|
+
|
|
128
|
+
// Cancel on unmount / navigation:
|
|
129
|
+
const cleanup = () => controller.abort()
|
|
130
|
+
|
|
131
|
+
const user = await api.users.CreateUser(
|
|
132
|
+
{ email, displayName },
|
|
133
|
+
{ signal: controller.signal },
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
When the signal fires, the in-flight call rejects with `ClientAbortError` (or resolves to `kind: 'aborted'` under `.safe()`), which you typically treat as silent. A per-call `timeout` fires `ClientTimeoutError` the same way:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
// A deliberately slow endpoint gets a longer deadline, just for this call:
|
|
141
|
+
const report = await api.reports.GenerateReport(
|
|
142
|
+
{ range },
|
|
143
|
+
{ timeout: 60_000, signal: controller.signal },
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Per-call options layer over client-wide `defaults` (set via `createApiClient({ defaults })`): headers and `meta` merge (per-call keys win), signals combine via `AbortSignal.any` (whichever aborts first wins), and per-call `timeout` overrides the default — with `timeout: 0` opting out of an inherited default entirely. Options are applied before hooks, so an `onBeforeRequest` hook still has the final say. For the full precedence table and the rotating-token `headers` function form, see [`docs/client-and-codegen.md`](./client-and-codegen.md).
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
91
151
|
## 4. `.safe()` Form: Exhaustive Narrowing
|
|
92
152
|
|
|
93
153
|
The same operation rewritten with `.safe()`. The call never rejects. `r.ok` is the top-level gate; `r.kind` narrows the failure:
|
|
@@ -355,3 +415,30 @@ A framework-level "skip `onError` for `.safe()`" toggle was deliberately deferre
|
|
|
355
415
|
- Design spec: [`docs/superpowers/specs/2026-04-29-safe-result-api-design.md`](./superpowers/specs/2026-04-29-safe-result-api-design.md)
|
|
356
416
|
- Client types and interfaces: `CLAUDE.md` — "Key Files" → `src/client/`
|
|
357
417
|
- Agent config patterns and anti-patterns: `agent_config/claude-code/skills/ts-procedures/patterns.md` and `anti-patterns.md`
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## 11. Design note: typed errors and your state layer
|
|
422
|
+
|
|
423
|
+
ts-procedures throws real, `instanceof`-catchable error classes. On the throwing path you `catch (err)` and narrow with `instanceof` (§3); with `.safe()` you get the same instances inside a `Result` (§4). Either way, the actual thrown value reaches your handler intact — that is the headline of this client's error model, and nothing below qualifies it.
|
|
424
|
+
|
|
425
|
+
### Where the boundary sits
|
|
426
|
+
|
|
427
|
+
A state-management layer that sits between the call and your UI (for example, an async-task tracker in an MVC/store library) sometimes records a failure as a flattened, closed code union — mapping every rejection down to a `string` code or a single `error` enum before your view layer sees it. When that happens, the typed instance is intact when ts-procedures throws it, and lossy by the time your component reads task state. The narrowing in §3/§4 still works at the call site; what changes is what survives storage in the layer above.
|
|
428
|
+
|
|
429
|
+
That flattening is a property of the state layer, not of the transport. ts-procedures has already done its job: it produced an instance you can narrow. The fix — preserving the original thrown value (or its `cause`) on the task state so the UI can still narrow with `instanceof` — belongs to the state layer, which owns that storage decision.
|
|
430
|
+
|
|
431
|
+
### Why the client does not add a transform hook
|
|
432
|
+
|
|
433
|
+
It would be possible to add a client-level "error map" or transform hook that pre-shapes thrown errors into whatever a given state layer expects. We have deliberately chosen not to, for two reasons:
|
|
434
|
+
|
|
435
|
+
1. **It would erase the win.** The value of typed errors is that the *original instance* reaches you. A transform that reshapes errors at the transport boundary to satisfy a downstream consumer is the same flattening, just moved one layer earlier — every other consumer of the same client would inherit a lossy shape to accommodate one state layer.
|
|
436
|
+
2. **The seam already exists, and it is an observer by design.** The `onError` hook (`ClientHooks.onError`) is typed to return `void` — it is a cross-cutting observer for telemetry, not a mutator. The error it observes is the same instance the client then throws; the hook cannot rewrite it, and that is intentional. Both call paths re-throw the original: the typed registry match is thrown as-is (tagged only with an internal `__tsProceduresTyped` marker so `.safe()` can label its `kind`), and the classified adapter error is thrown as the normalized framework instance. The transport's contract is "you get the instance"; honoring that means not reshaping it on the way out.
|
|
437
|
+
|
|
438
|
+
### What to do instead
|
|
439
|
+
|
|
440
|
+
- **Catch at the call site.** Narrow with `instanceof` on the throwing path (§3), or read `Result.error` from `.safe()` (§4), before the value enters a state layer that might flatten it.
|
|
441
|
+
- **Carry the original through your state layer.** If your tracker stores a flattened code, also store the original thrown value (or `error.cause`) alongside it, and narrow against that in the UI. Every framework class carries `cause` for exactly this kind of pass-through (§2).
|
|
442
|
+
- **If your state layer can't carry it, that's where the change goes.** Surfacing the original error on task state is a state-layer concern. ts-procedures will keep throwing the instance; preserving it across the storage boundary is the layer that owns that boundary's responsibility.
|
|
443
|
+
|
|
444
|
+
This keeps each layer's contract clean: the client guarantees a typed, narrowable instance at the throw site, and the state layer decides how much of it to retain.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# DX Round 2 — Findings #13 and #11: schema-authoring remedies
|
|
2
|
+
|
|
3
|
+
Thanks for the careful round-2 report — both #13 and #11 are real friction, and we want to give you the clean fix for each. Both turn out to be schema-authoring choices that live on your side of the contract, so the durable remedy is upstream of codegen. Codegen faithfully reflects the schema it's handed; by the time it runs, each `$id`-bearing model has already been collected as an independent, flattened type (deduped by `$id` and emitted standalone), so codegen has no view of the relationships *between* your models and can't normalize or re-relate them after the fact. Here's the recommended path for each.
|
|
4
|
+
|
|
5
|
+
## #13 — Optional field spells "empty" two ways across Create vs Update
|
|
6
|
+
|
|
7
|
+
**The clean fix (do this):** make the Create/Update pair agree on a single "empty" spelling for the optional field, then one form→body mapping serves both branches.
|
|
8
|
+
|
|
9
|
+
The two bodies currently disagree at the source:
|
|
10
|
+
|
|
11
|
+
- Create authors the field as `Type.Optional(Type.String())` → `string | undefined`
|
|
12
|
+
- Update authors it as `Type.Optional(Type.Union([Type.String(), Type.Null()]))` → `string | null` (plus `undefined`)
|
|
13
|
+
|
|
14
|
+
That divergence is in the authored contract, so the generated types reflect it exactly — codegen widening or normalizing one to match the other would mean overriding your schema and silently emitting a type that no longer matches what the server validates and accepts. We don't want generated client types to disagree with the wire contract.
|
|
15
|
+
|
|
16
|
+
Pick one convention and apply it to both procedures:
|
|
17
|
+
|
|
18
|
+
- Both `string | undefined` — `Type.Optional(Type.String())` on each; "omit to leave unchanged."
|
|
19
|
+
- Both `string | null` — `Type.Optional(Type.Union([Type.String(), Type.Null()]))` on each; `null` is the explicit "clear it" signal.
|
|
20
|
+
|
|
21
|
+
Once the pair is symmetric, a single form→body mapper covers both create and update, and the per-call laundering disappears.
|
|
22
|
+
|
|
23
|
+
## #11 — `UpdateXBody` should be assignable to `Partial<Entity>` without an `as` cast
|
|
24
|
+
|
|
25
|
+
**The clean fix (do this):** derive the update body from a shared entity schema so the subset relationship is expressed in the *schema*, where it can survive into the generated types.
|
|
26
|
+
|
|
27
|
+
This one codegen genuinely cannot synthesize. By the time codegen sees `UpdateXBody`, it's a flattened, independent `$id` model — the "this is a subset of `Entity`" relationship was never encoded in the JSON Schema we received, so there's nothing in the input from which to reconstruct the `Partial`/subset linkage. We'd be inventing a relationship the contract didn't state.
|
|
28
|
+
|
|
29
|
+
Express the relationship at authoring time so it carries through:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// shared entity schema — single source of truth
|
|
33
|
+
const Entity = Type.Object({ /* … all fields … */ }, { $id: 'Entity' })
|
|
34
|
+
|
|
35
|
+
// update body is a structural subset, authored as such
|
|
36
|
+
const UpdateXBody = Type.Partial(Type.Pick(Entity, ['name', 'email', /* … */ ]))
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Authored this way, `UpdateXBody` is structurally a partial subset of `Entity`, and the generated update-body type is assignable to `Partial<Entity>` without a cast.
|
|
40
|
+
|
|
41
|
+
If you'd rather not restructure the schemas right now, the documented `as Partial<Entity>` bridge remains a supported, intentional escape hatch — it's a one-line annotation at the call site and doesn't compromise anything else.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
Happy to pair on either change if it's useful, or to review the schema diff once you've made the Create/Update pair symmetric.
|