@workos/oagen-emitters 0.0.1 → 0.2.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 (49) hide show
  1. package/.github/workflows/release-please.yml +9 -1
  2. package/.husky/commit-msg +0 -0
  3. package/.husky/pre-commit +1 -0
  4. package/.husky/pre-push +1 -0
  5. package/.oxfmtrc.json +8 -1
  6. package/.prettierignore +1 -0
  7. package/.release-please-manifest.json +3 -0
  8. package/.vscode/settings.json +3 -0
  9. package/CHANGELOG.md +61 -0
  10. package/README.md +2 -2
  11. package/dist/index.d.mts +7 -0
  12. package/dist/index.d.mts.map +1 -0
  13. package/dist/index.mjs +4070 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/package.json +14 -18
  16. package/release-please-config.json +11 -0
  17. package/smoke/sdk-dotnet.ts +17 -3
  18. package/smoke/sdk-elixir.ts +17 -3
  19. package/smoke/sdk-go.ts +21 -4
  20. package/smoke/sdk-kotlin.ts +23 -4
  21. package/smoke/sdk-node.ts +15 -3
  22. package/smoke/sdk-ruby.ts +17 -3
  23. package/smoke/sdk-rust.ts +16 -3
  24. package/src/node/client.ts +521 -206
  25. package/src/node/common.ts +74 -4
  26. package/src/node/config.ts +1 -0
  27. package/src/node/enums.ts +53 -9
  28. package/src/node/errors.ts +82 -3
  29. package/src/node/fixtures.ts +87 -16
  30. package/src/node/index.ts +66 -10
  31. package/src/node/manifest.ts +4 -2
  32. package/src/node/models.ts +251 -124
  33. package/src/node/naming.ts +107 -3
  34. package/src/node/resources.ts +1162 -108
  35. package/src/node/serializers.ts +512 -52
  36. package/src/node/tests.ts +650 -110
  37. package/src/node/type-map.ts +89 -11
  38. package/src/node/utils.ts +426 -113
  39. package/test/node/client.test.ts +1083 -20
  40. package/test/node/enums.test.ts +73 -4
  41. package/test/node/errors.test.ts +4 -21
  42. package/test/node/models.test.ts +499 -5
  43. package/test/node/naming.test.ts +14 -7
  44. package/test/node/resources.test.ts +1568 -9
  45. package/test/node/serializers.test.ts +241 -5
  46. package/tsconfig.json +2 -3
  47. package/{tsup.config.ts → tsdown.config.ts} +1 -1
  48. package/dist/index.d.ts +0 -5
  49. package/dist/index.js +0 -2158
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "@workos/oagen-emitters",
3
- "version": "0.0.1",
3
+ "version": "0.2.1",
4
4
  "description": "WorkOS' oagen emitters",
5
5
  "license": "MIT",
6
6
  "author": "WorkOS",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/workos/oagen-emitters"
10
+ },
7
11
  "type": "module",
8
- "main": "dist/index.js",
9
- "types": "dist/index.d.ts",
12
+ "main": "dist/index.mjs",
13
+ "types": "dist/index.d.mts",
10
14
  "exports": {
11
15
  ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js"
16
+ "types": "./dist/index.d.mts",
17
+ "import": "./dist/index.mjs"
14
18
  }
15
19
  },
