@workos/oagen 0.2.0 → 0.4.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 +72 -0
- package/dist/cli/index.mjs +1076 -73
- package/dist/cli/index.mjs.map +1 -1
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.mjs +9 -4
- package/dist/compat/index.mjs.map +1 -1
- package/dist/{diff-DyQF4sel.mjs → diff-DcY93sii.mjs} +619 -18
- package/dist/diff-DcY93sii.mjs.map +1 -0
- package/dist/{differ-BwelBJN0.mjs → differ-CG5ZErKl.mjs} +2 -2
- package/dist/{differ-BwelBJN0.mjs.map → differ-CG5ZErKl.mjs.map} +1 -1
- package/dist/index.d.mts +136 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +337 -29
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +351 -34
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.d.mts +138 -0
- package/dist/smoke.d.mts.map +1 -1
- package/dist/smoke.mjs +351 -34
- package/dist/smoke.mjs.map +1 -1
- package/dist/{tree-sitter-BPNfbEzY.mjs → tree-sitter-C53w_0WE.mjs} +42 -9
- package/dist/tree-sitter-C53w_0WE.mjs.map +1 -0
- package/dist/{types-O25qZxMl.d.mts → types-D1tMqLVB.d.mts} +165 -2
- package/dist/types-D1tMqLVB.d.mts.map +1 -0
- package/dist/verify/index.d.mts +1 -1
- package/dist/verify/index.mjs +5 -5
- package/dist/verify/index.mjs.map +1 -1
- package/docs/architecture/ir-types.md +73 -1
- package/docs/cli.md +29 -8
- package/package.json +4 -4
- package/skills/review-operations/SKILL.md +83 -0
- package/dist/diff-DyQF4sel.mjs.map +0 -1
- package/dist/tree-sitter-BPNfbEzY.mjs.map +0 -1
- package/dist/types-O25qZxMl.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -69,6 +69,8 @@ The default `@workos/oagen` entrypoint is intentionally focused on the framework
|
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
71
|
import {
|
|
72
|
+
defaultSdkBehavior,
|
|
73
|
+
mergeSdkBehavior,
|
|
72
74
|
diffSpecs,
|
|
73
75
|
generate,
|
|
74
76
|
generateFiles,
|
|
@@ -82,6 +84,7 @@ import {
|
|
|
82
84
|
} from "@workos/oagen";
|
|
83
85
|
import type {
|
|
84
86
|
ApiSpec,
|
|
87
|
+
SdkBehavior,
|
|
85
88
|
Emitter,
|
|
86
89
|
EmitterContext,
|
|
87
90
|
GeneratedFile,
|
|
@@ -138,6 +141,74 @@ Start with:
|
|
|
138
141
|
- [Emitter Contract](docs/architecture/emitter-contract.md)
|
|
139
142
|
- [IR Type System Reference](docs/architecture/ir-types.md)
|
|
140
143
|
|
|
144
|
+
## SDK Behavior
|
|
145
|
+
|
|
146
|
+
`ApiSpec.sdk` contains language-agnostic runtime policies — retry logic, error mapping, telemetry, pagination delays, User-Agent construction, and more. It is always populated (via `defaultSdkBehavior()` during parsing).
|
|
147
|
+
|
|
148
|
+
Emitters read policy from `ctx.spec.sdk` instead of hardcoding values:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
function generateHttpClient(ctx: EmitterContext) {
|
|
152
|
+
const sdk = ctx.spec.sdk;
|
|
153
|
+
const retryCodes = sdk.retry.retryableStatusCodes; // [429, 500, 502, 503, 504]
|
|
154
|
+
const maxRetries = sdk.retry.maxRetries; // 3
|
|
155
|
+
const backoff = sdk.retry.backoff; // { initialDelay: 1, multiplier: 2, maxDelay: 30, jitterFactor: 0.5 }
|
|
156
|
+
// ...generate code using these values
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Override defaults per-SDK via `oagen.config.ts`:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
// oagen.config.ts — Python SDK overrides
|
|
164
|
+
export default {
|
|
165
|
+
sdkBehavior: {
|
|
166
|
+
retry: { backoff: { initialDelay: 0.5, maxDelay: 8.0 } },
|
|
167
|
+
timeout: {
|
|
168
|
+
defaultTimeoutSeconds: 30,
|
|
169
|
+
timeoutEnvVar: "WORKOS_REQUEST_TIMEOUT",
|
|
170
|
+
},
|
|
171
|
+
pagination: { autoPageDelayMs: 0 },
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
See [`src/ir/sdk-behavior.ts`](src/ir/sdk-behavior.ts) for all interfaces and default values.
|
|
177
|
+
|
|
178
|
+
## Operation Resolution
|
|
179
|
+
|
|
180
|
+
`resolveOperations(spec, hints?, mountRules?)` derives method names and mount targets for every operation in the spec. The algorithm produces a snake_case name from the HTTP method and path, then applies optional overrides from a hint map.
|
|
181
|
+
|
|
182
|
+
Emitters consume `ctx.resolvedOperations` instead of computing names independently, ensuring all SDKs use the same method names (converted to each language's convention).
|
|
183
|
+
|
|
184
|
+
Configure hints and mount rules in `oagen.config.ts`:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
export default {
|
|
188
|
+
operationHints: {
|
|
189
|
+
'GET /sso/authorize': { name: 'get_authorization_url' },
|
|
190
|
+
'POST /user_management/authenticate': {
|
|
191
|
+
split: [
|
|
192
|
+
{ name: 'authenticate_with_password', targetVariant: 'PasswordRequest', ... },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
mountRules: {
|
|
197
|
+
Connections: 'SSO', // All Connections ops mount on SSO
|
|
198
|
+
DirectoryGroups: 'DirectorySync',
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Review resolved names with `oagen resolve`:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
oagen resolve --spec openapi.yml --format table # Markdown review table
|
|
207
|
+
oagen resolve --spec openapi.yml --format json # JSON for programmatic use
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
See [`src/ir/operation-hints.ts`](src/ir/operation-hints.ts) for types and [`docs/architecture/ir-types.md`](docs/architecture/ir-types.md) for the full reference.
|
|
211
|
+
|
|
141
212
|
## Commands
|
|
142
213
|
|
|
143
214
|
| Command | Purpose |
|
|
@@ -145,6 +216,7 @@ Start with:
|
|
|
145
216
|
| `oagen parse` | Parse a spec and print IR JSON |
|
|
146
217
|
| `oagen init` | Scaffold an emitter project |
|
|
147
218
|
| `oagen generate` | Run a registered emitter |
|
|
219
|
+
| `oagen resolve` | Review resolved operation names (table or JSON) |
|
|
148
220
|
| `oagen diff` | Compare two specs and output a diff report |
|
|
149
221
|
| `oagen extract` | Advanced: extract an SDK API surface for compat use |
|
|
150
222
|
| `oagen verify` | Advanced: smoke-test output and run compat checks |
|