@ts-pf/codegen 0.1.0-beta.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,52 @@
1
+ ---
2
+ name: ts-pf-codegen
3
+ description: Use when emitting a split-repo ts-pf Contract .d.ts from catalog() with emit, catalogHash, or ts-pf-codegen. Triggers: @ts-pf/codegen, emit(), catalogHash(), ts-pf-codegen, generated Contract.
4
+ ---
5
+
6
+ # @ts-pf/codegen
7
+
8
+ Print a nested `Contract` `.d.ts` from `catalog()`. Frontend still uses `createClient<Contract>(link)`.
9
+
10
+ Install: `npm i @ts-pf/codegen@beta`
11
+
12
+ Link for agents: `npx skills experimental_sync -y`
13
+
14
+ ## Do
15
+
16
+ ```ts
17
+ import { catalog } from '@ts-pf/docs'
18
+ import { emit, catalogHash } from '@ts-pf/codegen'
19
+ import { writeFileSync } from 'node:fs'
20
+
21
+ const spec = catalog(contract, { prefix: '/rpc' })
22
+ writeFileSync('contract.d.ts', emit(spec))
23
+ catalogHash(spec) // 'sha256:<hex>'
24
+ ```
25
+
26
+ ```ts
27
+ import { createClient } from '@ts-pf/client'
28
+ import { FetchLink } from '@ts-pf/client-http'
29
+ import type { Contract } from './contract.js'
30
+
31
+ const client = createClient<Contract>(new FetchLink({ url: '/rpc' }))
32
+ ```
33
+
34
+ CLI: `ts-pf-codegen emit <catalog.json|-> [-o contract.d.ts]`. Also `pull` / `hash`. Serve `catalog.json` in userland, not `FetchHandler`.
35
+
36
+ ## API
37
+
38
+ - `emit`, `catalogHash`, `EmitOptions`
39
+ - CLI `ts-pf-codegen` (not exported from `"."`)
40
+
41
+ ## Pair with
42
+
43
+ - Catalog: `ts-pf-docs`
44
+ - Client: `ts-pf-client`
45
+ - Polyglot spec: `ts-pf-openapi`
46
+
47
+ ## Don't
48
+
49
+ - `createClientFromCatalog`.
50
+ - Generate from a live `app` or `tsc --dts` of the backend.
51
+ - Name the generated type `AppRouter` — it is `Contract`.
52
+ - Serve the catalog from `FetchHandler`.