@workos/oagen-emitters 0.0.1

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 (73) hide show
  1. package/.github/workflows/ci.yml +20 -0
  2. package/.github/workflows/lint-pr-title.yml +16 -0
  3. package/.github/workflows/lint.yml +21 -0
  4. package/.github/workflows/release-please.yml +28 -0
  5. package/.github/workflows/release.yml +32 -0
  6. package/.husky/commit-msg +1 -0
  7. package/.husky/pre-commit +1 -0
  8. package/.husky/pre-push +1 -0
  9. package/.node-version +1 -0
  10. package/.oxfmtrc.json +10 -0
  11. package/.oxlintrc.json +29 -0
  12. package/.vscode/settings.json +11 -0
  13. package/LICENSE.txt +21 -0
  14. package/README.md +123 -0
  15. package/commitlint.config.ts +1 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +2158 -0
  18. package/docs/endpoint-coverage.md +275 -0
  19. package/docs/sdk-architecture/node.md +355 -0
  20. package/oagen.config.ts +51 -0
  21. package/package.json +83 -0
  22. package/renovate.json +26 -0
  23. package/smoke/sdk-dotnet.ts +903 -0
  24. package/smoke/sdk-elixir.ts +771 -0
  25. package/smoke/sdk-go.ts +948 -0
  26. package/smoke/sdk-kotlin.ts +799 -0
  27. package/smoke/sdk-node.ts +516 -0
  28. package/smoke/sdk-php.ts +699 -0
  29. package/smoke/sdk-python.ts +738 -0
  30. package/smoke/sdk-ruby.ts +723 -0
  31. package/smoke/sdk-rust.ts +774 -0
  32. package/src/compat/extractors/dotnet.ts +8 -0
  33. package/src/compat/extractors/elixir.ts +8 -0
  34. package/src/compat/extractors/go.ts +8 -0
  35. package/src/compat/extractors/kotlin.ts +8 -0
  36. package/src/compat/extractors/node.ts +8 -0
  37. package/src/compat/extractors/php.ts +8 -0
  38. package/src/compat/extractors/python.ts +8 -0
  39. package/src/compat/extractors/ruby.ts +8 -0
  40. package/src/compat/extractors/rust.ts +8 -0
  41. package/src/index.ts +1 -0
  42. package/src/node/client.ts +356 -0
  43. package/src/node/common.ts +203 -0
  44. package/src/node/config.ts +70 -0
  45. package/src/node/enums.ts +87 -0
  46. package/src/node/errors.ts +205 -0
  47. package/src/node/fixtures.ts +139 -0
  48. package/src/node/index.ts +57 -0
  49. package/src/node/manifest.ts +23 -0
  50. package/src/node/models.ts +323 -0
  51. package/src/node/naming.ts +96 -0
  52. package/src/node/resources.ts +380 -0
  53. package/src/node/serializers.ts +286 -0
  54. package/src/node/tests.ts +336 -0
  55. package/src/node/type-map.ts +56 -0
  56. package/src/node/utils.ts +164 -0
  57. package/test/compat/extractors/node.test.ts +145 -0
  58. package/test/fixtures/sample-sdk-node/package.json +7 -0
  59. package/test/fixtures/sample-sdk-node/src/client.ts +24 -0
  60. package/test/fixtures/sample-sdk-node/src/index.ts +4 -0
  61. package/test/fixtures/sample-sdk-node/src/models.ts +28 -0
  62. package/test/fixtures/sample-sdk-node/tsconfig.json +13 -0
  63. package/test/node/client.test.ts +165 -0
  64. package/test/node/enums.test.ts +128 -0
  65. package/test/node/errors.test.ts +65 -0
  66. package/test/node/models.test.ts +301 -0
  67. package/test/node/naming.test.ts +212 -0
  68. package/test/node/resources.test.ts +260 -0
  69. package/test/node/serializers.test.ts +206 -0
  70. package/test/node/type-map.test.ts +127 -0
  71. package/tsconfig.json +20 -0
  72. package/tsup.config.ts +8 -0
  73. package/vitest.config.ts +4 -0
