@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.
- package/README.md +96 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +232 -0
- package/dist/cli.js.map +1 -0
- package/dist/emit.d.ts +11 -0
- package/dist/emit.d.ts.map +1 -0
- package/dist/emit.js +147 -0
- package/dist/emit.js.map +1 -0
- package/dist/hash.d.ts +3 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +21 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/names.d.ts +6 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +73 -0
- package/dist/names.js.map +1 -0
- package/dist/phantom.d.ts +2 -0
- package/dist/phantom.d.ts.map +1 -0
- package/dist/phantom.js +9 -0
- package/dist/phantom.js.map +1 -0
- package/dist/print-type.d.ts +11 -0
- package/dist/print-type.d.ts.map +1 -0
- package/dist/print-type.js +390 -0
- package/dist/print-type.js.map +1 -0
- package/dist/tree.d.ts +12 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +45 -0
- package/dist/tree.js.map +1 -0
- package/package.json +56 -0
- package/skills/ts-pf-codegen/SKILL.md +52 -0
|
@@ -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`.
|