16
20
  "scripts": {
17
- "build": "tsup",
18
- "lint": "oxlint",
21
+ "build": "tsdown",
22
+ "lint": "oxlint -D warnings",
19
23
  "lint:fix": "oxlint --fix",
20
24
  "format": "oxfmt --check .",
21
25
  "format:fix": "oxfmt --write .",
@@ -26,44 +30,35 @@
26
30
  "typecheck": "tsc --noEmit",
27
31
  "prepare": "husky",
28
32
  "sdk:generate:dotnet": "oagen generate --lang dotnet --output ./sdk-dotnet --namespace workos --api-surface ./sdk-dotnet-surface.json",
29
- "sdk:diff:dotnet": "oagen diff --old ./sdk-dotnet/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang dotnet --output ./sdk-dotnet --api-surface ./sdk-dotnet-surface.json",
30
33
  "sdk:verify:dotnet": "oagen verify --lang dotnet --output ./sdk-dotnet --api-surface ./sdk-dotnet-surface.json",
31
34
  "sdk:extract:dotnet": "oagen extract --lang dotnet --sdk-path ../backend/workos-dotnet --output ./sdk-dotnet-surface.json",
32
35
  "sdk:generate:elixir": "oagen generate --lang elixir --output ./sdk-elixir --namespace workos --api-surface ./sdk-elixir-surface.json",
33
- "sdk:diff:elixir": "oagen diff --old ./sdk-elixir/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang elixir --output ./sdk-elixir --api-surface ./sdk-elixir-surface.json",
34
36
  "sdk:verify:elixir": "oagen verify --lang elixir --output ./sdk-elixir --api-surface ./sdk-elixir-surface.json",
35
37
  "sdk:extract:elixir": "oagen extract --lang elixir --sdk-path ../backend/workos-elixir --output ./sdk-elixir-surface.json",
36
38
  "sdk:generate:go": "oagen generate --lang go --output ./sdk-go --namespace workos --api-surface ./sdk-go-surface.json",
37
- "sdk:diff:go": "oagen diff --old ./sdk-go/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang go --output ./sdk-go --api-surface ./sdk-go-surface.json",
38
39
  "sdk:verify:go": "oagen verify --lang go --output ./sdk-go --api-surface ./sdk-go-surface.json",
39
40
  "sdk:extract:go": "oagen extract --lang go --sdk-path ../backend/workos-go --output ./sdk-go-surface.json",
40
41
  "sdk:generate:kotlin": "oagen generate --lang kotlin --output ./sdk-kotlin --namespace workos --api-surface ./sdk-kotlin-surface.json",
41
- "sdk:diff:kotlin": "oagen diff --old ./sdk-kotlin/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang kotlin --output ./sdk-kotlin --api-surface ./sdk-kotlin-surface.json",
42
42
  "sdk:verify:kotlin": "oagen verify --lang kotlin --output ./sdk-kotlin --api-surface ./sdk-kotlin-surface.json",
43
43
  "sdk:extract:kotlin": "oagen extract --lang kotlin --sdk-path ../backend/workos-kotlin --output ./sdk-kotlin-surface.json",
44
44
  "sdk:generate:node": "oagen generate --lang node --output ./sdk-node --namespace workos --api-surface ./sdk-node-surface.json",
45
- "sdk:diff:node": "oagen diff --old ./sdk-node/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang node --output ./sdk-node --api-surface ./sdk-node-surface.json",
46
45
  "sdk:verify:node": "oagen verify --lang node --output ./sdk-node --api-surface ./sdk-node-surface.json",
47
46
  "sdk:extract:node": "oagen extract --lang node --sdk-path ../backend/workos-node --output ./sdk-node-surface.json",
48
47
  "sdk:generate:php": "oagen generate --lang php --output ./sdk-php --namespace workos --api-surface ./sdk-php-surface.json",
49
- "sdk:diff:php": "oagen diff --old ./sdk-php/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang php --output ./sdk-php --api-surface ./sdk-php-surface.json",
50
48
  "sdk:verify:php": "oagen verify --lang php --output ./sdk-php --api-surface ./sdk-php-surface.json",
51
49
  "sdk:extract:php": "oagen extract --lang php --sdk-path ../backend/workos-php --output ./sdk-php-surface.json",
52
50
  "sdk:generate:python": "oagen generate --lang python --output ./sdk-python --namespace workos --api-surface ./sdk-python-surface.json",
53
- "sdk:diff:python": "oagen diff --old ./sdk-python/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang python --output ./sdk-python --api-surface ./sdk-python-surface.json",
54
51
  "sdk:verify:python": "oagen verify --lang python --output ./sdk-python --api-surface ./sdk-python-surface.json",
55
52
  "sdk:extract:python": "oagen extract --lang python --sdk-path ../backend/workos-python --output ./sdk-python-surface.json",
56
53
  "sdk:generate:ruby": "oagen generate --lang ruby --output ./sdk-ruby --namespace workos --api-surface ./sdk-ruby-surface.json",
57
- "sdk:diff:ruby": "oagen diff --old ./sdk-ruby/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang ruby --output ./sdk-ruby --api-surface ./sdk-ruby-surface.json",
58
54
  "sdk:verify:ruby": "oagen verify --lang ruby --output ./sdk-ruby --api-surface ./sdk-ruby-surface.json",
59
55
  "sdk:extract:ruby": "oagen extract --lang ruby --sdk-path ../backend/workos-ruby --output ./sdk-ruby-surface.json",
60
56
  "sdk:generate:rust": "oagen generate --lang rust --output ./sdk-rust --namespace workos --api-surface ./sdk-rust-surface.json",
61
- "sdk:diff:rust": "oagen diff --old ./sdk-rust/spec-snapshot.yaml --new ../openapi-spec/spec/open-api-spec.yaml --lang rust --output ./sdk-rust --api-surface ./sdk-rust-surface.json",
62
57
  "sdk:verify:rust": "oagen verify --lang rust --output ./sdk-rust --api-surface ./sdk-rust-surface.json",
63
58
  "sdk:extract:rust": "oagen extract --lang rust --sdk-path ../backend/workos-rust --output ./sdk-rust-surface.json"
64
59
  },
