@aws/nx-plugin 1.0.0-rc.92 → 1.0.0-rc.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +16 -1
- package/package.json +1 -1
- package/src/agentcore-harness/generator.d.ts +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/infra/app/generator.d.ts +1 -1
- package/src/infra/app/generator.js +5 -3
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +1 -1
- package/src/migrations/latest/agent-core-vendor-target/metadata.json +3 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.d.ts +6 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.js +98 -0
- package/src/migrations/latest/agent-core-vendor-target/migration.js.map +1 -0
- package/src/migrations/latest/infra-deploy-express-mode/metadata.json +3 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.d.ts +6 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.js +83 -0
- package/src/migrations/latest/infra-deploy-express-mode/migration.js.map +1 -0
- package/src/migrations/latest/shx-fs-commands/metadata.json +3 -0
- package/src/migrations/latest/shx-fs-commands/migration.d.ts +6 -0
- package/src/migrations/latest/shx-fs-commands/migration.js +216 -0
- package/src/migrations/latest/shx-fs-commands/migration.js.map +1 -0
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +18 -12
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5 -2
- package/src/open-api/utils/codegen-data/types.d.ts +6 -0
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +32 -7
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +39 -14
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.js +51 -5
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/preset/generator.d.ts +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +1 -1
- package/src/py/agent/generator.d.ts +2 -26
- package/src/py/agent/generator.js +2 -2
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +1 -1
- package/src/py/agent/react-connection/generator.d.ts +1 -1
- package/src/py/fast-api/generator.d.ts +1 -13
- package/src/py/fast-api/generator.js +1 -1
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +1 -1
- package/src/py/mcp-server/generator.d.ts +2 -26
- package/src/py/mcp-server/generator.js +2 -2
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +2 -26
- package/src/py/rdb/generator.js +6 -6
- package/src/py/rdb/generator.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +24 -20
- package/src/smithy/project/generator.d.ts +2 -14
- package/src/smithy/project/generator.js +2 -1
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +8 -7
- package/src/smithy/ts/api/generator.d.ts +1 -13
- package/src/smithy/ts/api/generator.js +1 -1
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +2 -2
- package/src/terraform/project/generator.js +4 -4
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +1 -1
- package/src/ts/agent/generator.d.ts +3 -39
- package/src/ts/agent/generator.js +1 -1
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +1 -1
- package/src/ts/astro-docs/generator.d.ts +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +1 -1
- package/src/ts/lambda-function/generator.d.ts +1 -1
- package/src/ts/lib/generator.d.ts +1 -1
- package/src/ts/mcp-server/generator.d.ts +3 -39
- package/src/ts/mcp-server/generator.js +1 -1
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +1 -1
- package/src/ts/nx-migration/generator.d.ts +1 -1
- package/src/ts/nx-plugin/generator.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +3 -27
- package/src/ts/rdb/generator.js +3 -3
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +1 -1
- package/src/utils/agent-core-packaging.d.ts +25 -12
- package/src/utils/agent-core-packaging.js +47 -11
- package/src/utils/agent-core-packaging.js.map +1 -1
- package/src/utils/docker.d.ts +1 -7
- package/src/utils/docker.js +1 -1
- package/src/utils/docker.js.map +1 -1
- package/src/utils/format.d.ts +5 -0
- package/src/utils/format.js +5 -0
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.d.ts +21 -11
- package/src/utils/fs.js +30 -22
- package/src/utils/fs.js.map +1 -1
- package/src/utils/version-lockstep/lockstep.d.ts +27 -0
- package/src/utils/version-lockstep/lockstep.js +46 -0
- package/src/utils/version-lockstep/lockstep.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js +30 -3
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
- package/src/utils/versions.d.ts +9 -4
- package/src/utils/versions.js +24 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport orderBy from 'lodash.orderby';\nimport trim from 'lodash.trim';\nimport uniqBy from 'lodash.uniqby';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport {\n camelCase,\n pascalCase,\n snakeCase,\n toClassName,\n upperFirst,\n} from '../../utils/names.js';\nimport {\n toPythonName,\n toPythonType,\n toTypeScriptModelName,\n toTypeScriptName,\n toTypeScriptType,\n} from './codegen-data/languages.js';\nimport {\n COLLECTION_TYPES,\n COMPOSED_SCHEMA_TYPES,\n type CodeGenData,\n type CollectionFormat,\n createModel,\n DEFAULT_SERVICE_NAME,\n indexModelsByName,\n type Model,\n type ModelsByName,\n type Operation,\n type PatternPropertyModel,\n PRIMITIVE_TYPES,\n type Service,\n STREAMING_CONTENT_TYPES,\n VENDOR_EXTENSIONS,\n type VendorExtensions,\n} from './codegen-data/types.js';\nimport { normaliseOpenApiSpecForCodeGen } from './normalise.js';\nimport {\n buildClientData,\n buildInlineModel,\n compositeMemberSchemas,\n getSpecOperation,\n getSpecParametersByKey,\n getSpecPathParameters,\n linkModel,\n specParameterKey,\n} from './parser.js';\nimport { isRef, resolveIfRef, splitRef } from './refs.js';\nimport type { OpenApiSchema, OpenApiSchemaOrRef, Spec } from './types.js';\n\n/**\n * Build the data structure used to generate code from an OpenAPI spec.\n */\nexport const buildOpenApiCodeGenData = (inSpec: Spec): CodeGenData => {\n const spec = normaliseOpenApiSpecForCodeGen(inSpec);\n const data = buildClientData(spec);\n\n const modelsByName = indexModelsByName(data.models);\n\n for (const service of data.services) {\n augmentService(spec, service, modelsByName);\n }\n\n const allOperations = uniqBy(\n data.services.flatMap((s) => s.operations),\n (o) => o.uniqueName,\n );\n\n // A model per operation request parameter position (query/path/body/...).\n data.models = [\n ...data.models,\n ...allOperations.flatMap((op) =>\n buildRequestParameterModels(op, modelsByName),\n ),\n ];\n\n for (const model of data.models) {\n augmentModel(spec, model, modelsByName);\n }\n for (const model of data.models) {\n model.typescriptName = toTypeScriptModelName(model.name);\n model.typescriptType = model.typescriptName;\n }\n\n for (const model of data.models) {\n assertNoClashingPropertyNames(model);\n assertNoConflictingUnionMemberMarshalling(model);\n }\n\n for (const op of allOperations) {\n assertEncodableUrlEncodedBody(op);\n }\n\n data.models = orderBy(data.models, (d) => d.name);\n // Default service first, then by name.\n data.services = orderBy(data.services, (s) =>\n s.name === DEFAULT_SERVICE_NAME ? '' : s.name,\n );\n\n const { operationsByTag, untaggedOperations } =\n groupOperationsByTag(allOperations);\n\n return {\n ...data,\n operationsByTag,\n untaggedOperations,\n info: spec.info,\n allOperations,\n vendorExtensions: vendorExtensionsOf(spec),\n className: toClassName(spec.info.title),\n };\n};\n\n/**\n * Augment a service and each of its operations with the data needed for code\n * generation (names, imports, result/request types, behavioural flags), and\n * compute the set of models the service (ie API client) needs to import.\n */\nconst augmentService = (\n spec: Spec,\n service: Service,\n modelsByName: ModelsByName,\n): void => {\n const modelImports = service.operations.flatMap((op) =>\n augmentOperation(spec, op, modelsByName),\n );\n\n service.operations = orderBy(service.operations, (op) => op.uniqueName);\n service.modelImports = orderBy(\n uniqBy([...service.imports, ...modelImports], (x) => x),\n );\n service.className = `${service.name}Api`;\n service.nameSnakeCase = snakeCase(service.name);\n};\n\n/**\n * Augment a single operation with all the data the templates need, returning\n * the names of the models it references (for the service's import list).\n */\nconst augmentOperation = (\n spec: Spec,\n op: Operation,\n modelsByName: ModelsByName,\n): string[] => {\n const specOp = getSpecOperation(spec, op);\n\n assignOperationNames(op, specOp);\n\n op.vendorExtensions = vendorExtensionsOf(specOp);\n\n const modelImports = [\n ...(specOp ? augmentResponses(spec, op, specOp, modelsByName) : []),\n ...augmentParameters(spec, op, specOp, modelsByName),\n ];\n\n op.responses.forEach(addLanguageTypes);\n op.responses = orderBy(op.responses, (r) => r.code);\n\n // Result is the lowest successful response, otherwise the 2XX or default.\n op.result =\n op.responses.find(\n (r) => typeof r.code === 'number' && r.code >= 200 && r.code < 300,\n ) ?? op.responses.find((r) => r.code === '2XX' || r.code === 'default');\n\n op.operationIdPascalCase = pascalCase(op.uniqueName);\n op.operationIdSnakeCase = toPythonName('operation', op.uniqueName);\n\n if (op.parameters.length > 0) {\n const baseRequestTypeName = `${op.operationIdPascalCase}Request`;\n // Use the OperationRequest suffix when the standard Request name clashes\n // with an existing schema.\n op.requestTypeName = spec.components?.schemas?.[baseRequestTypeName]\n ? `${op.operationIdPascalCase}OperationRequest`\n : baseRequestTypeName;\n }\n\n augmentOperationBehaviour(op);\n\n return modelImports;\n};\n\n/**\n * Set an operation's name and its deduplicated variants from the vendor\n * extensions the normaliser added.\n */\nconst assignOperationNames = (\n op: Operation,\n specOp: OpenAPIV3.OperationObject | undefined,\n): void => {\n const deduplicatedOpId = specOp?.['x-aws-nx-deduplicated-op-id'] as\n | string\n | undefined;\n const dotNotationOpId = specOp?.['x-aws-nx-deduplicated-dot-op-id'] as\n | string\n | undefined;\n\n op.name = op.id ?? op.name;\n op.uniqueName = deduplicatedOpId ?? op.name;\n if (dotNotationOpId) {\n op.dotNotationName = dotNotationOpId;\n }\n};\n\n/**\n * Augment an operation's response models with schema-derived data, resolving\n * void responses and streaming item schemas. Returns the response model names\n * to import.\n */\nconst augmentResponses = (\n spec: Spec,\n op: Operation,\n specOp: OpenAPIV3.OperationObject,\n modelsByName: ModelsByName,\n): string[] => {\n const modelImports = op.responses\n .filter((r) => r.export === 'reference')\n .map((r) => r.type);\n\n for (const response of op.responses) {\n // We cannot distinguish a composite of primitives at runtime (it all comes\n // back as text), so validate this away.\n if (\n response.export === 'reference' &&\n COMPOSED_SCHEMA_TYPES.has(modelsByName[response.type]?.export)\n ) {\n const composedPrimitives = (\n modelsByName[response.type].composedPrimitives ?? []\n ).filter((p) => !COLLECTION_TYPES.has(p.export));\n if (composedPrimitives.length > 0) {\n throw new Error(\n `Operation \"${op.method} ${op.path}\" returns a composite schema of primitives with ${camelCase(modelsByName[response.type].export)}, which cannot be distinguished at runtime`,\n );\n }\n }\n\n const matchingSpecResponse = specOp.responses[`${response.code}`];\n if (!matchingSpecResponse) continue;\n\n const specResponse = resolveIfRef(spec, matchingSpecResponse);\n\n // When there's no content, the response type is 'void'\n if (!specResponse.content) {\n response.type = 'void';\n continue;\n }\n\n const mediaTypes = Object.keys(specResponse.content);\n response.mediaTypes = mediaTypes;\n\n for (const mediaType of mediaTypes) {\n const responseContent = specResponse.content[mediaType];\n const responseSchema = resolveIfRef(spec, responseContent.schema);\n if (responseSchema) {\n augmentModelFromSchema(spec, response, responseSchema, modelsByName);\n }\n if (\n STREAMING_CONTENT_TYPES.has(mediaType) &&\n 'itemSchema' in responseContent\n ) {\n response.isJsonlStreaming = true;\n response.itemSchemaModel = buildOrReferenceModel(\n spec,\n modelsByName,\n responseContent.itemSchema as OpenApiSchemaOrRef,\n );\n }\n }\n }\n\n return modelImports;\n};\n\n/**\n * Augment an operation's parameter models with schema-derived data, resolving\n * request bodies and query/header collection formats. Returns the parameter\n * model names to import.\n */\nconst augmentParameters = (\n spec: Spec,\n op: Operation,\n specOp: OpenAPIV3.OperationObject | undefined,\n modelsByName: ModelsByName,\n): string[] => {\n const specParametersByKey = getSpecParametersByKey(\n spec,\n specOp,\n getSpecPathParameters(spec, op),\n );\n\n const modelImports: string[] = [];\n\n for (const parameter of op.parameters) {\n if (parameter.export === 'reference') {\n modelImports.push(parameter.type);\n }\n\n const specParameter =\n specParametersByKey[\n specParameterKey({ in: parameter.in, name: parameter.prop })\n ];\n const specParameterSchema = resolveIfRef(spec, specParameter?.schema);\n if (specParameterSchema) {\n augmentModelFromSchema(\n spec,\n parameter,\n specParameterSchema,\n modelsByName,\n );\n }\n\n if (parameter.in === 'body') {\n augmentBodyParameter(spec, parameter, specOp, modelsByName);\n } else if (\n (parameter.in === 'query' || parameter.in === 'header') &&\n specParameter\n ) {\n parameter.collectionFormat = getCollectionFormat(\n parameter.in,\n specParameter,\n );\n if (parameter.in === 'query' && specParameter.allowReserved) {\n parameter.allowReserved = true;\n }\n } else if (parameter.in === 'path' && specParameter) {\n const style = specParameter.style;\n if (style === 'matrix' || style === 'label') {\n parameter.pathStyle = style;\n parameter.pathExplode = !!specParameter.explode;\n }\n }\n\n addLanguageTypes(parameter);\n }\n\n return modelImports;\n};\n\n/**\n * Augment a request body parameter with its schema (the body is not in the\n * spec's `parameters`, so it is resolved from `requestBody` here) and record\n * its acceptable media types.\n */\nconst augmentBodyParameter = (\n spec: Spec,\n parameter: Model,\n specOp: OpenAPIV3.OperationObject | undefined,\n modelsByName: ModelsByName,\n): void => {\n // The request body parameter is named 'body' downstream.\n parameter.name = 'body';\n parameter.prop = 'body';\n\n const specBody = resolveIfRef(spec, specOp?.requestBody);\n if (!specBody) return;\n\n if (parameter.mediaType) {\n const bodySchema = resolveIfRef(\n spec,\n specBody.content?.[parameter.mediaType]?.schema,\n );\n if (bodySchema) {\n augmentModelFromSchema(spec, parameter, bodySchema, modelsByName);\n }\n }\n // Track all the media types that can be accepted in the request body\n parameter.mediaTypes = Object.keys(specBody.content);\n};\n\n/**\n * Translate an OpenAPI v3 parameter's style/explode into a v2-style\n * collectionFormat used when serialising array parameters.\n * @see https://spec.openapis.org/oas/v3.0.3.html#style-values\n */\nconst getCollectionFormat = (\n position: 'query' | 'header',\n specParameter: OpenAPIV3.ParameterObject,\n): CollectionFormat => {\n const style =\n specParameter.style ?? (position === 'query' ? 'form' : 'simple');\n const explode = specParameter.explode ?? style === 'form';\n\n if (position === 'header') {\n return explode ? 'multi' : 'csv';\n }\n // `deepObject` serialises an object as `key[prop]=value` pairs regardless of\n // explode; the object shape (not array collection) drives its serialisation.\n if (style === 'deepObject') {\n return 'deepObject';\n }\n return explode\n ? 'multi'\n : ((\n {\n spaceDelimited: 'ssv',\n pipeDelimited: 'pipes',\n simple: 'csv',\n form: 'csv',\n } as const\n )[style] ?? 'multi');\n};\n\n/**\n * Build the request parameter models for an operation — one model per parameter\n * position (query/path/header/cookie/body), named e.g.\n * `FooRequestQueryParameters`. Request bodies that can be represented directly\n * (the sole parameter, or a non-clashing object reference) are inlined rather\n * than given a wrapper model, and recorded on `op.explicitRequestBodyParameter`.\n */\nconst buildRequestParameterModels = (\n op: Operation,\n modelsByName: ModelsByName,\n): Model[] => {\n if (!op.parameters || op.parameters.length === 0) {\n return [];\n }\n\n // Whether the request body can be represented directly, without a wrapper\n // model (ie the request will be the body itself).\n const canInlineBody = (body: Model): boolean => {\n // If the body is the only parameter, we can inline it no matter the type\n if (op.parameters.length === 1) {\n return true;\n }\n // We inline object bodies, so long as they aren't dictionaries (as\n // dictionary keys could clash with other parameters), and so long as they\n // don't have a property name that clashes with another parameter\n const hasClashingPropertyName = (\n modelsByName?.[body.type]?.properties ?? []\n ).some((prop) => op.parameters.some((param) => param.name === prop.name));\n return (\n body.export === 'reference' &&\n modelsByName?.[body.type]?.export !== 'dictionary' &&\n !hasClashingPropertyName\n );\n };\n\n // Group parameters by their position (`in`: query/path/header/cookie/body),\n // dropping any body that can be inlined.\n const parametersByPosition = op.parameters\n .filter((p) => !(p.in === 'body' && canInlineBody(p)))\n .reduce<{ [position: string]: Model[] }>(\n (acc, p) => ({ ...acc, [p.in]: [...(acc[p.in] ?? []), p] }),\n {},\n );\n\n // The body parameter was already renamed to \"body\" by augmentBodyParameter.\n op.explicitRequestBodyParameter = parametersByPosition['body']?.[0];\n\n return Object.entries(parametersByPosition).map(([position, parameters]) => {\n const name = `${op.operationIdPascalCase}Request${upperFirst(position)}Parameters`;\n return createModel({\n description: op.description,\n export: 'interface',\n name,\n properties: parameters,\n type: name,\n isRequired: true,\n });\n });\n};\n\n/**\n * Augment a single model with schema-derived data (from its matching spec\n * schema, if any) and language-specific names and types.\n */\nconst augmentModel = (\n spec: Spec,\n model: Model,\n modelsByName: ModelsByName,\n): void => {\n model.nameSnakeCase = toPythonName('model', model.name);\n\n const matchingSpecModel = spec?.components?.schemas?.[model.name];\n if (matchingSpecModel) {\n const specModel = resolveIfRef(spec, matchingSpecModel);\n\n augmentModelFromSchema(spec, model, specModel, modelsByName);\n\n for (const property of model.properties) {\n const matchingSpecProperty = specModel.properties?.[property.name];\n if (matchingSpecProperty) {\n const specProperty = resolveIfRef(spec, matchingSpecProperty);\n augmentModelFromSchema(spec, property, specProperty, modelsByName);\n }\n }\n }\n\n model.properties.forEach(addLanguageTypes);\n\n // Resolve the discriminator's TypeScript property name for marshalling.\n if (model.discriminator) {\n model.discriminator.typescriptPropertyName = toTypeScriptName(\n model.discriminator.propertyName,\n );\n }\n};\n\n/**\n * Ensure no two properties/parameters of an object model collapse onto the same\n * TypeScript identifier (e.g. `foo-bar` and `foo_bar` both camelCase to\n * `fooBar`, or a query and header parameter sharing a name within one request\n * position). Such a clash would emit a type with duplicate members that does\n * not compile, so fail fast with an actionable error instead.\n */\nconst assertNoClashingPropertyNames = (model: Model): void => {\n const seen = new Map<string, string>();\n for (const property of model.properties) {\n // Composite members are unnamed (their names are empty); skip them.\n if (!property.name) continue;\n const existing = seen.get(property.typescriptName!);\n if (existing !== undefined && existing !== property.name) {\n throw new Error(\n `Property name conflict in \"${model.name}\": \"${existing}\" and \"${property.name}\" both map to the TypeScript name \"${property.typescriptName}\". Please rename one of these in your OpenAPI specification.`,\n );\n }\n seen.set(property.typescriptName!, property.name);\n }\n};\n\n/**\n * The marshalling semantics of a property — two properties with the same key\n * convert identically on the wire (so either branch's conversion is safe).\n */\nconst marshallingKey = (m: Model): string => {\n if (['date', 'date-time'].includes(m.format ?? '')) return 'date';\n if (m.type === 'binary') return 'binary';\n // Enums serialise as their bare primitive (no conversion).\n if (m.isEnum || m.export === 'enum') return 'plain';\n if (COLLECTION_TYPES.has(m.export)) {\n return `${m.export}<${m.link ? marshallingKey(m.link) : 'plain'}>`;\n }\n if (m.export === 'tuple') {\n return `tuple<${m.properties.map(marshallingKey).join(',')}>`;\n }\n if (m.export === 'reference' && !PRIMITIVE_TYPES.has(m.type)) {\n return `ref:${m.type}`;\n }\n return 'plain';\n};\n\n/**\n * A non-discriminated `oneOf`/`anyOf` of object members marshals by composing\n * every member, taking only the properties present on the value. That is sound\n * exactly when no wire property is claimed by two members with different\n * marshalling (e.g. a `date-time` in one and a plain string in another) —\n * otherwise the branch cannot be determined without guessing, so fail fast and\n * ask for a discriminator rather than corrupt data at runtime.\n */\nconst assertNoConflictingUnionMemberMarshalling = (model: Model): void => {\n if (\n (model.export !== 'one-of' && model.export !== 'any-of') ||\n model.discriminator\n ) {\n return;\n }\n const seen = new Map<string, { memberName: string; key: string }>();\n for (const member of model.composedModels ?? []) {\n for (const property of member.properties) {\n if (!property.name) continue;\n const key = marshallingKey(property);\n const existing = seen.get(property.name);\n if (existing && existing.key !== key) {\n throw new Error(\n `Schema \"${model.name}\" is a non-discriminated ${camelCase(model.export)} of \"${existing.memberName}\" and \"${member.name}\", which both declare a property \"${property.name}\" with different types, so the correct conversion cannot be determined. Add a discriminator to the union in your OpenAPI specification (e.g. with Pydantic, Field(discriminator=...)).`,\n );\n }\n if (!existing) {\n seen.set(property.name, { memberName: member.name, key });\n }\n }\n }\n};\n\n/**\n * An `application/x-www-form-urlencoded` body is form-encoded as `key=value`\n * pairs, so the wire form is only defined for a schema with named properties\n * (an object) or a primitive sent verbatim. A top-level array or tuple has no\n * property names to key on — encoding it would emit index keys (`0=a&1=b`) that\n * no form parser can decode — so fail fast rather than generate a client that\n * is silently wrong on the wire.\n */\nconst assertEncodableUrlEncodedBody = (op: Operation): void => {\n const body = op.parametersBody;\n if (!body?.mediaTypes) return;\n const mediaTypes = Array.isArray(body.mediaTypes)\n ? body.mediaTypes\n : [body.mediaTypes];\n // Match the wire media type the client actually sends: JSON is preferred, so\n // an array body offering both JSON and urlencoded is sent as JSON and is fine.\n const chosenMediaType =\n mediaTypes.find(\n (mt) => mt === 'application/json' || mt.endsWith('+json'),\n ) ?? mediaTypes[0];\n if (chosenMediaType !== 'application/x-www-form-urlencoded') return;\n if (body.isPrimitive) return;\n if (body.export === 'array' || body.export === 'tuple') {\n throw new Error(\n `Operation ${op.method} ${op.path} has an application/x-www-form-urlencoded request body whose schema is a ${body.export}, which has no defined form encoding. Use an object schema (its properties become the form fields) or a primitive schema (sent verbatim) in your OpenAPI specification.`,\n );\n }\n};\n\n/**\n * Group operations by their (camelCased) tags, collecting any untagged\n * operations separately.\n */\nconst groupOperationsByTag = (\n allOperations: Operation[],\n): {\n operationsByTag: { [tag: string]: Operation[] };\n untaggedOperations: Operation[];\n} => {\n const isTagged = (op: Operation): boolean => !!op.tags && op.tags.length > 0;\n\n const operationsByTag = allOperations\n .filter(isTagged)\n .flatMap((op) => op.tags!.map((tag) => [camelCase(tag), op] as const))\n .reduce<{ [tag: string]: Operation[] }>(\n (acc, [tag, op]) => ({ ...acc, [tag]: [...(acc[tag] ?? []), op] }),\n {},\n );\n\n return {\n operationsByTag,\n untaggedOperations: allOperations.filter((op) => !isTagged(op)),\n };\n};\n\n/**\n * Resolve a schema to its model: an existing named model for a `$ref`, or a\n * freshly built-and-augmented model for an inline (nested value) schema.\n */\nconst buildOrReferenceModel = (\n spec: Spec,\n modelsByName: ModelsByName,\n schema: OpenApiSchemaOrRef,\n): Model => {\n if (isRef(schema)) {\n const name = splitRef(schema.$ref)[2];\n return modelsByName[name];\n }\n const model = buildInlineModel(spec, schema);\n linkModel(spec, modelsByName, model, schema);\n augmentModelFromSchema(spec, model, schema, modelsByName);\n return model;\n};\n\n/**\n * The `x-*` vendor extensions declared on an object.\n */\nconst vendorExtensionsOf = (object: object | undefined): VendorExtensions =>\n Object.fromEntries(\n Object.entries(object ?? {}).filter(([key]) => key.startsWith('x-')),\n );\n\nconst augmentModelFromSchema = (\n spec: Spec,\n model: Model,\n schema: OpenApiSchema,\n modelsByName: ModelsByName,\n visited: Set<Model> = new Set(),\n) => {\n model.format = schema.format;\n model.deprecated = !!schema.deprecated;\n model.openapiType = schema.type;\n model.isEnum = !!schema.enum && schema.enum.length > 0;\n model.vendorExtensions = vendorExtensionsOf(schema);\n\n // A \"dictionary\" has only additional properties; an \"interface\" may mix\n // explicit and additional properties.\n if (schema.additionalProperties) {\n const additionalPropertiesModel = buildOrReferenceModel(\n spec,\n modelsByName,\n schema.additionalProperties === true ? {} : schema.additionalProperties,\n );\n\n if (model.export === 'dictionary') {\n // A dictionary carries a self-referential property; the rest are explicit\n const explicitProperties = model.properties.filter(\n (p) => !(p.export === 'dictionary' && p.name === model.name),\n );\n\n // Explicit properties make this an interface rather than a dictionary\n if (explicitProperties.length > 0 || schema.patternProperties) {\n model.export = 'interface';\n model.hasAdditionalProperties = true;\n model.additionalPropertiesModel = additionalPropertiesModel;\n model.properties = explicitProperties;\n }\n } else {\n model.hasAdditionalProperties = true;\n model.additionalPropertiesModel = additionalPropertiesModel;\n }\n }\n\n // Pattern properties can have different value types per pattern, so the model\n // is an interface rather than a dictionary.\n if (schema.patternProperties) {\n const patternProperties = resolveIfRef(spec, schema.patternProperties);\n\n if (model.export === 'dictionary') {\n model.export = 'interface';\n }\n\n model.hasPatternProperties = true;\n model.patternPropertiesModels = Object.entries(patternProperties)\n .map(([pattern, patternProperty]) => ({\n pattern,\n model: buildOrReferenceModel(spec, modelsByName, patternProperty),\n }))\n .filter((entry): entry is PatternPropertyModel => !!entry.model);\n }\n\n addLanguageTypes(model);\n\n visited.add(model);\n\n const recurse = (target: Model, subSchema: OpenApiSchema): void =>\n augmentModelFromSchema(spec, target, subSchema, modelsByName, visited);\n\n // Array element type.\n if (\n model.export === 'array' &&\n model.link &&\n 'items' in schema &&\n schema.items &&\n !visited.has(model.link)\n ) {\n recurse(model.link, resolveIfRef(spec, schema.items));\n }\n\n // Dictionary value type (additionalProperties may be `true` rather than a\n // schema).\n if (\n model.export === 'dictionary' &&\n model.link &&\n 'additionalProperties' in schema &&\n schema.additionalProperties &&\n !visited.has(model.link)\n ) {\n const subSchema = resolveIfRef(spec, schema.additionalProperties);\n if (subSchema !== true) {\n recurse(model.link, subSchema);\n }\n }\n\n // Tuple element types (3.1 `prefixItems`), positionally.\n if (model.export === 'tuple' && 'prefixItems' in schema) {\n const memberSchemas =\n (schema as { prefixItems?: OpenApiSchemaOrRef[] }).prefixItems ?? [];\n model.properties.forEach((member, i) => {\n const subSchema = resolveIfRef(spec, memberSchemas[i]);\n if (subSchema && !visited.has(member)) {\n recurse(member, subSchema);\n }\n });\n }\n\n model.properties\n .filter((p) => !visited.has(p) && schema.properties?.[trim(p.name, `\"'`)])\n .forEach((property) =>\n recurse(\n property,\n resolveIfRef(spec, schema.properties![trim(property.name, `\"'`)]),\n ),\n );\n\n if (COMPOSED_SCHEMA_TYPES.has(model.export)) {\n const memberSchemas = compositeMemberSchemas(schema, model.export);\n model.properties.forEach((property, i) => {\n const subSchema = resolveIfRef(spec, memberSchemas[i]);\n if (subSchema) {\n recurse(property, subSchema);\n }\n });\n }\n};\n\nconst addLanguageTypes = (model: Model) => {\n model.name = trim(model.name, `\"'`);\n model.typescriptName = toTypeScriptName(model.name);\n model.typescriptType = toTypeScriptType(model);\n model.pythonName = toPythonName('property', model.name);\n model.pythonType = toPythonType(model);\n model.isPrimitive =\n PRIMITIVE_TYPES.has(model.type) &&\n !COMPOSED_SCHEMA_TYPES.has(model.export) &&\n !COLLECTION_TYPES.has(model.export);\n};\n\nconst isOperationMutation = (op: Operation): boolean => {\n // x-mutation/x-query override the HTTP-method default.\n const { vendorExtensions } = op;\n if (vendorExtensions?.[VENDOR_EXTENSIONS.MUTATION]) {\n return true;\n } else if (vendorExtensions?.[VENDOR_EXTENSIONS.QUERY]) {\n return false;\n }\n return ['PATCH', 'POST', 'PUT', 'DELETE'].includes(op.method);\n};\n\nconst augmentInfiniteQuery = (op: Operation) => {\n const { paginationDisabled, cursorPropertyName } = getCursorOptions(op);\n\n const cursorProperty = op.parameters.find(\n (p) => p.name === cursorPropertyName,\n );\n\n // An infinite query is a paginated operation that accepts the cursor parameter\n op.isInfiniteQuery = !paginationDisabled && !!cursorProperty;\n if (op.isInfiniteQuery) {\n op.infiniteQueryCursorProperty = cursorProperty;\n }\n};\n\n/**\n * Resolve the pagination cursor options from an operation's `x-cursor` vendor\n * extension. Accepted forms (object variants exist because Smithy vendor\n * extensions must be objects):\n *\n * - `'property'` / `{ inputToken: 'property' }` — the input property to page on\n * - `false` / `{ enabled: false }` — disable pagination\n */\nconst getCursorOptions = (\n op: Operation,\n): { paginationDisabled: boolean; cursorPropertyName: string } => {\n const cursor = op.vendorExtensions?.[VENDOR_EXTENSIONS.CURSOR];\n\n // Defaults: pagination enabled, paging on a property named 'cursor'.\n if (cursor === false) {\n return { paginationDisabled: true, cursorPropertyName: 'cursor' };\n }\n if (typeof cursor === 'string') {\n return { paginationDisabled: false, cursorPropertyName: cursor };\n }\n const options = (cursor ?? {}) as { enabled?: boolean; inputToken?: unknown };\n return {\n paginationDisabled: options.enabled === false,\n cursorPropertyName:\n typeof options.inputToken === 'string' ? options.inputToken : 'cursor',\n };\n};\n\n/**\n * Add query/mutation, streaming and infinite-query flags to an operation.\n */\nconst augmentOperationBehaviour = (op: Operation) => {\n const isMutation = isOperationMutation(op);\n op.isMutation = isMutation;\n op.isQuery = !isMutation;\n\n op.isStreaming =\n !!op.vendorExtensions?.[VENDOR_EXTENSIONS.STREAMING] ||\n op.responses.some((res) => res.isJsonlStreaming);\n\n // For JSON-lines streaming, the result is each streamed item, so the client\n // method returns AsyncIterableIterator<itemSchemaModel>. Named (hoisted)\n // item schemas become references; inline primitives keep their own type.\n const jsonlResponse = op.responses.find((res) => res.isJsonlStreaming);\n if (jsonlResponse) {\n const itemSchemaModel = jsonlResponse.itemSchemaModel;\n const result = op.result;\n if (result && itemSchemaModel) {\n if (itemSchemaModel.name) {\n result.type = itemSchemaModel.name;\n result.typescriptType = itemSchemaModel.name;\n result.export = 'reference';\n } else {\n result.type = itemSchemaModel.type;\n result.typescriptType = itemSchemaModel.typescriptType;\n result.export = itemSchemaModel.export;\n result.format = itemSchemaModel.format;\n result.link = itemSchemaModel.link;\n result.isPrimitive = itemSchemaModel.isPrimitive;\n }\n }\n }\n\n // Add infinite query details if applicable\n if (!isMutation) {\n augmentInfiniteQuery(op);\n }\n};\n"],"names":["orderBy","trim","uniqBy","camelCase","pascalCase","snakeCase","toClassName","upperFirst","toPythonName","toPythonType","toTypeScriptModelName","toTypeScriptName","toTypeScriptType","COLLECTION_TYPES","COMPOSED_SCHEMA_TYPES","createModel","DEFAULT_SERVICE_NAME","indexModelsByName","PRIMITIVE_TYPES","STREAMING_CONTENT_TYPES","VENDOR_EXTENSIONS","normaliseOpenApiSpecForCodeGen","buildClientData","buildInlineModel","compositeMemberSchemas","getSpecOperation","getSpecParametersByKey","getSpecPathParameters","linkModel","specParameterKey","isRef","resolveIfRef","splitRef","buildOpenApiCodeGenData","inSpec","spec","data","modelsByName","models","service","services","augmentService","allOperations","flatMap","s","operations","o","uniqueName","op","buildRequestParameterModels","model","augmentModel","typescriptName","name","typescriptType","assertNoClashingPropertyNames","assertNoConflictingUnionMemberMarshalling","assertEncodableUrlEncodedBody","d","operationsByTag","untaggedOperations","groupOperationsByTag","info","vendorExtensions","vendorExtensionsOf","className","title","modelImports","augmentOperation","imports","x","nameSnakeCase","specOp","assignOperationNames","augmentResponses","augmentParameters","responses","forEach","addLanguageTypes","r","code","result","find","operationIdPascalCase","operationIdSnakeCase","parameters","length","baseRequestTypeName","requestTypeName","components","schemas","augmentOperationBehaviour","deduplicatedOpId","dotNotationOpId","id","dotNotationName","filter","export","map","type","response","has","composedPrimitives","p","Error","method","path","matchingSpecResponse","specResponse","content","mediaTypes","Object","keys","mediaType","responseContent","responseSchema","schema","augmentModelFromSchema","isJsonlStreaming","itemSchemaModel","buildOrReferenceModel","itemSchema","specParametersByKey","parameter","push","specParameter","in","prop","specParameterSchema","augmentBodyParameter","collectionFormat","getCollectionFormat","allowReserved","style","pathStyle","pathExplode","explode","specBody","requestBody","bodySchema","position","spaceDelimited","pipeDelimited","simple","form","canInlineBody","body","hasClashingPropertyName","properties","some","param","parametersByPosition","reduce","acc","explicitRequestBodyParameter","entries","description","isRequired","matchingSpecModel","specModel","property","matchingSpecProperty","specProperty","discriminator","typescriptPropertyName","propertyName","seen","Map","existing","get","undefined","set","marshallingKey","m","includes","format","isEnum","link","join","member","composedModels","key","memberName","parametersBody","Array","isArray","chosenMediaType","mt","endsWith","isPrimitive","isTagged","tags","tag","$ref","object","fromEntries","startsWith","visited","Set","deprecated","openapiType","enum","additionalProperties","additionalPropertiesModel","explicitProperties","patternProperties","hasAdditionalProperties","hasPatternProperties","patternPropertiesModels","pattern","patternProperty","entry","add","recurse","target","subSchema","items","memberSchemas","prefixItems","i","pythonName","pythonType","isOperationMutation","MUTATION","QUERY","augmentInfiniteQuery","paginationDisabled","cursorPropertyName","getCursorOptions","cursorProperty","isInfiniteQuery","infiniteQueryCursorProperty","cursor","CURSOR","options","enabled","inputToken","isMutation","isQuery","isStreaming","STREAMING","res","jsonlResponse"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,aAAa,iBAAiB;AACrC,OAAOC,UAAU,cAAc;AAC/B,OAAOC,YAAY,gBAAgB;AAEnC,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,EACXC,UAAU,QACL,uBAAuB;AAC9B,SACEC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,gBAAgB,EAChBC,gBAAgB,QACX,8BAA8B;AACrC,SACEC,gBAAgB,EAChBC,qBAAqB,EAGrBC,WAAW,EACXC,oBAAoB,EACpBC,iBAAiB,EAKjBC,eAAe,EAEfC,uBAAuB,EACvBC,iBAAiB,QAEZ,0BAA0B;AACjC,SAASC,8BAA8B,QAAQ,iBAAiB;AAChE,SACEC,eAAe,EACfC,gBAAgB,EAChBC,sBAAsB,EACtBC,gBAAgB,EAChBC,sBAAsB,EACtBC,qBAAqB,EACrBC,SAAS,EACTC,gBAAgB,QACX,cAAc;AACrB,SAASC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,YAAY;AAG1D;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC;IACtC,MAAMC,OAAOd,+BAA+Ba;IAC5C,MAAME,OAAOd,gBAAgBa;IAE7B,MAAME,eAAepB,kBAAkBmB,KAAKE,MAAM;IAElD,KAAK,MAAMC,WAAWH,KAAKI,QAAQ,CAAE;QACnCC,eAAeN,MAAMI,SAASF;IAChC;IAEA,MAAMK,gBAAgBxC,OACpBkC,KAAKI,QAAQ,CAACG,OAAO,CAAC,CAACC,IAAMA,EAAEC,UAAU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;IAC3C,IAAI,CAACgD,YAAY;QACfZ,qBAAqBjL;IACvB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/codegen-data.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport orderBy from 'lodash.orderby';\nimport trim from 'lodash.trim';\nimport uniqBy from 'lodash.uniqby';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport {\n camelCase,\n pascalCase,\n snakeCase,\n toClassName,\n upperFirst,\n} from '../../utils/names.js';\nimport {\n toPythonName,\n toPythonType,\n toTypeScriptModelName,\n toTypeScriptName,\n toTypeScriptType,\n} from './codegen-data/languages.js';\nimport {\n COLLECTION_TYPES,\n COMPOSED_SCHEMA_TYPES,\n type CodeGenData,\n type CollectionFormat,\n createModel,\n DEFAULT_SERVICE_NAME,\n indexModelsByName,\n type Model,\n type ModelsByName,\n type Operation,\n type PatternPropertyModel,\n PRIMITIVE_TYPES,\n type Service,\n STREAMING_CONTENT_TYPES,\n VENDOR_EXTENSIONS,\n type VendorExtensions,\n} from './codegen-data/types.js';\nimport { normaliseOpenApiSpecForCodeGen } from './normalise.js';\nimport {\n buildClientData,\n buildInlineModel,\n compositeMemberSchemas,\n getSpecOperation,\n getSpecParametersByKey,\n getSpecPathParameters,\n linkModel,\n specParameterKey,\n} from './parser.js';\nimport { isRef, resolveIfRef, splitRef } from './refs.js';\nimport type { OpenApiSchema, OpenApiSchemaOrRef, Spec } from './types.js';\n\n/**\n * Build the data structure used to generate code from an OpenAPI spec.\n */\nexport const buildOpenApiCodeGenData = (inSpec: Spec): CodeGenData => {\n const spec = normaliseOpenApiSpecForCodeGen(inSpec);\n const data = buildClientData(spec);\n\n const modelsByName = indexModelsByName(data.models);\n\n for (const service of data.services) {\n augmentService(spec, service, modelsByName);\n }\n\n const allOperations = uniqBy(\n data.services.flatMap((s) => s.operations),\n (o) => o.uniqueName,\n );\n\n // A model per operation request parameter position (query/path/body/...).\n data.models = [\n ...data.models,\n ...allOperations.flatMap((op) =>\n buildRequestParameterModels(op, modelsByName),\n ),\n ];\n\n for (const model of data.models) {\n augmentModel(spec, model, modelsByName);\n }\n for (const model of data.models) {\n model.typescriptName = toTypeScriptModelName(model.name);\n model.typescriptType = model.typescriptName;\n }\n\n for (const model of data.models) {\n assertNoClashingPropertyNames(model);\n assertNoConflictingUnionMemberMarshalling(model, modelsByName);\n }\n\n for (const op of allOperations) {\n assertEncodableUrlEncodedBody(op);\n }\n\n data.models = orderBy(data.models, (d) => d.name);\n // Default service first, then by name.\n data.services = orderBy(data.services, (s) =>\n s.name === DEFAULT_SERVICE_NAME ? '' : s.name,\n );\n\n const { operationsByTag, untaggedOperations } =\n groupOperationsByTag(allOperations);\n\n return {\n ...data,\n operationsByTag,\n untaggedOperations,\n info: spec.info,\n allOperations,\n vendorExtensions: vendorExtensionsOf(spec),\n className: toClassName(spec.info.title),\n };\n};\n\n/**\n * Augment a service and each of its operations with the data needed for code\n * generation (names, imports, result/request types, behavioural flags), and\n * compute the set of models the service (ie API client) needs to import.\n */\nconst augmentService = (\n spec: Spec,\n service: Service,\n modelsByName: ModelsByName,\n): void => {\n const modelImports = service.operations.flatMap((op) =>\n augmentOperation(spec, op, modelsByName),\n );\n\n service.operations = orderBy(service.operations, (op) => op.uniqueName);\n service.modelImports = orderBy(\n uniqBy([...service.imports, ...modelImports], (x) => x),\n );\n service.className = `${service.name}Api`;\n service.nameSnakeCase = snakeCase(service.name);\n};\n\n/**\n * Augment a single operation with all the data the templates need, returning\n * the names of the models it references (for the service's import list).\n */\nconst augmentOperation = (\n spec: Spec,\n op: Operation,\n modelsByName: ModelsByName,\n): string[] => {\n const specOp = getSpecOperation(spec, op);\n\n assignOperationNames(op, specOp);\n\n op.vendorExtensions = vendorExtensionsOf(specOp);\n\n const modelImports = [\n ...(specOp ? augmentResponses(spec, op, specOp, modelsByName) : []),\n ...augmentParameters(spec, op, specOp, modelsByName),\n ];\n\n op.responses.forEach(addLanguageTypes);\n op.responses = orderBy(op.responses, (r) => r.code);\n\n // Result is the lowest successful response, otherwise the 2XX or default.\n op.result =\n op.responses.find(\n (r) => typeof r.code === 'number' && r.code >= 200 && r.code < 300,\n ) ?? op.responses.find((r) => r.code === '2XX' || r.code === 'default');\n\n op.operationIdPascalCase = pascalCase(op.uniqueName);\n op.operationIdSnakeCase = toPythonName('operation', op.uniqueName);\n\n if (op.parameters.length > 0) {\n const baseRequestTypeName = `${op.operationIdPascalCase}Request`;\n // Use the OperationRequest suffix when the standard Request name clashes\n // with an existing schema.\n op.requestTypeName = spec.components?.schemas?.[baseRequestTypeName]\n ? `${op.operationIdPascalCase}OperationRequest`\n : baseRequestTypeName;\n }\n\n augmentOperationBehaviour(op);\n\n return modelImports;\n};\n\n/**\n * Set an operation's name and its deduplicated variants from the vendor\n * extensions the normaliser added.\n */\nconst assignOperationNames = (\n op: Operation,\n specOp: OpenAPIV3.OperationObject | undefined,\n): void => {\n const deduplicatedOpId = specOp?.['x-aws-nx-deduplicated-op-id'] as\n | string\n | undefined;\n const dotNotationOpId = specOp?.['x-aws-nx-deduplicated-dot-op-id'] as\n | string\n | undefined;\n\n op.name = op.id ?? op.name;\n op.uniqueName = deduplicatedOpId ?? op.name;\n if (dotNotationOpId) {\n op.dotNotationName = dotNotationOpId;\n }\n};\n\n/**\n * Augment an operation's response models with schema-derived data, resolving\n * void responses and streaming item schemas. Returns the response model names\n * to import.\n */\nconst augmentResponses = (\n spec: Spec,\n op: Operation,\n specOp: OpenAPIV3.OperationObject,\n modelsByName: ModelsByName,\n): string[] => {\n const modelImports = op.responses\n .filter((r) => r.export === 'reference')\n .map((r) => r.type);\n\n for (const response of op.responses) {\n // We cannot distinguish a composite of primitives at runtime (it all comes\n // back as text), so validate this away.\n if (\n response.export === 'reference' &&\n COMPOSED_SCHEMA_TYPES.has(modelsByName[response.type]?.export)\n ) {\n const composedPrimitives = (\n modelsByName[response.type].composedPrimitives ?? []\n ).filter((p) => !COLLECTION_TYPES.has(p.export));\n if (composedPrimitives.length > 0) {\n throw new Error(\n `Operation \"${op.method} ${op.path}\" returns a composite schema of primitives with ${camelCase(modelsByName[response.type].export)}, which cannot be distinguished at runtime`,\n );\n }\n }\n\n const matchingSpecResponse = specOp.responses[`${response.code}`];\n if (!matchingSpecResponse) continue;\n\n const specResponse = resolveIfRef(spec, matchingSpecResponse);\n\n // When there's no content, the response type is 'void'\n if (!specResponse.content) {\n response.type = 'void';\n continue;\n }\n\n const mediaTypes = Object.keys(specResponse.content);\n response.mediaTypes = mediaTypes;\n\n for (const mediaType of mediaTypes) {\n const responseContent = specResponse.content[mediaType];\n const responseSchema = resolveIfRef(spec, responseContent.schema);\n if (responseSchema) {\n augmentModelFromSchema(spec, response, responseSchema, modelsByName);\n }\n if (\n STREAMING_CONTENT_TYPES.has(mediaType) &&\n 'itemSchema' in responseContent\n ) {\n response.isJsonlStreaming = true;\n response.itemSchemaModel = buildOrReferenceModel(\n spec,\n modelsByName,\n responseContent.itemSchema as OpenApiSchemaOrRef,\n );\n }\n }\n }\n\n return modelImports;\n};\n\n/**\n * Augment an operation's parameter models with schema-derived data, resolving\n * request bodies and query/header collection formats. Returns the parameter\n * model names to import.\n */\nconst augmentParameters = (\n spec: Spec,\n op: Operation,\n specOp: OpenAPIV3.OperationObject | undefined,\n modelsByName: ModelsByName,\n): string[] => {\n const specParametersByKey = getSpecParametersByKey(\n spec,\n specOp,\n getSpecPathParameters(spec, op),\n );\n\n const modelImports: string[] = [];\n\n for (const parameter of op.parameters) {\n if (parameter.export === 'reference') {\n modelImports.push(parameter.type);\n }\n\n const specParameter =\n specParametersByKey[\n specParameterKey({ in: parameter.in, name: parameter.prop })\n ];\n const specParameterSchema = resolveIfRef(spec, specParameter?.schema);\n if (specParameterSchema) {\n augmentModelFromSchema(\n spec,\n parameter,\n specParameterSchema,\n modelsByName,\n );\n }\n\n if (parameter.in === 'body') {\n augmentBodyParameter(spec, parameter, specOp, modelsByName);\n } else if (\n (parameter.in === 'query' || parameter.in === 'header') &&\n specParameter\n ) {\n parameter.collectionFormat = getCollectionFormat(\n parameter.in,\n specParameter,\n );\n if (parameter.in === 'query' && specParameter.allowReserved) {\n parameter.allowReserved = true;\n }\n } else if (parameter.in === 'path' && specParameter) {\n const style = specParameter.style;\n if (style === 'matrix' || style === 'label') {\n parameter.pathStyle = style;\n parameter.pathExplode = !!specParameter.explode;\n }\n }\n\n addLanguageTypes(parameter);\n }\n\n return modelImports;\n};\n\n/**\n * Augment a request body parameter with its schema (the body is not in the\n * spec's `parameters`, so it is resolved from `requestBody` here) and record\n * its acceptable media types.\n */\nconst augmentBodyParameter = (\n spec: Spec,\n parameter: Model,\n specOp: OpenAPIV3.OperationObject | undefined,\n modelsByName: ModelsByName,\n): void => {\n // The request body parameter is named 'body' downstream.\n parameter.name = 'body';\n parameter.prop = 'body';\n\n const specBody = resolveIfRef(spec, specOp?.requestBody);\n if (!specBody) return;\n\n if (parameter.mediaType) {\n const bodySchema = resolveIfRef(\n spec,\n specBody.content?.[parameter.mediaType]?.schema,\n );\n if (bodySchema) {\n augmentModelFromSchema(spec, parameter, bodySchema, modelsByName);\n }\n }\n // Track all the media types that can be accepted in the request body\n parameter.mediaTypes = Object.keys(specBody.content);\n};\n\n/**\n * Translate an OpenAPI v3 parameter's style/explode into a v2-style\n * collectionFormat used when serialising array parameters.\n * @see https://spec.openapis.org/oas/v3.0.3.html#style-values\n */\nconst getCollectionFormat = (\n position: 'query' | 'header',\n specParameter: OpenAPIV3.ParameterObject,\n): CollectionFormat => {\n const style =\n specParameter.style ?? (position === 'query' ? 'form' : 'simple');\n const explode = specParameter.explode ?? style === 'form';\n\n if (position === 'header') {\n return explode ? 'multi' : 'csv';\n }\n // `deepObject` serialises an object as `key[prop]=value` pairs regardless of\n // explode; the object shape (not array collection) drives its serialisation.\n if (style === 'deepObject') {\n return 'deepObject';\n }\n return explode\n ? 'multi'\n : ((\n {\n spaceDelimited: 'ssv',\n pipeDelimited: 'pipes',\n simple: 'csv',\n form: 'csv',\n } as const\n )[style] ?? 'multi');\n};\n\n/**\n * Build the request parameter models for an operation — one model per parameter\n * position (query/path/header/cookie/body), named e.g.\n * `FooRequestQueryParameters`. Request bodies that can be represented directly\n * (the sole parameter, or a non-clashing object reference) are inlined rather\n * than given a wrapper model, and recorded on `op.explicitRequestBodyParameter`.\n */\nconst buildRequestParameterModels = (\n op: Operation,\n modelsByName: ModelsByName,\n): Model[] => {\n if (!op.parameters || op.parameters.length === 0) {\n return [];\n }\n\n // Whether the request body can be represented directly, without a wrapper\n // model (ie the request will be the body itself).\n const canInlineBody = (body: Model): boolean => {\n // If the body is the only parameter, we can inline it no matter the type\n if (op.parameters.length === 1) {\n return true;\n }\n // We inline object bodies, so long as they aren't dictionaries (as\n // dictionary keys could clash with other parameters), and so long as they\n // don't have a property name that clashes with another parameter\n const hasClashingPropertyName = (\n modelsByName?.[body.type]?.properties ?? []\n ).some((prop) => op.parameters.some((param) => param.name === prop.name));\n return (\n body.export === 'reference' &&\n modelsByName?.[body.type]?.export !== 'dictionary' &&\n !hasClashingPropertyName\n );\n };\n\n // Group parameters by their position (`in`: query/path/header/cookie/body),\n // dropping any body that can be inlined.\n const parametersByPosition = op.parameters\n .filter((p) => !(p.in === 'body' && canInlineBody(p)))\n .reduce<{ [position: string]: Model[] }>(\n (acc, p) => ({ ...acc, [p.in]: [...(acc[p.in] ?? []), p] }),\n {},\n );\n\n // The body parameter was already renamed to \"body\" by augmentBodyParameter.\n op.explicitRequestBodyParameter = parametersByPosition['body']?.[0];\n\n return Object.entries(parametersByPosition).map(([position, parameters]) => {\n const name = `${op.operationIdPascalCase}Request${upperFirst(position)}Parameters`;\n return createModel({\n description: op.description,\n export: 'interface',\n name,\n properties: parameters,\n type: name,\n isRequired: true,\n });\n });\n};\n\n/**\n * Augment a single model with schema-derived data (from its matching spec\n * schema, if any) and language-specific names and types.\n */\nconst augmentModel = (\n spec: Spec,\n model: Model,\n modelsByName: ModelsByName,\n): void => {\n model.nameSnakeCase = toPythonName('model', model.name);\n\n const matchingSpecModel = spec?.components?.schemas?.[model.name];\n if (matchingSpecModel) {\n const specModel = resolveIfRef(spec, matchingSpecModel);\n\n augmentModelFromSchema(spec, model, specModel, modelsByName);\n\n for (const property of model.properties) {\n const matchingSpecProperty = specModel.properties?.[property.name];\n if (matchingSpecProperty) {\n const specProperty = resolveIfRef(spec, matchingSpecProperty);\n augmentModelFromSchema(spec, property, specProperty, modelsByName);\n }\n }\n }\n\n model.properties.forEach(addLanguageTypes);\n\n // Resolve the discriminator's TypeScript property name for marshalling.\n if (model.discriminator) {\n model.discriminator.typescriptPropertyName = toTypeScriptName(\n model.discriminator.propertyName,\n );\n }\n};\n\n/**\n * Ensure no two properties/parameters of an object model collapse onto the same\n * TypeScript identifier (e.g. `foo-bar` and `foo_bar` both camelCase to\n * `fooBar`, or a query and header parameter sharing a name within one request\n * position). Such a clash would emit a type with duplicate members that does\n * not compile, so fail fast with an actionable error instead.\n */\nconst assertNoClashingPropertyNames = (model: Model): void => {\n const seen = new Map<string, string>();\n for (const property of model.properties) {\n // Composite members are unnamed (their names are empty); skip them.\n if (!property.name) continue;\n const existing = seen.get(property.typescriptName!);\n if (existing !== undefined && existing !== property.name) {\n throw new Error(\n `Property name conflict in \"${model.name}\": \"${existing}\" and \"${property.name}\" both map to the TypeScript name \"${property.typescriptName}\". Please rename one of these in your OpenAPI specification.`,\n );\n }\n seen.set(property.typescriptName!, property.name);\n }\n};\n\n/**\n * The marshalling semantics of a property — two properties with the same key\n * convert identically on the wire (so either branch's conversion is safe).\n */\nconst marshallingKey = (\n m: Model,\n modelsByName: ModelsByName,\n visiting: Set<string> = new Set(),\n): string => {\n if (['date', 'date-time'].includes(m.format ?? '')) return 'date';\n if (m.type === 'binary') return 'binary';\n // Enums serialise as their bare primitive (no conversion).\n if (m.isEnum || m.export === 'enum') return 'plain';\n if (COLLECTION_TYPES.has(m.export)) {\n return `${m.export}<${m.link ? marshallingKey(m.link, modelsByName, visiting) : 'plain'}>`;\n }\n if (m.export === 'tuple') {\n return `tuple<${m.properties.map((p) => marshallingKey(p, modelsByName, visiting)).join(',')}>`;\n }\n if (m.export === 'reference' && !PRIMITIVE_TYPES.has(m.type)) {\n // Key on what the reference marshals to, not what it is called. The\n // normaliser hoists each inline schema to its own name, so two members\n // declaring an identical property get different names — keying on the name\n // alone rejected unions whose members convert identically.\n const referenced = modelsByName[m.type];\n if (!referenced || visiting.has(m.type)) return `ref:${m.type}`;\n const nested = new Set(visiting).add(m.type);\n if (referenced.export === 'one-of' || referenced.export === 'any-of') {\n const members = [\n ...(referenced.composedModels ?? []),\n ...(referenced.composedPrimitives ?? []),\n ]\n .map((member) => marshallingKey(member, modelsByName, nested))\n .sort();\n return `union<${[...new Set(members)].join('|')}>`;\n }\n if (referenced.export === 'interface') {\n // Keyed on the shape too, for the same reason: two members declaring an\n // identical inline object property are hoisted to different names.\n const fields = (referenced.properties ?? [])\n .filter((property) => property.name)\n .map(\n (property) =>\n `${property.name}:${property.isRequired ? '!' : '?'}${marshallingKey(property, modelsByName, nested)}`,\n )\n .sort();\n return `object<${fields.join(',')}>`;\n }\n // An `all-of` composes members that are resolved later, so it keeps its name\n // as its key rather than a shape this pass cannot see yet.\n if (referenced.export === 'all-of') return `ref:${m.type}`;\n return marshallingKey(referenced, modelsByName, nested);\n }\n return 'plain';\n};\n\n/**\n * A non-discriminated `oneOf`/`anyOf` of object members marshals by composing\n * every member, taking only the properties present on the value. That is sound\n * exactly when no wire property is claimed by two members with different\n * marshalling (e.g. a `date-time` in one and a plain string in another) —\n * otherwise the branch cannot be determined without guessing, so fail fast and\n * ask for a discriminator rather than corrupt data at runtime.\n */\nconst assertNoConflictingUnionMemberMarshalling = (\n model: Model,\n modelsByName: ModelsByName,\n): void => {\n if (\n (model.export !== 'one-of' && model.export !== 'any-of') ||\n model.discriminator\n ) {\n return;\n }\n const seen = new Map<string, { memberName: string; key: string }>();\n for (const member of model.composedModels ?? []) {\n for (const property of member.properties) {\n if (!property.name) continue;\n const key = marshallingKey(property, modelsByName);\n const existing = seen.get(property.name);\n if (existing && existing.key !== key) {\n throw new Error(\n `Schema \"${model.name}\" is a non-discriminated ${camelCase(model.export)} of \"${existing.memberName}\" and \"${member.name}\", which both declare a property \"${property.name}\" with different types, so the correct conversion cannot be determined. Add a discriminator to the union in your OpenAPI specification (e.g. with Pydantic, Field(discriminator=...)).`,\n );\n }\n if (!existing) {\n seen.set(property.name, { memberName: member.name, key });\n }\n }\n }\n};\n\n/**\n * An `application/x-www-form-urlencoded` body is form-encoded as `key=value`\n * pairs, so the wire form is only defined for a schema with named properties\n * (an object) or a primitive sent verbatim. A top-level array or tuple has no\n * property names to key on — encoding it would emit index keys (`0=a&1=b`) that\n * no form parser can decode — so fail fast rather than generate a client that\n * is silently wrong on the wire.\n */\nconst assertEncodableUrlEncodedBody = (op: Operation): void => {\n const body = op.parametersBody;\n if (!body?.mediaTypes) return;\n const mediaTypes = Array.isArray(body.mediaTypes)\n ? body.mediaTypes\n : [body.mediaTypes];\n // Match the wire media type the client actually sends: JSON is preferred, so\n // an array body offering both JSON and urlencoded is sent as JSON and is fine.\n const chosenMediaType =\n mediaTypes.find(\n (mt) => mt === 'application/json' || mt.endsWith('+json'),\n ) ?? mediaTypes[0];\n if (chosenMediaType !== 'application/x-www-form-urlencoded') return;\n if (body.isPrimitive) return;\n if (body.export === 'array' || body.export === 'tuple') {\n throw new Error(\n `Operation ${op.method} ${op.path} has an application/x-www-form-urlencoded request body whose schema is a ${body.export}, which has no defined form encoding. Use an object schema (its properties become the form fields) or a primitive schema (sent verbatim) in your OpenAPI specification.`,\n );\n }\n};\n\n/**\n * Group operations by their (camelCased) tags, collecting any untagged\n * operations separately.\n */\nconst groupOperationsByTag = (\n allOperations: Operation[],\n): {\n operationsByTag: { [tag: string]: Operation[] };\n untaggedOperations: Operation[];\n} => {\n const isTagged = (op: Operation): boolean => !!op.tags && op.tags.length > 0;\n\n const operationsByTag = allOperations\n .filter(isTagged)\n .flatMap((op) => op.tags!.map((tag) => [camelCase(tag), op] as const))\n .reduce<{ [tag: string]: Operation[] }>(\n (acc, [tag, op]) => ({ ...acc, [tag]: [...(acc[tag] ?? []), op] }),\n {},\n );\n\n return {\n operationsByTag,\n untaggedOperations: allOperations.filter((op) => !isTagged(op)),\n };\n};\n\n/**\n * Resolve a schema to its model: an existing named model for a `$ref`, or a\n * freshly built-and-augmented model for an inline (nested value) schema.\n */\nconst buildOrReferenceModel = (\n spec: Spec,\n modelsByName: ModelsByName,\n schema: OpenApiSchemaOrRef,\n): Model => {\n if (isRef(schema)) {\n const name = splitRef(schema.$ref)[2];\n return modelsByName[name];\n }\n const model = buildInlineModel(spec, schema);\n linkModel(spec, modelsByName, model, schema);\n augmentModelFromSchema(spec, model, schema, modelsByName);\n return model;\n};\n\n/**\n * The `x-*` vendor extensions declared on an object.\n */\nconst vendorExtensionsOf = (object: object | undefined): VendorExtensions =>\n Object.fromEntries(\n Object.entries(object ?? {}).filter(([key]) => key.startsWith('x-')),\n );\n\nconst augmentModelFromSchema = (\n spec: Spec,\n model: Model,\n schema: OpenApiSchema,\n modelsByName: ModelsByName,\n visited: Set<Model> = new Set(),\n) => {\n model.format = schema.format;\n model.deprecated = !!schema.deprecated;\n model.openapiType = schema.type;\n model.isEnum = !!schema.enum && schema.enum.length > 0;\n model.vendorExtensions = vendorExtensionsOf(schema);\n\n // A \"dictionary\" has only additional properties; an \"interface\" may mix\n // explicit and additional properties.\n if (schema.additionalProperties) {\n const additionalPropertiesModel = buildOrReferenceModel(\n spec,\n modelsByName,\n schema.additionalProperties === true ? {} : schema.additionalProperties,\n );\n\n if (model.export === 'dictionary') {\n // A dictionary carries a self-referential property; the rest are explicit\n const explicitProperties = model.properties.filter(\n (p) => !(p.export === 'dictionary' && p.name === model.name),\n );\n\n // Explicit properties make this an interface rather than a dictionary\n if (explicitProperties.length > 0 || schema.patternProperties) {\n model.export = 'interface';\n model.hasAdditionalProperties = true;\n model.additionalPropertiesModel = additionalPropertiesModel;\n model.properties = explicitProperties;\n }\n } else {\n model.hasAdditionalProperties = true;\n model.additionalPropertiesModel = additionalPropertiesModel;\n }\n }\n\n // Pattern properties can have different value types per pattern, so the model\n // is an interface rather than a dictionary.\n if (schema.patternProperties) {\n const patternProperties = resolveIfRef(spec, schema.patternProperties);\n\n if (model.export === 'dictionary') {\n model.export = 'interface';\n }\n\n model.hasPatternProperties = true;\n model.patternPropertiesModels = Object.entries(patternProperties)\n .map(([pattern, patternProperty]) => ({\n pattern,\n model: buildOrReferenceModel(spec, modelsByName, patternProperty),\n }))\n .filter((entry): entry is PatternPropertyModel => !!entry.model);\n }\n\n addLanguageTypes(model);\n\n visited.add(model);\n\n const recurse = (target: Model, subSchema: OpenApiSchema): void =>\n augmentModelFromSchema(spec, target, subSchema, modelsByName, visited);\n\n // Array element type.\n if (\n model.export === 'array' &&\n model.link &&\n 'items' in schema &&\n schema.items &&\n !visited.has(model.link)\n ) {\n recurse(model.link, resolveIfRef(spec, schema.items));\n }\n\n // Dictionary value type (additionalProperties may be `true` rather than a\n // schema).\n if (\n model.export === 'dictionary' &&\n model.link &&\n 'additionalProperties' in schema &&\n schema.additionalProperties &&\n !visited.has(model.link)\n ) {\n const subSchema = resolveIfRef(spec, schema.additionalProperties);\n if (subSchema !== true) {\n recurse(model.link, subSchema);\n }\n }\n\n // Tuple element types (3.1 `prefixItems`), positionally.\n if (model.export === 'tuple' && 'prefixItems' in schema) {\n const memberSchemas =\n (schema as { prefixItems?: OpenApiSchemaOrRef[] }).prefixItems ?? [];\n model.properties.forEach((member, i) => {\n const subSchema = resolveIfRef(spec, memberSchemas[i]);\n if (subSchema && !visited.has(member)) {\n recurse(member, subSchema);\n }\n });\n }\n\n model.properties\n .filter((p) => !visited.has(p) && schema.properties?.[trim(p.name, `\"'`)])\n .forEach((property) =>\n recurse(\n property,\n resolveIfRef(spec, schema.properties![trim(property.name, `\"'`)]),\n ),\n );\n\n if (COMPOSED_SCHEMA_TYPES.has(model.export)) {\n const memberSchemas = compositeMemberSchemas(schema, model.export);\n model.properties.forEach((property, i) => {\n const subSchema = resolveIfRef(spec, memberSchemas[i]);\n if (subSchema) {\n recurse(property, subSchema);\n }\n });\n }\n};\n\nconst addLanguageTypes = (model: Model) => {\n model.name = trim(model.name, `\"'`);\n model.typescriptName = toTypeScriptName(model.name);\n model.typescriptType = toTypeScriptType(model);\n model.pythonName = toPythonName('property', model.name);\n model.pythonType = toPythonType(model);\n model.isPrimitive =\n PRIMITIVE_TYPES.has(model.type) &&\n !COMPOSED_SCHEMA_TYPES.has(model.export) &&\n !COLLECTION_TYPES.has(model.export);\n};\n\nconst isOperationMutation = (op: Operation): boolean => {\n // x-mutation/x-query override the HTTP-method default.\n const { vendorExtensions } = op;\n if (vendorExtensions?.[VENDOR_EXTENSIONS.MUTATION]) {\n return true;\n } else if (vendorExtensions?.[VENDOR_EXTENSIONS.QUERY]) {\n return false;\n }\n return ['PATCH', 'POST', 'PUT', 'DELETE'].includes(op.method);\n};\n\nconst augmentInfiniteQuery = (op: Operation) => {\n const { paginationDisabled, cursorPropertyName } = getCursorOptions(op);\n\n const cursorProperty = op.parameters.find(\n (p) => p.name === cursorPropertyName,\n );\n\n // An infinite query is a paginated operation that accepts the cursor parameter\n op.isInfiniteQuery = !paginationDisabled && !!cursorProperty;\n if (op.isInfiniteQuery) {\n op.infiniteQueryCursorProperty = cursorProperty;\n }\n};\n\n/**\n * Resolve the pagination cursor options from an operation's `x-cursor` vendor\n * extension. Accepted forms (object variants exist because Smithy vendor\n * extensions must be objects):\n *\n * - `'property'` / `{ inputToken: 'property' }` — the input property to page on\n * - `false` / `{ enabled: false }` — disable pagination\n */\nconst getCursorOptions = (\n op: Operation,\n): { paginationDisabled: boolean; cursorPropertyName: string } => {\n const cursor = op.vendorExtensions?.[VENDOR_EXTENSIONS.CURSOR];\n\n // Defaults: pagination enabled, paging on a property named 'cursor'.\n if (cursor === false) {\n return { paginationDisabled: true, cursorPropertyName: 'cursor' };\n }\n if (typeof cursor === 'string') {\n return { paginationDisabled: false, cursorPropertyName: cursor };\n }\n const options = (cursor ?? {}) as { enabled?: boolean; inputToken?: unknown };\n return {\n paginationDisabled: options.enabled === false,\n cursorPropertyName:\n typeof options.inputToken === 'string' ? options.inputToken : 'cursor',\n };\n};\n\n/**\n * Add query/mutation, streaming and infinite-query flags to an operation.\n */\nconst augmentOperationBehaviour = (op: Operation) => {\n const isMutation = isOperationMutation(op);\n op.isMutation = isMutation;\n op.isQuery = !isMutation;\n\n op.isStreaming =\n !!op.vendorExtensions?.[VENDOR_EXTENSIONS.STREAMING] ||\n op.responses.some((res) => res.isJsonlStreaming);\n\n // For JSON-lines streaming, the result is each streamed item, so the client\n // method returns AsyncIterableIterator<itemSchemaModel>. Named (hoisted)\n // item schemas become references; inline primitives keep their own type.\n const jsonlResponse = op.responses.find((res) => res.isJsonlStreaming);\n if (jsonlResponse) {\n const itemSchemaModel = jsonlResponse.itemSchemaModel;\n const result = op.result;\n if (result && itemSchemaModel) {\n if (itemSchemaModel.name) {\n result.type = itemSchemaModel.name;\n result.typescriptType = itemSchemaModel.name;\n result.export = 'reference';\n } else {\n result.type = itemSchemaModel.type;\n result.typescriptType = itemSchemaModel.typescriptType;\n result.export = itemSchemaModel.export;\n result.format = itemSchemaModel.format;\n result.link = itemSchemaModel.link;\n result.isPrimitive = itemSchemaModel.isPrimitive;\n }\n }\n }\n\n // Add infinite query details if applicable\n if (!isMutation) {\n augmentInfiniteQuery(op);\n }\n};\n"],"names":["orderBy","trim","uniqBy","camelCase","pascalCase","snakeCase","toClassName","upperFirst","toPythonName","toPythonType","toTypeScriptModelName","toTypeScriptName","toTypeScriptType","COLLECTION_TYPES","COMPOSED_SCHEMA_TYPES","createModel","DEFAULT_SERVICE_NAME","indexModelsByName","PRIMITIVE_TYPES","STREAMING_CONTENT_TYPES","VENDOR_EXTENSIONS","normaliseOpenApiSpecForCodeGen","buildClientData","buildInlineModel","compositeMemberSchemas","getSpecOperation","getSpecParametersByKey","getSpecPathParameters","linkModel","specParameterKey","isRef","resolveIfRef","splitRef","buildOpenApiCodeGenData","inSpec","spec","data","modelsByName","models","service","services","augmentService","allOperations","flatMap","s","operations","o","uniqueName","op","buildRequestParameterModels","model","augmentModel","typescriptName","name","typescriptType","assertNoClashingPropertyNames","assertNoConflictingUnionMemberMarshalling","assertEncodableUrlEncodedBody","d","operationsByTag","untaggedOperations","groupOperationsByTag","info","vendorExtensions","vendorExtensionsOf","className","title","modelImports","augmentOperation","imports","x","nameSnakeCase","specOp","assignOperationNames","augmentResponses","augmentParameters","responses","forEach","addLanguageTypes","r","code","result","find","operationIdPascalCase","operationIdSnakeCase","parameters","length","baseRequestTypeName","requestTypeName","components","schemas","augmentOperationBehaviour","deduplicatedOpId","dotNotationOpId","id","dotNotationName","filter","export","map","type","response","has","composedPrimitives","p","Error","method","path","matchingSpecResponse","specResponse","content","mediaTypes","Object","keys","mediaType","responseContent","responseSchema","schema","augmentModelFromSchema","isJsonlStreaming","itemSchemaModel","buildOrReferenceModel","itemSchema","specParametersByKey","parameter","push","specParameter","in","prop","specParameterSchema","augmentBodyParameter","collectionFormat","getCollectionFormat","allowReserved","style","pathStyle","pathExplode","explode","specBody","requestBody","bodySchema","position","spaceDelimited","pipeDelimited","simple","form","canInlineBody","body","hasClashingPropertyName","properties","some","param","parametersByPosition","reduce","acc","explicitRequestBodyParameter","entries","description","isRequired","matchingSpecModel","specModel","property","matchingSpecProperty","specProperty","discriminator","typescriptPropertyName","propertyName","seen","Map","existing","get","undefined","set","marshallingKey","m","visiting","Set","includes","format","isEnum","link","join","referenced","nested","add","members","composedModels","member","sort","fields","key","memberName","parametersBody","Array","isArray","chosenMediaType","mt","endsWith","isPrimitive","isTagged","tags","tag","$ref","object","fromEntries","startsWith","visited","deprecated","openapiType","enum","additionalProperties","additionalPropertiesModel","explicitProperties","patternProperties","hasAdditionalProperties","hasPatternProperties","patternPropertiesModels","pattern","patternProperty","entry","recurse","target","subSchema","items","memberSchemas","prefixItems","i","pythonName","pythonType","isOperationMutation","MUTATION","QUERY","augmentInfiniteQuery","paginationDisabled","cursorPropertyName","getCursorOptions","cursorProperty","isInfiniteQuery","infiniteQueryCursorProperty","cursor","CURSOR","options","enabled","inputToken","isMutation","isQuery","isStreaming","STREAMING","res","jsonlResponse"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,aAAa,iBAAiB;AACrC,OAAOC,UAAU,cAAc;AAC/B,OAAOC,YAAY,gBAAgB;AAEnC,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,WAAW,EACXC,UAAU,QACL,uBAAuB;AAC9B,SACEC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,gBAAgB,EAChBC,gBAAgB,QACX,8BAA8B;AACrC,SACEC,gBAAgB,EAChBC,qBAAqB,EAGrBC,WAAW,EACXC,oBAAoB,EACpBC,iBAAiB,EAKjBC,eAAe,EAEfC,uBAAuB,EACvBC,iBAAiB,QAEZ,0BAA0B;AACjC,SAASC,8BAA8B,QAAQ,iBAAiB;AAChE,SACEC,eAAe,EACfC,gBAAgB,EAChBC,sBAAsB,EACtBC,gBAAgB,EAChBC,sBAAsB,EACtBC,qBAAqB,EACrBC,SAAS,EACTC,gBAAgB,QACX,cAAc;AACrB,SAASC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,YAAY;AAG1D;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC;IACtC,MAAMC,OAAOd,+BAA+Ba;IAC5C,MAAME,OAAOd,gBAAgBa;IAE7B,MAAME,eAAepB,kBAAkBmB,KAAKE,MAAM;IAElD,KAAK,MAAMC,WAAWH,KAAKI,QAAQ,CAAE;QACnCC,eAAeN,MAAMI,SAASF;IAChC;IAEA,MAAMK,gBAAgBxC,OACpBkC,KAAKI,QAAQ,CAACG,OAAO,CAAC,CAACC,IAAMA,EAAEC,UAAU,GACzC,CAACC,IAAMA,EAAEC,UAAU;IAGrB,0EAA0E;IAC1EX,KAAKE,MAAM,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BAAqBvL;IACvB;AACF"}
|
|
@@ -103,7 +103,12 @@ const isFormMediaType = (mediaType)=>FORM_MEDIA_TYPES.includes(mediaType.split('
|
|
|
103
103
|
const hasSubSchemasToVisit = (schema)=>!!schema && !isRef(schema) && ([
|
|
104
104
|
'object',
|
|
105
105
|
'array'
|
|
106
|
-
].includes(schema.type) ||
|
|
106
|
+
].includes(schema.type) || // `type` is optional, and `properties` implies an object — which is how the
|
|
107
|
+
// parser already classifies one. Requiring the explicit `type` left such a
|
|
108
|
+
// schema unhoisted, so an `allOf` member written that way stayed inline and
|
|
109
|
+
// was taken for a non-object, rejecting the whole document.
|
|
110
|
+
!!schema.properties || // `patternProperties` is JSON Schema, so it is not on the 3.0 type.
|
|
111
|
+
!!schema.patternProperties || isCompositeSchema(schema) || !!schema.not || schema.type === 'string' && !!schema.enum);
|
|
107
112
|
const filterInlineCompositeSchemas = (schemas, nameParts, namePartPrefix, propPath)=>{
|
|
108
113
|
let inlineSchemaIndex = 0;
|
|
109
114
|
return schemas.flatMap((s, i)=>{
|
|
@@ -247,8 +252,14 @@ const hoistInlineObjectSubSchemas = (nameParts, schema, seenModelNameCounts)=>{
|
|
|
247
252
|
];
|
|
248
253
|
// Hoist these recursively first (ie depth first search) so that we don't miss refs
|
|
249
254
|
const recursiveRefs = inlineSubSchemas.flatMap((s)=>hoistInlineObjectSubSchemas(s.nameParts, s.schema, seenModelNameCounts));
|
|
250
|
-
// Clone the object subschemas to build the refs. Note that only objects with
|
|
251
|
-
|
|
255
|
+
// Clone the object subschemas to build the refs. Note that only objects with
|
|
256
|
+
// "properties" are hoisted as these are non-dictionary types. `type` is
|
|
257
|
+
// optional in OpenAPI and `properties` implies an object, so a schema written
|
|
258
|
+
// without it counts — the parser classifies one the same way, and requiring
|
|
259
|
+
// the explicit `type` left it inline where an `allOf` member is then taken for
|
|
260
|
+
// a non-object and the whole document rejected.
|
|
261
|
+
const isObjectSchema = (s)=>(s.type === 'object' || s.type === undefined) && !!(s.properties || s.patternProperties);
|
|
262
|
+
const refs = inlineSubSchemas.filter((s)=>isObjectSchema(s.schema) || isCompositeSchema(s.schema) || s.schema.type === 'string' && s.schema.enum).map((s)=>{
|
|
252
263
|
const name = createUniqueModelName(s.nameParts, seenModelNameCounts);
|
|
253
264
|
const $ref = `#/components/schemas/${name}`;
|
|
254
265
|
const ref = {
|
|
@@ -259,10 +270,17 @@ const hoistInlineObjectSubSchemas = (nameParts, schema, seenModelNameCounts)=>{
|
|
|
259
270
|
'x-aws-nx-hoisted': true
|
|
260
271
|
})
|
|
261
272
|
};
|
|
262
|
-
// Replace each subschema with a ref in the spec
|
|
273
|
+
// Replace each subschema with a ref in the spec. `nullable` describes this
|
|
274
|
+
// use of the schema rather than the schema itself, so it stays beside the
|
|
275
|
+
// ref: moving it onto the hoisted definition made a required nullable
|
|
276
|
+
// object non-nullable here, and would have made every other user of the
|
|
277
|
+
// hoisted schema nullable instead.
|
|
263
278
|
const schemaWithPropToReplace = s.propPath.slice(0, -1).reduce((resolvedInSchema, pathPart)=>resolvedInSchema?.[pathPart], schema);
|
|
264
279
|
if (schemaWithPropToReplace) {
|
|
265
|
-
schemaWithPropToReplace[s.propPath[s.propPath.length - 1]] = {
|
|
280
|
+
schemaWithPropToReplace[s.propPath[s.propPath.length - 1]] = s.schema.nullable ? {
|
|
281
|
+
$ref,
|
|
282
|
+
nullable: true
|
|
283
|
+
} : {
|
|
266
284
|
$ref
|
|
267
285
|
};
|
|
268
286
|
}
|
|
@@ -540,17 +558,24 @@ const hoistInlineObjectSubSchemas = (nameParts, schema, seenModelNameCounts)=>{
|
|
|
540
558
|
});
|
|
541
559
|
}
|
|
542
560
|
});
|
|
543
|
-
// "Inline" any refs to non objects/enums
|
|
561
|
+
// "Inline" any refs to non objects/enums.
|
|
562
|
+
//
|
|
563
|
+
// The substituted body is itself walked for refs, so a chain — an array whose
|
|
564
|
+
// items are a named scalar — collapses in one pass. Substituting the array
|
|
565
|
+
// without following through left `items` pointing at a schema this same pass
|
|
566
|
+
// deletes, so the client referred to a type nothing declared and the emitted
|
|
567
|
+
// TypeScript did not compile.
|
|
544
568
|
const inlinedRefs = new Set();
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
569
|
+
const inlineNonObjectRefs = (value)=>cloneDeepWith(value, (v)=>{
|
|
570
|
+
if (v && typeof v === 'object' && v.$ref) {
|
|
571
|
+
const resolved = resolveRef(spec, v.$ref);
|
|
572
|
+
if (resolved && resolved.type && resolved.type !== 'object' && !(resolved.type === 'string' && resolved.enum)) {
|
|
573
|
+
inlinedRefs.add(v.$ref);
|
|
574
|
+
return inlineNonObjectRefs(resolved);
|
|
575
|
+
}
|
|
551
576
|
}
|
|
552
|
-
}
|
|
553
|
-
|
|
577
|
+
});
|
|
578
|
+
spec = inlineNonObjectRefs(spec);
|
|
554
579
|
// Delete the non object schemas that were inlined
|
|
555
580
|
[
|
|
556
581
|
...inlinedRefs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/normalise.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport cloneDeepWith from 'lodash.clonedeepwith';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport {\n camelCase,\n pascalCase,\n toClassName,\n upperFirst,\n} from '../../utils/names.js';\nimport { STREAMING_CONTENT_TYPES } from './codegen-data/types.js';\nimport { isRef, resolveIfRef, resolveRef, splitRef } from './refs.js';\nimport type { Spec } from './types.js';\n\ninterface SubSchema {\n readonly nameParts: string[];\n readonly schema: OpenAPIV3.SchemaObject;\n readonly propPath: (string | number)[];\n}\n\ninterface SubSchemaRef {\n readonly $ref: string;\n readonly name: string;\n readonly schema: OpenAPIV3.SchemaObject;\n}\n\n/**\n * Normalise schema names to valid TypeScript identifiers.\n * Converts names with hyphens or other invalid characters to PascalCase.\n * Throws an error if normalisation would create a name clash.\n */\nconst normaliseSchemaNames = (spec: Spec): Spec => {\n const schemaNameMapping: { [oldName: string]: string } = {};\n const originalNames = Object.keys(spec.components?.schemas ?? {});\n const existingSchemaNames = new Set(originalNames);\n\n // The name each schema resolves to (its normalised form, or itself when it\n // needs no normalisation). Used to detect two distinct schemas that would\n // collapse onto the same identifier.\n const resolvedNameOwners: { [resolvedName: string]: string } = {};\n\n // Build mapping of old names to new names\n originalNames.forEach((name) => {\n const normalizedName = toClassName(name);\n if (normalizedName !== name) {\n // Check if the normalized name would clash with an existing schema\n if (existingSchemaNames.has(normalizedName)) {\n throw new Error(\n `Schema name normalization conflict: \"${name}\" would be normalized to \"${normalizedName}\", but a schema with that name already exists. Please rename one of these schemas in your OpenAPI specification.`,\n );\n }\n schemaNameMapping[name] = normalizedName;\n }\n\n // Detect two distinct schemas resolving to the same name (e.g. \"Foo-Bar\"\n // and \"Foo.Bar\" both normalise to \"FooBar\"), which would otherwise\n // silently overwrite one another.\n const owner = resolvedNameOwners[normalizedName];\n if (owner !== undefined) {\n throw new Error(\n `Schema name normalization conflict: \"${name}\" and \"${owner}\" both normalize to \"${normalizedName}\". Please rename one of these schemas in your OpenAPI specification.`,\n );\n }\n resolvedNameOwners[normalizedName] = name;\n });\n\n // If no normalization needed, return spec as-is\n if (Object.keys(schemaNameMapping).length === 0) {\n return spec;\n }\n\n // Update all $ref references throughout the spec\n spec = cloneDeepWith(spec, (v) => {\n if (isRef(v)) {\n const parts = splitRef(v.$ref);\n if (\n parts.length === 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n const oldName = parts[2];\n const newName = schemaNameMapping[oldName];\n if (newName) {\n return { $ref: `#/components/schemas/${newName}` };\n }\n }\n }\n });\n\n // Rename schema keys, recording the original name so downstream code can\n // recover the on-the-wire value (e.g. an implicit discriminator matches on\n // the original schema name, not its normalised identifier).\n Object.entries(schemaNameMapping).forEach(([oldName, newName]) => {\n const schema = spec.components!.schemas![oldName];\n if (schema && !isRef(schema)) {\n (schema as { 'x-aws-nx-original-name'?: string })[\n 'x-aws-nx-original-name'\n ] = oldName;\n }\n spec.components!.schemas![newName] = schema;\n delete spec.components!.schemas![oldName];\n });\n\n return spec;\n};\n\nconst isCompositeSchema = (schema: OpenAPIV3.SchemaObject) =>\n !!schema.allOf || !!schema.anyOf || !!schema.oneOf;\n\n/**\n * The media type whose schema is hoisted for a request/response: prefer\n * `application/json`, falling back to any `+json` vendored type (e.g.\n * `application/problem+json`).\n */\nconst preferredJsonMediaType = (mediaTypes: string[]): string | undefined =>\n mediaTypes.find((mediaType) => mediaType === 'application/json') ??\n mediaTypes.find((mediaType) => mediaType.split(';')[0].endsWith('+json'));\n\nconst FORM_MEDIA_TYPES = [\n 'multipart/form-data',\n 'application/x-www-form-urlencoded',\n];\n\nconst isFormMediaType = (mediaType: string): boolean =>\n FORM_MEDIA_TYPES.includes(mediaType.split(';')[0]);\n\n/**\n * Whether a `contentMediaType` denotes binary (rather than textual/JSON)\n * content — an octet-stream, image, audio, etc.\n */\nconst isBinaryContentMediaType = (contentMediaType: string): boolean =>\n !(\n contentMediaType.startsWith('text/') ||\n contentMediaType === 'application/json' ||\n contentMediaType.endsWith('+json') ||\n contentMediaType === 'application/xml'\n );\n\n/**\n * Rewrite file string fields of a form body to `format: binary` so the\n * generator types them as `Blob`. FastAPI emits an identical schema\n * (`{type: string, contentMediaType: ...}`) for a multipart file field and for\n * `bytes` in a JSON body; only the enclosing media type distinguishes them, so\n * this promotion is scoped to form bodies. A base64 `contentEncoding` or a\n * textual/JSON `contentMediaType` keeps the field a string. `format: binary` is\n * left untouched (already binary anywhere).\n */\nconst markFormBinaryFields = (schema: OpenAPIV3.SchemaObject): void => {\n Object.values(schema.properties ?? {}).forEach((prop) => {\n if (isRef(prop)) return;\n const s = prop as OpenAPIV3.SchemaObject & {\n contentMediaType?: string;\n contentEncoding?: string;\n };\n if (\n s.type === 'string' &&\n s.format !== 'binary' &&\n s.contentMediaType &&\n !s.contentEncoding &&\n isBinaryContentMediaType(s.contentMediaType)\n ) {\n s.format = 'binary';\n }\n });\n};\n\nconst hasSubSchemasToVisit = (\n schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject,\n): schema is OpenAPIV3.SchemaObject =>\n !!schema &&\n !isRef(schema) &&\n (['object', 'array'].includes(schema.type as any) ||\n isCompositeSchema(schema) ||\n !!schema.not ||\n (schema.type === 'string' && !!schema.enum));\n\nconst filterInlineCompositeSchemas = (\n schemas: (OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject)[],\n nameParts: string[],\n namePartPrefix: string,\n propPath: (string | number)[],\n): SubSchema[] => {\n let inlineSchemaIndex = 0;\n return schemas.flatMap((s, i) => {\n if (hasSubSchemasToVisit(s)) {\n const subSchema: SubSchema = {\n nameParts: s.title\n ? [pascalCase(s.title)]\n : [\n ...nameParts,\n `${namePartPrefix}${inlineSchemaIndex === 0 ? '' : inlineSchemaIndex}`,\n ],\n schema: s,\n propPath: [...propPath, i],\n };\n inlineSchemaIndex++;\n return [subSchema];\n }\n return [];\n });\n};\n\n/**\n * Returns a unique model/schema name for any models which we hoist\n */\nconst createUniqueModelName = (\n nameParts: string[],\n seenModelNameCounts: { [name: string]: number },\n): string => {\n // Normalise each part to a class-name form (stripping `_`, hyphens, etc) so\n // the hoisted schema name matches what `toTypeScriptModelName`/`toClassName`\n // later derive — otherwise a part like `store_photos` yields a `Store_photos`\n // schema whose reference (`StorePhotos`) no longer resolves.\n const candidateName = nameParts.map(toClassName).join('');\n\n const seenModelNameCount = seenModelNameCounts[candidateName];\n\n // We have not seen this name so we're free to use it\n if (seenModelNameCount === undefined) {\n seenModelNameCounts[candidateName] = 1;\n return candidateName;\n }\n\n // We have seen the name before, so we must disambiguate\n seenModelNameCounts[candidateName]++;\n return `${candidateName}${seenModelNameCount}`;\n};\n\nconst hoistInlineObjectSubSchemas = (\n nameParts: string[],\n schema: OpenAPIV3.SchemaObject,\n seenModelNameCounts: { [name: string]: number },\n): SubSchemaRef[] => {\n // Find all the inline subschemas we should visit\n const inlineSubSchemas: SubSchema[] = [\n ...(hasSubSchemasToVisit(schema.not)\n ? [\n {\n nameParts: schema.not?.title\n ? [pascalCase(schema.not?.title)]\n : [...nameParts, 'Not'],\n schema: schema.not,\n propPath: ['not'],\n },\n ]\n : []),\n ...(schema.anyOf\n ? filterInlineCompositeSchemas(schema.anyOf, nameParts, 'AnyOf', [\n 'anyOf',\n ])\n : []),\n ...(schema.allOf\n ? filterInlineCompositeSchemas(schema.allOf, nameParts, 'AllOf', [\n 'allOf',\n ])\n : []),\n ...(schema.oneOf\n ? filterInlineCompositeSchemas(schema.oneOf, nameParts, 'OneOf', [\n 'oneOf',\n ])\n : []),\n ...('items' in schema && hasSubSchemasToVisit(schema.items)\n ? [\n {\n nameParts: schema.items?.title\n ? [pascalCase(schema.items?.title)]\n : [...nameParts, 'Item'],\n schema: schema.items,\n propPath: ['items'],\n },\n ]\n : []),\n ...(\n (schema as { prefixItems?: OpenAPIV3.SchemaObject[] }).prefixItems ?? []\n ).flatMap((s, i) =>\n hasSubSchemasToVisit(s)\n ? [\n {\n nameParts: s.title\n ? [pascalCase(s.title)]\n : [...nameParts, 'Item', `${i}`],\n schema: s,\n propPath: ['prefixItems', i],\n },\n ]\n : [],\n ),\n ...Object.entries(schema.properties ?? {})\n .filter(([, s]) => hasSubSchemasToVisit(s))\n .map(([name, s]) => ({\n nameParts: (s as OpenAPIV3.SchemaObject).title\n ? [pascalCase((s as OpenAPIV3.SchemaObject).title)]\n : [...nameParts, name],\n schema: s as OpenAPIV3.SchemaObject,\n propPath: ['properties', name],\n })),\n ...(typeof schema.additionalProperties !== 'boolean' &&\n hasSubSchemasToVisit(schema.additionalProperties)\n ? [\n {\n nameParts: schema.additionalProperties?.title\n ? [pascalCase(schema.additionalProperties?.title)]\n : [...nameParts, 'Value'],\n schema: schema.additionalProperties,\n propPath: ['additionalProperties'],\n },\n ]\n : []),\n ...Object.entries((schema as any).patternProperties ?? {})\n .filter(([, s]) => hasSubSchemasToVisit(s))\n .map(([pattern, s], i) => ({\n nameParts: (s as OpenAPIV3.SchemaObject).title\n ? [pascalCase((s as OpenAPIV3.SchemaObject).title)]\n : [...nameParts, pascalCase(pattern), `${i}`],\n schema: s as OpenAPIV3.SchemaObject,\n propPath: ['patternProperties', pattern],\n })),\n ];\n\n // Hoist these recursively first (ie depth first search) so that we don't miss refs\n const recursiveRefs = inlineSubSchemas.flatMap((s) =>\n hoistInlineObjectSubSchemas(s.nameParts, s.schema, seenModelNameCounts),\n );\n\n // Clone the object subschemas to build the refs. Note that only objects with \"properties\" are hoisted as these are non-dictionary types\n const refs = inlineSubSchemas\n .filter(\n (s) =>\n (s.schema.type === 'object' && s.schema.properties) ||\n isCompositeSchema(s.schema) ||\n (s.schema.type === 'object' && (s.schema as any).patternProperties) ||\n (s.schema.type === 'string' && s.schema.enum),\n )\n .map((s) => {\n const name = createUniqueModelName(s.nameParts, seenModelNameCounts);\n\n const $ref = `#/components/schemas/${name}`;\n const ref = {\n $ref,\n name,\n schema: structuredClone({\n ...s.schema,\n 'x-aws-nx-hoisted': true,\n }),\n };\n\n // Replace each subschema with a ref in the spec\n const schemaWithPropToReplace = s.propPath\n .slice(0, -1)\n .reduce(\n (resolvedInSchema, pathPart) => resolvedInSchema?.[pathPart],\n schema,\n );\n if (schemaWithPropToReplace) {\n schemaWithPropToReplace[s.propPath[s.propPath.length - 1]] = { $ref };\n }\n\n return ref;\n });\n\n return [...refs, ...recursiveRefs];\n};\n\n/**\n * Rewrites OpenAPI 3.1 `const` schemas to the semantically equivalent `enum`\n * form. FastAPI emits `{type: 'string', const: 'X'}` for `Literal['X']`; the\n * parser understands the enum shape, whereas the const shape would synthesise\n * phantom named references.\n */\nconst rewriteConstToEnum = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n 'const' in v &&\n !('enum' in v)\n ) {\n const { const: constValue, ...rest } = v;\n // Recurse with the same rewrite so consts nested within a rewritten\n // schema are also rewritten.\n return cloneDeepWith({ ...rest, enum: [constValue] }, rewrite);\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Rewrites a composite schema with sibling `properties`/`required` (a valid\n * JSON Schema conjunction, common in FastAPI/Pydantic output) into an\n * equivalent extra `allOf` member, so the parser sees a pure composite and the\n * sibling fields are neither dropped from the type nor stripped when\n * marshalling.\n */\nconst rewriteCompositeSiblingProperties = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Array.isArray(v.allOf) &&\n v.properties\n ) {\n const { properties, required, type: _type, ...rest } = v;\n return cloneDeepWith(\n {\n ...rest,\n allOf: [\n ...v.allOf,\n {\n type: 'object',\n properties,\n ...(required ? { required } : {}),\n },\n ],\n },\n rewrite,\n );\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Rewrites an OpenAPI 3.1 multi-type schema (`type: ['integer', 'string']`)\n * into the equivalent `anyOf` of single-type schemas, dropping `null` from the\n * list and marking the schema nullable instead. This lets the parser render a\n * proper union rather than collapsing to the first declared type.\n */\nconst rewriteMultiTypeToAnyOf = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Array.isArray(v.type) &&\n !('anyOf' in v) &&\n !('oneOf' in v) &&\n !('allOf' in v) &&\n !('enum' in v)\n ) {\n const { type, nullable, ...rest } = v;\n const nonNull = (type as string[]).filter((t) => t !== 'null');\n const isNullable = nullable === true || nonNull.length !== type.length;\n // Recurse with the same rewrite so multi-type schemas nested within a\n // rewritten schema (e.g. the items of a nullable array) are also\n // rewritten.\n // A single non-null type is not a union; keep it as a plain typed schema.\n if (nonNull.length <= 1) {\n return cloneDeepWith(\n {\n ...rest,\n ...(nonNull.length === 1 ? { type: nonNull[0] } : {}),\n ...(isNullable ? { nullable: true } : {}),\n },\n rewrite,\n );\n }\n return cloneDeepWith(\n {\n ...rest,\n anyOf: nonNull.map((t) => ({ type: t })),\n ...(isNullable ? { nullable: true } : {}),\n },\n rewrite,\n );\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Inlines `$ref` path items so that every operation is visited by the\n * normalisation below (operationId assignment, schema hoisting). Each path\n * gets its own copy, so paths sharing a path item are normalised\n * independently.\n */\nconst inlinePathItemRefs = (spec: Spec): void => {\n Object.entries(spec.paths ?? {}).forEach(([path, pathItem]) => {\n if (isRef(pathItem)) {\n const { $ref, ...rest } = pathItem;\n spec.paths![path] = {\n ...structuredClone(resolveRef(spec, $ref)),\n ...rest,\n };\n }\n });\n};\n\n/**\n * In order to ensure we generate models consistently whether or not users used refs or inline schemas,\n * we hoist any inline refs to non-primitives\n */\nexport const normaliseOpenApiSpecForCodeGen = (inSpec: Spec): Spec => {\n // Clone the spec so we're free to mutate it\n let spec = cloneDeepWith(inSpec);\n\n inlinePathItemRefs(spec);\n spec = rewriteConstToEnum(spec);\n spec = rewriteMultiTypeToAnyOf(spec);\n spec = rewriteCompositeSiblingProperties(spec);\n\n // Ensure spec has schemas set\n if (!spec?.components?.schemas) {\n spec.components = {\n ...spec.components,\n };\n spec.components.schemas = {\n ...spec.components.schemas,\n };\n }\n\n const seenOperationIds = new Set<string>();\n const duplicatedOperationIds = new Set<string>();\n\n // Make sure all operationIds are camelCase, and find which ones are duplicated\n Object.entries(spec.paths ?? {}).forEach(([path, pathOps]) =>\n Object.entries(pathOps ?? {}).forEach(([method, op]) => {\n const operation = resolveIfRef(spec, op);\n if (operation && typeof operation === 'object') {\n const operationId = camelCase(\n (operation as any).operationId ?? `${method}-${path}`,\n );\n (operation as any).operationId = operationId;\n if (seenOperationIds.has(operationId)) {\n duplicatedOperationIds.add(operationId);\n }\n seenOperationIds.add(operationId);\n }\n }),\n );\n\n // Reset seen operation ids\n seenOperationIds.clear();\n\n const untagged = Symbol('untagged');\n const seenOperationIdsByTag: { [tag: string | symbol]: Set<string> } = {};\n\n // \"Hoist\" inline request and response schemas\n Object.entries(spec.paths ?? {}).forEach(([path, pathOps]) =>\n Object.entries(pathOps ?? {}).forEach(([method, op]) => {\n const operation = resolveIfRef(spec, op);\n if (operation && typeof operation === 'object') {\n const tags: string[] = (operation as any).tags ?? [];\n const operationId = (operation as any).operationId as string;\n\n // Allow operations to have the same id\n let deduplicatedOpId = operationId;\n let deduplicatedDotNotationOpId = operationId;\n\n // Attempt to deduplicate the operationId by its tags\n if (duplicatedOperationIds.has(operationId)) {\n deduplicatedOpId = camelCase(\n tags.map((t) => `${t}-`).join('') + operationId,\n );\n deduplicatedDotNotationOpId =\n tags.map((t) => `${camelCase(t)}.`).join('') +\n camelCase(operationId);\n }\n\n (operation as any)['x-aws-nx-deduplicated-op-id'] = deduplicatedOpId;\n (operation as any)['x-aws-nx-deduplicated-dot-op-id'] =\n deduplicatedDotNotationOpId;\n\n seenOperationIds.add(deduplicatedOpId);\n\n // Throw an error for any duplicated operation ids with the same tag, or untagged\n [...(tags.length === 0 ? [untagged] : tags)].forEach((tag) => {\n if (\n seenOperationIdsByTag[tag] &&\n seenOperationIdsByTag[tag].has(operationId)\n ) {\n throw new Error(\n tag === untagged\n ? `Untagged operations cannot have the same operationId (${operationId})`\n : `Operations with the same tag (${String(tag)}) cannot have the same operationId (${operationId})`,\n );\n }\n\n seenOperationIdsByTag[tag] = new Set([\n ...(seenOperationIdsByTag[tag] ?? []),\n operationId,\n ]);\n });\n\n if ('responses' in operation) {\n Object.entries(operation.responses ?? {}).forEach(([code, res]) => {\n const response = resolveIfRef(spec, res);\n const jsonMediaType = preferredJsonMediaType(\n Object.keys(response?.content ?? {}),\n );\n const jsonResponseSchema = jsonMediaType\n ? response!.content![jsonMediaType].schema\n : undefined;\n if (\n jsonResponseSchema &&\n !isRef(jsonResponseSchema) &&\n (['object', 'array'].includes(jsonResponseSchema.type!) ||\n isCompositeSchema(jsonResponseSchema) ||\n (jsonResponseSchema?.type === 'string' &&\n jsonResponseSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}${code}Response`;\n spec.components!.schemas![schemaName] = jsonResponseSchema;\n response!.content![jsonMediaType!].schema = {\n $ref: `#/components/schemas/${schemaName}`,\n };\n }\n\n // Hoist inline streaming item schemas (OpenAPI 3.2 itemSchema) so\n // each streamed item gets a named model.\n STREAMING_CONTENT_TYPES.forEach((mediaType) => {\n const streamingContent = response?.content?.[mediaType] as\n | { itemSchema?: OpenAPIV3.SchemaObject }\n | undefined;\n const itemSchema = streamingContent?.itemSchema;\n if (\n itemSchema &&\n !isRef(itemSchema) &&\n (['object', 'array'].includes(itemSchema.type!) ||\n isCompositeSchema(itemSchema) ||\n (itemSchema.type === 'string' && itemSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}${code}ResponseItem`;\n spec.components!.schemas![schemaName] = itemSchema;\n streamingContent.itemSchema = {\n $ref: `#/components/schemas/${schemaName}`,\n } as OpenAPIV3.SchemaObject;\n }\n });\n });\n }\n if ('requestBody' in operation) {\n const requestBody = resolveIfRef(spec, operation.requestBody);\n const contentMediaTypes = Object.keys(requestBody?.content ?? {});\n // Hoist the JSON body, falling back to a form-data body (multipart or\n // urlencoded) so an inline form object is fully typed and marshalled\n // rather than left `unknown`.\n const bodyMediaType =\n preferredJsonMediaType(contentMediaTypes) ??\n contentMediaTypes.find(isFormMediaType);\n const bodyContentSchema = bodyMediaType\n ? requestBody!.content![bodyMediaType].schema\n : undefined;\n // A form body's binary string fields are file uploads (Blob). Mark\n // the resolved schema (inline or $ref target) before hoisting.\n if (bodyMediaType && isFormMediaType(bodyMediaType)) {\n const resolved = resolveIfRef(spec, bodyContentSchema) as\n | OpenAPIV3.SchemaObject\n | undefined;\n if (resolved) markFormBinaryFields(resolved);\n }\n if (\n bodyContentSchema &&\n !isRef(bodyContentSchema) &&\n (['object', 'array'].includes(bodyContentSchema.type!) ||\n isCompositeSchema(bodyContentSchema) ||\n (bodyContentSchema?.type === 'string' && bodyContentSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}RequestContent`;\n spec.components!.schemas![schemaName] = bodyContentSchema;\n requestBody!.content![bodyMediaType!].schema = {\n $ref: `#/components/schemas/${schemaName}`,\n };\n }\n }\n\n // Hoist parameter schemas. Composite and inline-object schemas are\n // hoisted to named models so the parameter is fully typed (e.g. a\n // `deepObject` query param's members are marshalled, not left `unknown`).\n if ('parameters' in operation) {\n (operation.parameters ?? []).forEach((p) => {\n const param = resolveIfRef(spec, p);\n const paramSchema = param?.schema as\n | OpenAPIV3.SchemaObject\n | undefined;\n if (\n paramSchema &&\n !isRef(paramSchema) &&\n (isCompositeSchema(paramSchema) ||\n (paramSchema.type === 'object' && !!paramSchema.properties))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}Request${upperFirst(param.in)}${upperFirst(camelCase(param.name))}`;\n spec.components!.schemas![schemaName] = paramSchema;\n param.schema = { $ref: `#/components/schemas/${schemaName}` };\n }\n });\n }\n }\n }),\n );\n\n // Normalize schema names to valid TypeScript identifiers (e.g., \"Message-Output\" -> \"MessageOutput\")\n spec = normaliseSchemaNames(spec);\n\n // Initialise the models that we have seen with all schemas.\n // This is required to ensure we do not create any clashing models below\n const seenModelNameCounts = Object.fromEntries(\n Object.keys(spec.components?.schemas ?? {}).map((name) => [name, 1]),\n );\n\n // \"Hoist\" any nested object definitions in arrays/maps that aren't already refs, as parseOpenapi will treat the\n // type as \"any\" if they're defined inline (and not a ref)\n Object.entries(spec.components?.schemas ?? {}).forEach(([name, schema]) => {\n if (!isRef(schema)) {\n const refs = hoistInlineObjectSubSchemas(\n [name],\n schema,\n seenModelNameCounts,\n );\n refs.forEach((ref) => {\n spec.components!.schemas![ref.name] = ref.schema;\n });\n }\n });\n\n // \"Inline\" any refs to non objects/enums\n const inlinedRefs: Set<string> = new Set();\n spec = cloneDeepWith(spec, (v) => {\n if (v && typeof v === 'object' && v.$ref) {\n const resolved = resolveRef(spec, v.$ref);\n if (\n resolved &&\n resolved.type &&\n resolved.type !== 'object' &&\n !(resolved.type === 'string' && resolved.enum)\n ) {\n inlinedRefs.add(v.$ref);\n return resolved;\n }\n }\n });\n\n // Delete the non object schemas that were inlined\n [...inlinedRefs].forEach((ref) => {\n const parts = splitRef(ref);\n if (\n parts.length === 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n delete spec.components!.schemas![parts[2]];\n }\n });\n\n return spec;\n};\n"],"names":["cloneDeepWith","camelCase","pascalCase","toClassName","upperFirst","STREAMING_CONTENT_TYPES","isRef","resolveIfRef","resolveRef","splitRef","normaliseSchemaNames","spec","schemaNameMapping","originalNames","Object","keys","components","schemas","existingSchemaNames","Set","resolvedNameOwners","forEach","name","normalizedName","has","Error","owner","undefined","length","v","parts","$ref","oldName","newName","entries","schema","isCompositeSchema","allOf","anyOf","oneOf","preferredJsonMediaType","mediaTypes","find","mediaType","split","endsWith","FORM_MEDIA_TYPES","isFormMediaType","includes","isBinaryContentMediaType","contentMediaType","startsWith","markFormBinaryFields","values","properties","prop","s","type","format","contentEncoding","hasSubSchemasToVisit","not","enum","filterInlineCompositeSchemas","nameParts","namePartPrefix","propPath","inlineSchemaIndex","flatMap","i","subSchema","title","createUniqueModelName","seenModelNameCounts","candidateName","map","join","seenModelNameCount","hoistInlineObjectSubSchemas","inlineSubSchemas","items","prefixItems","filter","additionalProperties","patternProperties","pattern","recursiveRefs","refs","ref","structuredClone","schemaWithPropToReplace","slice","reduce","resolvedInSchema","pathPart","rewriteConstToEnum","rewrite","Array","isArray","const","constValue","rest","rewriteCompositeSiblingProperties","required","_type","rewriteMultiTypeToAnyOf","nullable","nonNull","t","isNullable","inlinePathItemRefs","paths","path","pathItem","normaliseOpenApiSpecForCodeGen","inSpec","seenOperationIds","duplicatedOperationIds","pathOps","method","op","operation","operationId","add","clear","untagged","Symbol","seenOperationIdsByTag","tags","deduplicatedOpId","deduplicatedDotNotationOpId","tag","String","responses","code","res","response","jsonMediaType","content","jsonResponseSchema","schemaName","streamingContent","itemSchema","requestBody","contentMediaTypes","bodyMediaType","bodyContentSchema","resolved","parameters","p","param","paramSchema","in","fromEntries","inlinedRefs"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,mBAAmB,uBAAuB;AAEjD,SACEC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,UAAU,QACL,uBAAuB;AAC9B,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,KAAK,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,YAAY;AAetE;;;;CAIC,GACD,MAAMC,uBAAuB,CAACC;IAC5B,MAAMC,oBAAmD,CAAC;IAC1D,MAAMC,gBAAgBC,OAAOC,IAAI,CAACJ,KAAKK,UAAU,EAAEC,WAAW,CAAC;IAC/D,MAAMC,sBAAsB,IAAIC,IAAIN;IAEpC,2EAA2E;IAC3E,0EAA0E;IAC1E,qCAAqC;IACrC,MAAMO,qBAAyD,CAAC;IAEhE,0CAA0C;IAC1CP,cAAcQ,OAAO,CAAC,CAACC;QACrB,MAAMC,iBAAiBpB,YAAYmB;QACnC,IAAIC,mBAAmBD,MAAM;YAC3B,mEAAmE;YACnE,IAAIJ,oBAAoBM,GAAG,CAACD,iBAAiB;gBAC3C,MAAM,IAAIE,MACR,CAAC,qCAAqC,EAAEH,KAAK,0BAA0B,EAAEC,eAAe,gHAAgH,CAAC;YAE7M;YACAX,iBAAiB,CAACU,KAAK,GAAGC;QAC5B;QAEA,yEAAyE;QACzE,mEAAmE;QACnE,kCAAkC;QAClC,MAAMG,QAAQN,kBAAkB,CAACG,eAAe;QAChD,IAAIG,UAAUC,WAAW;YACvB,MAAM,IAAIF,MACR,CAAC,qCAAqC,EAAEH,KAAK,OAAO,EAAEI,MAAM,qBAAqB,EAAEH,eAAe,oEAAoE,CAAC;QAE3K;QACAH,kBAAkB,CAACG,eAAe,GAAGD;IACvC;IAEA,gDAAgD;IAChD,IAAIR,OAAOC,IAAI,CAACH,mBAAmBgB,MAAM,KAAK,GAAG;Q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,IACEoH,YACAA,SAAS1F,IAAI,IACb0F,SAAS1F,IAAI,KAAK,YAClB,CAAE0F,CAAAA,SAAS1F,IAAI,KAAK,YAAY0F,SAASrF,IAAI,AAAD,GAC5C;gBACA4F,YAAY/B,GAAG,CAAC9F,EAAEE,IAAI;gBACtB,OAAOoH;YACT;QACF;IACF;IAEA,kDAAkD;IAClD;WAAIO;KAAY,CAACrI,OAAO,CAAC,CAACmE;QACxB,MAAM1D,QAAQrB,SAAS+E;QACvB,IACE1D,MAAMF,MAAM,KAAK,KACjBE,KAAK,CAAC,EAAE,KAAK,gBACbA,KAAK,CAAC,EAAE,KAAK,WACb;YACA,OAAOnB,KAAKK,UAAU,CAAEC,OAAO,AAAC,CAACa,KAAK,CAAC,EAAE,CAAC;QAC5C;IACF;IAEA,OAAOnB;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/normalise.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport cloneDeepWith from 'lodash.clonedeepwith';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport {\n camelCase,\n pascalCase,\n toClassName,\n upperFirst,\n} from '../../utils/names.js';\nimport { STREAMING_CONTENT_TYPES } from './codegen-data/types.js';\nimport { isRef, resolveIfRef, resolveRef, splitRef } from './refs.js';\nimport type { Spec } from './types.js';\n\ninterface SubSchema {\n readonly nameParts: string[];\n readonly schema: OpenAPIV3.SchemaObject;\n readonly propPath: (string | number)[];\n}\n\ninterface SubSchemaRef {\n readonly $ref: string;\n readonly name: string;\n readonly schema: OpenAPIV3.SchemaObject;\n}\n\n/**\n * Normalise schema names to valid TypeScript identifiers.\n * Converts names with hyphens or other invalid characters to PascalCase.\n * Throws an error if normalisation would create a name clash.\n */\nconst normaliseSchemaNames = (spec: Spec): Spec => {\n const schemaNameMapping: { [oldName: string]: string } = {};\n const originalNames = Object.keys(spec.components?.schemas ?? {});\n const existingSchemaNames = new Set(originalNames);\n\n // The name each schema resolves to (its normalised form, or itself when it\n // needs no normalisation). Used to detect two distinct schemas that would\n // collapse onto the same identifier.\n const resolvedNameOwners: { [resolvedName: string]: string } = {};\n\n // Build mapping of old names to new names\n originalNames.forEach((name) => {\n const normalizedName = toClassName(name);\n if (normalizedName !== name) {\n // Check if the normalized name would clash with an existing schema\n if (existingSchemaNames.has(normalizedName)) {\n throw new Error(\n `Schema name normalization conflict: \"${name}\" would be normalized to \"${normalizedName}\", but a schema with that name already exists. Please rename one of these schemas in your OpenAPI specification.`,\n );\n }\n schemaNameMapping[name] = normalizedName;\n }\n\n // Detect two distinct schemas resolving to the same name (e.g. \"Foo-Bar\"\n // and \"Foo.Bar\" both normalise to \"FooBar\"), which would otherwise\n // silently overwrite one another.\n const owner = resolvedNameOwners[normalizedName];\n if (owner !== undefined) {\n throw new Error(\n `Schema name normalization conflict: \"${name}\" and \"${owner}\" both normalize to \"${normalizedName}\". Please rename one of these schemas in your OpenAPI specification.`,\n );\n }\n resolvedNameOwners[normalizedName] = name;\n });\n\n // If no normalization needed, return spec as-is\n if (Object.keys(schemaNameMapping).length === 0) {\n return spec;\n }\n\n // Update all $ref references throughout the spec\n spec = cloneDeepWith(spec, (v) => {\n if (isRef(v)) {\n const parts = splitRef(v.$ref);\n if (\n parts.length === 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n const oldName = parts[2];\n const newName = schemaNameMapping[oldName];\n if (newName) {\n return { $ref: `#/components/schemas/${newName}` };\n }\n }\n }\n });\n\n // Rename schema keys, recording the original name so downstream code can\n // recover the on-the-wire value (e.g. an implicit discriminator matches on\n // the original schema name, not its normalised identifier).\n Object.entries(schemaNameMapping).forEach(([oldName, newName]) => {\n const schema = spec.components!.schemas![oldName];\n if (schema && !isRef(schema)) {\n (schema as { 'x-aws-nx-original-name'?: string })[\n 'x-aws-nx-original-name'\n ] = oldName;\n }\n spec.components!.schemas![newName] = schema;\n delete spec.components!.schemas![oldName];\n });\n\n return spec;\n};\n\nconst isCompositeSchema = (schema: OpenAPIV3.SchemaObject) =>\n !!schema.allOf || !!schema.anyOf || !!schema.oneOf;\n\n/**\n * The media type whose schema is hoisted for a request/response: prefer\n * `application/json`, falling back to any `+json` vendored type (e.g.\n * `application/problem+json`).\n */\nconst preferredJsonMediaType = (mediaTypes: string[]): string | undefined =>\n mediaTypes.find((mediaType) => mediaType === 'application/json') ??\n mediaTypes.find((mediaType) => mediaType.split(';')[0].endsWith('+json'));\n\nconst FORM_MEDIA_TYPES = [\n 'multipart/form-data',\n 'application/x-www-form-urlencoded',\n];\n\nconst isFormMediaType = (mediaType: string): boolean =>\n FORM_MEDIA_TYPES.includes(mediaType.split(';')[0]);\n\n/**\n * Whether a `contentMediaType` denotes binary (rather than textual/JSON)\n * content — an octet-stream, image, audio, etc.\n */\nconst isBinaryContentMediaType = (contentMediaType: string): boolean =>\n !(\n contentMediaType.startsWith('text/') ||\n contentMediaType === 'application/json' ||\n contentMediaType.endsWith('+json') ||\n contentMediaType === 'application/xml'\n );\n\n/**\n * Rewrite file string fields of a form body to `format: binary` so the\n * generator types them as `Blob`. FastAPI emits an identical schema\n * (`{type: string, contentMediaType: ...}`) for a multipart file field and for\n * `bytes` in a JSON body; only the enclosing media type distinguishes them, so\n * this promotion is scoped to form bodies. A base64 `contentEncoding` or a\n * textual/JSON `contentMediaType` keeps the field a string. `format: binary` is\n * left untouched (already binary anywhere).\n */\nconst markFormBinaryFields = (schema: OpenAPIV3.SchemaObject): void => {\n Object.values(schema.properties ?? {}).forEach((prop) => {\n if (isRef(prop)) return;\n const s = prop as OpenAPIV3.SchemaObject & {\n contentMediaType?: string;\n contentEncoding?: string;\n };\n if (\n s.type === 'string' &&\n s.format !== 'binary' &&\n s.contentMediaType &&\n !s.contentEncoding &&\n isBinaryContentMediaType(s.contentMediaType)\n ) {\n s.format = 'binary';\n }\n });\n};\n\nconst hasSubSchemasToVisit = (\n schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject,\n): schema is OpenAPIV3.SchemaObject =>\n !!schema &&\n !isRef(schema) &&\n (['object', 'array'].includes(schema.type as any) ||\n // `type` is optional, and `properties` implies an object — which is how the\n // parser already classifies one. Requiring the explicit `type` left such a\n // schema unhoisted, so an `allOf` member written that way stayed inline and\n // was taken for a non-object, rejecting the whole document.\n !!schema.properties ||\n // `patternProperties` is JSON Schema, so it is not on the 3.0 type.\n !!(schema as { patternProperties?: unknown }).patternProperties ||\n isCompositeSchema(schema) ||\n !!schema.not ||\n (schema.type === 'string' && !!schema.enum));\n\nconst filterInlineCompositeSchemas = (\n schemas: (OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject)[],\n nameParts: string[],\n namePartPrefix: string,\n propPath: (string | number)[],\n): SubSchema[] => {\n let inlineSchemaIndex = 0;\n return schemas.flatMap((s, i) => {\n if (hasSubSchemasToVisit(s)) {\n const subSchema: SubSchema = {\n nameParts: s.title\n ? [pascalCase(s.title)]\n : [\n ...nameParts,\n `${namePartPrefix}${inlineSchemaIndex === 0 ? '' : inlineSchemaIndex}`,\n ],\n schema: s,\n propPath: [...propPath, i],\n };\n inlineSchemaIndex++;\n return [subSchema];\n }\n return [];\n });\n};\n\n/**\n * Returns a unique model/schema name for any models which we hoist\n */\nconst createUniqueModelName = (\n nameParts: string[],\n seenModelNameCounts: { [name: string]: number },\n): string => {\n // Normalise each part to a class-name form (stripping `_`, hyphens, etc) so\n // the hoisted schema name matches what `toTypeScriptModelName`/`toClassName`\n // later derive — otherwise a part like `store_photos` yields a `Store_photos`\n // schema whose reference (`StorePhotos`) no longer resolves.\n const candidateName = nameParts.map(toClassName).join('');\n\n const seenModelNameCount = seenModelNameCounts[candidateName];\n\n // We have not seen this name so we're free to use it\n if (seenModelNameCount === undefined) {\n seenModelNameCounts[candidateName] = 1;\n return candidateName;\n }\n\n // We have seen the name before, so we must disambiguate\n seenModelNameCounts[candidateName]++;\n return `${candidateName}${seenModelNameCount}`;\n};\n\nconst hoistInlineObjectSubSchemas = (\n nameParts: string[],\n schema: OpenAPIV3.SchemaObject,\n seenModelNameCounts: { [name: string]: number },\n): SubSchemaRef[] => {\n // Find all the inline subschemas we should visit\n const inlineSubSchemas: SubSchema[] = [\n ...(hasSubSchemasToVisit(schema.not)\n ? [\n {\n nameParts: schema.not?.title\n ? [pascalCase(schema.not?.title)]\n : [...nameParts, 'Not'],\n schema: schema.not,\n propPath: ['not'],\n },\n ]\n : []),\n ...(schema.anyOf\n ? filterInlineCompositeSchemas(schema.anyOf, nameParts, 'AnyOf', [\n 'anyOf',\n ])\n : []),\n ...(schema.allOf\n ? filterInlineCompositeSchemas(schema.allOf, nameParts, 'AllOf', [\n 'allOf',\n ])\n : []),\n ...(schema.oneOf\n ? filterInlineCompositeSchemas(schema.oneOf, nameParts, 'OneOf', [\n 'oneOf',\n ])\n : []),\n ...('items' in schema && hasSubSchemasToVisit(schema.items)\n ? [\n {\n nameParts: schema.items?.title\n ? [pascalCase(schema.items?.title)]\n : [...nameParts, 'Item'],\n schema: schema.items,\n propPath: ['items'],\n },\n ]\n : []),\n ...(\n (schema as { prefixItems?: OpenAPIV3.SchemaObject[] }).prefixItems ?? []\n ).flatMap((s, i) =>\n hasSubSchemasToVisit(s)\n ? [\n {\n nameParts: s.title\n ? [pascalCase(s.title)]\n : [...nameParts, 'Item', `${i}`],\n schema: s,\n propPath: ['prefixItems', i],\n },\n ]\n : [],\n ),\n ...Object.entries(schema.properties ?? {})\n .filter(([, s]) => hasSubSchemasToVisit(s))\n .map(([name, s]) => ({\n nameParts: (s as OpenAPIV3.SchemaObject).title\n ? [pascalCase((s as OpenAPIV3.SchemaObject).title)]\n : [...nameParts, name],\n schema: s as OpenAPIV3.SchemaObject,\n propPath: ['properties', name],\n })),\n ...(typeof schema.additionalProperties !== 'boolean' &&\n hasSubSchemasToVisit(schema.additionalProperties)\n ? [\n {\n nameParts: schema.additionalProperties?.title\n ? [pascalCase(schema.additionalProperties?.title)]\n : [...nameParts, 'Value'],\n schema: schema.additionalProperties,\n propPath: ['additionalProperties'],\n },\n ]\n : []),\n ...Object.entries((schema as any).patternProperties ?? {})\n .filter(([, s]) => hasSubSchemasToVisit(s))\n .map(([pattern, s], i) => ({\n nameParts: (s as OpenAPIV3.SchemaObject).title\n ? [pascalCase((s as OpenAPIV3.SchemaObject).title)]\n : [...nameParts, pascalCase(pattern), `${i}`],\n schema: s as OpenAPIV3.SchemaObject,\n propPath: ['patternProperties', pattern],\n })),\n ];\n\n // Hoist these recursively first (ie depth first search) so that we don't miss refs\n const recursiveRefs = inlineSubSchemas.flatMap((s) =>\n hoistInlineObjectSubSchemas(s.nameParts, s.schema, seenModelNameCounts),\n );\n\n // Clone the object subschemas to build the refs. Note that only objects with\n // \"properties\" are hoisted as these are non-dictionary types. `type` is\n // optional in OpenAPI and `properties` implies an object, so a schema written\n // without it counts — the parser classifies one the same way, and requiring\n // the explicit `type` left it inline where an `allOf` member is then taken for\n // a non-object and the whole document rejected.\n const isObjectSchema = (s: OpenAPIV3.SchemaObject): boolean =>\n (s.type === 'object' || s.type === undefined) &&\n !!(s.properties || (s as any).patternProperties);\n const refs = inlineSubSchemas\n .filter(\n (s) =>\n isObjectSchema(s.schema) ||\n isCompositeSchema(s.schema) ||\n (s.schema.type === 'string' && s.schema.enum),\n )\n .map((s) => {\n const name = createUniqueModelName(s.nameParts, seenModelNameCounts);\n\n const $ref = `#/components/schemas/${name}`;\n const ref = {\n $ref,\n name,\n schema: structuredClone({\n ...s.schema,\n 'x-aws-nx-hoisted': true,\n }),\n };\n\n // Replace each subschema with a ref in the spec. `nullable` describes this\n // use of the schema rather than the schema itself, so it stays beside the\n // ref: moving it onto the hoisted definition made a required nullable\n // object non-nullable here, and would have made every other user of the\n // hoisted schema nullable instead.\n const schemaWithPropToReplace = s.propPath\n .slice(0, -1)\n .reduce(\n (resolvedInSchema, pathPart) => resolvedInSchema?.[pathPart],\n schema,\n );\n if (schemaWithPropToReplace) {\n schemaWithPropToReplace[s.propPath[s.propPath.length - 1]] = s.schema\n .nullable\n ? { $ref, nullable: true }\n : { $ref };\n }\n\n return ref;\n });\n\n return [...refs, ...recursiveRefs];\n};\n\n/**\n * Rewrites OpenAPI 3.1 `const` schemas to the semantically equivalent `enum`\n * form. FastAPI emits `{type: 'string', const: 'X'}` for `Literal['X']`; the\n * parser understands the enum shape, whereas the const shape would synthesise\n * phantom named references.\n */\nconst rewriteConstToEnum = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n 'const' in v &&\n !('enum' in v)\n ) {\n const { const: constValue, ...rest } = v;\n // Recurse with the same rewrite so consts nested within a rewritten\n // schema are also rewritten.\n return cloneDeepWith({ ...rest, enum: [constValue] }, rewrite);\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Rewrites a composite schema with sibling `properties`/`required` (a valid\n * JSON Schema conjunction, common in FastAPI/Pydantic output) into an\n * equivalent extra `allOf` member, so the parser sees a pure composite and the\n * sibling fields are neither dropped from the type nor stripped when\n * marshalling.\n */\nconst rewriteCompositeSiblingProperties = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Array.isArray(v.allOf) &&\n v.properties\n ) {\n const { properties, required, type: _type, ...rest } = v;\n return cloneDeepWith(\n {\n ...rest,\n allOf: [\n ...v.allOf,\n {\n type: 'object',\n properties,\n ...(required ? { required } : {}),\n },\n ],\n },\n rewrite,\n );\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Rewrites an OpenAPI 3.1 multi-type schema (`type: ['integer', 'string']`)\n * into the equivalent `anyOf` of single-type schemas, dropping `null` from the\n * list and marking the schema nullable instead. This lets the parser render a\n * proper union rather than collapsing to the first declared type.\n */\nconst rewriteMultiTypeToAnyOf = (spec: Spec): Spec => {\n const rewrite = (v: any): any => {\n if (\n v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n Array.isArray(v.type) &&\n !('anyOf' in v) &&\n !('oneOf' in v) &&\n !('allOf' in v) &&\n !('enum' in v)\n ) {\n const { type, nullable, ...rest } = v;\n const nonNull = (type as string[]).filter((t) => t !== 'null');\n const isNullable = nullable === true || nonNull.length !== type.length;\n // Recurse with the same rewrite so multi-type schemas nested within a\n // rewritten schema (e.g. the items of a nullable array) are also\n // rewritten.\n // A single non-null type is not a union; keep it as a plain typed schema.\n if (nonNull.length <= 1) {\n return cloneDeepWith(\n {\n ...rest,\n ...(nonNull.length === 1 ? { type: nonNull[0] } : {}),\n ...(isNullable ? { nullable: true } : {}),\n },\n rewrite,\n );\n }\n return cloneDeepWith(\n {\n ...rest,\n anyOf: nonNull.map((t) => ({ type: t })),\n ...(isNullable ? { nullable: true } : {}),\n },\n rewrite,\n );\n }\n };\n return cloneDeepWith(spec, rewrite);\n};\n\n/**\n * Inlines `$ref` path items so that every operation is visited by the\n * normalisation below (operationId assignment, schema hoisting). Each path\n * gets its own copy, so paths sharing a path item are normalised\n * independently.\n */\nconst inlinePathItemRefs = (spec: Spec): void => {\n Object.entries(spec.paths ?? {}).forEach(([path, pathItem]) => {\n if (isRef(pathItem)) {\n const { $ref, ...rest } = pathItem;\n spec.paths![path] = {\n ...structuredClone(resolveRef(spec, $ref)),\n ...rest,\n };\n }\n });\n};\n\n/**\n * In order to ensure we generate models consistently whether or not users used refs or inline schemas,\n * we hoist any inline refs to non-primitives\n */\nexport const normaliseOpenApiSpecForCodeGen = (inSpec: Spec): Spec => {\n // Clone the spec so we're free to mutate it\n let spec = cloneDeepWith(inSpec);\n\n inlinePathItemRefs(spec);\n spec = rewriteConstToEnum(spec);\n spec = rewriteMultiTypeToAnyOf(spec);\n spec = rewriteCompositeSiblingProperties(spec);\n\n // Ensure spec has schemas set\n if (!spec?.components?.schemas) {\n spec.components = {\n ...spec.components,\n };\n spec.components.schemas = {\n ...spec.components.schemas,\n };\n }\n\n const seenOperationIds = new Set<string>();\n const duplicatedOperationIds = new Set<string>();\n\n // Make sure all operationIds are camelCase, and find which ones are duplicated\n Object.entries(spec.paths ?? {}).forEach(([path, pathOps]) =>\n Object.entries(pathOps ?? {}).forEach(([method, op]) => {\n const operation = resolveIfRef(spec, op);\n if (operation && typeof operation === 'object') {\n const operationId = camelCase(\n (operation as any).operationId ?? `${method}-${path}`,\n );\n (operation as any).operationId = operationId;\n if (seenOperationIds.has(operationId)) {\n duplicatedOperationIds.add(operationId);\n }\n seenOperationIds.add(operationId);\n }\n }),\n );\n\n // Reset seen operation ids\n seenOperationIds.clear();\n\n const untagged = Symbol('untagged');\n const seenOperationIdsByTag: { [tag: string | symbol]: Set<string> } = {};\n\n // \"Hoist\" inline request and response schemas\n Object.entries(spec.paths ?? {}).forEach(([path, pathOps]) =>\n Object.entries(pathOps ?? {}).forEach(([method, op]) => {\n const operation = resolveIfRef(spec, op);\n if (operation && typeof operation === 'object') {\n const tags: string[] = (operation as any).tags ?? [];\n const operationId = (operation as any).operationId as string;\n\n // Allow operations to have the same id\n let deduplicatedOpId = operationId;\n let deduplicatedDotNotationOpId = operationId;\n\n // Attempt to deduplicate the operationId by its tags\n if (duplicatedOperationIds.has(operationId)) {\n deduplicatedOpId = camelCase(\n tags.map((t) => `${t}-`).join('') + operationId,\n );\n deduplicatedDotNotationOpId =\n tags.map((t) => `${camelCase(t)}.`).join('') +\n camelCase(operationId);\n }\n\n (operation as any)['x-aws-nx-deduplicated-op-id'] = deduplicatedOpId;\n (operation as any)['x-aws-nx-deduplicated-dot-op-id'] =\n deduplicatedDotNotationOpId;\n\n seenOperationIds.add(deduplicatedOpId);\n\n // Throw an error for any duplicated operation ids with the same tag, or untagged\n [...(tags.length === 0 ? [untagged] : tags)].forEach((tag) => {\n if (\n seenOperationIdsByTag[tag] &&\n seenOperationIdsByTag[tag].has(operationId)\n ) {\n throw new Error(\n tag === untagged\n ? `Untagged operations cannot have the same operationId (${operationId})`\n : `Operations with the same tag (${String(tag)}) cannot have the same operationId (${operationId})`,\n );\n }\n\n seenOperationIdsByTag[tag] = new Set([\n ...(seenOperationIdsByTag[tag] ?? []),\n operationId,\n ]);\n });\n\n if ('responses' in operation) {\n Object.entries(operation.responses ?? {}).forEach(([code, res]) => {\n const response = resolveIfRef(spec, res);\n const jsonMediaType = preferredJsonMediaType(\n Object.keys(response?.content ?? {}),\n );\n const jsonResponseSchema = jsonMediaType\n ? response!.content![jsonMediaType].schema\n : undefined;\n if (\n jsonResponseSchema &&\n !isRef(jsonResponseSchema) &&\n (['object', 'array'].includes(jsonResponseSchema.type!) ||\n isCompositeSchema(jsonResponseSchema) ||\n (jsonResponseSchema?.type === 'string' &&\n jsonResponseSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}${code}Response`;\n spec.components!.schemas![schemaName] = jsonResponseSchema;\n response!.content![jsonMediaType!].schema = {\n $ref: `#/components/schemas/${schemaName}`,\n };\n }\n\n // Hoist inline streaming item schemas (OpenAPI 3.2 itemSchema) so\n // each streamed item gets a named model.\n STREAMING_CONTENT_TYPES.forEach((mediaType) => {\n const streamingContent = response?.content?.[mediaType] as\n | { itemSchema?: OpenAPIV3.SchemaObject }\n | undefined;\n const itemSchema = streamingContent?.itemSchema;\n if (\n itemSchema &&\n !isRef(itemSchema) &&\n (['object', 'array'].includes(itemSchema.type!) ||\n isCompositeSchema(itemSchema) ||\n (itemSchema.type === 'string' && itemSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}${code}ResponseItem`;\n spec.components!.schemas![schemaName] = itemSchema;\n streamingContent.itemSchema = {\n $ref: `#/components/schemas/${schemaName}`,\n } as OpenAPIV3.SchemaObject;\n }\n });\n });\n }\n if ('requestBody' in operation) {\n const requestBody = resolveIfRef(spec, operation.requestBody);\n const contentMediaTypes = Object.keys(requestBody?.content ?? {});\n // Hoist the JSON body, falling back to a form-data body (multipart or\n // urlencoded) so an inline form object is fully typed and marshalled\n // rather than left `unknown`.\n const bodyMediaType =\n preferredJsonMediaType(contentMediaTypes) ??\n contentMediaTypes.find(isFormMediaType);\n const bodyContentSchema = bodyMediaType\n ? requestBody!.content![bodyMediaType].schema\n : undefined;\n // A form body's binary string fields are file uploads (Blob). Mark\n // the resolved schema (inline or $ref target) before hoisting.\n if (bodyMediaType && isFormMediaType(bodyMediaType)) {\n const resolved = resolveIfRef(spec, bodyContentSchema) as\n | OpenAPIV3.SchemaObject\n | undefined;\n if (resolved) markFormBinaryFields(resolved);\n }\n if (\n bodyContentSchema &&\n !isRef(bodyContentSchema) &&\n (['object', 'array'].includes(bodyContentSchema.type!) ||\n isCompositeSchema(bodyContentSchema) ||\n (bodyContentSchema?.type === 'string' && bodyContentSchema.enum))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}RequestContent`;\n spec.components!.schemas![schemaName] = bodyContentSchema;\n requestBody!.content![bodyMediaType!].schema = {\n $ref: `#/components/schemas/${schemaName}`,\n };\n }\n }\n\n // Hoist parameter schemas. Composite and inline-object schemas are\n // hoisted to named models so the parameter is fully typed (e.g. a\n // `deepObject` query param's members are marshalled, not left `unknown`).\n if ('parameters' in operation) {\n (operation.parameters ?? []).forEach((p) => {\n const param = resolveIfRef(spec, p);\n const paramSchema = param?.schema as\n | OpenAPIV3.SchemaObject\n | undefined;\n if (\n paramSchema &&\n !isRef(paramSchema) &&\n (isCompositeSchema(paramSchema) ||\n (paramSchema.type === 'object' && !!paramSchema.properties))\n ) {\n const schemaName = `${upperFirst(deduplicatedOpId)}Request${upperFirst(param.in)}${upperFirst(camelCase(param.name))}`;\n spec.components!.schemas![schemaName] = paramSchema;\n param.schema = { $ref: `#/components/schemas/${schemaName}` };\n }\n });\n }\n }\n }),\n );\n\n // Normalize schema names to valid TypeScript identifiers (e.g., \"Message-Output\" -> \"MessageOutput\")\n spec = normaliseSchemaNames(spec);\n\n // Initialise the models that we have seen with all schemas.\n // This is required to ensure we do not create any clashing models below\n const seenModelNameCounts = Object.fromEntries(\n Object.keys(spec.components?.schemas ?? {}).map((name) => [name, 1]),\n );\n\n // \"Hoist\" any nested object definitions in arrays/maps that aren't already refs, as parseOpenapi will treat the\n // type as \"any\" if they're defined inline (and not a ref)\n Object.entries(spec.components?.schemas ?? {}).forEach(([name, schema]) => {\n if (!isRef(schema)) {\n const refs = hoistInlineObjectSubSchemas(\n [name],\n schema,\n seenModelNameCounts,\n );\n refs.forEach((ref) => {\n spec.components!.schemas![ref.name] = ref.schema;\n });\n }\n });\n\n // \"Inline\" any refs to non objects/enums.\n //\n // The substituted body is itself walked for refs, so a chain — an array whose\n // items are a named scalar — collapses in one pass. Substituting the array\n // without following through left `items` pointing at a schema this same pass\n // deletes, so the client referred to a type nothing declared and the emitted\n // TypeScript did not compile.\n const inlinedRefs: Set<string> = new Set();\n const inlineNonObjectRefs = (value: unknown): unknown =>\n cloneDeepWith(value, (v) => {\n if (v && typeof v === 'object' && v.$ref) {\n const resolved = resolveRef(spec, v.$ref);\n if (\n resolved &&\n resolved.type &&\n resolved.type !== 'object' &&\n !(resolved.type === 'string' && resolved.enum)\n ) {\n inlinedRefs.add(v.$ref);\n return inlineNonObjectRefs(resolved);\n }\n }\n });\n spec = inlineNonObjectRefs(spec) as Spec;\n\n // Delete the non object schemas that were inlined\n [...inlinedRefs].forEach((ref) => {\n const parts = splitRef(ref);\n if (\n parts.length === 3 &&\n parts[0] === 'components' &&\n parts[1] === 'schemas'\n ) {\n delete spec.components!.schemas![parts[2]];\n }\n });\n\n return spec;\n};\n"],"names":["cloneDeepWith","camelCase","pascalCase","toClassName","upperFirst","STREAMING_CONTENT_TYPES","isRef","resolveIfRef","resolveRef","splitRef","normaliseSchemaNames","spec","schemaNameMapping","originalNames","Object","keys","components","schemas","existingSchemaNames","Set","resolvedNameOwners","forEach","name","normalizedName","has","Error","owner","undefined","length","v","parts","$ref","oldName","newName","entries","schema","isCompositeSchema","allOf","anyOf","oneOf","preferredJsonMediaType","mediaTypes","find","mediaType","split","endsWith","FORM_MEDIA_TYPES","isFormMediaType","includes","isBinaryContentMediaType","contentMediaType","startsWith","markFormBinaryFields","values","properties","prop","s","type","format","contentEncoding","hasSubSchemasToVisit","patternProperties","not","enum","filterInlineCompositeSchemas","nameParts","namePartPrefix","propPath","inlineSchemaIndex","flatMap","i","subSchema","title","createUniqueModelName","seenModelNameCounts","candidateName","map","join","seenModelNameCount","hoistInlineObjectSubSchemas","inlineSubSchemas","items","prefixItems","filter","additionalProperties","pattern","recursiveRefs","isObjectSchema","refs","ref","structuredClone","schemaWithPropToReplace","slice","reduce","resolvedInSchema","pathPart","nullable","rewriteConstToEnum","rewrite","Array","isArray","const","constValue","rest","rewriteCompositeSiblingProperties","required","_type","rewriteMultiTypeToAnyOf","nonNull","t","isNullable","inlinePathItemRefs","paths","path","pathItem","normaliseOpenApiSpecForCodeGen","inSpec","seenOperationIds","duplicatedOperationIds","pathOps","method","op","operation","operationId","add","clear","untagged","Symbol","seenOperationIdsByTag","tags","deduplicatedOpId","deduplicatedDotNotationOpId","tag","String","responses","code","res","response","jsonMediaType","content","jsonResponseSchema","schemaName","streamingContent","itemSchema","requestBody","contentMediaTypes","bodyMediaType","bodyContentSchema","resolved","parameters","p","param","paramSchema","in","fromEntries","inlinedRefs","inlineNonObjectRefs","value"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,mBAAmB,uBAAuB;AAEjD,SACEC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,UAAU,QACL,uBAAuB;AAC9B,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,KAAK,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,YAAY;AAetE;;;;CAIC,GACD,MAAMC,uBAAuB,CAACC;IAC5B,MAAMC,oBAAmD,CAAC;IAC1D,MAAMC,gBAAgBC,OAAOC,IAAI,CAACJ,KAAKK,UAAU,EAAEC,WAAW,CAAC;IAC/D,MAAMC,sBAAsB,IAAIC,IAAIN;IAEpC,2EAA2E;IAC3E,0EAA0E;IAC1E,qCAAqC;IACrC,MAAMO,qBAAyD,CAAC;IAEhE,0CA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