@@ -0,0 +1,20 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
13
+
14
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
15
+ with:
16
+ node-version-file: .node-version
17
+
18
+ - run: npm install
19
+ - run: npm run typecheck
20
+ - run: npm test
@@ -0,0 +1,16 @@
1
+ name: Lint PR Title
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, edited, synchronize]
6
+
7
+ permissions:
8
+ pull-requests: read
9
+
10
+ jobs:
11
+ lint_pr_title:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: amannn/action-semantic-pull-request@e32d7e603df1aa1ba07e981f2a23455dee596825 # v5
15
+ env:
16
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
13
+
14
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
15
+ with:
16
+ node-version-file: .node-version
17
+
18
+ - run: npm install
19
+ - run: npm run lint
20
+ - run: npm run format
21
+ - run: npx prettier --check '**/*.md'
@@ -0,0 +1,28 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ release-please:
15
+ runs-on: ubuntu-latest
16
+ outputs:
17
+ release_created: ${{ steps.release.outputs.release_created }}
18
+ tag_name: ${{ steps.release.outputs.tag_name }}
19
+ steps:
20
+ - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
21
+ id: release
22
+ with:
23
+ token: ${{ secrets.GITHUB_TOKEN }}
24
+
25
+ publish:
26
+ needs: release-please
27
+ if: ${{ needs.release-please.outputs.release_created == 'true' }}
28
+ uses: ./.github/workflows/release.yml
@@ -0,0 +1,32 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+
7
+ jobs:
8
+ publish:
9
+ name: Publish to npm
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16
+
17
+ - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
18
+ with:
19
+ node-version-file: .node-version
20
+ registry-url: 'https://registry.npmjs.org'
21
+
22
+ - name: Install Dependencies
23
+ run: npm install
24
+
25
+ - name: Build Project
26
+ run: npm run build
27
+
28
+ - name: Run Tests
29
+ run: npm run test
30
+
31
+ - name: Publish
32
+ run: npm publish --tag latest --access public --provenance
@@ -0,0 +1 @@
1
+ npx --no -- commitlint --edit "$1"
@@ -0,0 +1 @@
1
+ npm run lint
@@ -0,0 +1 @@
1
+ npm test
package/.node-version ADDED
@@ -0,0 +1 @@
1
+ 24.13.0
package/.oxfmtrc.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "trailingComma": "all",
4
+ "tabWidth": 2,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "printWidth": 120,
8
+ "sortPackageJson": false,
9
+ "ignorePatterns": ["dist/", "node_modules/", "pnpm-lock.yaml", "**/*.json", "**/*.md", "**/*.yaml"]
10
+ }
package/.oxlintrc.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": null,
4
+ "categories": {},
5
+ "rules": {
6
+ "no-unused-expressions": "off",
7
+ "no-control-regex": "off"
8
+ },
9
+ "settings": {
10
+ "jsdoc": {
11
+ "ignorePrivate": false,
12
+ "ignoreInternal": false,
13
+ "ignoreReplacesDocs": true,
14
+ "overrideReplacesDocs": true,
15
+ "augmentsExtendsReplacesDocs": false,
16
+ "implementsReplacesDocs": false,
17
+ "exemptDestructuredRootsFromChecks": false,
18
+ "tagNamePreference": {}
19
+ },
20
+ "vitest": {
21
+ "typecheck": false
22
+ }
23
+ },
24
+ "env": {
25
+ "builtin": true
26
+ },
27
+ "globals": {},
28
+ "ignorePatterns": ["test/fixtures/**"]
29
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "[json]": {
3
+ "editor.defaultFormatter": "vscode.json-language-features"
4
+ },
5
+ "[markdown]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ },
8
+ "[typescript]": {
9
+ "editor.defaultFormatter": "vscode.typescript-language-features"
10
+ }
11
+ }
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WorkOS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # oagen-plugins
2
+
3
+ Language plugins for [oagen](../oagen); generates SDK code from OpenAPI specs.
4
+
5
+ ## Supported languages
6
+
7
+ | Language | Emitter | Extractor | Smoke Test |
8
+ | --------------- | ------------- | --------------- | ------------------- |
9
+ | Node/TypeScript | `nodeEmitter` | `nodeExtractor` | `smoke/sdk-node.ts` |
10
+
11
+ ## Quickstart
12
+
13
+ ```bash
14
+ npm install
15
+ npm test # run emitter unit tests
16
+ npm run typecheck # verify types
17
+ ```
18
+
19
+ ## Workflows
20
+
21
+ ### Setting up a new language
22
+
23
+ ```bash
24
+ # 1. Extract the live SDK's public API surface
25
+ npm run sdk:extract:node
26
+
27
+ # 2. Generate and integrate
28
+ npm run sdk:generate:node
29
+
30
+ # 3. Verify
31
+ npm run sdk:verify:node
32
+ ```
33
+
34
+ ### Ongoing spec updates
35
+
36
+ ```bash
37
+ # 1. Incremental generation from spec changes
38
+ npm run sdk:diff:node
39
+
40
+ # 2. Verify
41
+ npm run sdk:verify:node
42
+ ```
43
+
44
+ ### After manually editing the live SDK
45
+
46
+ If you rename methods, add exports, or change the live SDK's public API by hand:
47
+
48
+ ```bash
49
+ # 1. Re-extract the baseline so the overlay stays in sync
50
+ npm run sdk:extract:node
51
+
52
+ # 2. Regenerate (the overlay will use the updated baseline)
53
+ npm run sdk:generate:node
54
+ ```
55
+
56
+ ## Commands
57
+
58
+ All SDK commands are in `package.json` under `scripts`. Replace `node` with the target language for other SDKs.
59
+
60
+ ### `npm run sdk:extract:node`
61
+
62
+ ```bash
63
+ oagen extract --lang node --sdk-path ../backend/workos-node --output ./sdk-node-surface.json
64
+ ```
65
+
66
+ Extracts the live SDK's public API surface (classes, interfaces, type aliases, enums, exports) into `sdk-node-surface.json`. This is **per-language** — each language has its own extractor that understands the language's public surface conventions (TypeScript exports, Ruby public methods, Python `__all__`, etc.).
67
+
68
+ **When to run:** Before the first generation, and whenever the live SDK's public API changes (hand-written additions, renamed methods, new exports).
69
+
70
+ ### `npm run sdk:generate:node`
71
+
72
+ ```bash
73
+ oagen generate --lang node --output ./sdk --namespace workos \
74
+ --spec ../openapi-spec/spec/open-api-spec.yaml \
75
+ --api-surface ./sdk-node-surface.json \
76
+ --target ../backend/workos-node
77
+ ```
78
+
79
+ Full generation from the OpenAPI spec. Produces a standalone SDK at `./sdk/` and integrates new interface, serializer, enum, and fixture files into the live SDK at `--target`.
80
+
81
+ **What gets integrated:** New type definitions (interfaces, serializers, enums, fixtures) that don't already exist in the live SDK. Existing files are never modified.
82
+
83
+ **What stays standalone:** Resource classes, tests, client, barrel exports, error classes, and common utilities remain in `./sdk/` only. The developer wires up resource classes and client accessors manually.
84
+
85
+ **When to run:** First-time setup, or when you want a full regeneration (e.g., after a major spec overhaul).
86
+
87
+ ### `npm run sdk:diff:node`
88
+
89
+ ```bash
90
+ oagen diff --old ./sdk/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml \
91
+ --lang node --output ./sdk \
92
+ --target ../backend/workos-node \
93
+ --api-surface ./sdk-node-surface.json
94
+ ```
95
+
96
+ Incremental generation — compares the previous spec snapshot against the current spec and only regenerates files affected by the changes.
97
+
98
+ **Requires** a prior `sdk:generate:node` run which creates `./sdk/spec-snapshot.yaml`.
99
+
100
+ **When to run:** After the OpenAPI spec is updated (new endpoints, changed models, etc.).
101
+
102
+ ### `npm run sdk:verify:node`
103
+
104
+ ```bash
105
+ oagen verify --lang node --output ./sdk \
106
+ --spec ../openapi-spec/spec/open-api-spec.yaml \
107
+ --api-surface ./sdk-node-surface.json
108
+ ```
109
+
110
+ Runs compat verification (checks that generated types preserve the live SDK's public API surface) and smoke tests (checks wire-level HTTP behavior).
111
+
112
+ **When to run:** After any generation to verify correctness, or in CI.
113
+
114
+ ## Adding a new language
115
+
116
+ Use the oagen skills:
117
+
118
+ ```bash
119
+ claude --plugin-dir ../oagen
120
+ /oagen:generate-sdk <language>
121
+ ```
122
+
123
+ This orchestrates: emitter scaffolding → extractor → compat verification → smoke tests → integration.
@@ -0,0 +1 @@
1
+ export default { extends: ['@commitlint/config-conventional'] };
@@ -0,0 +1,5 @@
1
+ import { Emitter } from '@workos/oagen';
2
+
3
+ declare const nodeEmitter: Emitter;
4
+
5
+ export { nodeEmitter };