65
60
  "dependencies": {
66
- "@workos/oagen": "^0.0.1"
61
+ "@workos/oagen": "^0.3.0"
67
62
  },
68
63
  "devDependencies": {
69
64
  "@commitlint/cli": "^20.5.0",
@@ -73,8 +68,9 @@
73
68
  "oxfmt": "^0.36.0",
74
69
  "oxlint": "^1.51.0",
75
70
  "prettier": "^3.8.1",
76
- "tsup": "^8.4.0",
71
+ "tsdown": "^0.21.5",
77
72
  "tsx": "^4.19.0",
73
+ "typescript": "^6.0.0-dev.20260324",
78
74
  "vitest": "^3.0.0"
79
75
  },
80
76
  "engines": {
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3
+ "include-component-in-tag": false,
4
+ "packages": {
5
+ ".": {
6
+ "release-type": "node",
7
+ "changelog-path": "CHANGELOG.md",
8
+ "versioning": "default"
9
+ }
10
+ }
11
+ }
@@ -115,7 +115,12 @@ function createProxyServer(apiKey: string, captures: ProxyCapture[]): Promise<{
115
115
  }
116
116
 
117
117
  captures.push({
118
- request: { method: req.method!, path: url.pathname, queryParams, body },
118
+ request: {
119
+ method: req.method!,
120
+ path: url.pathname,
121
+ queryParams,
122
+ body,
123
+ },
119
124
  response: { status: proxyRes.statusCode!, body: resBody },
120
125
  });
121
126
 
