@apollo-deploy/tesseract 1.8.0 → 2.0.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 +218 -110
- package/dist/adapters/csharp/index.d.ts +5 -8
- package/dist/adapters/csharp/index.d.ts.map +1 -1
- package/dist/adapters/csharp/index.js +314 -74
- package/dist/adapters/csharp/index.js.map +1 -1
- package/dist/adapters/documentation.d.ts +17 -0
- package/dist/adapters/documentation.d.ts.map +1 -0
- package/dist/adapters/documentation.js +268 -0
- package/dist/adapters/documentation.js.map +1 -0
- package/dist/adapters/go/index.d.ts +5 -8
- package/dist/adapters/go/index.d.ts.map +1 -1
- package/dist/adapters/go/index.js +197 -101
- package/dist/adapters/go/index.js.map +1 -1
- package/dist/adapters/kotlin/index.d.ts +5 -9
- package/dist/adapters/kotlin/index.d.ts.map +1 -1
- package/dist/adapters/kotlin/index.js +280 -212
- package/dist/adapters/kotlin/index.js.map +1 -1
- package/dist/adapters/php/index.d.ts +5 -15
- package/dist/adapters/php/index.d.ts.map +1 -1
- package/dist/adapters/php/index.js +362 -90
- package/dist/adapters/php/index.js.map +1 -1
- package/dist/adapters/python/index.d.ts +5 -8
- package/dist/adapters/python/index.d.ts.map +1 -1
- package/dist/adapters/python/index.js +240 -109
- package/dist/adapters/python/index.js.map +1 -1
- package/dist/adapters/ruby/index.d.ts +3 -3
- package/dist/adapters/ruby/index.d.ts.map +1 -1
- package/dist/adapters/ruby/index.js +235 -46
- package/dist/adapters/ruby/index.js.map +1 -1
- package/dist/adapters/rust/index.d.ts +5 -9
- package/dist/adapters/rust/index.d.ts.map +1 -1
- package/dist/adapters/rust/index.js +237 -169
- package/dist/adapters/rust/index.js.map +1 -1
- package/dist/adapters/shared.d.ts +7 -0
- package/dist/adapters/shared.d.ts.map +1 -0
- package/dist/adapters/shared.js +68 -0
- package/dist/adapters/shared.js.map +1 -0
- package/dist/adapters/type-utils.d.ts +13 -0
- package/dist/adapters/type-utils.d.ts.map +1 -0
- package/dist/adapters/type-utils.js +105 -0
- package/dist/adapters/type-utils.js.map +1 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/emitSchema.d.ts +2 -2
- package/dist/adapters/typescript/emitter/emitSchema.js +39 -27
- package/dist/adapters/typescript/emitter/emitSchema.js.map +1 -1
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.d.ts +2 -2
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.js +15 -15
- package/dist/adapters/typescript/emitter/importCollector.d.ts +2 -4
- package/dist/adapters/typescript/emitter/importCollector.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/importCollector.js +40 -50
- package/dist/adapters/typescript/emitter/importCollector.js.map +1 -1
- package/dist/adapters/typescript/emitter/parsers.d.ts +1 -1
- package/dist/adapters/typescript/emitter/parsers.js +13 -13
- package/dist/adapters/typescript/emitter/typeHoister.d.ts +1 -1
- package/dist/adapters/typescript/emitter/typeHoister.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/typeHoister.js +12 -20
- package/dist/adapters/typescript/emitter/typeHoister.js.map +1 -1
- package/dist/adapters/typescript/index.d.ts +3 -3
- package/dist/adapters/typescript/index.d.ts.map +1 -1
- package/dist/adapters/typescript/index.js +148 -166
- package/dist/adapters/typescript/index.js.map +1 -1
- package/dist/adapters/typescript/shared.d.ts +2 -2
- package/dist/adapters/typescript/shared.js +12 -12
- package/dist/cli.js +50 -37
- package/dist/cli.js.map +1 -1
- package/dist/collector.d.ts +77 -3
- package/dist/collector.d.ts.map +1 -1
- package/dist/collector.js +198 -20
- package/dist/collector.js.map +1 -1
- package/dist/elysia.js +2 -2
- package/dist/elysia.js.map +1 -1
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js.map +1 -1
- package/dist/fastify.d.ts +8 -9
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +105 -164
- package/dist/fastify.js.map +1 -1
- package/dist/helpers/handlebars.d.ts +7 -16
- package/dist/helpers/handlebars.d.ts.map +1 -1
- package/dist/helpers/handlebars.js +127 -177
- package/dist/helpers/handlebars.js.map +1 -1
- package/dist/hono.d.ts.map +1 -1
- package/dist/hono.js.map +1 -1
- package/dist/index.d.ts +14 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -30
- package/dist/index.js.map +1 -1
- package/dist/koa.d.ts.map +1 -1
- package/dist/koa.js.map +1 -1
- package/dist/nestjs.d.ts.map +1 -1
- package/dist/nestjs.js +41 -14
- package/dist/nestjs.js.map +1 -1
- package/dist/pipeline/enrich.d.ts +2 -13
- package/dist/pipeline/enrich.d.ts.map +1 -1
- package/dist/pipeline/enrich.js +157 -212
- package/dist/pipeline/enrich.js.map +1 -1
- package/dist/pipeline/intake.d.ts +3 -3
- package/dist/pipeline/intake.d.ts.map +1 -1
- package/dist/pipeline/intake.js +342 -238
- package/dist/pipeline/intake.js.map +1 -1
- package/dist/pipeline/write.d.ts +1 -14
- package/dist/pipeline/write.d.ts.map +1 -1
- package/dist/pipeline/write.js +73 -113
- package/dist/pipeline/write.js.map +1 -1
- package/dist/types/config.d.ts +14 -26
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +16 -12
- package/dist/types/config.js.map +1 -1
- package/dist/types/ir.d.ts +12 -8
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/manifest.d.ts +10 -11
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/manifest.js +54 -14
- package/dist/types/manifest.js.map +1 -1
- package/dist/types/sdk-module.d.ts +2 -2
- package/dist/types/sdk-module.js +1 -1
- package/dist/utils/format.d.ts +1 -3
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +3 -10
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/naming.d.ts.map +1 -1
- package/dist/utils/naming.js +174 -184
- package/dist/utils/naming.js.map +1 -1
- package/dist/utils/npm-token.d.ts +1 -17
- package/dist/utils/npm-token.d.ts.map +1 -1
- package/dist/utils/npm-token.js +27 -76
- package/dist/utils/npm-token.js.map +1 -1
- package/dist/utils/version.d.ts +14 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +60 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +4 -3
- package/templates/csharp/client.hbs +26 -49
- package/templates/csharp/csproj.hbs +7 -0
- package/templates/csharp/domain.hbs +48 -130
- package/templates/csharp/errors.hbs +17 -25
- package/templates/csharp/readme.hbs +31 -44
- package/templates/csharp/transport.hbs +238 -136
- package/templates/csharp/types.hbs +30 -76
- package/templates/go/client.hbs +44 -109
- package/templates/go/domain.hbs +83 -25
- package/templates/go/go-mod.hbs +1 -4
- package/templates/go/readme.hbs +32 -29
- package/templates/go/transport.hbs +174 -173
- package/templates/go/types.hbs +17 -53
- package/templates/go/utils.hbs +3 -2
- package/templates/kotlin/build-gradle.hbs +1 -1
- package/templates/kotlin/client.hbs +18 -15
- package/templates/kotlin/domain.hbs +54 -51
- package/templates/kotlin/errors.hbs +1 -1
- package/templates/kotlin/readme.hbs +35 -137
- package/templates/kotlin/transport.hbs +140 -123
- package/templates/kotlin/types.hbs +30 -81
- package/templates/php/client.hbs +8 -46
- package/templates/php/composer.hbs +2 -1
- package/templates/php/domain.hbs +86 -117
- package/templates/php/errors.hbs +1 -1
- package/templates/php/readme.hbs +42 -49
- package/templates/php/transport.hbs +192 -145
- package/templates/php/types.hbs +63 -60
- package/templates/python/client.hbs +15 -2
- package/templates/python/domain.hbs +50 -108
- package/templates/python/pyproject.hbs +5 -0
- package/templates/python/readme.hbs +47 -30
- package/templates/python/resources-init.hbs +1 -1
- package/templates/python/transport.hbs +167 -53
- package/templates/python/types.hbs +22 -58
- package/templates/ruby/client.hbs +10 -6
- package/templates/ruby/domain.hbs +48 -67
- package/templates/ruby/errors.hbs +3 -3
- package/templates/ruby/gemspec.hbs +3 -10
- package/templates/ruby/index.hbs +3 -3
- package/templates/ruby/readme.hbs +33 -70
- package/templates/ruby/transport.hbs +129 -103
- package/templates/ruby/types.hbs +11 -16
- package/templates/ruby/version.hbs +1 -1
- package/templates/rust/cargo.hbs +2 -0
- package/templates/rust/client.hbs +10 -1
- package/templates/rust/domain.hbs +69 -52
- package/templates/rust/error.hbs +3 -1
- package/templates/rust/lib.hbs +4 -5
- package/templates/rust/readme.hbs +33 -46
- package/templates/rust/transport.hbs +170 -159
- package/templates/rust/types.hbs +34 -111
- package/templates/typescript/domain-class.hbs +14 -6
- package/templates/typescript/domain.hbs +13 -5
- package/templates/typescript/package-json.hbs +3 -1
- package/templates/typescript/readme.hbs +42 -42
- package/templates/typescript/transport.hbs +46 -8
- package/templates/typescript/types-errors.hbs +1 -1
- package/dist/adapters/typescript/model-emitter.d.ts +0 -13
- package/dist/adapters/typescript/model-emitter.d.ts.map +0 -1
- package/dist/adapters/typescript/model-emitter.js +0 -415
- package/dist/adapters/typescript/model-emitter.js.map +0 -1
package/README.md
CHANGED
|
@@ -26,22 +26,36 @@ This reads your manifest and produces a complete npm-ready TypeScript SDK in `./
|
|
|
26
26
|
|
|
27
27
|
Generate an SDK from a static manifest file.
|
|
28
28
|
|
|
29
|
-
| Flag
|
|
30
|
-
|
|
31
|
-
| `-i, --input <path>`
|
|
32
|
-
| `-o, --output <dir>`
|
|
33
|
-
| `-l, --language <lang>`
|
|
34
|
-
| `-n, --name <name>`
|
|
35
|
-
| `--package-version <version>` | No
|
|
36
|
-
| `--
|
|
37
|
-
| `--
|
|
38
|
-
| `--
|
|
39
|
-
| `--
|
|
40
|
-
| `--
|
|
41
|
-
| `--
|
|
29
|
+
| Flag | Required | Description |
|
|
30
|
+
| ----------------------------- | -------- | -------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `-i, --input <path>` | Yes | Path to the `sdk-manifold/v1` manifest JSON file |
|
|
32
|
+
| `-o, --output <dir>` | Yes | Output directory for the generated SDK |
|
|
33
|
+
| `-l, --language <lang>` | No | Target language: `typescript` (default), `python`, `ruby`, `php`, `go`, `rust`, `kotlin`, `csharp` |
|
|
34
|
+
| `-n, --name <name>` | No | Override the npm package name |
|
|
35
|
+
| `--package-version <version>` | No | Override the generated package version |
|
|
36
|
+
| `--version-bump <type>` | No | Automatic bump type: `patch` (default), `minor`, or `major` |
|
|
37
|
+
| `--client-name <name>` | No | Override the generated client class name |
|
|
38
|
+
| `--base-url <url>` | No | Override the default base URL |
|
|
39
|
+
| `--sdk-style <style>` | No | `functional` (default) or `class` (Resend-style `new MySDK('key')`) |
|
|
40
|
+
| `--client-type <type>` | No | `internal` (full options, default) or `public` (auth key only, baseUrl baked in) |
|
|
41
|
+
| `--dry-run` | No | Preview changes without writing files |
|
|
42
|
+
| `--check` | No | Exit non-zero if generated output is out of date |
|
|
42
43
|
|
|
43
44
|
`--dry-run` and `--check` are mutually exclusive.
|
|
44
45
|
|
|
46
|
+
### Versioning
|
|
47
|
+
|
|
48
|
+
When `packageVersion` is omitted, Tesseract applies `versionBump` to the current package version. TypeScript checks npm first and falls back to `info.version`; other adapters use `info.version`. The default bump is `patch`.
|
|
49
|
+
|
|
50
|
+
Patch and minor components use decimal carry instead of double digits:
|
|
51
|
+
|
|
52
|
+
- `0.0.9` + patch → `0.1.0`
|
|
53
|
+
- `0.9.9` + patch → `1.0.0`
|
|
54
|
+
- `2.9.4` + minor → `3.0.0`
|
|
55
|
+
- `2.8.7` + major → `3.0.0`
|
|
56
|
+
|
|
57
|
+
Set the policy with `--version-bump`, `versionBump` in generator/collector config, or `info.versionBump` in a static manifest. An explicit `packageVersion` always wins.
|
|
58
|
+
|
|
45
59
|
### `tesseract run`
|
|
46
60
|
|
|
47
61
|
Boot an instrumented Fastify app with `TESSERACT_GENERATE=1` to collect annotated routes at runtime and generate an SDK without a static manifest file.
|
|
@@ -56,16 +70,16 @@ The app must register `tesseractPlugin` from `@apollo-deploy/tesseract/fastify`.
|
|
|
56
70
|
|
|
57
71
|
Tesseract ships adapters for multiple target languages. Pass `-l <lang>` to `tesseract generate`, set `language` in `CollectorOptions`, or use `additionalTargets` to emit multiple languages in a single run.
|
|
58
72
|
|
|
59
|
-
| Language
|
|
60
|
-
|
|
61
|
-
| TypeScript | `typescript` | npm-ready package with Axios transport
|
|
62
|
-
| Python
|
|
63
|
-
| Ruby
|
|
64
|
-
| PHP
|
|
65
|
-
| Go
|
|
66
|
-
| Rust
|
|
67
|
-
| Kotlin
|
|
68
|
-
| C#
|
|
73
|
+
| Language | Value | Output |
|
|
74
|
+
| ---------- | ------------ | ------------------------------------------------ |
|
|
75
|
+
| TypeScript | `typescript` | npm-ready package with Axios transport |
|
|
76
|
+
| Python | `python` | pip-ready package |
|
|
77
|
+
| Ruby | `ruby` | gem-ready package |
|
|
78
|
+
| PHP | `php` | Composer package |
|
|
79
|
+
| Go | `go` | Go module |
|
|
80
|
+
| Rust | `rust` | Cargo crate |
|
|
81
|
+
| Kotlin | `kotlin` | Gradle project with Ktor + kotlinx.serialization |
|
|
82
|
+
| C# | `csharp` | NuGet package |
|
|
69
83
|
|
|
70
84
|
### Multiple targets in one run
|
|
71
85
|
|
|
@@ -73,8 +87,12 @@ Use `additionalTargets` on any collector or the Fastify plugin to emit multiple
|
|
|
73
87
|
|
|
74
88
|
```ts
|
|
75
89
|
const collector = new SDKCollector({
|
|
76
|
-
info: {
|
|
77
|
-
|
|
90
|
+
info: {
|
|
91
|
+
title: 'My API',
|
|
92
|
+
version: '1.0.0',
|
|
93
|
+
baseUrl: 'https://api.example.com',
|
|
94
|
+
},
|
|
95
|
+
output: './sdk/typescript', // primary — TypeScript
|
|
78
96
|
additionalTargets: [
|
|
79
97
|
{ language: 'kotlin', output: './sdk/java' },
|
|
80
98
|
{ language: 'python', output: './sdk/python', packageName: 'my-api' },
|
|
@@ -84,6 +102,39 @@ const collector = new SDKCollector({
|
|
|
84
102
|
|
|
85
103
|
Each additional target inherits `clientType`, `packageName`, `packageVersion`, and `sdkStyle` from the primary options unless overridden per-target.
|
|
86
104
|
|
|
105
|
+
Non-TypeScript additional targets automatically expand registered Zod / `$defs` types into local models (they cannot import a TypeScript `schemaPackage`). TypeScript additional targets inherit `schemaPackage` and re-export those types instead of regenerating them.
|
|
106
|
+
|
|
107
|
+
## Generated SDK structure
|
|
108
|
+
|
|
109
|
+
Every adapter emits a compact package overview and a separate reference tree:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
README.md
|
|
113
|
+
docs/
|
|
114
|
+
├── README.md # documentation index
|
|
115
|
+
├── types.md # generated models, enums, unions, and aliases
|
|
116
|
+
└── domains/
|
|
117
|
+
├── users.md # operations for one API domain
|
|
118
|
+
└── billing.md
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The root README contains installation, quick start, reliability configuration, error handling, and links into the reference. Domain pages document HTTP paths, parameters by location, request bodies, response types, deprecations, streaming behavior, and links to generated source.
|
|
122
|
+
|
|
123
|
+
### Generated transport reliability
|
|
124
|
+
|
|
125
|
+
Generated transports share the same baseline behavior across all target languages:
|
|
126
|
+
|
|
127
|
+
- Bounded request timeouts and cancellation where the language supports it
|
|
128
|
+
- Structured errors with status, code, message, and request ID
|
|
129
|
+
- Retries for transient network failures and HTTP `408`, `425`, `429`, `500`, `502`, `503`, and `504`
|
|
130
|
+
- Exponential backoff with jitter and `Retry-After` support
|
|
131
|
+
- Automatic retries for idempotent methods only
|
|
132
|
+
- `POST` and `PATCH` retries only when explicitly enabled or an `X-Idempotency-Key` is supplied
|
|
133
|
+
- Default headers and a generated SDK user agent where the runtime permits it
|
|
134
|
+
- Explicit client cleanup for transports that own sockets or connection pools
|
|
135
|
+
|
|
136
|
+
The exact option names follow each target language's conventions and are shown in the generated README.
|
|
137
|
+
|
|
87
138
|
## Input: The Manifest
|
|
88
139
|
|
|
89
140
|
Tesseract consumes a `BackendManifest` JSON file with `$schema: "sdk-manifold/v1"`:
|
|
@@ -94,6 +145,7 @@ Tesseract consumes a `BackendManifest` JSON file with `$schema: "sdk-manifold/v1
|
|
|
94
145
|
"info": {
|
|
95
146
|
"title": "My API",
|
|
96
147
|
"version": "1.0.0",
|
|
148
|
+
"versionBump": "patch",
|
|
97
149
|
"description": "An example API",
|
|
98
150
|
"baseUrl": "https://api.example.com"
|
|
99
151
|
},
|
|
@@ -129,7 +181,7 @@ Tesseract consumes a `BackendManifest` JSON file with `$schema: "sdk-manifold/v1
|
|
|
129
181
|
|
|
130
182
|
### Key Manifest Fields
|
|
131
183
|
|
|
132
|
-
- **`info`** — Title, version, description, and base URL for the API
|
|
184
|
+
- **`info`** — Title, version, optional `versionBump`, description, and base URL for the API
|
|
133
185
|
- **`domains`** — Groups of routes organized by domain, each with a prefix, stability level (`stable` / `experimental` / `internal`), and route definitions. `internal`-stability domains are excluded from public SDK builds.
|
|
134
186
|
- **`definitions`** — JSON Schema definitions for shared types
|
|
135
187
|
- **`schemaPackage`** _(optional)_ — An external npm package to import types from instead of generating them
|
|
@@ -147,14 +199,14 @@ Each route in a domain can specify:
|
|
|
147
199
|
|
|
148
200
|
Tesseract ships adapters for every major Node.js API framework. Each adapter is a separate subpath export so you only pull in what you use.
|
|
149
201
|
|
|
150
|
-
| Framework
|
|
151
|
-
|
|
152
|
-
| **Fastify**
|
|
153
|
-
| **Express**
|
|
154
|
-
| **Hono**
|
|
155
|
-
| **Koa**
|
|
156
|
-
| **Elysia**
|
|
157
|
-
| **NestJS**
|
|
202
|
+
| Framework | Import |
|
|
203
|
+
| --------------------------- | --------------------------------------------------------- |
|
|
204
|
+
| **Fastify** | `@apollo-deploy/tesseract/fastify` |
|
|
205
|
+
| **Express** | `@apollo-deploy/tesseract/express` |
|
|
206
|
+
| **Hono** | `@apollo-deploy/tesseract/hono` |
|
|
207
|
+
| **Koa** | `@apollo-deploy/tesseract/koa` |
|
|
208
|
+
| **Elysia** | `@apollo-deploy/tesseract/elysia` |
|
|
209
|
+
| **NestJS** | `@apollo-deploy/tesseract/nestjs` |
|
|
158
210
|
| **Generic / any framework** | `import { SDKCollector } from '@apollo-deploy/tesseract'` |
|
|
159
211
|
|
|
160
212
|
All adapters share the same `CollectorOptions` interface, which means `language` and `additionalTargets` work identically across every framework.
|
|
@@ -170,12 +222,14 @@ The Fastify adapter hooks into `onRoute` to collect routes automatically at boot
|
|
|
170
222
|
import { tesseractPlugin } from '@apollo-deploy/tesseract/fastify';
|
|
171
223
|
|
|
172
224
|
app.register(tesseractPlugin, {
|
|
173
|
-
info: {
|
|
225
|
+
info: {
|
|
226
|
+
title: 'My API',
|
|
227
|
+
version: '1.0.0',
|
|
228
|
+
baseUrl: 'https://api.example.com',
|
|
229
|
+
},
|
|
174
230
|
output: './packages/api-sdk',
|
|
175
231
|
// Generate a Kotlin SDK alongside the primary TypeScript one:
|
|
176
|
-
additionalTargets: [
|
|
177
|
-
{ language: 'kotlin', output: './sdk/java' },
|
|
178
|
-
],
|
|
232
|
+
additionalTargets: [{ language: 'kotlin', output: './sdk/java' }],
|
|
179
233
|
// Optional: import types from a shared package instead of regenerating them
|
|
180
234
|
schemaPackage: { name: '@my-org/schemas', version: '^2.0.0' },
|
|
181
235
|
sdkStyle: 'functional', // or 'class'
|
|
@@ -188,10 +242,14 @@ The plugin is a complete no-op unless `TESSERACT_GENERATE=1` is set, so it is sa
|
|
|
188
242
|
Add `sdk` as a top-level option on each route (sibling to `schema`):
|
|
189
243
|
|
|
190
244
|
```ts
|
|
191
|
-
fastify.get(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
245
|
+
fastify.get(
|
|
246
|
+
'/:id',
|
|
247
|
+
{
|
|
248
|
+
schema: { response: { 200: UserSchema } },
|
|
249
|
+
sdk: { methodName: 'getUser' },
|
|
250
|
+
},
|
|
251
|
+
handler,
|
|
252
|
+
);
|
|
195
253
|
```
|
|
196
254
|
|
|
197
255
|
Use `sdkDomain()` to name the domain and set a description:
|
|
@@ -203,10 +261,14 @@ import { sdkDomain } from '@apollo-deploy/tesseract/fastify';
|
|
|
203
261
|
export default fp(async (fastify) => {
|
|
204
262
|
sdkDomain(fastify, { domain: 'users', description: 'User management' });
|
|
205
263
|
|
|
206
|
-
fastify.get(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
264
|
+
fastify.get(
|
|
265
|
+
'/:id',
|
|
266
|
+
{
|
|
267
|
+
schema: { response: { 200: UserSchema } },
|
|
268
|
+
sdk: { methodName: 'getUser' },
|
|
269
|
+
},
|
|
270
|
+
handler,
|
|
271
|
+
);
|
|
210
272
|
});
|
|
211
273
|
```
|
|
212
274
|
|
|
@@ -224,6 +286,7 @@ export class UsersPlugin {
|
|
|
224
286
|
```
|
|
225
287
|
|
|
226
288
|
**Trigger:**
|
|
289
|
+
|
|
227
290
|
```bash
|
|
228
291
|
tesseract run dist/app.js
|
|
229
292
|
# or
|
|
@@ -240,21 +303,29 @@ import { ExpressSDKCollector } from '@apollo-deploy/tesseract/express';
|
|
|
240
303
|
|
|
241
304
|
const app = express();
|
|
242
305
|
const collector = new ExpressSDKCollector({
|
|
243
|
-
info: {
|
|
306
|
+
info: {
|
|
307
|
+
title: 'My API',
|
|
308
|
+
version: '1.0.0',
|
|
309
|
+
baseUrl: 'https://api.example.com',
|
|
310
|
+
},
|
|
244
311
|
output: './packages/api-sdk',
|
|
245
|
-
additionalTargets: [
|
|
246
|
-
{ language: 'kotlin', output: './sdk/java' },
|
|
247
|
-
],
|
|
312
|
+
additionalTargets: [{ language: 'kotlin', output: './sdk/java' }],
|
|
248
313
|
});
|
|
249
314
|
|
|
250
315
|
collector.domain('/users', { domain: 'users', description: 'User management' });
|
|
251
316
|
|
|
252
|
-
app.get(
|
|
253
|
-
|
|
317
|
+
app.get(
|
|
318
|
+
'/users/:id',
|
|
319
|
+
collector.expressRoute('/users/:id', 'GET', {
|
|
320
|
+
sdk: { methodName: 'getUser' },
|
|
321
|
+
}),
|
|
254
322
|
getUserHandler,
|
|
255
323
|
);
|
|
256
|
-
app.post(
|
|
257
|
-
|
|
324
|
+
app.post(
|
|
325
|
+
'/users',
|
|
326
|
+
collector.expressRoute('/users', 'POST', {
|
|
327
|
+
sdk: { methodName: 'createUser' },
|
|
328
|
+
}),
|
|
258
329
|
createUserHandler,
|
|
259
330
|
);
|
|
260
331
|
|
|
@@ -276,14 +347,21 @@ import { HonoSDKCollector } from '@apollo-deploy/tesseract/hono';
|
|
|
276
347
|
|
|
277
348
|
const app = new Hono();
|
|
278
349
|
const collector = new HonoSDKCollector({
|
|
279
|
-
info: {
|
|
350
|
+
info: {
|
|
351
|
+
title: 'My API',
|
|
352
|
+
version: '1.0.0',
|
|
353
|
+
baseUrl: 'https://api.example.com',
|
|
354
|
+
},
|
|
280
355
|
output: './packages/api-sdk',
|
|
281
356
|
});
|
|
282
357
|
|
|
283
358
|
collector.domain('/users', { domain: 'users', description: 'User management' });
|
|
284
359
|
|
|
285
|
-
app.get(
|
|
286
|
-
|
|
360
|
+
app.get(
|
|
361
|
+
'/users/:id',
|
|
362
|
+
collector.honoMiddleware('/users/:id', 'GET', {
|
|
363
|
+
sdk: { methodName: 'getUser' },
|
|
364
|
+
}),
|
|
287
365
|
(c) => c.json(getUser(c.req.param('id'))),
|
|
288
366
|
);
|
|
289
367
|
|
|
@@ -306,14 +384,21 @@ import { KoaSDKCollector } from '@apollo-deploy/tesseract/koa';
|
|
|
306
384
|
const app = new Koa();
|
|
307
385
|
const router = new Router();
|
|
308
386
|
const collector = new KoaSDKCollector({
|
|
309
|
-
info: {
|
|
387
|
+
info: {
|
|
388
|
+
title: 'My API',
|
|
389
|
+
version: '1.0.0',
|
|
390
|
+
baseUrl: 'https://api.example.com',
|
|
391
|
+
},
|
|
310
392
|
output: './packages/api-sdk',
|
|
311
393
|
});
|
|
312
394
|
|
|
313
395
|
collector.domain('/users', { domain: 'users', description: 'User management' });
|
|
314
396
|
|
|
315
|
-
router.get(
|
|
316
|
-
|
|
397
|
+
router.get(
|
|
398
|
+
'/users/:id',
|
|
399
|
+
collector.koaMiddleware('/users/:id', 'GET', {
|
|
400
|
+
sdk: { methodName: 'getUser' },
|
|
401
|
+
}),
|
|
317
402
|
getUserHandler,
|
|
318
403
|
);
|
|
319
404
|
|
|
@@ -335,7 +420,11 @@ import { Elysia } from 'elysia';
|
|
|
335
420
|
import { tesseractPlugin } from '@apollo-deploy/tesseract/elysia';
|
|
336
421
|
|
|
337
422
|
const { plugin, collector } = tesseractPlugin({
|
|
338
|
-
info: {
|
|
423
|
+
info: {
|
|
424
|
+
title: 'My API',
|
|
425
|
+
version: '1.0.0',
|
|
426
|
+
baseUrl: 'https://api.example.com',
|
|
427
|
+
},
|
|
339
428
|
output: './packages/api-sdk',
|
|
340
429
|
});
|
|
341
430
|
|
|
@@ -382,7 +471,10 @@ export class UsersController {
|
|
|
382
471
|
// main.ts
|
|
383
472
|
import { NestFactory } from '@nestjs/core';
|
|
384
473
|
import { AppModule } from './app.module';
|
|
385
|
-
import {
|
|
474
|
+
import {
|
|
475
|
+
SDKCollector,
|
|
476
|
+
collectFromNestControllers,
|
|
477
|
+
} from '@apollo-deploy/tesseract/nestjs';
|
|
386
478
|
import { UsersController } from './users/users.controller';
|
|
387
479
|
|
|
388
480
|
async function bootstrap() {
|
|
@@ -391,11 +483,13 @@ async function bootstrap() {
|
|
|
391
483
|
|
|
392
484
|
if (process.env.TESSERACT_GENERATE) {
|
|
393
485
|
const collector = new SDKCollector({
|
|
394
|
-
info: {
|
|
486
|
+
info: {
|
|
487
|
+
title: 'My API',
|
|
488
|
+
version: '1.0.0',
|
|
489
|
+
baseUrl: 'https://api.example.com',
|
|
490
|
+
},
|
|
395
491
|
output: './packages/api-sdk',
|
|
396
|
-
additionalTargets: [
|
|
397
|
-
{ language: 'kotlin', output: './sdk/java' },
|
|
398
|
-
],
|
|
492
|
+
additionalTargets: [{ language: 'kotlin', output: './sdk/java' }],
|
|
399
493
|
});
|
|
400
494
|
collectFromNestControllers([UsersController], collector);
|
|
401
495
|
await collector.generate();
|
|
@@ -422,7 +516,11 @@ Use `SDKCollector` directly from the main package with any HTTP framework:
|
|
|
422
516
|
import { SDKCollector } from '@apollo-deploy/tesseract';
|
|
423
517
|
|
|
424
518
|
const collector = new SDKCollector({
|
|
425
|
-
info: {
|
|
519
|
+
info: {
|
|
520
|
+
title: 'My API',
|
|
521
|
+
version: '1.0.0',
|
|
522
|
+
baseUrl: 'https://api.example.com',
|
|
523
|
+
},
|
|
426
524
|
output: './packages/api-sdk',
|
|
427
525
|
additionalTargets: [
|
|
428
526
|
{ language: 'kotlin', output: './sdk/java' },
|
|
@@ -521,14 +619,18 @@ const client = createMyApiClient({
|
|
|
521
619
|
apiKey: 'sk_...',
|
|
522
620
|
timeoutMs: 10000,
|
|
523
621
|
retries: { attempts: 3, backoffMs: 500, jitter: true },
|
|
524
|
-
plugins: [
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
622
|
+
plugins: [
|
|
623
|
+
{
|
|
624
|
+
name: 'logger',
|
|
625
|
+
beforeRequest(config) {
|
|
626
|
+
console.log('→', config.method, config.url);
|
|
627
|
+
},
|
|
528
628
|
},
|
|
529
|
-
|
|
629
|
+
],
|
|
530
630
|
onError({ method, url, error, attempt, willRetry }) {
|
|
531
|
-
console.error(
|
|
631
|
+
console.error(
|
|
632
|
+
`${method} ${url} failed (attempt ${attempt}, retry: ${willRetry})`,
|
|
633
|
+
);
|
|
532
634
|
},
|
|
533
635
|
});
|
|
534
636
|
|
|
@@ -581,7 +683,7 @@ await generate({
|
|
|
581
683
|
output: './sdk',
|
|
582
684
|
language: 'kotlin',
|
|
583
685
|
packageName: '@my-org/api-sdk',
|
|
584
|
-
|
|
686
|
+
versionBump: 'minor',
|
|
585
687
|
});
|
|
586
688
|
```
|
|
587
689
|
|
|
@@ -591,7 +693,9 @@ You can also pass a pre-parsed manifest object:
|
|
|
591
693
|
import { generate } from '@apollo-deploy/tesseract';
|
|
592
694
|
import type { BackendManifest } from '@apollo-deploy/tesseract';
|
|
593
695
|
|
|
594
|
-
const manifest: BackendManifest = {
|
|
696
|
+
const manifest: BackendManifest = {
|
|
697
|
+
/* ... */
|
|
698
|
+
};
|
|
595
699
|
|
|
596
700
|
await generate({ manifest, output: './sdk', language: 'kotlin' });
|
|
597
701
|
```
|
|
@@ -600,49 +704,53 @@ await generate({ manifest, output: './sdk', language: 'kotlin' });
|
|
|
600
704
|
|
|
601
705
|
Either `input` or `manifest` must be provided.
|
|
602
706
|
|
|
603
|
-
| Option
|
|
604
|
-
|
|
605
|
-
| `input`
|
|
606
|
-
| `manifest`
|
|
607
|
-
| `output`
|
|
608
|
-
| `language`
|
|
609
|
-
| `packageName`
|
|
610
|
-
| `packageVersion` | `string?`
|
|
611
|
-
| `
|
|
612
|
-
| `
|
|
613
|
-
| `
|
|
614
|
-
| `
|
|
615
|
-
| `
|
|
616
|
-
| `
|
|
617
|
-
| `
|
|
618
|
-
| `
|
|
707
|
+
| Option | Type | Description |
|
|
708
|
+
| ---------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
709
|
+
| `input` | `string?` | Path to the manifest file. Required if `manifest` is not provided. |
|
|
710
|
+
| `manifest` | `BackendManifest?` | Pre-parsed manifest object. Alternative to `input`. |
|
|
711
|
+
| `output` | `string` | Output directory |
|
|
712
|
+
| `language` | `TargetLanguage?` | Target language (default: `typescript`). One of: `typescript`, `python`, `ruby`, `php`, `go`, `rust`, `kotlin`, `csharp` |
|
|
713
|
+
| `packageName` | `string?` | Override npm/package name |
|
|
714
|
+
| `packageVersion` | `string?` | Exact generated package version override |
|
|
715
|
+
| `versionBump` | `'patch' \| 'minor' \| 'major'?` | Automatic bump when `packageVersion` is omitted; defaults to `patch` |
|
|
716
|
+
| `clientName` | `string?` | Override client class name |
|
|
717
|
+
| `baseUrl` | `string?` | Override default base URL |
|
|
718
|
+
| `sdkStyle` | `'functional' \| 'class'?` | `functional` (default) generates a `createMyClient(config)` factory; `class` generates a Resend-style `new MySDK('api_key', options?)` class |
|
|
719
|
+
| `clientType` | `'internal' \| 'public'?` | `internal` (default) exposes full config options; `public` accepts only an auth key with `baseUrl` baked in |
|
|
720
|
+
| `environments` | `{ name: string; baseUrl: string }[]?` | Named environment presets |
|
|
721
|
+
| `dryRun` | `boolean?` | Transform only, no file I/O |
|
|
722
|
+
| `check` | `boolean?` | Compare output without writing |
|
|
723
|
+
| `prettier` | `boolean?` | Toggle formatting (default: `true`) |
|
|
619
724
|
|
|
620
725
|
### `CollectorOptions`
|
|
621
726
|
|
|
622
727
|
Shared by all framework adapters and `SDKCollector`. Extends the programmatic API config with `additionalTargets`.
|
|
623
728
|
|
|
624
|
-
| Option
|
|
625
|
-
|
|
626
|
-
| `info`
|
|
627
|
-
| `output`
|
|
628
|
-
| `language`
|
|
629
|
-
| `additionalTargets` | `AdditionalTarget[]?`
|
|
630
|
-
| `schemaPackage`
|
|
631
|
-
| `sdkStyle`
|
|
632
|
-
| `clientType`
|
|
633
|
-
| `packageName`
|
|
634
|
-
| `packageVersion`
|
|
729
|
+
| Option | Type | Description |
|
|
730
|
+
| ------------------- | -------------------------------- | ------------------------------------------------------------ |
|
|
731
|
+
| `info` | `object` | API metadata: `title`, `version`, `baseUrl?`, `description?` |
|
|
732
|
+
| `output` | `string` | Primary output directory |
|
|
733
|
+
| `language` | `TargetLanguage?` | Primary target language (default: `typescript`) |
|
|
734
|
+
| `additionalTargets` | `AdditionalTarget[]?` | Extra languages to emit alongside the primary output |
|
|
735
|
+
| `schemaPackage` | `object?` | External type package: `name`, `version?`, `importPath?` |
|
|
736
|
+
| `sdkStyle` | `'functional' \| 'class'?` | SDK style |
|
|
737
|
+
| `clientType` | `'internal' \| 'public'?` | Client type |
|
|
738
|
+
| `packageName` | `string?` | Override package name |
|
|
739
|
+
| `packageVersion` | `string?` | Exact package version override |
|
|
740
|
+
| `versionBump` | `'patch' \| 'minor' \| 'major'?` | Automatic bump policy; defaults to `patch` |
|
|
635
741
|
|
|
636
742
|
Each `AdditionalTarget` entry:
|
|
637
743
|
|
|
638
|
-
| Field
|
|
639
|
-
|
|
640
|
-
| `language`
|
|
641
|
-
| `output`
|
|
642
|
-
| `packageName`
|
|
643
|
-
| `packageVersion` | `string?`
|
|
644
|
-
| `
|
|
645
|
-
| `
|
|
744
|
+
| Field | Type | Description |
|
|
745
|
+
| ---------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
746
|
+
| `language` | `TargetLanguage` | Required. Target language for this output |
|
|
747
|
+
| `output` | `string` | Required. Output directory |
|
|
748
|
+
| `packageName` | `string?` | Overrides primary `packageName` for this target |
|
|
749
|
+
| `packageVersion` | `string?` | Overrides primary `packageVersion` for this target |
|
|
750
|
+
| `versionBump` | `'patch' \| 'minor' \| 'major'?` | Overrides primary `versionBump` for this target |
|
|
751
|
+
| `clientType` | `'internal' \| 'public'?` | Overrides primary `clientType` for this target |
|
|
752
|
+
| `sdkStyle` | `'functional' \| 'class'?` | Overrides primary `sdkStyle` for this target |
|
|
753
|
+
| `schemaPackage` | `object \| null?` | Override schema package. Non-TS languages default to expanding types inline (`null`). Pass an object to force external imports, or `null` explicitly. |
|
|
646
754
|
|
|
647
755
|
## Requirements
|
|
648
756
|
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { EnrichedSDKIR } from "../../types/ir.js";
|
|
6
|
-
import type { LanguageAdapter, EmitResult } from "../types.js";
|
|
7
|
-
import type { ResolvedConfig } from "../../types/config.js";
|
|
1
|
+
/** C# language adapter targeting .NET 8. */
|
|
2
|
+
import type { EnrichedSDKIR } from '../../types/ir.js';
|
|
3
|
+
import type { ResolvedConfig } from '../../types/config.js';
|
|
4
|
+
import type { EmitResult, LanguageAdapter } from '../types.js';
|
|
8
5
|
export declare class CSharpAdapter implements LanguageAdapter {
|
|
9
6
|
readonly language = "csharp";
|
|
10
|
-
emit(enriched: EnrichedSDKIR,
|
|
7
|
+
emit(enriched: EnrichedSDKIR, _outputDir: string, config?: ResolvedConfig): Promise<EmitResult>;
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/csharp/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/csharp/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAK5C,OAAO,KAAK,EACV,aAAa,EAId,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAuU/D,qBAAa,aAAc,YAAW,eAAe;IACnD,QAAQ,CAAC,QAAQ,YAAY;IAEvB,IAAI,CACR,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC;CAsGvB"}
|