@roundtable-bb/sdk 0.1.0 → 0.1.3
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 +48 -0
- package/codegen/extract-spec.ts +1 -1
- package/openapi.json +10207 -484
- package/package.json +1 -1
- package/project.json +8 -0
- package/src/generated/client.ts +11 -11
- package/tsconfig.lib.json +8 -1
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @roundtable-bb/sdk
|
|
2
|
+
|
|
3
|
+
Typed client SDK for the Roundtable API. Auto-generated from the live OpenAPI spec.
|
|
4
|
+
|
|
5
|
+
## How the generation pipeline works
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
API routes (Fastify + Zod)
|
|
9
|
+
│
|
|
10
|
+
▼
|
|
11
|
+
codegen/extract-spec.ts → openapi.json ← generated, do not edit
|
|
12
|
+
│
|
|
13
|
+
▼
|
|
14
|
+
codegen/generate.ts → src/generated/client.ts ← generated, do not edit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
1. **extract-spec.ts** — boots the Fastify app in memory (no real DB/Redis), calls `app.swagger()`, and writes the result to `openapi.json`.
|
|
18
|
+
2. **generate.ts** — reads `openapi.json`, matches request/response schemas against Zod types exported from `@roundtable-bb/types`, and emits a typed `RoundtableClient` class with one method per `operationId`.
|
|
19
|
+
|
|
20
|
+
## Updating the SDK
|
|
21
|
+
|
|
22
|
+
Run this after changing any API route, request body, or response shape:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx nx run @roundtable-bb/sdk:codegen
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This regenerates both `openapi.json` and `src/generated/client.ts`.
|
|
29
|
+
|
|
30
|
+
## Building the browser bundle (optional)
|
|
31
|
+
|
|
32
|
+
For legacy frontends that need a browser IIFE (`window.Roundtable`):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx nx run @roundtable-bb/sdk:bundle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Output: `dist/roundtable.iife.js`
|
|
39
|
+
|
|
40
|
+
## Files
|
|
41
|
+
|
|
42
|
+
| Path | Description |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `openapi.json` | Generated OpenAPI spec — do not edit |
|
|
45
|
+
| `src/generated/client.ts` | Generated typed client — do not edit |
|
|
46
|
+
| `codegen/extract-spec.ts` | Step 1: extracts spec from the live app |
|
|
47
|
+
| `codegen/generate.ts` | Step 2: generates the client from the spec |
|
|
48
|
+
| `codegen/bundle.mjs` | Step 3 (optional): esbuild IIFE bundle |
|
package/codegen/extract-spec.ts
CHANGED
|
@@ -8,7 +8,7 @@ process.env['DATABASE_URL'] ??= 'postgresql://x:x@localhost:5432/x'
|
|
|
8
8
|
process.env['VALKEY_URL'] ??= 'redis://localhost:6379'
|
|
9
9
|
process.env['JWT_SECRET'] ??= 'dummy-for-spec-extraction'
|
|
10
10
|
process.env['BETTER_AUTH_SECRET'] ??= 'dummy-for-spec-extraction'
|
|
11
|
-
process.env['
|
|
11
|
+
process.env['MAIN_DOMAIN'] ??= 'auth.localhost'
|
|
12
12
|
process.env['PLATFORM_OWNER_IDS'] ??= ''
|
|
13
13
|
|
|
14
14
|
import { writeFileSync } from 'fs'
|