@@ -689,7 +694,11 @@ async function main(): Promise<void> {
689
694
 
690
695
  // Build planned calls for this wave, resolving methods
691
696
  const plannedCalls: PlannedCall[] = [];
692
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
697
+ const waveSkipped: Array<{
698
+ op: Operation;
699
+ irService: string;
700
+ reason: string;
701
+ }> = [];
693
702
 
694
703
  for (const { op, irService, pathParams } of wave.calls) {
695
704
  const resolution = resolveMethod(op, irService, manifest);
@@ -858,7 +867,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
858
867
  operationId: op.name,
859
868
  service,
860
869
  operationName: op.name,
861
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
870
+ request: {
871
+ method: op.httpMethod.toUpperCase(),
872
+ path: op.path,
873
+ queryParams: {},
874
+ body: null,
875
+ },
862
876
  response: { status: 0, body: null },
863
877
  outcome: 'skipped',
864
878
  error: reason,
@@ -103,7 +103,12 @@ function startProxy(
103
103
  }
104
104
  }
105
105
 
106
- const capturedReq: CapturedRequest = { method, path, queryParams, body: reqBody };
106
+ const capturedReq: CapturedRequest = {
107
+ method,
108
+ path,
109
+ queryParams,
110
+ body: reqBody,
111
+ };
107
112
 
108
113
  // Forward to real API
109
114
  const forwardHeaders: Record<string, string> = {
@@ -467,7 +472,11 @@ async function main(): Promise<void> {
467
472
 
468
473
  // Build planned calls for this wave, resolving methods
469
474
  const plannedCalls: PlannedCall[] = [];
470
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
475
+ const waveSkipped: Array<{
476
+ op: Operation;
477
+ irService: string;
478
+ reason: string;
479
+ }> = [];
471
480
 
472
481
  for (const { op, irService, pathParams } of wave.calls) {
473
482
  const resolution = resolveMethod(op, irService, manifest);
@@ -726,7 +735,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
726
735
  operationId: op.name,
727
736
  service,
728
737
  operationName: op.name,
729
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
738
+ request: {
739
+ method: op.httpMethod.toUpperCase(),
740
+ path: op.path,
741
+ queryParams: {},
742
+ body: null,
743
+ },
730
744
  response: { status: 0, body: null },
731
745
  outcome: 'skipped',
732
746
  error: reason,
package/smoke/sdk-go.ts CHANGED
@@ -257,7 +257,12 @@ class CaptureProxy {
257
257
  }
258
258
  }
259
259
 
260
- const capturedReq: CapturedRequest = { method, path, queryParams, body: parsedReqBody };
260
+ const capturedReq: CapturedRequest = {
261
+ method,
262
+ path,
263
+ queryParams,
264
+ body: parsedReqBody,
265
+ };
261
266
 
262
267
  // Forward to the real API
263
268
  const targetUrl = new URL(path, this.targetBaseUrl);
@@ -580,7 +585,11 @@ async function main(): Promise<void> {
580
585
 
581
586
  // Build planned calls for this wave, resolving methods
582
587
  const plannedCalls: PlannedCall[] = [];
583
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
588
+ const waveSkipped: Array<{
589
+ op: Operation;
590
+ irService: string;
591
+ reason: string;
592
+ }> = [];
584
593
 
585
594
  for (const { op, irService, pathParams } of wave.calls) {
586
595
  const resolution = resolveMethod(op, irService, manifest);
@@ -655,7 +664,10 @@ async function main(): Promise<void> {
655
664
  execSync('go build -o smoke-driver main.go', {
656
665
  cwd: tmpDir,
657
666
  timeout: 120_000,
658
- env: { ...process.env, GOPATH: process.env.GOPATH || resolve(process.env.HOME || '~', 'go') },
667
+ env: {
668
+ ...process.env,
669
+ GOPATH: process.env.GOPATH || resolve(process.env.HOME || '~', 'go'),
670
+ },
659
671
  encoding: 'utf-8',
660
672
  stdio: ['pipe', 'pipe', 'pipe'],
661
673
  });
@@ -903,7 +915,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
903
915
  operationId: op.name,
904
916
  service,
905
917
  operationName: op.name,
906
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
918
+ request: {
919
+ method: op.httpMethod.toUpperCase(),
920
+ path: op.path,
921
+ queryParams: {},
922
+ body: null,
923
+ },
907
924
  response: { status: 0, body: null },
908
925
  outcome: 'skipped',
909
926
  error: reason,
@@ -123,7 +123,12 @@ function createProxyServer(
123
123
  }
124
124
 
125
125
  captures.push({
126
- request: { method: req.method!, path: url.pathname, queryParams, body },
126
+ request: {
127
+ method: req.method!,
128
+ path: url.pathname,
129
+ queryParams,
130
+ body,
131
+ },
127
132
  response: { status: proxyRes.statusCode!, body: resBody },
128
133
  });
129
134
 
@@ -135,7 +140,12 @@ function createProxyServer(
135
140
  proxyReq.on('error', (err) => {
136
141
  console.error('Proxy request error:', err.message);
137
142
  captures.push({
138
- request: { method: req.method!, path: url.pathname, queryParams, body },
143
+ request: {
144
+ method: req.method!,
145
+ path: url.pathname,
146
+ queryParams,
147
+ body,
148
+ },
139
149
  response: { status: 502, body: { error: err.message } },
140
150
  });
141
151
  res.writeHead(502);
@@ -499,7 +509,11 @@ async function main(): Promise<void> {
499
509
 
500
510
  // Build planned calls for this wave, resolving methods
501
511
  const plannedCalls: PlannedCall[] = [];
502
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
512
+ const waveSkipped: Array<{
513
+ op: Operation;
514
+ irService: string;
515
+ reason: string;
516
+ }> = [];
503
517
 
504
518
  for (const { op, irService, pathParams } of wave.calls) {
505
519
  const resolution = resolveMethod(op, irService, manifest);
@@ -754,7 +768,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
754
768
  operationId: op.name,
755
769
  service,
756
770
  operationName: op.name,
757
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
771
+ request: {
772
+ method: op.httpMethod.toUpperCase(),
773
+ path: op.path,
774
+ queryParams: {},
775
+ body: null,
776
+ },
758
777
  response: { status: 0, body: null },
759
778
  outcome: 'skipped',
760
779
  error: reason,
package/smoke/sdk-node.ts CHANGED
@@ -52,7 +52,10 @@ interface CapturedResponse {
52
52
  // HTTP Interception
53
53
  // ---------------------------------------------------------------------------
54
54
 
55
- let currentCapture: { request: CapturedRequest; response: CapturedResponse } | null = null;
55
+ let currentCapture: {
56
+ request: CapturedRequest;
57
+ response: CapturedResponse;
58
+ } | null = null;
56
59
  const originalFetch = globalThis.fetch;
57
60
 
58
61
  function interceptFetch(): void {
@@ -259,7 +262,11 @@ async function main(): Promise<void> {
259
262
  const groups = planOperations(spec);
260
263
  const ids = new IdRegistry();
261
264
  const exchanges: CapturedExchange[] = [];
262
- const createdEntities: Array<{ service: string; id: string; deleteFn?: () => Promise<void> }> = [];
265
+ const createdEntities: Array<{
266
+ service: string;
267
+ id: string;
268
+ deleteFn?: () => Promise<void>;
269
+ }> = [];
263
270
  const delayMs = Number(process.env.SMOKE_DELAY_MS) || 200;
264
271
 
265
272
  let successCount = 0;
@@ -452,7 +459,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
452
459
  operationId: op.name,
453
460
  service,
454
461
  operationName: op.name,
455
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
462
+ request: {
463
+ method: op.httpMethod.toUpperCase(),
464
+ path: op.path,
465
+ queryParams: {},
466
+ body: null,
467
+ },
456
468
  response: { status: 0, body: null },
457
469
  outcome: 'skipped',
458
470
  error: reason,
package/smoke/sdk-ruby.ts CHANGED
@@ -160,7 +160,12 @@ function startProxy(
160
160
  }
161
161
  }
162
162
 
163
- const capturedReq: CapturedRequest = { method, path, queryParams, body: reqBody };
163
+ const capturedReq: CapturedRequest = {
164
+ method,
165
+ path,
166
+ queryParams,
167
+ body: reqBody,
168
+ };
164
169
 
165
170
  // Forward to real API
166
171
  const forwardHeaders: Record<string, string> = {
@@ -420,7 +425,11 @@ async function main(): Promise<void> {
420
425
 
421
426
  // Build planned calls for this wave, resolving methods
422
427
  const plannedCalls: PlannedCall[] = [];
423
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
428
+ const waveSkipped: Array<{
429
+ op: Operation;
430
+ irService: string;
431
+ reason: string;
432
+ }> = [];
424
433
 
425
434
  for (const { op, irService, pathParams } of wave.calls) {
426
435
  const resolution = resolveMethod(op, irService, manifest);
@@ -678,7 +687,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
678
687
  operationId: op.name,
679
688
  service,
680
689
  operationName: op.name,
681
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
690
+ request: {
691
+ method: op.httpMethod.toUpperCase(),
692
+ path: op.path,
693
+ queryParams: {},
694
+ body: null,
695
+ },
682
696
  response: { status: 0, body: null },
683
697
  outcome: 'skipped',
684
698
  error: reason,
package/smoke/sdk-rust.ts CHANGED
@@ -452,7 +452,11 @@ serde_json = "1"
452
452
 
453
453
  // Build planned calls for this wave, resolving methods
454
454
  const plannedCalls: PlannedCall[] = [];
455
- const waveSkipped: Array<{ op: Operation; irService: string; reason: string }> = [];
455
+ const waveSkipped: Array<{
456
+ op: Operation;
457
+ irService: string;
458
+ reason: string;
459
+ }> = [];
456
460
 
457
461
  for (const { op, irService, pathParams } of wave.calls) {
458
462
  const resolution = resolveMethod(op, irService, manifest);
@@ -534,7 +538,11 @@ serde_json = "1"
534
538
  await new Promise<void>((resolvePromise, rejectPromise) => {
535
539
  const child = spawn(join(tmpDir, 'target', 'debug', 'smoke-driver'), [], {
536
540
  cwd: tmpDir,
537
- env: { ...process.env, WORKOS_API_KEY: apiKey, WORKOS_BASE_URL: `http://localhost:${proxy.port}` },
541
+ env: {
542
+ ...process.env,
543
+ WORKOS_API_KEY: apiKey,
544
+ WORKOS_BASE_URL: `http://localhost:${proxy.port}`,
545
+ },
538
546
  stdio: ['pipe', 'pipe', 'pipe'],
539
547
  });
540
548
 
@@ -729,7 +737,12 @@ function makeSkippedExchange(op: Operation, service: string, reason: string): Ca
729
737
  operationId: op.name,
730
738
  service,
731
739
  operationName: op.name,
732
- request: { method: op.httpMethod.toUpperCase(), path: op.path, queryParams: {}, body: null },
740
+ request: {
741
+ method: op.httpMethod.toUpperCase(),
742
+ path: op.path,
743
+ queryParams: {},
744
+ body: null,
745
+ },
733
746
  response: { status: 0, body: null },
734
747
  outcome: 'skipped',
735
748
  error: reason,