@workos/oagen-emitters 0.2.0 → 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/.oxfmtrc.json +8 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +15 -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 +11943 -2728
- 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-dotnet.ts +17 -3
- package/smoke/sdk-elixir.ts +17 -3
- package/smoke/sdk-go.ts +137 -46
- package/smoke/sdk-kotlin.ts +23 -4
- package/smoke/sdk-node.ts +15 -3
- package/smoke/sdk-php.ts +28 -26
- package/smoke/sdk-python.ts +5 -2
- package/smoke/sdk-ruby.ts +17 -3
- package/smoke/sdk-rust.ts +16 -3
- 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 +167 -122
- package/src/node/enums.ts +13 -4
- package/src/node/errors.ts +42 -233
- package/src/node/field-plan.ts +726 -0
- package/src/node/fixtures.ts +15 -5
- package/src/node/index.ts +65 -16
- package/src/node/models.ts +264 -96
- package/src/node/naming.ts +52 -25
- package/src/node/resources.ts +621 -172
- package/src/node/sdk-errors.ts +41 -0
- package/src/node/tests.ts +71 -27
- package/src/node/type-map.ts +4 -2
- package/src/node/utils.ts +56 -64
- 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 +199 -94
- package/test/node/enums.test.ts +75 -3
- package/test/node/errors.test.ts +2 -41
- package/test/node/models.test.ts +109 -20
- package/test/node/naming.test.ts +37 -4
- package/test/node/resources.test.ts +662 -30
- package/test/node/serializers.test.ts +36 -7
- 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 -744
package/test/node/enums.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateEnums } from '../../src/node/enums.js';
|
|
3
3
|
import type { EmitterContext, ApiSpec, Enum, Service } from '@workos/oagen';
|
|
4
|
+
import { defaultSdkBehavior } from '@workos/oagen';
|
|
4
5
|
|
|
5
6
|
const emptySpec: ApiSpec = {
|
|
6
7
|
name: 'Test',
|
|
@@ -9,6 +10,7 @@ const emptySpec: ApiSpec = {
|
|
|
9
10
|
services: [],
|
|
10
11
|
models: [],
|
|
11
12
|
enums: [],
|
|
13
|
+
sdk: defaultSdkBehavior(),
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
const ctx: EmitterContext = {
|
|
@@ -30,7 +32,13 @@ describe('generateEnums', () => {
|
|
|
30
32
|
name: 'getOrganization',
|
|
31
33
|
httpMethod: 'get',
|
|
32
34
|
path: '/organizations/{id}',
|
|
33
|
-
pathParams: [
|
|
35
|
+
pathParams: [
|
|
36
|
+
{
|
|
37
|
+
name: 'id',
|
|
38
|
+
type: { kind: 'primitive', type: 'string' },
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
34
42
|
queryParams: [],
|
|
35
43
|
headerParams: [],
|
|
36
44
|
response: {
|
|
@@ -76,7 +84,13 @@ describe('generateEnums', () => {
|
|
|
76
84
|
name: 'getOrganization',
|
|
77
85
|
httpMethod: 'get',
|
|
78
86
|
path: '/organizations/{id}',
|
|
79
|
-
pathParams: [
|
|
87
|
+
pathParams: [
|
|
88
|
+
{
|
|
89
|
+
name: 'id',
|
|
90
|
+
type: { kind: 'primitive', type: 'string' },
|
|
91
|
+
required: true,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
80
94
|
queryParams: [],
|
|
81
95
|
headerParams: [],
|
|
82
96
|
response: { kind: 'enum', name: 'OrgStatus' },
|
|
@@ -103,13 +117,71 @@ describe('generateEnums', () => {
|
|
|
103
117
|
expect(files[0].path).toBe('src/organizations/interfaces/org-status.interface.ts');
|
|
104
118
|
});
|
|
105
119
|
|
|
120
|
+
it('derives PascalCase member names when merging new enum values into baseline', () => {
|
|
121
|
+
const enums: Enum[] = [
|
|
122
|
+
{
|
|
123
|
+
name: 'OrganizationDomainState',
|
|
124
|
+
values: [
|
|
125
|
+
{ name: 'FAILED', value: 'failed' },
|
|
126
|
+
{ name: 'PENDING', value: 'pending' },
|
|
127
|
+
{ name: 'VERIFIED', value: 'verified' },
|
|
128
|
+
{ name: 'LEGACY_VERIFIED', value: 'legacy_verified' },
|
|
129
|
+
{ name: 'UNVERIFIED', value: 'unverified' },
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const testCtx: EmitterContext = {
|
|
135
|
+
...ctx,
|
|
136
|
+
apiSurface: {
|
|
137
|
+
language: 'node',
|
|
138
|
+
extractedFrom: 'test',
|
|
139
|
+
extractedAt: '2024-01-01',
|
|
140
|
+
classes: {},
|
|
141
|
+
interfaces: {},
|
|
142
|
+
typeAliases: {},
|
|
143
|
+
enums: {
|
|
144
|
+
OrganizationDomainState: {
|
|
145
|
+
name: 'OrganizationDomainState',
|
|
146
|
+
members: {
|
|
147
|
+
Failed: 'failed',
|
|
148
|
+
Pending: 'pending',
|
|
149
|
+
Verified: 'verified',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
exports: {},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const files = generateEnums(enums, testCtx);
|
|
158
|
+
const content = files[0].content;
|
|
159
|
+
|
|
160
|
+
// Existing members should be preserved as-is
|
|
161
|
+
expect(content).toContain("Failed = 'failed',");
|
|
162
|
+
expect(content).toContain("Pending = 'pending',");
|
|
163
|
+
expect(content).toContain("Verified = 'verified',");
|
|
164
|
+
|
|
165
|
+
// New members should be PascalCase, not lowercased
|
|
166
|
+
expect(content).toContain("LegacyVerified = 'legacy_verified',");
|
|
167
|
+
expect(content).toContain("Unverified = 'unverified',");
|
|
168
|
+
|
|
169
|
+
// Should NOT produce lowercased member names
|
|
170
|
+
expect(content).not.toContain('legacyverified');
|
|
171
|
+
});
|
|
172
|
+
|
|
106
173
|
it('renders @deprecated on enum values', () => {
|
|
107
174
|
const enums: Enum[] = [
|
|
108
175
|
{
|
|
109
176
|
name: 'Status',
|
|
110
177
|
values: [
|
|
111
178
|
{ name: 'ACTIVE', value: 'active' },
|
|
112
|
-
{
|
|
179
|
+
{
|
|
180
|
+
name: 'LEGACY',
|
|
181
|
+
value: 'legacy',
|
|
182
|
+
description: 'No longer supported.',
|
|
183
|
+
deprecated: true,
|
|
184
|
+
},
|
|
113
185
|
{ name: 'OLD', value: 'old', deprecated: true },
|
|
114
186
|
],
|
|
115
187
|
},
|
package/test/node/errors.test.ts
CHANGED
|
@@ -2,47 +2,8 @@ import { describe, it, expect } from 'vitest';
|
|
|
2
2
|
import { generateErrors } from '../../src/node/errors.js';
|
|
3
3
|
|
|
4
4
|
describe('generateErrors', () => {
|
|
5
|
-
it('
|
|
5
|
+
it('returns empty array without context (static exceptions now hand-maintained)', () => {
|
|
6
6
|
const files = generateErrors();
|
|
7
|
-
|
|
8
|
-
const names = files.map((f) => f.path);
|
|
9
|
-
expect(names).toContain('src/common/exceptions/bad-request.exception.ts');
|
|
10
|
-
expect(names).toContain('src/common/exceptions/unauthorized.exception.ts');
|
|
11
|
-
expect(names).toContain('src/common/exceptions/not-found.exception.ts');
|
|
12
|
-
expect(names).toContain('src/common/exceptions/conflict.exception.ts');
|
|
13
|
-
expect(names).toContain('src/common/exceptions/unprocessable-entity.exception.ts');
|
|
14
|
-
expect(names).toContain('src/common/exceptions/rate-limit-exceeded.exception.ts');
|
|
15
|
-
expect(names).toContain('src/common/exceptions/generic-server.exception.ts');
|
|
16
|
-
expect(names).toContain('src/common/exceptions/no-api-key-provided.exception.ts');
|
|
17
|
-
expect(names).toContain('src/common/exceptions/index.ts');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('generates NotFoundException with correct status', () => {
|
|
21
|
-
const files = generateErrors();
|
|
22
|
-
const notFoundFile = files.find((f) => f.path.includes('not-found.exception.ts'))!;
|
|
23
|
-
|
|
24
|
-
expect(notFoundFile.content).toContain('export class NotFoundException extends Error');
|
|
25
|
-
expect(notFoundFile.content).toContain('readonly status = 404;');
|
|
26
|
-
expect(notFoundFile.content).toContain('requestID: string');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('generates RateLimitExceededException with retryAfter', () => {
|
|
30
|
-
const files = generateErrors();
|
|
31
|
-
const rateLimitFile = files.find((f) => f.path.includes('rate-limit-exceeded.exception.ts'))!;
|
|
32
|
-
|
|
33
|
-
expect(rateLimitFile.content).toContain('export class RateLimitExceededException extends Error');
|
|
34
|
-
expect(rateLimitFile.content).toContain('readonly status = 429;');
|
|
35
|
-
expect(rateLimitFile.content).toContain('retryAfter?: number');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('generates exception barrel with all exports', () => {
|
|
39
|
-
const files = generateErrors();
|
|
40
|
-
const barrel = files.find((f) => f.path === 'src/common/exceptions/index.ts')!;
|
|
41
|
-
|
|
42
|
-
expect(barrel.content).toContain('export { BadRequestException }');
|
|
43
|
-
expect(barrel.content).toContain('export { UnauthorizedException }');
|
|
44
|
-
expect(barrel.content).toContain('export { NotFoundException }');
|
|
45
|
-
expect(barrel.content).toContain('export { RateLimitExceededException }');
|
|
46
|
-
expect(barrel.content).toContain('export { NoApiKeyProvidedException }');
|
|
7
|
+
expect(files).toEqual([]);
|
|
47
8
|
});
|
|
48
9
|
});
|
package/test/node/models.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateModels } from '../../src/node/models.js';
|
|
3
3
|
import type { EmitterContext, ApiSpec, Model, Service } from '@workos/oagen';
|
|
4
|
+
import { defaultSdkBehavior } from '@workos/oagen';
|
|
4
5
|
|
|
5
6
|
const emptySpec: ApiSpec = {
|
|
6
7
|
name: 'Test',
|
|
@@ -9,6 +10,7 @@ const emptySpec: ApiSpec = {
|
|
|
9
10
|
services: [],
|
|
10
11
|
models: [],
|
|
11
12
|
enums: [],
|
|
13
|
+
sdk: defaultSdkBehavior(),
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
const ctx: EmitterContext = {
|
|
@@ -30,7 +32,13 @@ describe('generateModels', () => {
|
|
|
30
32
|
name: 'getOrganization',
|
|
31
33
|
httpMethod: 'get',
|
|
32
34
|
path: '/organizations/{id}',
|
|
33
|
-
pathParams: [
|
|
35
|
+
pathParams: [
|
|
36
|
+
{
|
|
37
|
+
name: 'id',
|
|
38
|
+
type: { kind: 'primitive', type: 'string' },
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
34
42
|
queryParams: [],
|
|
35
43
|
headerParams: [],
|
|
36
44
|
response: { kind: 'model', name: 'Organization' },
|
|
@@ -101,7 +109,13 @@ describe('generateModels', () => {
|
|
|
101
109
|
name: 'getOrganization',
|
|
102
110
|
httpMethod: 'get',
|
|
103
111
|
path: '/organizations/{id}',
|
|
104
|
-
pathParams: [
|
|
112
|
+
pathParams: [
|
|
113
|
+
{
|
|
114
|
+
name: 'id',
|
|
115
|
+
type: { kind: 'primitive', type: 'string' },
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
105
119
|
queryParams: [],
|
|
106
120
|
headerParams: [],
|
|
107
121
|
response: { kind: 'model', name: 'Organization' },
|
|
@@ -247,7 +261,13 @@ describe('generateModels', () => {
|
|
|
247
261
|
name: 'getOrganization',
|
|
248
262
|
httpMethod: 'get',
|
|
249
263
|
path: '/organizations/{id}',
|
|
250
|
-
pathParams: [
|
|
264
|
+
pathParams: [
|
|
265
|
+
{
|
|
266
|
+
name: 'id',
|
|
267
|
+
type: { kind: 'primitive', type: 'string' },
|
|
268
|
+
required: true,
|
|
269
|
+
},
|
|
270
|
+
],
|
|
251
271
|
queryParams: [],
|
|
252
272
|
headerParams: [],
|
|
253
273
|
response: { kind: 'model', name: 'Organization' },
|
|
@@ -306,7 +326,13 @@ describe('generateModels', () => {
|
|
|
306
326
|
name: 'getOrganization',
|
|
307
327
|
httpMethod: 'get',
|
|
308
328
|
path: '/organizations/{id}',
|
|
309
|
-
pathParams: [
|
|
329
|
+
pathParams: [
|
|
330
|
+
{
|
|
331
|
+
name: 'id',
|
|
332
|
+
type: { kind: 'primitive', type: 'string' },
|
|
333
|
+
required: true,
|
|
334
|
+
},
|
|
335
|
+
],
|
|
310
336
|
queryParams: [],
|
|
311
337
|
headerParams: [],
|
|
312
338
|
response: { kind: 'model', name: 'Organization' },
|
|
@@ -386,7 +412,13 @@ describe('generateModels', () => {
|
|
|
386
412
|
name: 'getOrganization',
|
|
387
413
|
httpMethod: 'get',
|
|
388
414
|
path: '/organizations/{id}',
|
|
389
|
-
pathParams: [
|
|
415
|
+
pathParams: [
|
|
416
|
+
{
|
|
417
|
+
name: 'id',
|
|
418
|
+
type: { kind: 'primitive', type: 'string' },
|
|
419
|
+
required: true,
|
|
420
|
+
},
|
|
421
|
+
],
|
|
390
422
|
queryParams: [],
|
|
391
423
|
headerParams: [],
|
|
392
424
|
response: { kind: 'model', name: 'Organization' },
|
|
@@ -470,12 +502,18 @@ describe('generateModels', () => {
|
|
|
470
502
|
fields: [
|
|
471
503
|
{
|
|
472
504
|
name: 'before',
|
|
473
|
-
type: {
|
|
505
|
+
type: {
|
|
506
|
+
kind: 'nullable',
|
|
507
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
508
|
+
},
|
|
474
509
|
required: false,
|
|
475
510
|
},
|
|
476
511
|
{
|
|
477
512
|
name: 'after',
|
|
478
|
-
type: {
|
|
513
|
+
type: {
|
|
514
|
+
kind: 'nullable',
|
|
515
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
516
|
+
},
|
|
479
517
|
required: false,
|
|
480
518
|
},
|
|
481
519
|
],
|
|
@@ -542,7 +580,10 @@ describe('generateModels', () => {
|
|
|
542
580
|
},
|
|
543
581
|
{
|
|
544
582
|
name: 'data',
|
|
545
|
-
type: {
|
|
583
|
+
type: {
|
|
584
|
+
kind: 'array',
|
|
585
|
+
items: { kind: 'model', name: 'Connection' },
|
|
586
|
+
},
|
|
546
587
|
required: true,
|
|
547
588
|
},
|
|
548
589
|
{
|
|
@@ -557,12 +598,18 @@ describe('generateModels', () => {
|
|
|
557
598
|
fields: [
|
|
558
599
|
{
|
|
559
600
|
name: 'before',
|
|
560
|
-
type: {
|
|
601
|
+
type: {
|
|
602
|
+
kind: 'nullable',
|
|
603
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
604
|
+
},
|
|
561
605
|
required: false,
|
|
562
606
|
},
|
|
563
607
|
{
|
|
564
608
|
name: 'after',
|
|
565
|
-
type: {
|
|
609
|
+
type: {
|
|
610
|
+
kind: 'nullable',
|
|
611
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
612
|
+
},
|
|
566
613
|
required: false,
|
|
567
614
|
},
|
|
568
615
|
],
|
|
@@ -607,7 +654,13 @@ describe('generateModels', () => {
|
|
|
607
654
|
name: 'getOrganization',
|
|
608
655
|
httpMethod: 'get',
|
|
609
656
|
path: '/organizations/{id}',
|
|
610
|
-
pathParams: [
|
|
657
|
+
pathParams: [
|
|
658
|
+
{
|
|
659
|
+
name: 'id',
|
|
660
|
+
type: { kind: 'primitive', type: 'string' },
|
|
661
|
+
required: true,
|
|
662
|
+
},
|
|
663
|
+
],
|
|
611
664
|
queryParams: [],
|
|
612
665
|
headerParams: [],
|
|
613
666
|
response: { kind: 'model', name: 'Pagination' },
|
|
@@ -623,12 +676,18 @@ describe('generateModels', () => {
|
|
|
623
676
|
fields: [
|
|
624
677
|
{
|
|
625
678
|
name: 'before',
|
|
626
|
-
type: {
|
|
679
|
+
type: {
|
|
680
|
+
kind: 'nullable',
|
|
681
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
682
|
+
},
|
|
627
683
|
required: false,
|
|
628
684
|
},
|
|
629
685
|
{
|
|
630
686
|
name: 'after',
|
|
631
|
-
type: {
|
|
687
|
+
type: {
|
|
688
|
+
kind: 'nullable',
|
|
689
|
+
inner: { kind: 'primitive', type: 'string' },
|
|
690
|
+
},
|
|
632
691
|
required: false,
|
|
633
692
|
},
|
|
634
693
|
{
|
|
@@ -661,7 +720,13 @@ describe('model deduplication', () => {
|
|
|
661
720
|
name: 'getRole',
|
|
662
721
|
httpMethod: 'get',
|
|
663
722
|
path: '/roles/{id}',
|
|
664
|
-
pathParams: [
|
|
723
|
+
pathParams: [
|
|
724
|
+
{
|
|
725
|
+
name: 'id',
|
|
726
|
+
type: { kind: 'primitive', type: 'string' },
|
|
727
|
+
required: true,
|
|
728
|
+
},
|
|
729
|
+
],
|
|
665
730
|
queryParams: [],
|
|
666
731
|
headerParams: [],
|
|
667
732
|
response: { kind: 'model', name: 'EnvironmentRole' },
|
|
@@ -675,17 +740,41 @@ describe('model deduplication', () => {
|
|
|
675
740
|
{
|
|
676
741
|
name: 'EnvironmentRole',
|
|
677
742
|
fields: [
|
|
678
|
-
{
|
|
679
|
-
|
|
680
|
-
|
|
743
|
+
{
|
|
744
|
+
name: 'id',
|
|
745
|
+
type: { kind: 'primitive', type: 'string' },
|
|
746
|
+
required: true,
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
name: 'name',
|
|
750
|
+
type: { kind: 'primitive', type: 'string' },
|
|
751
|
+
required: true,
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
name: 'type',
|
|
755
|
+
type: { kind: 'literal', value: 'environment_role' },
|
|
756
|
+
required: true,
|
|
757
|
+
},
|
|
681
758
|
],
|
|
682
759
|
},
|
|
683
760
|
{
|
|
684
761
|
name: 'OrganizationRole',
|
|
685
762
|
fields: [
|
|
686
|
-
{
|
|
687
|
-
|
|
688
|
-
|
|
763
|
+
{
|
|
764
|
+
name: 'id',
|
|
765
|
+
type: { kind: 'primitive', type: 'string' },
|
|
766
|
+
required: true,
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
name: 'name',
|
|
770
|
+
type: { kind: 'primitive', type: 'string' },
|
|
771
|
+
required: true,
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: 'type',
|
|
775
|
+
type: { kind: 'literal', value: 'environment_role' },
|
|
776
|
+
required: true,
|
|
777
|
+
},
|
|
689
778
|
],
|
|
690
779
|
},
|
|
691
780
|
];
|
package/test/node/naming.test.ts
CHANGED
|
@@ -10,10 +10,31 @@ import {
|
|
|
10
10
|
servicePropertyName,
|
|
11
11
|
resolveServiceName,
|
|
12
12
|
buildServiceNameMap,
|
|
13
|
+
stripNoiseSuffixes,
|
|
13
14
|
} from '../../src/node/naming.js';
|
|
14
15
|
import type { EmitterContext, ApiSpec, Service } from '@workos/oagen';
|
|
16
|
+
import { defaultSdkBehavior } from '@workos/oagen';
|
|
15
17
|
|
|
16
18
|
describe('naming', () => {
|
|
19
|
+
describe('stripNoiseSuffixes', () => {
|
|
20
|
+
it('strips trailing Dto', () => {
|
|
21
|
+
expect(stripNoiseSuffixes('OrganizationDto')).toBe('Organization');
|
|
22
|
+
expect(stripNoiseSuffixes('UpdateOrganizationDto')).toBe('UpdateOrganization');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('is case-insensitive for the Dto suffix', () => {
|
|
26
|
+
expect(stripNoiseSuffixes('OrganizationDTO')).toBe('Organization');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('does not strip Dto from the middle of a name', () => {
|
|
30
|
+
expect(stripNoiseSuffixes('DtoFactory')).toBe('DtoFactory');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('leaves names without Dto unchanged', () => {
|
|
34
|
+
expect(stripNoiseSuffixes('Organization')).toBe('Organization');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
17
38
|
describe('className', () => {
|
|
18
39
|
it('converts to PascalCase', () => {
|
|
19
40
|
expect(className('organizations')).toBe('Organizations');
|
|
@@ -88,6 +109,7 @@ describe('naming', () => {
|
|
|
88
109
|
services: [],
|
|
89
110
|
models: [],
|
|
90
111
|
enums: [],
|
|
112
|
+
sdk: defaultSdkBehavior(),
|
|
91
113
|
};
|
|
92
114
|
|
|
93
115
|
it('returns overlay class name when available', () => {
|
|
@@ -116,7 +138,12 @@ describe('naming', () => {
|
|
|
116
138
|
methodByOperation: new Map([
|
|
117
139
|
[
|
|
118
140
|
'POST /auth/factors/enroll',
|
|
119
|
-
{
|
|
141
|
+
{
|
|
142
|
+
className: 'Mfa',
|
|
143
|
+
methodName: 'enrollFactor',
|
|
144
|
+
params: [],
|
|
145
|
+
returnType: 'void',
|
|
146
|
+
},
|
|
120
147
|
],
|
|
121
148
|
]),
|
|
122
149
|
httpKeyByMethod: new Map(),
|
|
@@ -133,7 +160,7 @@ describe('naming', () => {
|
|
|
133
160
|
|
|
134
161
|
it('falls back to PascalCase of service.name', () => {
|
|
135
162
|
const service: Service = {
|
|
136
|
-
name: '
|
|
163
|
+
name: 'SomeNewService',
|
|
137
164
|
operations: [],
|
|
138
165
|
};
|
|
139
166
|
|
|
@@ -143,7 +170,7 @@ describe('naming', () => {
|
|
|
143
170
|
spec: emptySpec,
|
|
144
171
|
};
|
|
145
172
|
|
|
146
|
-
expect(resolveServiceName(service, ctx)).toBe('
|
|
173
|
+
expect(resolveServiceName(service, ctx)).toBe('SomeNewService');
|
|
147
174
|
});
|
|
148
175
|
});
|
|
149
176
|
|
|
@@ -155,6 +182,7 @@ describe('naming', () => {
|
|
|
155
182
|
services: [],
|
|
156
183
|
models: [],
|
|
157
184
|
enums: [],
|
|
185
|
+
sdk: defaultSdkBehavior(),
|
|
158
186
|
};
|
|
159
187
|
|
|
160
188
|
it('maps IR names to resolved names', () => {
|
|
@@ -189,7 +217,12 @@ describe('naming', () => {
|
|
|
189
217
|
methodByOperation: new Map([
|
|
190
218
|
[
|
|
191
219
|
'POST /auth/factors/enroll',
|
|
192
|
-
{
|
|
220
|
+
{
|
|
221
|
+
className: 'Mfa',
|
|
222
|
+
methodName: 'enrollFactor',
|
|
223
|
+
params: [],
|
|
224
|
+
returnType: 'void',
|
|
225
|
+
},
|
|
193
226
|
],
|
|
194
227
|
]),
|
|
195
228
|
httpKeyByMethod: new Map(),
|