@workos/oagen-emitters 0.2.1 → 0.3.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/.husky/pre-commit +1 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +129 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11893 -3226
- package/dist/index.mjs.map +1 -1
- package/docs/sdk-architecture/go.md +338 -0
- package/docs/sdk-architecture/php.md +315 -0
- package/docs/sdk-architecture/python.md +511 -0
- package/oagen.config.ts +298 -2
- package/package.json +9 -5
- package/scripts/generate-php.js +13 -0
- package/scripts/git-push-with-published-oagen.sh +21 -0
- package/smoke/sdk-go.ts +116 -42
- package/smoke/sdk-php.ts +28 -26
- package/smoke/sdk-python.ts +5 -2
- package/src/go/client.ts +141 -0
- package/src/go/enums.ts +196 -0
- package/src/go/fixtures.ts +212 -0
- package/src/go/index.ts +81 -0
- package/src/go/manifest.ts +36 -0
- package/src/go/models.ts +254 -0
- package/src/go/naming.ts +191 -0
- package/src/go/resources.ts +827 -0
- package/src/go/tests.ts +751 -0
- package/src/go/type-map.ts +82 -0
- package/src/go/wrappers.ts +261 -0
- package/src/index.ts +3 -0
- package/src/node/client.ts +78 -115
- package/src/node/enums.ts +9 -0
- package/src/node/errors.ts +37 -232
- package/src/node/field-plan.ts +726 -0
- package/src/node/fixtures.ts +9 -1
- package/src/node/index.ts +2 -9
- package/src/node/models.ts +178 -21
- package/src/node/naming.ts +49 -111
- package/src/node/resources.ts +374 -364
- package/src/node/sdk-errors.ts +41 -0
- package/src/node/tests.ts +32 -12
- package/src/node/type-map.ts +4 -2
- package/src/node/utils.ts +13 -71
- package/src/node/wrappers.ts +151 -0
- package/src/php/client.ts +171 -0
- package/src/php/enums.ts +67 -0
- package/src/php/errors.ts +9 -0
- package/src/php/fixtures.ts +181 -0
- package/src/php/index.ts +96 -0
- package/src/php/manifest.ts +36 -0
- package/src/php/models.ts +310 -0
- package/src/php/naming.ts +298 -0
- package/src/php/resources.ts +561 -0
- package/src/php/tests.ts +533 -0
- package/src/php/type-map.ts +90 -0
- package/src/php/utils.ts +18 -0
- package/src/php/wrappers.ts +151 -0
- package/src/python/client.ts +337 -0
- package/src/python/enums.ts +313 -0
- package/src/python/fixtures.ts +196 -0
- package/src/python/index.ts +95 -0
- package/src/python/manifest.ts +38 -0
- package/src/python/models.ts +688 -0
- package/src/python/naming.ts +209 -0
- package/src/python/resources.ts +1322 -0
- package/src/python/tests.ts +1335 -0
- package/src/python/type-map.ts +93 -0
- package/src/python/wrappers.ts +191 -0
- package/src/shared/model-utils.ts +255 -0
- package/src/shared/naming-utils.ts +107 -0
- package/src/shared/non-spec-services.ts +54 -0
- package/src/shared/resolved-ops.ts +109 -0
- package/src/shared/wrapper-utils.ts +59 -0
- package/test/go/client.test.ts +92 -0
- package/test/go/enums.test.ts +132 -0
- package/test/go/errors.test.ts +9 -0
- package/test/go/models.test.ts +265 -0
- package/test/go/resources.test.ts +408 -0
- package/test/go/tests.test.ts +143 -0
- package/test/node/client.test.ts +18 -12
- package/test/node/enums.test.ts +2 -0
- package/test/node/errors.test.ts +2 -41
- package/test/node/models.test.ts +2 -0
- package/test/node/naming.test.ts +23 -0
- package/test/node/resources.test.ts +99 -69
- package/test/node/serializers.test.ts +3 -1
- package/test/node/type-map.test.ts +11 -0
- package/test/php/client.test.ts +94 -0
- package/test/php/enums.test.ts +173 -0
- package/test/php/errors.test.ts +9 -0
- package/test/php/models.test.ts +497 -0
- package/test/php/resources.test.ts +644 -0
- package/test/php/tests.test.ts +118 -0
- package/test/python/client.test.ts +200 -0
- package/test/python/enums.test.ts +228 -0
- package/test/python/errors.test.ts +16 -0
- package/test/python/manifest.test.ts +74 -0
- package/test/python/models.test.ts +716 -0
- package/test/python/resources.test.ts +617 -0
- package/test/python/tests.test.ts +202 -0
- package/src/node/common.ts +0 -273
- package/src/node/config.ts +0 -71
- package/src/node/serializers.ts +0 -746
package/.husky/pre-commit
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/workos/oagen-emitters/compare/v0.2.1...v0.3.0) (2026-04-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Improve PHP and Python emitter generation ([#30](https://github.com/workos/oagen-emitters/issues/30)) ([9f4aa98](https://github.com/workos/oagen-emitters/commit/9f4aa981a35e125a6e9316bb91b666eaf0e2d2bd))
|
|
9
|
+
* oagen-emitter updates to handle Golang ([#33](https://github.com/workos/oagen-emitters/issues/33)) ([bf8b872](https://github.com/workos/oagen-emitters/commit/bf8b872a93f20c77f64e6cec9657adfd24d14871))
|
|
10
|
+
|
|
3
11
|
## [0.2.1](https://github.com/workos/oagen-emitters/compare/v0.2.0...v0.2.1) (2026-03-26)
|
|
4
12
|
|
|
5
13
|
|
package/README.md
CHANGED
|
@@ -16,6 +16,51 @@ npm test # run emitter unit tests
|
|
|
16
16
|
npm run typecheck # verify types
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
### Using a local `oagen` checkout
|
|
20
|
+
|
|
21
|
+
This repo depends on a published `@workos/oagen` by default.
|
|
22
|
+
|
|
23
|
+
If you are actively changing the sibling checkout at `../oagen`, you can switch this repo to a local linked copy:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run oagen:use:local
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
That script:
|
|
30
|
+
|
|
31
|
+
1. builds `../oagen`
|
|
32
|
+
2. links it into this repo with `npm link`
|
|
33
|
+
|
|
34
|
+
`@workos/oagen` exports from `dist/`, so rebuild the local repo after changes:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run oagen:build:local
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To go back to the published package from npm:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run oagen:use:published
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Git does not provide a standard `post-push` hook, so the reliable way to push with the published package and then restore the local link is the wrapper script:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run git:push -- <git push args>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run git:push -- origin HEAD
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
That command:
|
|
59
|
+
|
|
60
|
+
1. switches to the published `@workos/oagen`
|
|
61
|
+
2. runs `git push ...`
|
|
62
|
+
3. restores the local `../oagen` link on exit, even if the push fails
|
|
63
|
+
|
|
19
64
|
## Workflows
|
|
20
65
|
|
|
21
66
|
### Setting up a new language
|
|
@@ -111,6 +156,90 @@ Runs compat verification (checks that generated types preserve the live SDK's pu
|
|
|
111
156
|
|
|
112
157
|
**When to run:** After any generation to verify correctness, or in CI.
|
|
113
158
|
|
|
159
|
+
## SDK Behavior
|
|
160
|
+
|
|
161
|
+
Emitters read runtime policy (retry, errors, telemetry, pagination, etc.) from `ctx.spec.sdk` rather than hardcoding values. The `ApiSpec.sdk` field is always populated with defaults from `defaultSdkBehavior()`.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
function generateHttpClient(ctx: EmitterContext) {
|
|
165
|
+
const sdk = ctx.spec.sdk;
|
|
166
|
+
const retryCodes = sdk.retry.retryableStatusCodes; // [429, 500, 502, 503, 504]
|
|
167
|
+
const timeout = sdk.timeout.defaultTimeoutSeconds; // 60
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Per-language overrides go in the SDK's `oagen.config.ts`:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// Example: Python SDK overrides
|
|
175
|
+
export default {
|
|
176
|
+
sdkBehavior: {
|
|
177
|
+
retry: { backoff: { initialDelay: 0.5, maxDelay: 8.0 } },
|
|
178
|
+
timeout: {
|
|
179
|
+
defaultTimeoutSeconds: 30,
|
|
180
|
+
timeoutEnvVar: "WORKOS_REQUEST_TIMEOUT",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
See `@workos/oagen`'s `src/ir/sdk-behavior.ts` for all interfaces and default values.
|
|
187
|
+
|
|
188
|
+
## Operation Hints
|
|
189
|
+
|
|
190
|
+
`oagen.config.ts` defines `operationHints` and `mountRules` that control how operations are named and organized across all SDKs.
|
|
191
|
+
|
|
192
|
+
### Adding a hint for a new operation
|
|
193
|
+
|
|
194
|
+
When the spec adds a new endpoint and the algorithm-derived name is wrong, add an entry to `operationHints`:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const operationHints: Record<string, OperationHint> = {
|
|
198
|
+
// Override derived name
|
|
199
|
+
"GET /sso/authorize": { name: "get_authorization_url" },
|
|
200
|
+
|
|
201
|
+
// Remount to a different service
|
|
202
|
+
"GET /organizations/{id}/audit_logs_retention": { mountOn: "AuditLogs" },
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Adding a union split
|
|
207
|
+
|
|
208
|
+
For endpoints that accept a discriminated union body (multiple request shapes), use `split`:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
'POST /user_management/authenticate': {
|
|
212
|
+
split: [
|
|
213
|
+
{
|
|
214
|
+
name: 'authenticate_with_password',
|
|
215
|
+
targetVariant: 'PasswordSessionAuthenticateRequest',
|
|
216
|
+
defaults: { grant_type: 'password' },
|
|
217
|
+
inferFromClient: ['client_id', 'client_secret'],
|
|
218
|
+
exposedParams: ['email', 'password', 'invitation_token'],
|
|
219
|
+
},
|
|
220
|
+
// ... more variants
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Mount rules
|
|
226
|
+
|
|
227
|
+
Instead of adding `mountOn` to every operation individually, use `mountRules` for service-level remounting:
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
const mountRules: Record<string, string> = {
|
|
231
|
+
Connections: "SSO", // All Connections ops → SSO namespace
|
|
232
|
+
DirectoryGroups: "DirectorySync",
|
|
233
|
+
UserManagementUsers: "UserManagement",
|
|
234
|
+
};
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Reviewing operations
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
npx oagen resolve --spec ../openapi-spec/spec/open-api-spec.yaml --format table
|
|
241
|
+
```
|
|
242
|
+
|
|
114
243
|
## Adding a new language
|
|
115
244
|
|
|
116
245
|
Use the oagen skills:
|
package/dist/index.d.mts
CHANGED
|
@@ -3,5 +3,14 @@ import { Emitter } from "@workos/oagen";
|
|
|
3
3
|
//#region src/node/index.d.ts
|
|
4
4
|
declare const nodeEmitter: Emitter;
|
|
5
5
|
//#endregion
|
|
6
|
-
|
|
6
|
+
//#region src/python/index.d.ts
|
|
7
|
+
declare const pythonEmitter: Emitter;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/php/index.d.ts
|
|
10
|
+
declare const phpEmitter: Emitter;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/go/index.d.ts
|
|
13
|
+
declare const goEmitter: Emitter;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { goEmitter, nodeEmitter, phpEmitter, pythonEmitter };
|
|
7
16
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/node/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/node/index.ts","../src/python/index.ts","../src/php/index.ts","../src/go/index.ts"],"mappings":";;;cA+Ba,WAAA,EAAa,OAAA;;;cCFb,aAAA,EAAe,OAAA;;;cCOf,UAAA,EAAY,OAAA;;;cCPZ,SAAA,EAAW,OAAA"}
|