@aws/nx-plugin 1.0.0-rc.30 → 1.0.0-rc.31

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 (47) hide show
  1. package/LICENSE-THIRD-PARTY +235 -1336
  2. package/README.md +1 -1
  3. package/package.json +1 -2
  4. package/src/mcp-server/tools/create-workspace-command.js +2 -2
  5. package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
  6. package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +147 -33
  7. package/src/open-api/ts-client/__snapshots__/generator.arrays.spec.ts.snap +308 -75
  8. package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +286 -62
  9. package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +674 -93
  10. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +147 -33
  11. package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +196 -44
  12. package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5507 -0
  13. package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +219 -60
  14. package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
  15. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
  16. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
  17. package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
  18. package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
  19. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
  20. package/src/open-api/ts-client/files/client.gen.ts.template +130 -18
  21. package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
  22. package/src/open-api/ts-client/generator.js +1 -1
  23. package/src/open-api/ts-client/generator.js.map +1 -1
  24. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
  25. package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
  26. package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
  27. package/src/open-api/utils/codegen-data/languages.js +23 -18
  28. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  29. package/src/open-api/utils/codegen-data/types.d.ts +240 -10
  30. package/src/open-api/utils/codegen-data/types.js +24 -1
  31. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  32. package/src/open-api/utils/codegen-data.d.ts +2 -2
  33. package/src/open-api/utils/codegen-data.js +357 -617
  34. package/src/open-api/utils/codegen-data.js.map +1 -1
  35. package/src/open-api/utils/normalise.js +157 -19
  36. package/src/open-api/utils/normalise.js.map +1 -1
  37. package/src/open-api/utils/parser.d.ts +55 -0
  38. package/src/open-api/utils/parser.js +743 -0
  39. package/src/open-api/utils/parser.js.map +1 -0
  40. package/src/open-api/utils/types.d.ts +15 -0
  41. package/src/open-api/utils/types.js.map +1 -1
  42. package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
  43. package/src/utils/mcp.js +1 -1
  44. package/src/utils/mcp.js.map +1 -1
  45. package/src/utils/names.d.ts +6 -0
  46. package/src/utils/names.js +6 -1
  47. package/src/utils/names.js.map +1 -1
@@ -17,7 +17,7 @@ import { parseOpenApiSpec } from "../utils/parse.js";
17
17
  * Build a data structure which can be used to generate code from OpenAPI
18
18
  */ export const buildOpenApiCodeGenerationData = async (tree, specPath)=>{
19
19
  const spec = await parseOpenApiSpec(tree, specPath);
20
- return await buildOpenApiCodeGenData(spec);
20
+ return buildOpenApiCodeGenData(spec);
21
21
  };
22
22
  /**
23
23
  * Generate an OpenAPI typescript client in the target directory
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-client/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, type Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { buildOpenApiCodeGenData } from '../utils/codegen-data';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport { parseOpenApiSpec } from '../utils/parse';\nimport type { OpenApiTsClientGeneratorSchema } from './schema';\n\n/**\n * Generates typescript client from an openapi spec\n */\nexport const openApiTsClientGenerator = async (\n tree: Tree,\n options: OpenApiTsClientGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Build a data structure which can be used to generate code from OpenAPI\n */\nexport const buildOpenApiCodeGenerationData = async (\n tree: Tree,\n specPath: string,\n) => {\n const spec = await parseOpenApiSpec(tree, specPath);\n return await buildOpenApiCodeGenData(spec);\n};\n\n/**\n * Generate an OpenAPI typescript client in the target directory\n */\nexport const generateOpenApiTsClient = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(\n tree,\n path.join(import.meta.dirname, 'files'),\n outputPath,\n data,\n );\n};\n\nexport default openApiTsClientGenerator;\n"],"names":["generateFiles","path","formatFilesInSubtree","buildOpenApiCodeGenData","parseOpenApiSpec","openApiTsClientGenerator","tree","options","data","buildOpenApiCodeGenerationData","openApiSpecPath","generateOpenApiTsClient","outputPath","specPath","spec","join","dirname"],"mappings":"AAAA;;;CAGC,GACD,SAASA,aAAa,QAAmB,aAAa;AACtD,YAAYC,UAAU,OAAO;AAC7B,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,uBAAuB,QAAQ,2BAAwB;AAEhE,SAASC,gBAAgB,QAAQ,oBAAiB;AAGlD;;CAEC,GACD,OAAO,MAAMC,2BAA2B,OACtCC,MACAC;IAEA,MAAMC,OAAO,MAAMC,+BACjBH,MACAC,QAAQG,eAAe;IAGzBC,wBAAwBL,MAAME,MAAMD,QAAQK,UAAU;IAEtD,MAAMV,qBAAqBI;AAC7B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMG,iCAAiC,OAC5CH,MACAO;IAEA,MAAMC,OAAO,MAAMV,iBAAiBE,MAAMO;IAC1C,OAAO,MAAMV,wBAAwBW;AACvC,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMH,0BAA0B,CACrCL,MACAE,MACAI;IAEAZ,cACEM,MACAL,KAAKc,IAAI,CAAC,YAAYC,OAAO,EAAE,UAC/BJ,YACAJ;AAEJ,EAAE;AAEF,eAAeH,yBAAyB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/ts-client/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { generateFiles, type Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { buildOpenApiCodeGenData } from '../utils/codegen-data';\nimport type { CodeGenData } from '../utils/codegen-data/types';\nimport { parseOpenApiSpec } from '../utils/parse';\nimport type { OpenApiTsClientGeneratorSchema } from './schema';\n\n/**\n * Generates typescript client from an openapi spec\n */\nexport const openApiTsClientGenerator = async (\n tree: Tree,\n options: OpenApiTsClientGeneratorSchema,\n) => {\n const data = await buildOpenApiCodeGenerationData(\n tree,\n options.openApiSpecPath,\n );\n\n generateOpenApiTsClient(tree, data, options.outputPath);\n\n await formatFilesInSubtree(tree);\n};\n\n/**\n * Build a data structure which can be used to generate code from OpenAPI\n */\nexport const buildOpenApiCodeGenerationData = async (\n tree: Tree,\n specPath: string,\n) => {\n const spec = await parseOpenApiSpec(tree, specPath);\n return buildOpenApiCodeGenData(spec);\n};\n\n/**\n * Generate an OpenAPI typescript client in the target directory\n */\nexport const generateOpenApiTsClient = (\n tree: Tree,\n data: CodeGenData,\n outputPath: string,\n) => {\n generateFiles(\n tree,\n path.join(import.meta.dirname, 'files'),\n outputPath,\n data,\n );\n};\n\nexport default openApiTsClientGenerator;\n"],"names":["generateFiles","path","formatFilesInSubtree","buildOpenApiCodeGenData","parseOpenApiSpec","openApiTsClientGenerator","tree","options","data","buildOpenApiCodeGenerationData","openApiSpecPath","generateOpenApiTsClient","outputPath","specPath","spec","join","dirname"],"mappings":"AAAA;;;CAGC,GACD,SAASA,aAAa,QAAmB,aAAa;AACtD,YAAYC,UAAU,OAAO;AAC7B,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,uBAAuB,QAAQ,2BAAwB;AAEhE,SAASC,gBAAgB,QAAQ,oBAAiB;AAGlD;;CAEC,GACD,OAAO,MAAMC,2BAA2B,OACtCC,MACAC;IAEA,MAAMC,OAAO,MAAMC,+BACjBH,MACAC,QAAQG,eAAe;IAGzBC,wBAAwBL,MAAME,MAAMD,QAAQK,UAAU;IAEtD,MAAMV,qBAAqBI;AAC7B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMG,iCAAiC,OAC5CH,MACAO;IAEA,MAAMC,OAAO,MAAMV,iBAAiBE,MAAMO;IAC1C,OAAOV,wBAAwBW;AACjC,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMH,0BAA0B,CACrCL,MACAE,MACAI;IAEAZ,cACEM,MACAL,KAAKc,IAAI,CAAC,YAAYC,OAAO,EAAE,UAC/BJ,YACAJ;AAEJ,EAAE;AAEF,eAAeH,yBAAyB"}
@@ -36,6 +36,11 @@ import type {
36
36
  <%_ uniq(allOperations.flatMap((op) => op.result && modelsByName[op.result.type] ? [modelsByName[op.result.type].typescriptType] : [])).forEach((returnTypeModel) => { _%>
37
37
  <%- returnTypeModel %>,
38
38
  <%_ }); _%>
39
+ <%_ /* Infinite-query cursor types may reference a named model (e.g. an enum),
40
+ which the cursorType uses but is otherwise not imported. */ _%>
41
+ <%_ uniq(allOperations.flatMap((op) => op.isInfiniteQuery && op.infiniteQueryCursorProperty && modelsByName[op.infiniteQueryCursorProperty.type] ? [modelsByName[op.infiniteQueryCursorProperty.type].typescriptType] : [])).forEach((cursorTypeModel) => { _%>
42
+ <%- cursorTypeModel %>,
43
+ <%_ }); _%>
39
44
  } from './types.gen.js';
40
45
  <%_ } _%>
