@workos/oagen-emitters 0.5.0 → 0.6.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.
@@ -15,7 +15,7 @@ import { generateEnums } from './enums.js';
15
15
  import { generateResources } from './resources.js';
16
16
  import { generateClient } from './client.js';
17
17
  import { generateTests } from './tests.js';
18
- import { generateManifest } from './manifest.js';
18
+ import { buildOperationsMap } from './manifest.js';
19
19
  /** Ensure every generated file's content ends with a trailing newline. */
20
20
  function ensureTrailingNewlines(files: GeneratedFile[]): GeneratedFile[] {
21
21
  for (const f of files) {
@@ -81,8 +81,8 @@ export const pythonEmitter: Emitter = {
81
81
  return ensureTrailingNewlines(generateTests(testSpec, { ...ctx, spec: testSpec }));
82
82
  },
83
83
 
84
- generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[] {
85
- return ensureTrailingNewlines(generateManifest(spec, ctx));
84
+ buildOperationsMap(spec: ApiSpec, ctx: EmitterContext) {
85
+ return buildOperationsMap(spec, ctx);
86
86
  },
87
87
 
88
88
  fileHeader(): string {
@@ -1,13 +1,13 @@
1
- import type { ApiSpec, EmitterContext, GeneratedFile } from '@workos/oagen';
1
+ import type { ApiSpec, EmitterContext, OperationsMap } from '@workos/oagen';
2
2
  import { resolveMethodName } from './naming.js';
3
3
  import { buildServiceAccessPaths } from './client.js';
4
4
  import { getMountTarget } from '../shared/resolved-ops.js';
5
5
 
6
6
  /**
7
- * Generate smoke test manifest mapping HTTP operations to SDK methods.
7
+ * Build operation-to-SDK-method mapping for the manifest.
8
8
  */
9
- export function generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[] {
10
- const manifest: Record<string, { sdkMethod: string; service: string }> = {};
9
+ export function buildOperationsMap(spec: ApiSpec, ctx: EmitterContext): OperationsMap {
10
+ const manifest: OperationsMap = {};
11
11
  const accessPaths = buildServiceAccessPaths(spec.services, ctx);
12
12
 
13
13
  for (const service of spec.services) {
@@ -27,12 +27,5 @@ export function generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedF
27
27
  }
28
28
  }
29
29
 
30
- return [
31
- {
32
- path: 'smoke-manifest.json',
33
- content: JSON.stringify(manifest, null, 2),
34
- integrateTarget: false,
35
- overwriteExisting: true,
36
- },
37
- ];
30
+ return manifest;
38
31
  }
package/src/ruby/index.ts CHANGED
@@ -13,7 +13,7 @@ import { generateEnums } from './enums.js';
13
13
  import { generateResources } from './resources.js';
14
14
  import { generateClient } from './client.js';
15
15
  import { generateTests } from './tests.js';
16
- import { generateManifest } from './manifest.js';
16
+ import { buildOperationsMap } from './manifest.js';
17
17
  import { generateRbiFiles } from './rbi.js';
18
18
 
19
19
  /** Ensure every generated file's content ends with a trailing newline. */
@@ -61,8 +61,8 @@ export const rubyEmitter: Emitter = {
61
61
  return ensureTrailingNewlines(generateTests(spec, ctx));
62
62
  },
63
63
 
64
- generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[] {
65
- return ensureTrailingNewlines(generateManifest(spec, ctx));
64
+ buildOperationsMap(spec: ApiSpec, ctx: EmitterContext) {
65
+ return buildOperationsMap(spec, ctx);
66
66
  },
67
67
 
68
68
  fileHeader(): string {
@@ -1,16 +1,16 @@
1
- import type { ApiSpec, EmitterContext, GeneratedFile } from '@workos/oagen';
1
+ import type { ApiSpec, EmitterContext, OperationsMap } from '@workos/oagen';
2
2
  import { servicePropertyName } from './naming.js';
3
3
 
4
4
  /**
5
- * Generate smoke test manifest mapping HTTP operations to SDK methods.
5
+ * Build operation-to-SDK-method mapping for the manifest.
6
6
  *
7
7
  * Uses each resolved operation's actual mountOn (not the service default) so
8
8
  * operations remounted via operationHints land on the correct service prop.
9
9
  * Split operations emit one entry per wrapper (keyed by wrapper name + variant).
10
10
  */
11
- export function generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[] {
11
+ export function buildOperationsMap(spec: ApiSpec, ctx: EmitterContext): OperationsMap {
12
12
  void spec;
13
- const manifest: Record<string, { sdkMethod: string; service: string }> = {};
13
+ const manifest: OperationsMap = {};
14
14
 
15
15
  for (const r of ctx.resolvedOperations ?? []) {
16
16
  const op = r.operation;
@@ -24,12 +24,5 @@ export function generateManifest(spec: ApiSpec, ctx: EmitterContext): GeneratedF
24
24
  }
25
25
  }
26
26
 
27
- return [
28
- {
29
- path: 'smoke-manifest.json',
30
- content: JSON.stringify(manifest, null, 2),
31
- integrateTarget: false,
32
- overwriteExisting: true,
33
- },
34
- ];
27
+ return manifest;
35
28
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { generateManifest } from '../../src/dotnet/manifest.js';
2
+ import { buildOperationsMap } from '../../src/dotnet/manifest.js';
3
3
  import type { ApiSpec, EmitterContext, Service, Model } from '@workos/oagen';
4
4
  import { defaultSdkBehavior } from '@workos/oagen';
5
5
 
@@ -62,21 +62,22 @@ const ctx: EmitterContext = {
62
62
  };
63
63
 
64
64
  describe('dotnet/manifest', () => {
65
- it('generates smoke-manifest.json', () => {
66
- const files = generateManifest(spec, ctx);
67
- expect(files).toHaveLength(1);
68
- expect(files[0].path).toBe('smoke-manifest.json');
65
+ it('returns an operations map', () => {
66
+ const ops = buildOperationsMap(spec, ctx);
67
+ expect(typeof ops).toBe('object');
68
+ expect(Object.keys(ops).length).toBeGreaterThan(0);
69
69
  });
70
70
 
71
71
  it('maps HTTP operations to SDK method names and services', () => {
72
- const files = generateManifest(spec, ctx);
73
- const manifest = JSON.parse(files[0].content) as Record<string, { sdkMethod: string; service: string }>;
72
+ const ops = buildOperationsMap(spec, ctx);
74
73
 
75
- expect(manifest['GET /organizations']).toBeDefined();
76
- expect(manifest['GET /organizations'].sdkMethod).toBeDefined();
77
- expect(manifest['GET /organizations'].service).toBeDefined();
74
+ expect(ops['GET /organizations']).toBeDefined();
75
+ const entry = ops['GET /organizations'] as { sdkMethod: string; service: string };
76
+ expect(entry.sdkMethod).toBeDefined();
77
+ expect(entry.service).toBeDefined();
78
78
 
79
- expect(manifest['GET /organizations/api_keys']).toBeDefined();
80
- expect(manifest['GET /organizations/api_keys'].sdkMethod).toBeDefined();
79
+ expect(ops['GET /organizations/api_keys']).toBeDefined();
80
+ const entry2 = ops['GET /organizations/api_keys'] as { sdkMethod: string; service: string };
81
+ expect(entry2.sdkMethod).toBeDefined();
81
82
  });
82
83
  });
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { generateManifest } from '../../src/python/manifest.js';
2
+ import { buildOperationsMap } from '../../src/python/manifest.js';
3
3
  import type { ApiSpec, EmitterContext, Service, Model } from '@workos/oagen';
4
4
  import { defaultSdkBehavior } from '@workos/oagen';
5
5
 
@@ -61,14 +61,14 @@ const ctx: EmitterContext = {
61
61
  spec,
62
62
  };
63
63
 
64
- describe('generateManifest', () => {
64
+ describe('buildOperationsMap', () => {
65
65
  it('uses flat client access paths (no dotted namespaces)', () => {
66
- const files = generateManifest(spec, ctx);
67
- expect(files).toHaveLength(1);
66
+ const ops = buildOperationsMap(spec, ctx);
68
67
 
69
- const manifest = JSON.parse(files[0].content) as Record<string, { sdkMethod: string; service: string }>;
70
- expect(manifest['GET /organizations'].service).toBe('organizations');
68
+ const orgEntry = ops['GET /organizations'] as { sdkMethod: string; service: string };
69
+ expect(orgEntry.service).toBe('organizations');
71
70
  // Flat: no dotted access, each service has its own accessor
72
- expect(manifest['GET /organizations/api_keys'].service).toBe('organizations_api_keys');
71
+ const apiKeysEntry = ops['GET /organizations/api_keys'] as { sdkMethod: string; service: string };
72
+ expect(apiKeysEntry.service).toBe('organizations_api_keys');
73
73
  });
74
74
  });
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "bundler",
6
6
  "strict": true,
7
+ "types": ["node"],
7
8
  "declaration": true,
8
9
  "declarationMap": true,
9
10
  "sourceMap": true,