@workos/oagen 0.3.0 → 0.5.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.
Files changed (42) hide show
  1. package/README.md +72 -1
  2. package/dist/cli/index.mjs +955 -90
  3. package/dist/cli/index.mjs.map +1 -1
  4. package/dist/compat/index.d.mts +1 -1
  5. package/dist/compat/index.mjs +9 -4
  6. package/dist/compat/index.mjs.map +1 -1
  7. package/dist/{diff-Cn6S74vV.mjs → diff-CSy3g-Bq.mjs} +541 -43
  8. package/dist/diff-CSy3g-Bq.mjs.map +1 -0
  9. package/dist/{differ-B6472Yef.mjs → differ-CG5ZErKl.mjs} +2 -2
  10. package/dist/{differ-B6472Yef.mjs.map → differ-CG5ZErKl.mjs.map} +1 -1
  11. package/dist/index.d.mts +111 -3
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.mjs +340 -30
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/scripts/smoke/baseline.mjs +317 -33
  16. package/dist/scripts/smoke/baseline.mjs.map +1 -1
  17. package/dist/smoke.d.mts +140 -0
  18. package/dist/smoke.d.mts.map +1 -1
  19. package/dist/smoke.mjs +317 -33
  20. package/dist/smoke.mjs.map +1 -1
  21. package/dist/{tree-sitter-DFRXfWg9.mjs → tree-sitter-C53w_0WE.mjs} +5 -7
  22. package/dist/tree-sitter-C53w_0WE.mjs.map +1 -0
  23. package/dist/{types-O25qZxMl.d.mts → types-D84LjrVG.d.mts} +167 -2
  24. package/dist/types-D84LjrVG.d.mts.map +1 -0
  25. package/dist/verify/index.d.mts +1 -1
  26. package/dist/verify/index.mjs +4 -4
  27. package/dist/verify/index.mjs.map +1 -1
  28. package/docs/agents/architecture.md +1 -1
  29. package/docs/architecture/emitter-contract.md +1 -2
  30. package/docs/architecture/ir-types.md +73 -1
  31. package/docs/architecture/pipeline.md +0 -1
  32. package/docs/cli.md +29 -8
  33. package/docs/core/minimal-emitter.md +0 -4
  34. package/docs/core/quickstart.md +0 -1
  35. package/examples/reference-emitter/README.md +0 -1
  36. package/examples/reference-emitter/src/emitter.ts +0 -5
  37. package/package.json +4 -4
  38. package/skills/review-operations/SKILL.md +83 -0
  39. package/dist/diff-Cn6S74vV.mjs.map +0 -1
  40. package/dist/tree-sitter-DFRXfWg9.mjs.map +0 -1
  41. package/dist/types-O25qZxMl.d.mts.map +0 -1
  42. package/examples/reference-emitter/src/generators/config.ts +0 -19
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,
@@ -125,7 +128,6 @@ const myEmitter: Emitter = {
125
128
  /* ... */
126
129
  ],
127
130
  generateErrors: () => [],
128
- generateConfig: () => [],
129
131
  generateTests: () => [],
130
132
  fileHeader: () => "// Auto-generated by oagen. Do not edit.",
131
133
  };
@@ -138,6 +140,74 @@ Start with:
138
140
  - [Emitter Contract](docs/architecture/emitter-contract.md)
139
141
  - [IR Type System Reference](docs/architecture/ir-types.md)
140
142
 
143
+ ## SDK Behavior
144
+
145
+ `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).
146
+
147
+ Emitters read policy from `ctx.spec.sdk` instead of hardcoding values:
148
+
149
+ ```ts
150
+ function generateHttpClient(ctx: EmitterContext) {
151
+ const sdk = ctx.spec.sdk;
152
+ const retryCodes = sdk.retry.retryableStatusCodes; // [429, 500, 502, 503, 504]
153
+ const maxRetries = sdk.retry.maxRetries; // 3
154
+ const backoff = sdk.retry.backoff; // { initialDelay: 1, multiplier: 2, maxDelay: 30, jitterFactor: 0.5 }
155
+ // ...generate code using these values
156
+ }
157
+ ```
158
+
159
+ Override defaults per-SDK via `oagen.config.ts`:
160
+
161
+ ```ts
162
+ // oagen.config.ts — Python SDK overrides
163
+ export default {
164
+ sdkBehavior: {
165
+ retry: { backoff: { initialDelay: 0.5, maxDelay: 8.0 } },
166
+ timeout: {
167
+ defaultTimeoutSeconds: 30,
168
+ timeoutEnvVar: "WORKOS_REQUEST_TIMEOUT",
169
+ },
170
+ pagination: { autoPageDelayMs: 0 },
171
+ },
172
+ };
173
+ ```
174
+
175
+ See [`src/ir/sdk-behavior.ts`](src/ir/sdk-behavior.ts) for all interfaces and default values.
176
+
177
+ ## Operation Resolution
178
+
179
+ `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.
180
+
181
+ Emitters consume `ctx.resolvedOperations` instead of computing names independently, ensuring all SDKs use the same method names (converted to each language's convention).
182
+
183
+ Configure hints and mount rules in `oagen.config.ts`:
184
+
185
+ ```ts
186
+ export default {
187
+ operationHints: {
188
+ 'GET /sso/authorize': { name: 'get_authorization_url' },
189
+ 'POST /user_management/authenticate': {
190
+ split: [
191
+ { name: 'authenticate_with_password', targetVariant: 'PasswordRequest', ... },
192
+ ],
193
+ },
194
+ },
195
+ mountRules: {
196
+ Connections: 'SSO', // All Connections ops mount on SSO
197
+ DirectoryGroups: 'DirectorySync',
198
+ },
199
+ };
200
+ ```
201
+
202
+ Review resolved names with `oagen resolve`:
203
+
204
+ ```bash
205
+ oagen resolve --spec openapi.yml --format table # Markdown review table
206
+ oagen resolve --spec openapi.yml --format json # JSON for programmatic use
207
+ ```
208
+
209
+ 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.
210
+
141
211
  ## Commands
142
212
 
143
213
  | Command | Purpose |
@@ -145,6 +215,7 @@ Start with:
145
215
  | `oagen parse` | Parse a spec and print IR JSON |
146
216
  | `oagen init` | Scaffold an emitter project |
147
217
  | `oagen generate` | Run a registered emitter |
218
+ | `oagen resolve` | Review resolved operation names (table or JSON) |
148
219
  | `oagen diff` | Compare two specs and output a diff report |
149
220
  | `oagen extract` | Advanced: extract an SDK API surface for compat use |
150
221
  | `oagen verify` | Advanced: smoke-test output and run compat checks |