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

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 (59) 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 +211 -36
  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.multipart.spec.ts.snap +280 -0
  15. package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
  16. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
  17. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
  18. package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
  19. package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
  20. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
  21. package/src/open-api/ts-client/files/client.gen.ts.template +166 -19
  22. package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
  23. package/src/open-api/ts-client/generator.js +1 -1
  24. package/src/open-api/ts-client/generator.js.map +1 -1
  25. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
  26. package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
  27. package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
  28. package/src/open-api/utils/codegen-data/languages.js +23 -18
  29. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  30. package/src/open-api/utils/codegen-data/types.d.ts +240 -10
  31. package/src/open-api/utils/codegen-data/types.js +24 -1
  32. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  33. package/src/open-api/utils/codegen-data.d.ts +2 -2
  34. package/src/open-api/utils/codegen-data.js +357 -617
  35. package/src/open-api/utils/codegen-data.js.map +1 -1
  36. package/src/open-api/utils/normalise.js +167 -22
  37. package/src/open-api/utils/normalise.js.map +1 -1
  38. package/src/open-api/utils/parser.d.ts +55 -0
  39. package/src/open-api/utils/parser.js +754 -0
  40. package/src/open-api/utils/parser.js.map +1 -0
  41. package/src/open-api/utils/types.d.ts +18 -0
  42. package/src/open-api/utils/types.js.map +1 -1
  43. package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
  44. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +414 -6
  45. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +276 -4
  46. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +414 -6
  47. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +0 -23
  48. package/src/ts/mcp-server/generator.js +10 -22
  49. package/src/ts/mcp-server/generator.js.map +1 -1
  50. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  51. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
  52. package/src/utils/mcp.js +1 -1
  53. package/src/utils/mcp.js.map +1 -1
  54. package/src/utils/names.d.ts +6 -0
  55. package/src/utils/names.js +6 -1
  56. package/src/utils/names.js.map +1 -1
  57. package/src/utils/versions.d.ts +5 -5
  58. package/src/utils/versions.js +4 -4
  59. package/src/utils/versions.js.map +1 -1
@@ -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;