41
46
  import { <%- className %> } from './client.gen.js';
@@ -1226,6 +1226,76 @@ describe('openApiTsHooksGenerator', () => {
1226
1226
  );
1227
1227
  });
1228
1228
 
1229
+ it('should import the cursor model when the cursor parameter is a $ref', async () => {
1230
+ // Regression: when the infinite-query cursor parameter is a $ref to a named
1231
+ // schema (e.g. an enum), the options proxy references that model in the
1232
+ // cursor type but must also import it, or the proxy fails to compile.
1233
+ const spec: Spec = {
1234
+ openapi: '3.0.0',
1235
+ info: { title, version: '1.0.0' },
1236
+ paths: {
1237
+ '/records': {
1238
+ get: {
1239
+ ...{ 'x-cursor': 'token' },
1240
+ operationId: 'listRecords',
1241
+ parameters: [
1242
+ {
1243
+ name: 'token',
1244
+ in: 'query',
1245
+ required: false,
1246
+ schema: { $ref: '#/components/schemas/PageToken' },
1247
+ },
1248
+ ],
1249
+ responses: {
1250
+ '200': {
1251
+ description: 'ok',
1252
+ content: {
1253
+ 'application/json': {
1254
+ schema: {
1255
+ type: 'object',
1256
+ required: ['records'],
1257
+ properties: {
1258
+ records: { type: 'array', items: { type: 'string' } },
1259
+ },
1260
+ },
1261
+ },
1262
+ },
1263
+ },
1264
+ },
1265
+ },
1266
+ },
1267
+ },
1268
+ components: {
1269
+ schemas: {
1270
+ PageToken: { type: 'string', enum: ['a', 'b', 'c'] },
1271
+ },
1272
+ },
1273
+ };
1274
+
1275
+ tree.write('openapi.json', JSON.stringify(spec));
1276
+
1277
+ await openApiTsHooksGenerator(tree, {
1278
+ openApiSpecPath: 'openapi.json',
1279
+ outputPath: 'src/generated',
1280
+ });
1281
+
1282
+ const optionsProxy = tree.read(
1283
+ 'src/generated/options-proxy.gen.ts',
1284
+ 'utf-8',
1285
+ )!;
1286
+ // The cursor model is used in the cursor type and imported from types.gen.
1287
+ expect(optionsProxy).toContain('PageToken | undefined | null');
1288
+ expect(optionsProxy).toMatch(
1289
+ /import type \{[\s\S]*PageToken,[\s\S]*\} from '\.\/types\.gen\.js'/,
1290
+ );
1291
+
1292
+ validateTypeScript([
1293
+ 'src/generated/client.gen.ts',
1294
+ 'src/generated/types.gen.ts',
1295
+ 'src/generated/options-proxy.gen.ts',
1296
+ ]);
1297
+ });
1298
+
1229
1299
  it('should handle infinite query with custom cursor parameter via object vendor extension', async () => {
1230
1300
  const spec: Spec = {
1231
1301
  openapi: '3.0.0',
@@ -3,14 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type Model } from './types';
6
- /**
7
- * Return the typescript type for the given model
8
- */
9
6
  export declare const toTypeScriptType: (property: Model) => string;
10
7
  export declare const toTypeScriptName: (name: string) => string;
11
8
  export declare const toTypeScriptModelName: (name: string) => string;
12
- /**
13
- * Return the python type for a given property
14
- */
15
9
  export declare const toPythonType: (property: Model) => string;
16
10
  export declare const toPythonName: (namedEntity: "model" | "property" | "operation", name: string) => string;
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
- */ import camelCase from "lodash.camelcase";
5
- import { snakeCase, toClassName } from "../../../utils/names.js";
6
- import { flattenModelLink, PRIMITIVE_TYPES } from "./types.js";
4
+ */ import { camelCase, snakeCase, toClassName } from "../../../utils/names.js";
5
+ import { PRIMITIVE_TYPES } from "./types.js";
7
6
  const toTypescriptPrimitive = (property)=>{
8
7
  if (property.type === 'string' && [
9
8
  'date',
@@ -15,18 +14,23 @@ const toTypescriptPrimitive = (property)=>{
15
14
  }
16
15
  return property.type;
17
16
  };
18
- /**
19
- * Return the typescript type for the given model
20
- */ export const toTypeScriptType = (property)=>{
21
- const propertyLink = flattenModelLink(property.link);
17
+ export const toTypeScriptType = (property)=>{
18
+ // A discriminated subtype's discriminator property renders as its literal
19
+ // tag, making the union a true (narrowable) tagged union.
20
+ if (property.discriminatorValue) {
21
+ return property.discriminatorValue;
22
+ }
23
+ const link = property.link;
24
+ // Enum links serialise as their primitive; use the model's own type instead.
25
+ const valueType = ()=>link && link.export !== 'enum' ? toTypeScriptType(link) : property.type;
22
26
  switch(property.export){
23
27
  case 'enum':
24
28
  case 'generic':
25
29
  return toTypescriptPrimitive(property);
26
30
  case 'array':
27
- return `Array<${propertyLink && propertyLink.export !== 'enum' ? toTypeScriptType(propertyLink) : property.type}>`;
31
+ return `Array<${valueType()}>`;
28
32
  case 'dictionary':
29
- return `{ [key: string]: ${propertyLink && propertyLink.export !== 'enum' ? toTypeScriptType(propertyLink) : property.type}; }`;
33
+ return `{ [key: string]: ${valueType()}; }`;
30
34
  case 'one-of':
31
35
  case 'any-of':
32
36
  case 'all-of':
@@ -43,7 +47,9 @@ const toTypescriptPrimitive = (property)=>{
43
47
  }
44
48
  };
45
49
  export const toTypeScriptName = (name)=>{
46
- return camelCase(name);
50
+ // A name of only non-identifier characters (e.g. "_") camelCases to an empty
51
+ // string; fall back to an underscore so the emitted property stays valid.
52
+ return camelCase(name) || (name ?? '').replace(/[^a-zA-Z0-9]/g, '_') || '_';
47
53
  };
48
54
  const TYPESCRIPT_RESERVED_MODEL_NAMES = new Set([
49
55
  'Date',
@@ -102,18 +108,17 @@ const toPythonPrimitive = (property)=>{
102
108
  }
103
109
  return property.type;
104
110
  };
105
- /**
106
- * Return the python type for a given property
107
- */ export const toPythonType = (property)=>{
108
- const propertyLink = flattenModelLink(property.link);
111
+ export const toPythonType = (property)=>{
112
+ const link = property.link;
113
+ const valueType = ()=>link && link.export !== 'enum' ? toPythonType(link) : property.type;
109
114
  switch(property.export){
110
115
  case 'generic':
111
116
  case 'reference':
112
117
  return toPythonPrimitive(property);
113
118
  case 'array':
114
- return `List[${propertyLink && propertyLink.export !== 'enum' ? toPythonType(propertyLink) : property.type}]`;
119
+ return `List[${valueType()}]`;
115
120
  case 'dictionary':
116
- return `Dict[str, ${propertyLink && propertyLink.export !== 'enum' ? toPythonType(propertyLink) : property.type}]`;
121
+ return `Dict[str, ${valueType()}]`;
117
122
  case 'one-of':
118
123
  case 'any-of':
119
124
  case 'all-of':
@@ -178,8 +183,8 @@ const PYTHON_KEYWORDS = new Set([
178
183
  ]);
179
184
  export const toPythonName = (namedEntity, name)=>{
180
185
  const nameSnakeCase = snakeCase(name);
181
- // Check if the name is a reserved word. Reserved words that overlap with TypeScript will already be escaped
182
- // with a leading _ by @hey-api/openapi-ts, so we remove this to test
186
+ // Names overlapping a TypeScript reserved word carry a leading `_`; strip it
187
+ // before testing against the Python keyword set.
183
188
  if (PYTHON_KEYWORDS.has(name.startsWith('_') ? name.slice(1) : name)) {
184
189
  const nameSuffix = `_${nameSnakeCase}`;
185
190
  switch(namedEntity){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data/languages.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport camelCase from 'lodash.camelcase';\nimport { snakeCase, toClassName } from '../../../utils/names';\nimport { flattenModelLink, type Model, PRIMITIVE_TYPES } from './types';\n\nconst toTypescriptPrimitive = (property: Model): string => {\n if (\n property.type === 'string' &&\n ['date', 'date-time'].includes(property.format ?? '')\n ) {\n return 'Date';\n } else if (property.type === 'binary') {\n return 'Blob';\n }\n return property.type;\n};\n\n/**\n * Return the typescript type for the given model\n */\nexport const toTypeScriptType = (property: Model): string => {\n const propertyLink = flattenModelLink(property.link);\n switch (property.export) {\n case 'enum':\n case 'generic':\n return toTypescriptPrimitive(property);\n case 'array':\n return `Array<${propertyLink && propertyLink.export !== 'enum' ? toTypeScriptType(propertyLink) : property.type}>`;\n case 'dictionary':\n return `{ [key: string]: ${propertyLink && propertyLink.export !== 'enum' ? toTypeScriptType(propertyLink) : property.type}; }`;\n case 'one-of':\n case 'any-of':\n case 'all-of':\n return toTypeScriptModelName(property.name);\n case 'reference':\n default:\n if (property.type === 'unknown') {\n return 'unknown';\n }\n if (PRIMITIVE_TYPES.has(property.type)) {\n return toTypescriptPrimitive(property);\n }\n return toTypeScriptModelName(property.type);\n }\n};\n\nexport const toTypeScriptName = (name: string): string => {\n return camelCase(name);\n};\n\nconst TYPESCRIPT_RESERVED_MODEL_NAMES = new Set([\n 'Date',\n 'Blob',\n 'Object',\n 'String',\n 'Boolean',\n 'Integer',\n 'Long',\n 'Float',\n 'Array',\n 'ReadonlyArray',\n 'File',\n 'Error',\n 'Map',\n 'Set',\n 'Number',\n 'Symbol',\n 'BigInt',\n 'Function',\n 'Promise',\n 'RegExp',\n 'JSON',\n]);\n\nexport const toTypeScriptModelName = (name: string): string => {\n const candidateName = toClassName(name);\n\n // Prepend underscore for any reserved model names\n return TYPESCRIPT_RESERVED_MODEL_NAMES.has(candidateName)\n ? `_${candidateName}`\n : candidateName;\n};\n\nconst toPythonPrimitive = (property: Model): string => {\n if (property.type === 'string' && property.format === 'date') {\n return 'date';\n } else if (property.type === 'string' && property.format === 'date-time') {\n return 'datetime';\n } else if (property.type === 'any') {\n return 'object';\n } else if (property.type === 'binary') {\n return 'bytearray';\n } else if (property.type === 'number') {\n if ((property as any).openapiType === 'integer') {\n return 'int';\n }\n\n switch (property.format) {\n case 'int32':\n case 'int64':\n return 'int';\n case 'float':\n case 'double':\n default:\n return 'float';\n }\n } else if (property.type === 'boolean') {\n return 'bool';\n } else if (property.type === 'string') {\n return 'str';\n }\n return property.type;\n};\n\n/**\n * Return the python type for a given property\n */\nexport const toPythonType = (property: Model): string => {\n const propertyLink = flattenModelLink(property.link);\n switch (property.export) {\n case 'generic':\n case 'reference':\n return toPythonPrimitive(property);\n case 'array':\n return `List[${propertyLink && propertyLink.export !== 'enum' ? toPythonType(propertyLink) : property.type}]`;\n case 'dictionary':\n return `Dict[str, ${propertyLink && propertyLink.export !== 'enum' ? toPythonType(propertyLink) : property.type}]`;\n case 'one-of':\n case 'any-of':\n case 'all-of':\n return property.name;\n default:\n // \"any\" has export = interface\n if (PRIMITIVE_TYPES.has(property.type)) {\n return toPythonPrimitive(property);\n }\n return property.type;\n }\n};\n\n// @see https://github.com/OpenAPITools/openapi-generator/blob/e2a62ace74de361bef6338b7fa37da8577242aef/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java#L106\nconst PYTHON_KEYWORDS = new Set([\n // @property\n 'property',\n // typing keywords\n 'schema',\n 'base64',\n 'json',\n 'date',\n 'float',\n // python reserved words\n 'and',\n 'del',\n 'from',\n 'not',\n 'while',\n 'as',\n 'elif',\n 'global',\n 'or',\n 'with',\n 'assert',\n 'else',\n 'if',\n 'pass',\n 'yield',\n 'break',\n 'except',\n 'import',\n 'print',\n 'class',\n 'exec',\n 'in',\n 'raise',\n 'continue',\n 'finally',\n 'is',\n 'return',\n 'def',\n 'for',\n 'lambda',\n 'try',\n 'self',\n 'nonlocal',\n 'None',\n 'True',\n 'False',\n 'async',\n 'await',\n]);\n\nexport const toPythonName = (\n namedEntity: 'model' | 'property' | 'operation',\n name: string,\n) => {\n const nameSnakeCase = snakeCase(name);\n\n // Check if the name is a reserved word. Reserved words that overlap with TypeScript will already be escaped\n // with a leading _ by @hey-api/openapi-ts, so we remove this to test\n if (PYTHON_KEYWORDS.has(name.startsWith('_') ? name.slice(1) : name)) {\n const nameSuffix = `_${nameSnakeCase}`;\n switch (namedEntity) {\n case 'model':\n return `model${nameSuffix}`;\n case 'operation':\n return `call${nameSuffix}`;\n case 'property':\n return `var${nameSuffix}`;\n default:\n break;\n }\n }\n return nameSnakeCase;\n};\n"],"names":["camelCase","snakeCase","toClassName","flattenModelLink","PRIMITIVE_TYPES","toTypescriptPrimitive","property","type","includes","format","toTypeScriptType","propertyLink","link","export","toTypeScriptModelName","name","has","toTypeScriptName","TYPESCRIPT_RESERVED_MODEL_NAMES","Set","candidateName","toPythonPrimitive","openapiType","toPythonType","PYTHON_KEYWORDS","toPythonName","namedEntity","nameSnakeCase","startsWith","slice","nameSuffix"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,eAAe,mB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L,KAAK;QACL,KAAK;YACH,OAAOD,SAASS,IAAI;QACtB;YACE,+BAA+B;YAC/B,IAAIX,gBAAgBY,GAAG,CAACV,SAASC,IAAI,GAAG;gBACtC,OAAOc,kBAAkBf;YAC3B;YACA,OAAOA,SAASC,IAAI;IACxB;AACF,EAAE;AAEF,kNAAkN;AAClN,MAAMiB,kBAAkB,IAAIL,IAAI;IAC9B,YAAY;IACZ;IACA,kBAAkB;IAClB;IACA;IACA;IACA;IACA;IACA,wBAAwB;IACxB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMM,eAAe,CAC1BC,aACAX;IAEA,MAAMY,gBAAgB1B,UAAUc;IAEhC,4GAA4G;IAC5G,qEAAqE;IACrE,IAAIS,gBAAgBR,GAAG,CAACD,KAAKa,UAAU,CAAC,OAAOb,KAAKc,KAAK,CAAC,KAAKd,OAAO;QACpE,MAAMe,aAAa,CAAC,CAAC,EAAEH,eAAe;QACtC,OAAQD;YACN,KAAK;gBACH,OAAO,CAAC,KAAK,EAAEI,YAAY;YAC7B,KAAK;gBACH,OAAO,CAAC,IAAI,EAAEA,YAAY;YAC5B,KAAK;gBACH,OAAO,CAAC,GAAG,EAAEA,YAAY;YAC3B;gBACE;QACJ;IACF;IACA,OAAOH;AACT,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data/languages.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { camelCase, snakeCase, toClassName } from '../../../utils/names';\nimport { type Model, PRIMITIVE_TYPES } from './types';\n\nconst toTypescriptPrimitive = (property: Model): string => {\n if (\n property.type === 'string' &&\n ['date', 'date-time'].includes(property.format ?? '')\n ) {\n return 'Date';\n } else if (property.type === 'binary') {\n return 'Blob';\n }\n return property.type;\n};\n\nexport const toTypeScriptType = (property: Model): string => {\n // A discriminated subtype's discriminator property renders as its literal\n // tag, making the union a true (narrowable) tagged union.\n if (property.discriminatorValue) {\n return property.discriminatorValue;\n }\n const link = property.link;\n // Enum links serialise as their primitive; use the model's own type instead.\n const valueType = () =>\n link && link.export !== 'enum' ? toTypeScriptType(link) : property.type;\n switch (property.export) {\n case 'enum':\n case 'generic':\n return toTypescriptPrimitive(property);\n case 'array':\n return `Array<${valueType()}>`;\n case 'dictionary':\n return `{ [key: string]: ${valueType()}; }`;\n case 'one-of':\n case 'any-of':\n case 'all-of':\n return toTypeScriptModelName(property.name);\n case 'reference':\n default:\n if (property.type === 'unknown') {\n return 'unknown';\n }\n if (PRIMITIVE_TYPES.has(property.type)) {\n return toTypescriptPrimitive(property);\n }\n return toTypeScriptModelName(property.type);\n }\n};\n\nexport const toTypeScriptName = (name: string): string => {\n // A name of only non-identifier characters (e.g. \"_\") camelCases to an empty\n // string; fall back to an underscore so the emitted property stays valid.\n return camelCase(name) || (name ?? '').replace(/[^a-zA-Z0-9]/g, '_') || '_';\n};\n\nconst TYPESCRIPT_RESERVED_MODEL_NAMES = new Set([\n 'Date',\n 'Blob',\n 'Object',\n 'String',\n 'Boolean',\n 'Integer',\n 'Long',\n 'Float',\n 'Array',\n 'ReadonlyArray',\n 'File',\n 'Error',\n 'Map',\n 'Set',\n 'Number',\n 'Symbol',\n 'BigInt',\n 'Function',\n 'Promise',\n 'RegExp',\n 'JSON',\n]);\n\nexport const toTypeScriptModelName = (name: string): string => {\n const candidateName = toClassName(name);\n\n // Prepend underscore for any reserved model names\n return TYPESCRIPT_RESERVED_MODEL_NAMES.has(candidateName)\n ? `_${candidateName}`\n : candidateName;\n};\n\nconst toPythonPrimitive = (property: Model): string => {\n if (property.type === 'string' && property.format === 'date') {\n return 'date';\n } else if (property.type === 'string' && property.format === 'date-time') {\n return 'datetime';\n } else if (property.type === 'any') {\n return 'object';\n } else if (property.type === 'binary') {\n return 'bytearray';\n } else if (property.type === 'number') {\n if (property.openapiType === 'integer') {\n return 'int';\n }\n\n switch (property.format) {\n case 'int32':\n case 'int64':\n return 'int';\n case 'float':\n case 'double':\n default:\n return 'float';\n }\n } else if (property.type === 'boolean') {\n return 'bool';\n } else if (property.type === 'string') {\n return 'str';\n }\n return property.type;\n};\n\nexport const toPythonType = (property: Model): string => {\n const link = property.link;\n const valueType = () =>\n link && link.export !== 'enum' ? toPythonType(link) : property.type;\n switch (property.export) {\n case 'generic':\n case 'reference':\n return toPythonPrimitive(property);\n case 'array':\n return `List[${valueType()}]`;\n case 'dictionary':\n return `Dict[str, ${valueType()}]`;\n case 'one-of':\n case 'any-of':\n case 'all-of':\n return property.name;\n default:\n // \"any\" has export = interface\n if (PRIMITIVE_TYPES.has(property.type)) {\n return toPythonPrimitive(property);\n }\n return property.type;\n }\n};\n\n// @see https://github.com/OpenAPITools/openapi-generator/blob/e2a62ace74de361bef6338b7fa37da8577242aef/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java#L106\nconst PYTHON_KEYWORDS = new Set([\n // @property\n 'property',\n // typing keywords\n 'schema',\n 'base64',\n 'json',\n 'date',\n 'float',\n // python reserved words\n 'and',\n 'del',\n 'from',\n 'not',\n 'while',\n 'as',\n 'elif',\n 'global',\n 'or',\n 'with',\n 'assert',\n 'else',\n 'if',\n 'pass',\n 'yield',\n 'break',\n 'except',\n 'import',\n 'print',\n 'class',\n 'exec',\n 'in',\n 'raise',\n 'continue',\n 'finally',\n 'is',\n 'return',\n 'def',\n 'for',\n 'lambda',\n 'try',\n 'self',\n 'nonlocal',\n 'None',\n 'True',\n 'False',\n 'async',\n 'await',\n]);\n\nexport const toPythonName = (\n namedEntity: 'model' | 'property' | 'operation',\n name: string,\n) => {\n const nameSnakeCase = snakeCase(name);\n\n // Names overlapping a TypeScript reserved word carry a leading `_`; strip it\n // before testing against the Python keyword set.\n if (PYTHON_KEYWORDS.has(name.startsWith('_') ? name.slice(1) : name)) {\n const nameSuffix = `_${nameSnakeCase}`;\n switch (namedEntity) {\n case 'model':\n return `model${nameSuffix}`;\n case 'operation':\n return `call${nameSuffix}`;\n case 'property':\n return `var${nameSuffix}`;\n default:\n break;\n }\n }\n return nameSnakeCase;\n};\n"],"names":["camelCase","snakeCase","toClassName","PRIMITIVE_TYPES","toTypescriptPrimitive","property","type","includes","format","toTypeScriptType","discriminatorValue","link","valueType","export","toTypeScriptModelName","name","has","toTypeScriptName","replace","TYPESCRIPT_RESERVED_MODEL_NAMES","Set","candidateName","toPythonPrimitive","openapiType","toPythonType","PYTHON_KEYWORDS","toPythonName","namedEntity","nameSnakeCase","startsWith","slice","nameSuffix"],"mappings":"AAAA;;;CAGC,GAED,SAASA,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,0BAAuB;AACzE,SAAqBC,eAAe,QAAQ,aAAU;AAEtD,MAAMC,wBAAwB,CAACC;IAC7B,IACEA,SAASC,IAAI,KAAK,YAClB;QAAC;QAAQ;KAAY,CAACC,QAAQ,CAACF,SAASG,MAAM,IAAI,KAClD;QACA,OAAO;IACT,OAAO,IAAIH,SAASC,IAAI,KAAK,UAAU;QACrC,OAAO;IACT;IACA,OAAOD,SAASC,IAAI;AACtB;AAEA,OAAO,MAAMG,mBAAmB,CAACJ;IAC/B,0EAA0E;IAC1E,0DAA0D;IAC1D,IAAIA,SAASK,kBAAkB,EAAE;QAC/B,OAAOL,SAASK,kBAAkB;IACpC;IACA,MAAMC,OAAON,SAASM,IAAI;IAC1B,6EAA6E;IAC7E,MAAMC,YAAY,IAChBD,QAAQA,KAAKE,MAAM,KAAK,SAASJ,iBAAiBE,QAAQN,SAASC,IAAI;IACzE,OAAQD,SAASQ,MAAM;QACrB,KAAK;QACL,KAAK;YACH,OAAOT,sBAAsBC;QAC/B,KAAK;YACH,OAAO,CAAC,MAAM,EAAEO,YAAY,CA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,UAAU,CAAC,OAAOd,KAAKe,KAAK,CAAC,KAAKf,OAAO;QACpE,MAAMgB,aAAa,CAAC,CAAC,EAAEH,eAAe;QACtC,OAAQD;YACN,KAAK;gBACH,OAAO,CAAC,KAAK,EAAEI,YAAY;YAC7B,KAAK;gBACH,OAAO,CAAC,IAAI,EAAEA,YAAY;YAC5B,KAAK;gBACH,OAAO,CAAC,GAAG,EAAEA,YAAY;YAC3B;gBACE;QACJ;IACF;IACA,OAAOH;AACT,EAAE"}
@@ -2,11 +2,239 @@
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import type { Plugin } from '@hey-api/openapi-ts';
6
5
  import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
7
- export type ClientData = Parameters<Plugin.LegacyHandler<any>>[0]['client'];
8
- export type Operation = ClientData['services'][number]['operations'][number];
9
- export type Model = ClientData['models'][number];
6
+ /**
7
+ * The kind of a {@link Model}, describing how it should be rendered.
8
+ *
9
+ * - `interface` — an object type with named properties
10
+ * - `enum` — a set of string/number literal values
11
+ * - `array` — a list whose element type is described by `link`
12
+ * - `dictionary` — a map whose value type is described by `link`
13
+ * - `reference` — a reference to another named model (`type` is its name)
14
+ * - `generic` — a primitive (string/number/boolean/null/void/binary/any)
15
+ * - `one-of` / `any-of` / `all-of` — a composite of other schemas
16
+ */
17
+ export type ModelExport = 'interface' | 'enum' | 'array' | 'dictionary' | 'reference' | 'generic' | 'one-of' | 'any-of' | 'all-of';
18
+ /**
19
+ * Where a parameter-like {@link Model} appears in a request/response.
20
+ * Empty string is used for models that are not parameters (schemas/properties).
21
+ */
22
+ export type ModelIn = '' | 'query' | 'path' | 'header' | 'cookie' | 'body' | 'response';
23
+ /**
24
+ * How array/object query & header parameters are serialised on the wire.
25
+ * `deepObject` explodes an object into `key[prop]=value` query pairs.
26
+ */
27
+ export type CollectionFormat = 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
28
+ /** A single enum member value. */
29
+ export interface EnumMember {
30
+ value: string | number | boolean;
31
+ }
32
+ /**
33
+ * A discriminated-composite mapping entry: a discriminator value and the name
34
+ * of the composed model it selects.
35
+ */
36
+ export interface DiscriminatorMapping {
37
+ /** The discriminator property value (e.g. `"cat"`). */
38
+ value: string;
39
+ /** The name of the composed model this value selects (e.g. `"Cat"`). */
40
+ modelName: string;
41
+ }
42
+ /**
43
+ * The discriminator of a composite (`oneOf`/`anyOf`) or an inheritance base
44
+ * (an `object` schema whose subtypes `allOf`-compose it), used to marshal
45
+ * directly to the matching branch/subtype rather than merging every branch or
46
+ * dropping subtype-only fields.
47
+ */
48
+ export interface Discriminator {
49
+ /** The wire property name carrying the discriminator value. */
50
+ propertyName: string;
51
+ /** The TypeScript property name (resolved during augmentation). */
52
+ typescriptPropertyName?: string;
53
+ /** The value → composed-model mapping. */
54
+ mapping: DiscriminatorMapping[];
55
+ /**
56
+ * True when this discriminator sits on an inheritance base (an `object`
57
+ * schema selected by `allOf`-composing subtypes) rather than a `oneOf`/
58
+ * `anyOf` composite. The base marshals via dispatch to its subtypes, but its
59
+ * subtypes compose the base's own (non-dispatching) body — so the base emits
60
+ * a separate non-dispatching marshaller to break the recursion.
61
+ */
62
+ isBase?: boolean;
63
+ }
64
+ /** A pattern-property entry: a regex pattern and the model for its values. */
65
+ export interface PatternPropertyModel {
66
+ pattern: string;
67
+ model: Model;
68
+ }
69
+ /**
70
+ * A model represents an OpenAPI schema, or something derived from one (a
71
+ * property, parameter, or response). It is produced by the parser
72
+ * (`../parser.ts`) and progressively augmented by `../codegen-data.ts` with
73
+ * language-specific and code-generation fields before being handed to the
74
+ * templates. Augmentation fields are optional as they are absent on raw parser
75
+ * output.
76
+ */
77
+ export interface Model {
78
+ /** The schema, property, or parameter name. */
79
+ name: string;
80
+ /** How this model should be rendered. */
81
+ export: ModelExport;
82
+ /**
83
+ * The model's type: a primitive name (`string`, `number`, `boolean`, `null`,
84
+ * `void`, `binary`, `any`), `unknown`, or the name of a referenced model.
85
+ */
86
+ type: string;
87
+ /** The OpenAPI `format` (e.g. `int32`, `date-time`, `binary`), if any. */
88
+ format?: string;
89
+ /** Description, used to render doc comments. */
90
+ description: string | null;
91
+ /** Whether the schema is marked deprecated. */
92
+ deprecated: boolean;
93
+ /** Whether the value may be null. */
94
+ isNullable: boolean;
95
+ /** Whether the property is read-only. */
96
+ isReadOnly: boolean;
97
+ /** Whether the property/parameter is required. */
98
+ isRequired: boolean;
99
+ /** Whether an array enforces uniqueness (rendered as a `Set`). */
100
+ uniqueItems?: boolean;
101
+ /** For arrays/dictionaries, the model describing the element/value type. */
102
+ link?: Model | null;
103
+ /** Child properties (for interfaces) or members (for composites). */
104
+ properties: Model[];
105
+ /** Enum members, when `export === 'enum'`. */
106
+ enum: EnumMember[];
107
+ /** Names of other models this model references (for import generation). */
108
+ imports: string[];
109
+ /** Where a parameter appears; `''` for non-parameter models. */
110
+ in: ModelIn;
111
+ /** The source property name for a parameter (body parameters use `body`). */
112
+ prop?: string;
113
+ /** The chosen request/response media type, for body params and responses. */
114
+ mediaType?: string | null;
115
+ /** All acceptable media types (request body / response). */
116
+ mediaTypes?: string[];
117
+ /** The response status code, for response models. */
118
+ code?: number | string;
119
+ /**
120
+ * For a discriminated subtype's discriminator property: the rendered literal
121
+ * TypeScript type (e.g. `'cat'`, or `'cat' | 'kitten'` when several values
122
+ * map to one subtype) that makes the union a true tagged union. Absent when
123
+ * the subtype's tag can't be pinned to a literal (e.g. it appears in
124
+ * multiple unions with different values).
125
+ */
126
+ discriminatorValue?: string;
127
+ /** The raw OpenAPI `type` (used to distinguish integer from number). */
128
+ openapiType?: string | string[];
129
+ /** Vendor extensions (`x-*`) copied from the schema. */
130
+ vendorExtensions?: VendorExtensions;
131
+ /** True when the schema has additionalProperties. */
132
+ hasAdditionalProperties?: boolean;
133
+ /** The model describing additionalProperties values. */
134
+ additionalPropertiesModel?: Model;
135
+ /** True when the schema has patternProperties. */
136
+ hasPatternProperties?: boolean;
137
+ /** The models describing each pattern's values. */
138
+ patternPropertiesModels?: PatternPropertyModel[];
139
+ /** For composites: the referenced (object) models composed together. */
140
+ composedModels?: Model[];
141
+ /** For composites: the primitive/enum/array members composed together. */
142
+ composedPrimitives?: Model[];
143
+ /** For discriminated one-of/any-of composites: the discriminator metadata. */
144
+ discriminator?: Discriminator;
145
+ /** The TypeScript identifier for this model/property. */
146
+ typescriptName?: string;
147
+ /** The rendered TypeScript type. */
148
+ typescriptType?: string;
149
+ /** The Python identifier for this model/property. */
150
+ pythonName?: string;
151
+ /** The rendered Python type. */
152
+ pythonType?: string;
153
+ /** snake_case model name (Python). */
154
+ nameSnakeCase?: string;
155
+ /** True when the model is a renderable primitive (not composite/collection). */
156
+ isPrimitive?: boolean;
157
+ /** True when the schema declares an enum. */
158
+ isEnum?: boolean;
159
+ /** True for JSON-lines streaming responses. */
160
+ isJsonlStreaming?: boolean;
161
+ /** The model describing each streamed item. */
162
+ itemSchemaModel?: Model;
163
+ /** Collection serialisation format for array query/header parameters. */
164
+ collectionFormat?: CollectionFormat;
165
+ }
166
+ /** Vendor extension bag (`x-*` keys copied from a schema/operation/spec). */
167
+ export type VendorExtensions = {
168
+ [key: string]: unknown;
169
+ };
170
+ /**
171
+ * An operation represents a single OpenAPI path + method. Produced by the
172
+ * parser and augmented by `../codegen-data.ts`.
173
+ */
174
+ export interface Operation {
175
+ id: string;
176
+ name: string;
177
+ method: string;
178
+ path: string;
179
+ description: string | null;
180
+ tags?: string[] | null;
181
+ deprecated: boolean;
182
+ imports: string[];
183
+ parameters: Model[];
184
+ /** The request body parameter (same object reference as in `parameters`). */
185
+ parametersBody?: Model | null;
186
+ responses: Model[];
187
+ /** Deduplicated operation name used throughout generated code. */
188
+ uniqueName?: string;
189
+ /** Dot-notation name (tag-qualified), used for metadata keys. */
190
+ dotNotationName?: string;
191
+ operationIdPascalCase?: string;
192
+ operationIdSnakeCase?: string;
193
+ /** The generated request type name (e.g. `FooRequest`). */
194
+ requestTypeName?: string;
195
+ /** The response model used as the operation's result. */
196
+ result?: Model;
197
+ /** The explicit body parameter when the body is not inlined. */
198
+ explicitRequestBodyParameter?: Model;
199
+ vendorExtensions?: VendorExtensions;
200
+ isMutation?: boolean;
201
+ isQuery?: boolean;
202
+ isStreaming?: boolean;
203
+ isInfiniteQuery?: boolean;
204
+ /** The cursor parameter, for infinite queries. */
205
+ infiniteQueryCursorProperty?: Model;
206
+ }
207
+ /**
208
+ * A service groups operations. Currently the parser produces a single
209
+ * `Default` service; operations are re-grouped by tag downstream.
210
+ */
211
+ export interface Service {
212
+ name: string;
213
+ operations: Operation[];
214
+ imports: string[];
215
+ /** All model names the service (API client) needs to import. */
216
+ modelImports?: string[];
217
+ className?: string;
218
+ nameSnakeCase?: string;
219
+ }
220
+ /**
221
+ * The initial data structure produced by the OpenAPI parser.
222
+ */
223
+ export interface ClientData {
224
+ models: Model[];
225
+ services: Service[];
226
+ }
227
+ /** Models indexed by name, for reference resolution during augmentation. */
228
+ export type ModelsByName = {
229
+ [name: string]: Model;
230
+ };
231
+ /** Index a list of models by name. */
232
+ export declare const indexModelsByName: (models: Model[]) => ModelsByName;
233
+ /** The single service the parser emits; operations are re-grouped by tag. */
234
+ export declare const DEFAULT_SERVICE_NAME = "Default";
235
+ /**
236
+ * The full data structure handed to the code generation templates.
237
+ */
10
238
  export interface CodeGenData extends ClientData {
11
239
  className: string;
12
240
  info: OpenAPIV3.InfoObject | OpenAPIV3_1.InfoObject;
@@ -15,13 +243,15 @@ export interface CodeGenData extends ClientData {
15
243
  [tag: string]: Operation[];
16
244
  };
17
245
  untaggedOperations: Operation[];
18
- vendorExtensions: {
19
- [key: string]: any;
20
- };
246
+ vendorExtensions: VendorExtensions;
21
247
  }
22
- export declare const flattenModelLink: (link?: Model | Model[]) => Model;
23
- export declare const COMPOSED_SCHEMA_TYPES: Set<string>;
24
- export declare const COLLECTION_TYPES: Set<string>;
248
+ /**
249
+ * Create a {@link Model} with the default fields the parser always emits.
250
+ * Callers override the fields relevant to their specific schema.
251
+ */
252
+ export declare const createModel: (overrides?: Partial<Model>) => Model;
253
+ export declare const COMPOSED_SCHEMA_TYPES: Set<ModelExport>;
254
+ export declare const COLLECTION_TYPES: Set<ModelExport>;
25
255
  export declare const PRIMITIVE_TYPES: Set<string>;
26
256
  /**
27
257
  * Content types that indicate JSON Lines streaming (OpenAPI 3.2)
@@ -1,7 +1,30 @@
1
1
  /**
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
- */ export const flattenModelLink = (link)=>link === undefined ? undefined : Array.isArray(link) ? link[0] : link;
4
+ */ /** Index a list of models by name. */ export const indexModelsByName = (models)=>Object.fromEntries(models.map((m)=>[
5
+ m.name,
6
+ m
7
+ ]));
8
+ /** The single service the parser emits; operations are re-grouped by tag. */ export const DEFAULT_SERVICE_NAME = 'Default';
9
+ /**
10
+ * Create a {@link Model} with the default fields the parser always emits.
11
+ * Callers override the fields relevant to their specific schema.
12
+ */ export const createModel = (overrides = {})=>({
13
+ name: '',
14
+ export: 'interface',
15
+ type: 'unknown',
16
+ description: null,
17
+ deprecated: false,
18
+ isNullable: false,
19
+ isReadOnly: false,
20
+ isRequired: false,
21
+ link: null,
22
+ properties: [],
23
+ enum: [],
24
+ imports: [],
25
+ in: '',
26
+ ...overrides
27
+ });
5
28
  // Model types which indicate it is composed (ie inherits/mixin's another schema)
6
29
  export const COMPOSED_SCHEMA_TYPES = new Set([
7
30
  'one-of',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Plugin } from '@hey-api/openapi-ts';\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nexport type ClientData = Parameters<Plugin.LegacyHandler<any>>[0]['client'];\nexport type Operation = ClientData['services'][number]['operations'][number];\nexport type Model = ClientData['models'][number];\n\nexport interface CodeGenData extends ClientData {\n className: string;\n info: OpenAPIV3.InfoObject | OpenAPIV3_1.InfoObject;\n allOperations: Operation[];\n operationsByTag: { [tag: string]: Operation[] };\n untaggedOperations: Operation[];\n vendorExtensions: { [key: string]: any };\n}\n\nexport const flattenModelLink = (link?: Model | Model[]): Model =>\n link === undefined ? undefined : Array.isArray(link) ? link[0] : link;\n\n// Model types which indicate it is composed (ie inherits/mixin's another schema)\nexport const COMPOSED_SCHEMA_TYPES = new Set(['one-of', 'any-of', 'all-of']);\nexport const COLLECTION_TYPES = new Set(['array', 'dictionary']);\nexport const PRIMITIVE_TYPES = new Set([\n 'string',\n 'integer',\n 'number',\n 'boolean',\n 'null',\n 'any',\n 'binary',\n 'void',\n]);\n\n/**\n * Content types that indicate JSON Lines streaming (OpenAPI 3.2)\n */\nexport const STREAMING_CONTENT_TYPES = new Set([\n 'application/jsonl',\n 'application/x-ndjson',\n]);\n\n/**\n * Vendor extensions which are used to customise generated code\n */\nexport const VENDOR_EXTENSIONS = {\n /**\n * Set to 'true' to indicate this is a streaming API\n */\n STREAMING: 'x-streaming',\n /**\n * Set to true to indicate this is a mutation, regardless of its HTTP method\n */\n MUTATION: 'x-mutation',\n /**\n * Set to true to indicate this is a query, regardless of its HTTP method\n */\n QUERY: 'x-query',\n /**\n * Set to the name of the input property used as the cursor for pagination if\n * the API accepts a cursor that is not named 'cursor'.\n * This can also be set to false to override behaviour and indicate this is not\n * a paginated API.\n * Used for tanstack infinite query hooks.\n */\n CURSOR: 'x-cursor',\n} as const;\n"],"names":["flattenModelLink","link","undefined","Array","isArray","COMPOSED_SCHEMA_TYPES","Set","COLLECTION_TYPES","PRIMITIVE_TYPES","STREAMING_CONTENT_TYPES","VENDOR_EXTENSIONS","STREAMING","MUTATION","QUERY","CURSOR"],"mappings":"AAAA;;;CAGC,GAiBD,OAAO,MAAMA,mBAAmB,CAACC,OAC/BA,SAASC,YAAYA,YAAYC,MAAMC,OAAO,CAACH,QAAQA,IAAI,CAAC,EAAE,GAAGA,KAAK;AAExE,iFAAiF;AACjF,OAAO,MAAMI,wBAAwB,IAAIC,IAAI;IAAC;IAAU;IAAU;CAAS,EAAE;AAC7E,OAAO,MAAMC,mBAAmB,IAAID,IAAI;IAAC;IAAS;CAAa,EAAE;AACjE,OAAO,MAAME,kBAAkB,IAAIF,IAAI;IACrC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;CAEC,GACD,OAAO,MAAMG,0BAA0B,IAAIH,IAAI;IAC7C;IACA;CACD,EAAE;AAEH;;CAEC,GACD,OAAO,MAAMI,oBAAoB;IAC/B;;GAEC,GACDC,WAAW;IACX;;GAEC,GACDC,UAAU;IACV;;GAEC,GACDC,OAAO;IACP;;;;;;GAMC,GACDC,QAAQ;AACV,EAAW"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * The kind of a {@link Model}, describing how it should be rendered.\n *\n * - `interface` — an object type with named properties\n * - `enum` — a set of string/number literal values\n * - `array` — a list whose element type is described by `link`\n * - `dictionary` — a map whose value type is described by `link`\n * - `reference` — a reference to another named model (`type` is its name)\n * - `generic` — a primitive (string/number/boolean/null/void/binary/any)\n * - `one-of` / `any-of` / `all-of` — a composite of other schemas\n */\nexport type ModelExport =\n | 'interface'\n | 'enum'\n | 'array'\n | 'dictionary'\n | 'reference'\n | 'generic'\n | 'one-of'\n | 'any-of'\n | 'all-of';\n\n/**\n * Where a parameter-like {@link Model} appears in a request/response.\n * Empty string is used for models that are not parameters (schemas/properties).\n */\nexport type ModelIn =\n | ''\n | 'query'\n | 'path'\n | 'header'\n | 'cookie'\n | 'body'\n | 'response';\n\n/**\n * How array/object query & header parameters are serialised on the wire.\n * `deepObject` explodes an object into `key[prop]=value` query pairs.\n */\nexport type CollectionFormat = 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';\n\n/** A single enum member value. */\nexport interface EnumMember {\n value: string | number | boolean;\n}\n\n/**\n * A discriminated-composite mapping entry: a discriminator value and the name\n * of the composed model it selects.\n */\nexport interface DiscriminatorMapping {\n /** The discriminator property value (e.g. `\"cat\"`). */\n value: string;\n /** The name of the composed model this value selects (e.g. `\"Cat\"`). */\n modelName: string;\n}\n\n/**\n * The discriminator of a composite (`oneOf`/`anyOf`) or an inheritance base\n * (an `object` schema whose subtypes `allOf`-compose it), used to marshal\n * directly to the matching branch/subtype rather than merging every branch or\n * dropping subtype-only fields.\n */\nexport interface Discriminator {\n /** The wire property name carrying the discriminator value. */\n propertyName: string;\n /** The TypeScript property name (resolved during augmentation). */\n typescriptPropertyName?: string;\n /** The value → composed-model mapping. */\n mapping: DiscriminatorMapping[];\n /**\n * True when this discriminator sits on an inheritance base (an `object`\n * schema selected by `allOf`-composing subtypes) rather than a `oneOf`/\n * `anyOf` composite. The base marshals via dispatch to its subtypes, but its\n * subtypes compose the base's own (non-dispatching) body — so the base emits\n * a separate non-dispatching marshaller to break the recursion.\n */\n isBase?: boolean;\n}\n\n/** A pattern-property entry: a regex pattern and the model for its values. */\nexport interface PatternPropertyModel {\n pattern: string;\n model: Model;\n}\n\n/**\n * A model represents an OpenAPI schema, or something derived from one (a\n * property, parameter, or response). It is produced by the parser\n * (`../parser.ts`) and progressively augmented by `../codegen-data.ts` with\n * language-specific and code-generation fields before being handed to the\n * templates. Augmentation fields are optional as they are absent on raw parser\n * output.\n */\nexport interface Model {\n /** The schema, property, or parameter name. */\n name: string;\n /** How this model should be rendered. */\n export: ModelExport;\n /**\n * The model's type: a primitive name (`string`, `number`, `boolean`, `null`,\n * `void`, `binary`, `any`), `unknown`, or the name of a referenced model.\n */\n type: string;\n /** The OpenAPI `format` (e.g. `int32`, `date-time`, `binary`), if any. */\n format?: string;\n /** Description, used to render doc comments. */\n description: string | null;\n /** Whether the schema is marked deprecated. */\n deprecated: boolean;\n /** Whether the value may be null. */\n isNullable: boolean;\n /** Whether the property is read-only. */\n isReadOnly: boolean;\n /** Whether the property/parameter is required. */\n isRequired: boolean;\n /** Whether an array enforces uniqueness (rendered as a `Set`). */\n uniqueItems?: boolean;\n /** For arrays/dictionaries, the model describing the element/value type. */\n link?: Model | null;\n /** Child properties (for interfaces) or members (for composites). */\n properties: Model[];\n /** Enum members, when `export === 'enum'`. */\n enum: EnumMember[];\n /** Names of other models this model references (for import generation). */\n imports: string[];\n\n /** Where a parameter appears; `''` for non-parameter models. */\n in: ModelIn;\n /** The source property name for a parameter (body parameters use `body`). */\n prop?: string;\n /** The chosen request/response media type, for body params and responses. */\n mediaType?: string | null;\n /** All acceptable media types (request body / response). */\n mediaTypes?: string[];\n /** The response status code, for response models. */\n code?: number | string;\n\n /**\n * For a discriminated subtype's discriminator property: the rendered literal\n * TypeScript type (e.g. `'cat'`, or `'cat' | 'kitten'` when several values\n * map to one subtype) that makes the union a true tagged union. Absent when\n * the subtype's tag can't be pinned to a literal (e.g. it appears in\n * multiple unions with different values).\n */\n discriminatorValue?: string;\n\n /** The raw OpenAPI `type` (used to distinguish integer from number). */\n openapiType?: string | string[];\n /** Vendor extensions (`x-*`) copied from the schema. */\n vendorExtensions?: VendorExtensions;\n /** True when the schema has additionalProperties. */\n hasAdditionalProperties?: boolean;\n /** The model describing additionalProperties values. */\n additionalPropertiesModel?: Model;\n /** True when the schema has patternProperties. */\n hasPatternProperties?: boolean;\n /** The models describing each pattern's values. */\n patternPropertiesModels?: PatternPropertyModel[];\n\n /** For composites: the referenced (object) models composed together. */\n composedModels?: Model[];\n /** For composites: the primitive/enum/array members composed together. */\n composedPrimitives?: Model[];\n /** For discriminated one-of/any-of composites: the discriminator metadata. */\n discriminator?: Discriminator;\n\n /** The TypeScript identifier for this model/property. */\n typescriptName?: string;\n /** The rendered TypeScript type. */\n typescriptType?: string;\n /** The Python identifier for this model/property. */\n pythonName?: string;\n /** The rendered Python type. */\n pythonType?: string;\n /** snake_case model name (Python). */\n nameSnakeCase?: string;\n /** True when the model is a renderable primitive (not composite/collection). */\n isPrimitive?: boolean;\n /** True when the schema declares an enum. */\n isEnum?: boolean;\n\n /** True for JSON-lines streaming responses. */\n isJsonlStreaming?: boolean;\n /** The model describing each streamed item. */\n itemSchemaModel?: Model;\n\n /** Collection serialisation format for array query/header parameters. */\n collectionFormat?: CollectionFormat;\n}\n\n/** Vendor extension bag (`x-*` keys copied from a schema/operation/spec). */\nexport type VendorExtensions = { [key: string]: unknown };\n\n/**\n * An operation represents a single OpenAPI path + method. Produced by the\n * parser and augmented by `../codegen-data.ts`.\n */\nexport interface Operation {\n id: string;\n name: string;\n method: string;\n path: string;\n description: string | null;\n tags?: string[] | null;\n deprecated: boolean;\n imports: string[];\n parameters: Model[];\n /** The request body parameter (same object reference as in `parameters`). */\n parametersBody?: Model | null;\n responses: Model[];\n\n /** Deduplicated operation name used throughout generated code. */\n uniqueName?: string;\n /** Dot-notation name (tag-qualified), used for metadata keys. */\n dotNotationName?: string;\n operationIdPascalCase?: string;\n operationIdSnakeCase?: string;\n /** The generated request type name (e.g. `FooRequest`). */\n requestTypeName?: string;\n\n /** The response model used as the operation's result. */\n result?: Model;\n\n /** The explicit body parameter when the body is not inlined. */\n explicitRequestBodyParameter?: Model;\n\n vendorExtensions?: VendorExtensions;\n isMutation?: boolean;\n isQuery?: boolean;\n isStreaming?: boolean;\n isInfiniteQuery?: boolean;\n /** The cursor parameter, for infinite queries. */\n infiniteQueryCursorProperty?: Model;\n}\n\n/**\n * A service groups operations. Currently the parser produces a single\n * `Default` service; operations are re-grouped by tag downstream.\n */\nexport interface Service {\n name: string;\n operations: Operation[];\n imports: string[];\n\n /** All model names the service (API client) needs to import. */\n modelImports?: string[];\n className?: string;\n nameSnakeCase?: string;\n}\n\n/**\n * The initial data structure produced by the OpenAPI parser.\n */\nexport interface ClientData {\n models: Model[];\n services: Service[];\n}\n\n/** Models indexed by name, for reference resolution during augmentation. */\nexport type ModelsByName = { [name: string]: Model };\n\n/** Index a list of models by name. */\nexport const indexModelsByName = (models: Model[]): ModelsByName =>\n Object.fromEntries(models.map((m) => [m.name, m]));\n\n/** The single service the parser emits; operations are re-grouped by tag. */\nexport const DEFAULT_SERVICE_NAME = 'Default';\n\n/**\n * The full data structure handed to the code generation templates.\n */\nexport interface CodeGenData extends ClientData {\n className: string;\n info: OpenAPIV3.InfoObject | OpenAPIV3_1.InfoObject;\n allOperations: Operation[];\n operationsByTag: { [tag: string]: Operation[] };\n untaggedOperations: Operation[];\n vendorExtensions: VendorExtensions;\n}\n\n/**\n * Create a {@link Model} with the default fields the parser always emits.\n * Callers override the fields relevant to their specific schema.\n */\nexport const createModel = (overrides: Partial<Model> = {}): Model => ({\n name: '',\n export: 'interface',\n type: 'unknown',\n description: null,\n deprecated: false,\n isNullable: false,\n isReadOnly: false,\n isRequired: false,\n link: null,\n properties: [],\n enum: [],\n imports: [],\n in: '',\n ...overrides,\n});\n\n// Model types which indicate it is composed (ie inherits/mixin's another schema)\nexport const COMPOSED_SCHEMA_TYPES = new Set<ModelExport>([\n 'one-of',\n 'any-of',\n 'all-of',\n]);\nexport const COLLECTION_TYPES = new Set<ModelExport>(['array', 'dictionary']);\nexport const PRIMITIVE_TYPES = new Set([\n 'string',\n 'integer',\n 'number',\n 'boolean',\n 'null',\n 'any',\n 'binary',\n 'void',\n]);\n\n/**\n * Content types that indicate JSON Lines streaming (OpenAPI 3.2)\n */\nexport const STREAMING_CONTENT_TYPES = new Set([\n 'application/jsonl',\n 'application/x-ndjson',\n]);\n\n/**\n * Vendor extensions which are used to customise generated code\n */\nexport const VENDOR_EXTENSIONS = {\n /**\n * Set to 'true' to indicate this is a streaming API\n */\n STREAMING: 'x-streaming',\n /**\n * Set to true to indicate this is a mutation, regardless of its HTTP method\n */\n MUTATION: 'x-mutation',\n /**\n * Set to true to indicate this is a query, regardless of its HTTP method\n */\n QUERY: 'x-query',\n /**\n * Set to the name of the input property used as the cursor for pagination if\n * the API accepts a cursor that is not named 'cursor'.\n * This can also be set to false to override behaviour and indicate this is not\n * a paginated API.\n * Used for tanstack infinite query hooks.\n */\n CURSOR: 'x-cursor',\n} as const;\n"],"names":["indexModelsByName","models","Object","fromEntries","map","m","name","DEFAULT_SERVICE_NAME","createModel","overrides","export","type","description","deprecated","isNullable","isReadOnly","isRequired","link","properties","enum","imports","in","COMPOSED_SCHEMA_TYPES","Set","COLLECTION_TYPES","PRIMITIVE_TYPES","STREAMING_CONTENT_TYPES","VENDOR_EXTENSIONS","STREAMING","MUTATION","QUERY","CURSOR"],"mappings":"AAAA;;;CAGC,GAyQD,oCAAoC,GACpC,OAAO,MAAMA,oBAAoB,CAACC,SAChCC,OAAOC,WAAW,CAACF,OAAOG,GAAG,CAAC,CAACC,IAAM;YAACA,EAAEC,IAAI;YAAED;SAAE,GAAG;AAErD,2EAA2E,GAC3E,OAAO,MAAME,uBAAuB,UAAU;AAc9C;;;CAGC,GACD,OAAO,MAAMC,cAAc,CAACC,YAA4B,CAAC,CAAC,GAAa,CAAA;QACrEH,MAAM;QACNI,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,YAAY;QACZC,YAAY;QACZC,YAAY;QACZC,YAAY;QACZC,MAAM;QACNC,YAAY,EAAE;QACdC,MAAM,EAAE;QACRC,SAAS,EAAE;QACXC,IAAI;QACJ,GAAGZ,SAAS;IACd,CAAA,EAAG;AAEH,iFAAiF;AACjF,OAAO,MAAMa,wBAAwB,IAAIC,IAAiB;IACxD;IACA;IACA;CACD,EAAE;AACH,OAAO,MAAMC,mBAAmB,IAAID,IAAiB;IAAC;IAAS;CAAa,EAAE;AAC9E,OAAO,MAAME,kBAAkB,IAAIF,IAAI;IACrC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;CAEC,GACD,OAAO,MAAMG,0BAA0B,IAAIH,IAAI;IAC7C;IACA;CACD,EAAE;AAEH;;CAEC,GACD,OAAO,MAAMI,oBAAoB;IAC/B;;GAEC,GACDC,WAAW;IACX;;GAEC,GACDC,UAAU;IACV;;GAEC,GACDC,OAAO;IACP;;;;;;GAMC,GACDC,QAAQ;AACV,EAAW"}
@@ -5,6 +5,6 @@
5
5
  import { type CodeGenData } from './codegen-data/types';
6
6
  import type { Spec } from './types';
7
7
  /**
8
- * Builds a data structure from an OpenAPI spec which can be used to generate code
8
+ * Build the data structure used to generate code from an OpenAPI spec.
9
9
  */
10
- export declare const buildOpenApiCodeGenData: (inSpec: Spec) => Promise<CodeGenData>;
10
+ export declare const buildOpenApiCodeGenData: (inSpec: Spec) => CodeGenData;