@aws/nx-plugin 1.0.0-rc.30 → 1.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-THIRD-PARTY +235 -1336
- package/README.md +1 -1
- package/package.json +1 -2
- package/src/mcp-server/tools/create-workspace-command.js +2 -2
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.arrays.spec.ts.snap +308 -75
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +286 -62
- package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +674 -93
- package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +196 -44
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5507 -0
- package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +219 -60
- package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
- package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
- package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
- package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
- package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
- package/src/open-api/ts-client/files/client.gen.ts.template +130 -18
- package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
- package/src/open-api/ts-client/generator.js +1 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
- package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
- package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
- package/src/open-api/utils/codegen-data/languages.js +23 -18
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.d.ts +240 -10
- package/src/open-api/utils/codegen-data/types.js +24 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +2 -2
- package/src/open-api/utils/codegen-data.js +357 -617
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +157 -19
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.d.ts +55 -0
- package/src/open-api/utils/parser.js +743 -0
- package/src/open-api/utils/parser.js.map +1 -0
- package/src/open-api/utils/types.d.ts +15 -0
- package/src/open-api/utils/types.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/utils/mcp.js +1 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/names.d.ts +6 -0
- package/src/utils/names.js +6 -1
- package/src/utils/names.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/parser.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport camelCase from 'lodash.camelcase';\nimport trim from 'lodash.trim';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport {\n type ClientData,\n COLLECTION_TYPES,\n COMPOSED_SCHEMA_TYPES,\n createModel,\n DEFAULT_SERVICE_NAME,\n type Discriminator,\n type DiscriminatorMapping,\n type EnumMember,\n indexModelsByName,\n type Model,\n type ModelExport,\n type ModelIn,\n type ModelsByName,\n type Operation,\n PRIMITIVE_TYPES,\n type Service,\n} from './codegen-data/types';\nimport { isRef, resolveIfRef, splitRef } from './refs';\nimport type {\n OpenApiSchemaOrRef,\n OpenApiSchema as Schema,\n Spec,\n} from './types';\n\n/**\n * OpenAPI primitive `type` values mapped to the internal model `type`.\n */\nconst PRIMITIVE_TYPE_MAP: { [openApiType: string]: string } = {\n string: 'string',\n number: 'number',\n integer: 'number',\n boolean: 'boolean',\n null: 'null',\n};\n\nconst HTTP_METHODS = [\n 'get',\n 'put',\n 'post',\n 'delete',\n 'options',\n 'head',\n 'patch',\n 'trace',\n] as const;\n\ntype HttpMethod = (typeof HTTP_METHODS)[number];\n\ntype SchemaOrRef = Schema | OpenAPIV3.ReferenceObject;\n\ntype ParameterOrRef = OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject;\n\nconst schemaType = (schema: Schema): string | string[] | undefined =>\n (schema as { type?: string | string[] }).type;\n\nconst isNullable = (schema: Schema): boolean => {\n const type = schemaType(schema);\n return (\n schema.nullable === true ||\n type === 'null' ||\n (Array.isArray(type) && type.includes('null'))\n );\n};\n\n/**\n * The \"primary\" type of a schema, ignoring 'null' in a 3.1 type array.\n */\nconst primaryType = (schema: Schema): string | undefined => {\n const type = schemaType(schema);\n return Array.isArray(type) ? type.find((t) => t !== 'null') : type;\n};\n\nconst isEnumSchema = (schema: Schema): boolean =>\n Array.isArray(schema.enum) && schema.enum.length > 0;\n\nconst compositeExport = (schema: Schema): ModelExport | undefined => {\n if (schema.allOf) return 'all-of';\n if (schema.anyOf) return 'any-of';\n if (schema.oneOf) return 'one-of';\n return undefined;\n};\n\nconst compositeMembers = (schema: Schema): SchemaOrRef[] =>\n (schema.allOf ?? schema.anyOf ?? schema.oneOf ?? []) as SchemaOrRef[];\n\n/**\n * A schema is a \"dictionary\" (map) when it is an object with no explicit\n * properties (it may have `additionalProperties`, or be a bare `object`).\n */\nconst isDictionarySchema = (schema: Schema): boolean => {\n if (primaryType(schema) !== 'object') return false;\n if (compositeExport(schema) || isEnumSchema(schema)) return false;\n const hasProperties = Object.keys(schema.properties ?? {}).length > 0;\n return !hasProperties && !schema.patternProperties;\n};\n\n/**\n * The internal primitive type name for a primitive schema.\n */\nconst primitiveType = (schema: Schema): string => {\n const type = primaryType(schema);\n if (type === 'string' && schema.format === 'binary') return 'binary';\n return (type && PRIMITIVE_TYPE_MAP[type]) ?? 'unknown';\n};\n\n/**\n * Prefer application/json, falling back to the first declared media type.\n */\nconst preferredMediaType = (content: { [media: string]: unknown }): string =>\n 'application/json' in content ? 'application/json' : Object.keys(content)[0];\n\nconst parseResponseCode = (code: string): number | string =>\n /^\\d+$/.test(code) ? parseInt(code, 10) : code;\n\n/**\n * The unique imports declared across a set of models, in first-seen order.\n */\nconst collectImports = (models: Model[]): string[] => [\n ...new Set(models.flatMap((m) => m.imports)),\n];\n\n/**\n * The structural fields (export/type/link/properties/enum/imports/format) a\n * schema contributes to a model.\n */\nconst schemaStructure = (spec: Spec, schema: Schema): Partial<Model> => {\n // A null member (3.0 nullable enums list null as a value) marks the model\n // nullable rather than becoming a literal. An enum of only null degrades to\n // a plain (nullable) schema.\n const enumMembers = (schema.enum ?? []).filter((value) => value !== null);\n if (isEnumSchema(schema) && enumMembers.length > 0) {\n // A string (or untyped) enum renders as a literal union; a boolean/number\n // enum renders as its bare primitive, so it must carry the declared type.\n const declared = primaryType(schema);\n return {\n export: 'enum',\n type: (declared && PRIMITIVE_TYPE_MAP[declared]) ?? 'string',\n enum: enumMembers.map(\n (value): EnumMember => ({ value: value as EnumMember['value'] }),\n ),\n ...(enumMembers.length < schema.enum!.length ? { isNullable: true } : {}),\n };\n }\n\n const composite = compositeExport(schema);\n if (composite) {\n const properties = compositeMembers(schema).map((member) =>\n buildInlineModel(spec, member),\n );\n return {\n export: composite,\n type: 'unknown',\n properties,\n imports: collectImports(properties),\n };\n }\n\n const type = primaryType(schema);\n\n if (type === 'array') {\n const items = (schema as { items?: SchemaOrRef }).items;\n return { export: 'array', ...collectionValue(spec, items) };\n }\n\n if (isDictionarySchema(schema)) {\n return { export: 'dictionary', ...dictionaryValue(spec, schema) };\n }\n\n if (type === 'object' || schema.properties || schema.patternProperties) {\n const properties = buildProperties(spec, schema);\n return {\n export: 'interface',\n type: 'unknown',\n properties,\n imports: collectImports(properties),\n };\n }\n\n // A schema with no type (e.g. `{}`) is an untyped object.\n if (type === undefined) {\n return { export: 'interface', type: 'unknown' };\n }\n\n return {\n export: 'generic',\n type: primitiveType(schema),\n ...(schema.format ? { format: schema.format } : {}),\n };\n};\n\n/**\n * The value type of a collection (array items / dictionary values): a `type`,\n * `link` and `imports`.\n *\n * - ref value → `type` is the referenced model name; `link` is left null and\n * resolved later by `linkModels`.\n * - non-ref value → a `link` model carrying the (innermost) type and imports.\n */\nconst collectionValue = (\n spec: Spec,\n value: SchemaOrRef | undefined,\n): Partial<Model> => {\n if (value && isRef(value)) {\n const type = splitRef(value.$ref)[2];\n return { type, imports: [type], link: null };\n }\n const link = createModel(schemaStructure(spec, (value ?? {}) as Schema));\n return { link, type: link.type, imports: [...link.imports] };\n};\n\n/**\n * The value type of a dictionary (map).\n */\nconst dictionaryValue = (spec: Spec, schema: Schema): Partial<Model> => {\n const additional = schema.additionalProperties;\n if (additional && additional !== true) {\n return collectionValue(spec, additional);\n }\n if (schema.properties && additional !== true) {\n // An object with an (empty) `properties` map but no additionalProperties\n // renders as `{}`.\n return { type: 'unknown', link: null };\n }\n // `additionalProperties: true`, or a bare `{ type: 'object' }` → an \"any\"\n // value type.\n return {\n type: 'unknown',\n link: createModel({ export: 'interface', type: 'unknown' }),\n };\n};\n\n/**\n * A model for an inline sub-schema (property value, array item, dictionary\n * value, composite member, parameter, or response).\n */\nexport const buildInlineModel = (\n spec: Spec,\n schemaOrRef: SchemaOrRef,\n): Model => {\n if (isRef(schemaOrRef)) {\n const name = splitRef(schemaOrRef.$ref)[2];\n return createModel({ export: 'reference', type: name, imports: [name] });\n }\n return createModel({\n description: schemaOrRef.description ?? null,\n deprecated: !!schemaOrRef.deprecated,\n isNullable: isNullable(schemaOrRef),\n isReadOnly: !!schemaOrRef.readOnly,\n ...schemaStructure(spec, schemaOrRef),\n });\n};\n\n/**\n * A model for a top-level named schema (a definition). Object definitions are\n * typed as their own name (the type the generator emits for them).\n */\nconst buildDefinitionModel = (\n spec: Spec,\n name: string,\n schema: Schema,\n): Model => {\n const structure = schemaStructure(spec, schema);\n const isNamedObject =\n schema.type === 'object' &&\n !!(schema.properties || schema.patternProperties);\n return createModel({\n name,\n description: schema.description ?? null,\n deprecated: !!schema.deprecated,\n isNullable: isNullable(schema),\n ...structure,\n ...(isNamedObject ? { type: name } : {}),\n });\n};\n\n/**\n * The property models for an object schema.\n */\nconst buildProperties = (spec: Spec, schema: Schema): Model[] => {\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties ?? {}).map(([name, propSchema]) => ({\n ...buildInlineModel(spec, propSchema),\n name,\n isRequired: required.has(name),\n }));\n};\n\n/**\n * A `{ modelName → { propertyName } }` map of the discriminator properties\n * declared by composite schemas with an explicit `mapping`.\n */\nconst discriminatorTargets = (spec: Spec): Map<string, Set<string>> => {\n const targets = new Map<string, Set<string>>();\n for (const schemaOrRef of Object.values(spec.components?.schemas ?? {})) {\n const { discriminator } = resolveIfRef(spec, schemaOrRef) as Schema;\n if (!discriminator?.propertyName || !discriminator.mapping) continue;\n for (const mappedRef of Object.values(discriminator.mapping)) {\n if (typeof mappedRef !== 'string' || !mappedRef.startsWith('#/'))\n continue;\n const modelName = splitRef(mappedRef)[2];\n const properties = targets.get(modelName) ?? new Set<string>();\n properties.add(discriminator.propertyName);\n targets.set(modelName, properties);\n }\n }\n return targets;\n};\n\n/**\n * For discriminated composites, collapse each mapped schema's discriminator\n * property from its enum reference to the bare primitive type (`export` stays\n * `reference`, `type` becomes the primitive, `imports` are cleared). The\n * referenced enum models are left in place. This drops the literal narrowing\n * but keeps the emitted code valid.\n */\nconst collapseDiscriminators = (spec: Spec, models: Model[]): Model[] => {\n const targets = discriminatorTargets(spec);\n if (targets.size === 0) return models;\n\n const byName = new Map(models.map((m) => [m.name, m]));\n return models.map((model) => {\n const properties = targets.get(model.name);\n if (!properties) return model;\n return {\n ...model,\n properties: model.properties.map((property) => {\n if (!properties.has(property.name) || property.export !== 'reference') {\n return property;\n }\n const referenced = byName.get(property.type);\n return referenced?.export === 'enum'\n ? { ...property, type: referenced.type, imports: [] }\n : property;\n }),\n };\n });\n};\n\nconst buildModels = (spec: Spec): Model[] =>\n collapseDiscriminators(\n spec,\n Object.entries(spec.components?.schemas ?? {}).map(([name, schemaOrRef]) =>\n buildDefinitionModel(spec, name, resolveIfRef(spec, schemaOrRef)),\n ),\n );\n\n/**\n * The synthetic `body` parameter for an operation's request body.\n */\nconst buildRequestBody = (\n spec: Spec,\n specOp: OpenAPIV3.OperationObject,\n): Model | null => {\n const requestBody = resolveIfRef<OpenAPIV3.RequestBodyObject | undefined>(\n spec,\n specOp.requestBody,\n );\n // An empty content map declares no acceptable media types, ie no body.\n if (!requestBody?.content || Object.keys(requestBody.content).length === 0)\n return null;\n\n const mediaType = preferredMediaType(requestBody.content);\n const base = buildInlineModel(\n spec,\n (requestBody.content[mediaType]?.schema ?? {}) as Schema,\n );\n return {\n ...base,\n name: 'requestBody',\n prop: 'requestBody',\n in: 'body',\n mediaType,\n isRequired: !!requestBody.required,\n description: requestBody.description ?? base.description,\n };\n};\n\n/**\n * The parameter models for an operation, including a synthetic body parameter.\n * Ordered required-first with a stable sort (`Array.prototype.sort`), so the\n * original relative order within each group is preserved.\n */\nconst buildParameters = (\n spec: Spec,\n specOp: OpenAPIV3.OperationObject,\n pathParameters: ParameterOrRef[] = [],\n): Model[] => {\n const declared: Model[] = mergeParameters(spec, pathParameters, [\n ...(specOp.parameters ?? []),\n ]).flatMap((p) => {\n const param = resolveIfRef<OpenAPIV3.ParameterObject | undefined>(spec, p);\n if (!param) return [];\n const base = buildInlineModel(spec, (param.schema ?? {}) as Schema);\n return [\n {\n ...base,\n name: param.name,\n prop: param.name,\n in: param.in as ModelIn,\n mediaType: null,\n isRequired: !!param.required,\n description: param.description ? param.description : base.description,\n },\n ];\n });\n\n const body = buildRequestBody(spec, specOp);\n const params = body ? [...declared, body] : declared;\n\n return [...params].sort((a, b) =>\n a.isRequired === b.isRequired ? 0 : a.isRequired ? -1 : 1,\n );\n};\n\n/**\n * Merge path-level parameters with operation-level parameters. Per the OpenAPI\n * spec, path-level parameters apply to every operation in the path unless an\n * operation-level parameter overrides one with the same `name` + `in`.\n */\nconst mergeParameters = (\n spec: Spec,\n pathParameters: ParameterOrRef[],\n operationParameters: ParameterOrRef[],\n): ParameterOrRef[] => {\n const key = (p: ParameterOrRef) => {\n const param = resolveIfRef<OpenAPIV3.ParameterObject | undefined>(spec, p);\n return param ? specParameterKey(param) : null;\n };\n const overridden = new Set(operationParameters.map(key));\n const inherited = pathParameters.filter((p) => !overridden.has(key(p)));\n return [...inherited, ...operationParameters];\n};\n\n/**\n * The response models for an operation.\n */\nconst buildResponses = (\n spec: Spec,\n specOp: OpenAPIV3.OperationObject,\n): Model[] =>\n Object.entries(specOp.responses ?? {}).flatMap(([code, resOrRef]) => {\n const response = resolveIfRef<OpenAPIV3.ResponseObject | undefined>(\n spec,\n resOrRef,\n );\n if (!response) return [];\n\n const content = response.content ?? {};\n const mediaType = Object.keys(content).length\n ? preferredMediaType(content)\n : undefined;\n const responseSchema = mediaType\n ? (content[mediaType]?.schema as SchemaOrRef | undefined)\n : undefined;\n\n return [\n {\n ...(responseSchema\n ? buildInlineModel(spec, responseSchema)\n : createModel({ export: 'generic', type: 'void' })),\n name: '',\n code: parseResponseCode(code),\n in: 'response' as ModelIn,\n description: response.description ?? null,\n },\n ];\n });\n\nconst buildOperation = (\n spec: Spec,\n path: string,\n method: string,\n specOp: OpenAPIV3.OperationObject,\n pathParameters: ParameterOrRef[] = [],\n): Operation => {\n const parameters = buildParameters(spec, specOp, pathParameters);\n const responses = buildResponses(spec, specOp);\n const id = (specOp as { operationId: string }).operationId;\n\n return {\n id,\n name: id,\n method: method.toUpperCase(),\n path,\n description: specOp.description ?? null,\n tags: specOp.tags ?? null,\n deprecated: !!specOp.deprecated,\n parameters,\n parametersBody: parameters.find((p) => p.in === 'body') ?? null,\n responses,\n imports: collectImports([...parameters, ...responses]),\n };\n};\n\nconst buildOperations = (spec: Spec): Operation[] =>\n Object.entries(spec.paths ?? {}).flatMap(([path, pathItemOrRef]) => {\n const pathItem = resolveIfRef<OpenAPIV3.PathItemObject | undefined>(\n spec,\n pathItemOrRef,\n );\n if (!pathItem) return [];\n const pathParameters = pathItem.parameters ?? [];\n return HTTP_METHODS.flatMap((method: HttpMethod) => {\n const specOp = pathItem[method as OpenAPIV3.HttpMethods];\n return specOp\n ? [buildOperation(spec, path, method, specOp, pathParameters)]\n : [];\n });\n });\n\nconst buildDefaultService = (spec: Spec): Service => {\n const operations = buildOperations(spec);\n return {\n name: DEFAULT_SERVICE_NAME,\n operations,\n imports: [...new Set(operations.flatMap((op) => op.imports))],\n };\n};\n\n/**\n * Look up the spec operation object for a parsed operation.\n */\nexport const getSpecOperation = (\n spec: Spec,\n op: Operation,\n): OpenAPIV3.OperationObject | undefined =>\n (spec.paths?.[op.path] as OpenAPIV3.PathItemObject | undefined)?.[\n op.method.toLowerCase() as OpenAPIV3.HttpMethods\n ];\n\n/**\n * The `in`-qualified key for a parameter, distinguishing parameters that share\n * a name across positions (e.g. `id` in both path and query).\n */\nexport const specParameterKey = (parameter: {\n in: string;\n name: string;\n}): string => `${parameter.in}:${parameter.name}`;\n\n/**\n * An operation's resolved parameters indexed by `in:name`, including any\n * path-level parameters inherited from the containing path item\n * (operation-level parameters take precedence when both declare the same\n * `name` + `in`).\n */\nexport const getSpecParametersByKey = (\n spec: Spec,\n specOp: OpenAPIV3.OperationObject | undefined,\n pathParameters: ParameterOrRef[] = [],\n): { [key: string]: OpenAPIV3.ParameterObject } =>\n Object.fromEntries(\n [...pathParameters, ...(specOp?.parameters ?? [])].map((p) => {\n const param = resolveIfRef(spec, p);\n return [specParameterKey(param), param];\n }),\n );\n\n/**\n * The path-level parameters declared on the path item containing an operation.\n */\nexport const getSpecPathParameters = (\n spec: Spec,\n op: Operation,\n): ParameterOrRef[] => {\n const pathItem = resolveIfRef<OpenAPIV3.PathItemObject | undefined>(\n spec,\n spec.paths?.[op.path],\n );\n return pathItem?.parameters ?? [];\n};\n\n/**\n * The member sub-schemas of a composite (allOf/anyOf/oneOf) schema, in order.\n */\nexport const compositeMemberSchemas = (\n schema: Schema,\n compositeExport: ModelExport,\n): OpenApiSchemaOrRef[] => {\n const keyword = camelCase(compositeExport) as 'allOf' | 'anyOf' | 'oneOf';\n return (schema[keyword] as OpenApiSchemaOrRef[] | undefined) ?? [];\n};\n\n/**\n * Recursively stitch a model's collection `link` to the named model it\n * references (ref values are left null by the builders, since the target model\n * does not exist until every definition is built).\n */\nexport const linkModel = (\n spec: Spec,\n modelsByName: ModelsByName,\n model: Model,\n schema: Schema,\n visited: Set<Model> = new Set(),\n): void => {\n if (visited.has(model)) return;\n visited.add(model);\n\n if (\n model.export === 'dictionary' &&\n 'additionalProperties' in schema &&\n schema.additionalProperties\n ) {\n if (isRef(schema.additionalProperties)) {\n const name = splitRef(schema.additionalProperties.$ref)[2];\n if (modelsByName[name] && !model.link) {\n model.link = modelsByName[name];\n }\n } else if (model.link && typeof schema.additionalProperties !== 'boolean') {\n linkModel(\n spec,\n modelsByName,\n model.link,\n schema.additionalProperties,\n visited,\n );\n }\n } else if (model.export === 'array' && 'items' in schema && schema.items) {\n if (isRef(schema.items)) {\n const name = splitRef(schema.items.$ref)[2];\n if (modelsByName[name] && !model.link) {\n model.link = modelsByName[name];\n }\n } else if (model.link) {\n linkModel(spec, modelsByName, model.link, schema.items, visited);\n }\n }\n\n model.properties\n .filter((p) => !visited.has(p) && schema.properties?.[trim(p.name, `\"'`)])\n .forEach((property) => {\n const subSchema = resolveIfRef(\n spec,\n schema.properties![trim(property.name, `\"'`)],\n );\n linkModel(spec, modelsByName, property, subSchema, visited);\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 linkModel(spec, modelsByName, property, subSchema, visited);\n }\n });\n }\n};\n\n/**\n * Stitch collection links across every model, operation parameter and response.\n */\nconst linkModels = (spec: Spec, data: ClientData): void => {\n const modelsByName = indexModelsByName(data.models);\n const visited = new Set<Model>();\n\n data.models.forEach((model) => {\n const schema = resolveIfRef<Schema | undefined>(\n spec,\n spec.components?.schemas?.[model.name],\n );\n if (schema) {\n linkModel(spec, modelsByName, model, schema, visited);\n }\n });\n\n data.services.forEach((service) => {\n service.operations.forEach((op) => {\n const specOp = getSpecOperation(spec, op);\n const specParametersByKey = getSpecParametersByKey(\n spec,\n specOp,\n getSpecPathParameters(spec, op),\n );\n\n op.parameters.forEach((parameter) => {\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 linkModel(\n spec,\n modelsByName,\n parameter,\n specParameterSchema,\n visited,\n );\n } else if (parameter.in === 'body') {\n const specBody = resolveIfRef(spec, specOp?.requestBody);\n const specBodySchema = resolveIfRef(\n spec,\n specBody?.content?.[parameter.mediaType]?.schema,\n );\n if (specBodySchema) {\n linkModel(spec, modelsByName, parameter, specBodySchema, visited);\n }\n }\n });\n\n op.responses.forEach((response) => {\n const specResponse = resolveIfRef(\n spec,\n specOp?.responses?.[response.code],\n );\n Object.keys(specResponse?.content ?? {}).forEach((mediaType) => {\n const responseSchema = resolveIfRef(\n spec,\n specResponse?.content?.[mediaType]?.schema,\n );\n if (responseSchema) {\n linkModel(spec, modelsByName, response, responseSchema, visited);\n }\n });\n });\n });\n });\n};\n\n/**\n * Populate `composedModels` and `composedPrimitives` on each composite model\n * with the models and primitive types it is composed of.\n */\nconst resolveComposedModel = (\n modelsByName: ModelsByName,\n model: Model,\n visited: Set<Model>,\n): void => {\n if (!COMPOSED_SCHEMA_TYPES.has(model.export) || visited.has(model)) return;\n visited.add(model);\n\n const members = model.properties.filter((p) => !p.name);\n const referenced = members\n .filter((p) => p.export === 'reference')\n .flatMap((r) => (modelsByName[r.type] ? [modelsByName[r.type]] : []));\n\n // Resolve recursively so all-of mixins include nested all-of properties\n referenced.forEach((m) => resolveComposedModel(modelsByName, m, visited));\n\n // Enums serialise as primitives, so group them with the primitives\n const composedModels = referenced.filter((m) => m.export !== 'enum');\n const composedPrimitives = [\n ...members.filter((p) => p.export !== 'reference'),\n ...referenced.filter((m) => m.export === 'enum'),\n ];\n\n // A composite of multiple non-primitive array members can't be told apart at\n // runtime: each arrives as a plain JSON array with no property to switch on.\n // A `discriminator` can't disambiguate here either — it names a property on\n // an object member, not on an array. Model a polymorphic list as an array of\n // a discriminated union instead (`type: array` whose `items` is the oneOf).\n const isPrimitiveArray = (m: Model): boolean =>\n m.link && COLLECTION_TYPES.has(m.export)\n ? isPrimitiveArray(m.link)\n : PRIMITIVE_TYPES.has(m.type) &&\n !['date', 'date-time'].includes(m.format ?? '');\n const arrayComposedModels = composedPrimitives.filter(\n (m) => m.export === 'array' && !isPrimitiveArray(m),\n );\n if (arrayComposedModels.length > 1) {\n throw new Error(\n `Schema \"${model.name}\" defines ${camelCase(model.export)} with multiple array types which cannot be distinguished at runtime. Model a polymorphic list as an array whose items are a discriminated union instead (a \"type: array\" schema with a \"oneOf\" in \"items\").`,\n );\n }\n\n if (model.export === 'all-of' && composedPrimitives.length > 0) {\n throw new Error(\n `Schema \"${model.name}\" defines allOf with non-object types. allOf may only compose object types in the OpenAPI specification.`,\n );\n }\n\n model.composedModels = composedModels;\n model.composedPrimitives = composedPrimitives;\n};\n\nconst resolveComposedModels = (data: ClientData): void => {\n const modelsByName = indexModelsByName(data.models);\n const visited = new Set<Model>();\n data.models.forEach((model) =>\n resolveComposedModel(modelsByName, model, visited),\n );\n};\n\nconst isHoisted = (spec: Spec, name: string): boolean =>\n !!(\n resolveIfRef<Schema | undefined>(\n spec,\n spec.components?.schemas?.[name],\n ) as { 'x-aws-nx-hoisted'?: boolean } | undefined\n )?.['x-aws-nx-hoisted'];\n\n/**\n * The on-the-wire name of a schema: its original name before normalisation to\n * a valid identifier (recorded by the normaliser), or its current name. An\n * implicit discriminator matches on this, not the normalised model name.\n */\nconst wireName = (spec: Spec, name: string): string =>\n (\n resolveIfRef<Schema | undefined>(\n spec,\n spec.components?.schemas?.[name],\n ) as { 'x-aws-nx-original-name'?: string } | undefined\n )?.['x-aws-nx-original-name'] ?? name;\n\n/**\n * The value → model-name mapping for a discriminator, resolved either from an\n * explicit `mapping` (value → schema ref) or implicitly (each candidate model's\n * schema name is its own discriminator value). Only candidates in\n * `candidateNames` are kept, so unknown values fall through to the default\n * marshalling; hoisted synthetic names (which never appear on the wire) are\n * excluded from the implicit form.\n */\nconst buildDiscriminatorMapping = (\n spec: Spec,\n discriminator: OpenAPIV3.DiscriminatorObject,\n candidateNames: Set<string>,\n): DiscriminatorMapping[] => {\n if (discriminator.mapping) {\n const mapping: DiscriminatorMapping[] = [];\n for (const [value, ref] of Object.entries(discriminator.mapping)) {\n if (typeof ref !== 'string' || !ref.startsWith('#/')) continue;\n const modelName = splitRef(ref)[2];\n if (candidateNames.has(modelName)) mapping.push({ value, modelName });\n }\n return mapping;\n }\n return [...candidateNames]\n .filter((name) => !isHoisted(spec, name))\n // The wire value is the schema's original name; the model it selects is the\n // normalised name.\n .map((name) => ({ value: wireName(spec, name), modelName: name }));\n};\n\n/**\n * Build the {@link Discriminator} for a `oneOf`/`anyOf` composite, if declared.\n * The candidates are the models composed by the union.\n */\nconst buildCompositeDiscriminator = (\n spec: Spec,\n model: Model,\n schema: Schema,\n): Discriminator | undefined => {\n const { discriminator } = schema;\n if (!discriminator?.propertyName) return undefined;\n\n const candidateNames = new Set(\n (model.composedModels ?? []).map((m) => m.name),\n );\n const mapping = buildDiscriminatorMapping(spec, discriminator, candidateNames);\n\n return mapping.length > 0\n ? { propertyName: discriminator.propertyName, mapping }\n : undefined;\n};\n\n/**\n * Build the {@link Discriminator} for an inheritance base — an `object` schema\n * carrying a `discriminator` whose subtypes `allOf`-compose it. The candidates\n * are those subtypes (found by scanning every model for one that composes this\n * base). Marked `isBase` so the generator emits a non-dispatching body the\n * subtypes can compose without recursing.\n */\nconst buildBaseDiscriminator = (\n spec: Spec,\n base: Model,\n schema: Schema,\n models: Model[],\n): Discriminator | undefined => {\n const { discriminator } = schema;\n if (!discriminator?.propertyName) return undefined;\n\n const subtypeNames = new Set(\n models\n .filter(\n (m) =>\n m.export === 'all-of' &&\n (m.composedModels ?? []).some((c) => c.name === base.name),\n )\n .map((m) => m.name),\n );\n if (subtypeNames.size === 0) return undefined;\n\n const mapping = buildDiscriminatorMapping(spec, discriminator, subtypeNames);\n\n return mapping.length > 0\n ? { propertyName: discriminator.propertyName, mapping, isBase: true }\n : undefined;\n};\n\n/**\n * Attach discriminator metadata so the generator can marshal directly to the\n * matching branch/subtype. Two shapes carry a discriminator:\n * - a `oneOf`/`anyOf` composite (dispatch to the matching member), and\n * - an inheritance base `object` whose subtypes `allOf`-compose it (dispatch\n * to the matching subtype so subtype-only fields survive marshalling).\n * `allOf` itself is a conjunction (not a choice) so it is never discriminated.\n */\nconst resolveDiscriminators = (spec: Spec, data: ClientData): void => {\n data.models.forEach((model) => {\n const schema = resolveIfRef<Schema | undefined>(\n spec,\n spec.components?.schemas?.[model.name],\n );\n if (!schema) return;\n\n if (model.export === 'one-of' || model.export === 'any-of') {\n const discriminator = buildCompositeDiscriminator(spec, model, schema);\n if (discriminator) model.discriminator = discriminator;\n } else if (model.export === 'interface') {\n const discriminator = buildBaseDiscriminator(\n spec,\n model,\n schema,\n data.models,\n );\n if (discriminator) model.discriminator = discriminator;\n }\n });\n};\n\n/**\n * Type each discriminated subtype's discriminator property as its literal\n * value(s), turning `Cat | Dog` into a true TypeScript tagged union that\n * narrows on the discriminator (e.g. `Cat.petType: 'cat'`).\n *\n * The literal is taken from every discriminator's `mapping` (value → subtype).\n * A subtype selected by several values within one discriminator becomes a union\n * of those literals. A subtype that appears in multiple discriminators with\n * conflicting values can't be pinned to a single literal, so it is left as the\n * plain primitive (`string`) — the marshalling dispatch is unaffected either\n * way, this only affects the emitted type.\n */\nconst resolveDiscriminatorLiterals = (data: ClientData): void => {\n const modelsByName = indexModelsByName(data.models);\n\n // Collect, per (subtype, discriminator property), the set of literal values\n // that select it — across every discriminator in the spec.\n const valuesBySubtypeProp = new Map<string, Set<string>>();\n const conflicting = new Set<string>();\n\n for (const model of data.models) {\n const discriminator = model.discriminator;\n if (!discriminator) continue;\n const byName = new Map<string, string[]>();\n for (const { value, modelName } of discriminator.mapping) {\n byName.set(modelName, [...(byName.get(modelName) ?? []), value]);\n }\n for (const [modelName, values] of byName) {\n const key = `${modelName}\u0000${discriminator.propertyName}`;\n const existing = valuesBySubtypeProp.get(key);\n const incoming = new Set(values);\n if (existing && !setsEqual(existing, incoming)) {\n // Same subtype+property tagged differently by another union.\n conflicting.add(key);\n }\n valuesBySubtypeProp.set(key, existing ? union(existing, incoming) : incoming);\n }\n }\n\n for (const [key, values] of valuesBySubtypeProp) {\n if (conflicting.has(key)) continue;\n const [modelName, propertyName] = key.split('\u0000');\n const property = modelsByName[modelName]?.properties.find(\n (p) => p.name === propertyName,\n );\n // Only pin a literal when the property is a plain (string/enum) scalar —\n // never an object/array reference.\n if (property && (property.type === 'string' || property.isEnum)) {\n property.discriminatorValue = [...values]\n .map((v) => JSON.stringify(v))\n .join(' | ');\n }\n }\n};\n\nconst setsEqual = (a: Set<string>, b: Set<string>): boolean =>\n a.size === b.size && [...a].every((v) => b.has(v));\n\nconst union = (a: Set<string>, b: Set<string>): Set<string> =>\n new Set([...a, ...b]);\n\n/**\n * Build the client data structure from a (normalised) OpenAPI spec: a fully\n * linked model graph with composite members resolved, ready for augmentation.\n */\nexport const buildClientData = (spec: Spec): ClientData => {\n const data: ClientData = {\n models: buildModels(spec),\n services: [buildDefaultService(spec)],\n };\n linkModels(spec, data);\n resolveComposedModels(data);\n resolveDiscriminators(spec, data);\n resolveDiscriminatorLiterals(data);\n return data;\n};\n"],"names":["camelCase","trim","COLLECTION_TYPES","COMPOSED_SCHEMA_TYPES","createModel","DEFAULT_SERVICE_NAME","indexModelsByName","PRIMITIVE_TYPES","isRef","resolveIfRef","splitRef","PRIMITIVE_TYPE_MAP","string","number","integer","boolean","null","HTTP_METHODS","schemaType","schema","type","isNullable","nullable","Array","isArray","includes","primaryType","find","t","isEnumSchema","enum","length","compositeExport","allOf","anyOf","oneOf","undefined","compositeMembers","isDictionarySchema","hasProperties","Object","keys","properties","patternProperties","primitiveType","format","preferredMediaType","content","parseResponseCode","code","test","parseInt","collectImports","models","Set","flatMap","m","imports","schemaStructure","spec","enumMembers","filter","value","declared","export","map","composite","member","buildInlineModel","items","collectionValue","dictionaryValue","buildProperties","$ref","link","additional","additionalProperties","schemaOrRef","name","description","deprecated","isReadOnly","readOnly","buildDefinitionModel","structure","isNamedObject","required","entries","propSchema","isRequired","has","discriminatorTargets","targets","Map","values","components","schemas","discriminator","propertyName","mapping","mappedRef","startsWith","modelName","get","add","set","collapseDiscriminators","size","byName","model","property","referenced","buildModels","buildRequestBody","specOp","requestBody","mediaType","base","prop","in","buildParameters","pathParameters","mergeParameters","parameters","p","param","body","params","sort","a","b","operationParameters","key","specParameterKey","overridden","inherited","buildResponses","responses","resOrRef","response","responseSchema","buildOperation","path","method","id","operationId","toUpperCase","tags","parametersBody","buildOperations","paths","pathItemOrRef","pathItem","buildDefaultService","operations","op","getSpecOperation","toLowerCase","parameter","getSpecParametersByKey","fromEntries","getSpecPathParameters","compositeMemberSchemas","keyword","linkModel","modelsByName","visited","forEach","subSchema","memberSchemas","i","linkModels","data","services","service","specParametersByKey","specParameter","specParameterSchema","specBody","specBodySchema","specResponse","resolveComposedModel","members","r","composedModels","composedPrimitives","isPrimitiveArray","arrayComposedModels","Error","resolveComposedModels","isHoisted","wireName","buildDiscriminatorMapping","candidateNames","ref","push","buildCompositeDiscriminator","buildBaseDiscriminator","subtypeNames","some","c","isBase","resolveDiscriminators","resolveDiscriminatorLiterals","valuesBySubtypeProp","conflicting","existing","incoming","setsEqual","union","split","isEnum","discriminator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WAAIsB;KAAE,CAACwF,KAAK,CAAC,CAACJ,IAAMnF,EAAExC,GAAG,CAAC2H;AAEjD,MAAMJ,QAAQ,CAAChF,GAAgBC,IAC7B,IAAI5E,IAAI;WAAI2E;WAAMC;KAAE;AAEtB;;;CAGC,GACD,OAAO,MAAMwF,kBAAkB,CAAC/J;IAC9B,MAAMiH,OAAmB;QACvBvH,QAAQ2D,YAAYrD;QACpBkH,UAAU;YAACpB,oBAAoB9F;SAAM;IACvC;IACAgH,WAAWhH,MAAMiH;IACjBiB,sBAAsBjB;IACtB8B,sBAAsB/I,MAAMiH;IAC5B+B,6BAA6B/B;IAC7B,OAAOA;AACT,EAAE"}
|
|
@@ -4,3 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
6
6
|
export type Spec = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
7
|
+
/**
|
|
8
|
+
* An OpenAPI schema object, spanning the 3.0 and 3.1 shapes plus the additional
|
|
9
|
+
* JSON-Schema / 3.1 keywords the code generator inspects that are absent from
|
|
10
|
+
* the `openapi-types` 3.0 definition (`patternProperties`, `const`, and the 3.0
|
|
11
|
+
* `nullable` flag).
|
|
12
|
+
*/
|
|
13
|
+
export type OpenApiSchema = (OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject) & {
|
|
14
|
+
nullable?: boolean;
|
|
15
|
+
const?: unknown;
|
|
16
|
+
patternProperties?: {
|
|
17
|
+
[pattern: string]: OpenApiSchemaOrRef;
|
|
18
|
+
};
|
|
19
|
+
discriminator?: OpenAPIV3.DiscriminatorObject;
|
|
20
|
+
};
|
|
21
|
+
export type OpenApiSchemaOrRef = OpenApiSchema | OpenAPIV3.ReferenceObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nexport type Spec = OpenAPIV3.Document | OpenAPIV3_1.Document;\n"],"names":[],"mappings":"AAAA;;;CAGC,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/open-api/utils/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nexport type Spec = OpenAPIV3.Document | OpenAPIV3_1.Document;\n\n/**\n * An OpenAPI schema object, spanning the 3.0 and 3.1 shapes plus the additional\n * JSON-Schema / 3.1 keywords the code generator inspects that are absent from\n * the `openapi-types` 3.0 definition (`patternProperties`, `const`, and the 3.0\n * `nullable` flag).\n */\nexport type OpenApiSchema = (\n | OpenAPIV3.SchemaObject\n | OpenAPIV3_1.SchemaObject\n) & {\n nullable?: boolean;\n const?: unknown;\n patternProperties?: {\n [pattern: string]: OpenApiSchemaOrRef;\n };\n discriminator?: OpenAPIV3.DiscriminatorObject;\n};\n\nexport type OpenApiSchemaOrRef = OpenApiSchema | OpenAPIV3.ReferenceObject;\n"],"names":[],"mappings":"AAAA;;;CAGC,GAuBD,WAA2E"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`preset generator > should run successfully > .codex/config.toml 1`] = `
|
|
4
4
|
"[mcp_servers.nx-plugin-for-aws]
|
|
5
5
|
command = "npx"
|
|
6
|
-
args = [ "-y", "@aws/nx-plugin-mcp
|
|
6
|
+
args = [ "-y", "@aws/nx-plugin-mcp" ]
|
|
7
7
|
"
|
|
8
8
|
`;
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ exports[`preset generator > should run successfully > .cursor/mcp.json 1`] = `
|
|
|
12
12
|
"mcpServers": {
|
|
13
13
|
"nx-plugin-for-aws": {
|
|
14
14
|
"command": "npx",
|
|
15
|
-
"args": ["-y", "@aws/nx-plugin-mcp
|
|
15
|
+
"args": ["-y", "@aws/nx-plugin-mcp"]
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -24,7 +24,7 @@ exports[`preset generator > should run successfully > .gemini/settings.json 1`]
|
|
|
24
24
|
"mcpServers": {
|
|
25
25
|
"nx-plugin-for-aws": {
|
|
26
26
|
"command": "npx",
|
|
27
|
-
"args": ["-y", "@aws/nx-plugin-mcp
|
|
27
|
+
"args": ["-y", "@aws/nx-plugin-mcp"]
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -38,7 +38,7 @@ exports[`preset generator > should run successfully > .kiro/settings/mcp.json 1`
|
|
|
38
38
|
"mcpServers": {
|
|
39
39
|
"nx-plugin-for-aws": {
|
|
40
40
|
"command": "npx",
|
|
41
|
-
"args": ["-y", "@aws/nx-plugin-mcp
|
|
41
|
+
"args": ["-y", "@aws/nx-plugin-mcp"]
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -50,7 +50,7 @@ exports[`preset generator > should run successfully > .mcp.json 1`] = `
|
|
|
50
50
|
"mcpServers": {
|
|
51
51
|
"nx-plugin-for-aws": {
|
|
52
52
|
"command": "npx",
|
|
53
|
-
"args": ["-y", "@aws/nx-plugin-mcp
|
|
53
|
+
"args": ["-y", "@aws/nx-plugin-mcp"]
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -65,7 +65,7 @@ exports[`preset generator > should run successfully > .vscode/mcp.json 1`] = `
|
|
|
65
65
|
"nx-plugin-for-aws": {
|
|
66
66
|
"type": "stdio",
|
|
67
67
|
"command": "npx",
|
|
68
|
-
"args": ["-y", "@aws/nx-plugin-mcp
|
|
68
|
+
"args": ["-y", "@aws/nx-plugin-mcp"]
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/utils/mcp.js
CHANGED
|
@@ -13,7 +13,7 @@ import { updateToml } from "./toml.js";
|
|
|
13
13
|
* Arguments used to launch the Nx Plugin for AWS MCP server.
|
|
14
14
|
*/ export const NX_PLUGIN_MCP_SERVER_ARGS = [
|
|
15
15
|
'-y',
|
|
16
|
-
'@aws/nx-plugin-mcp
|
|
16
|
+
'@aws/nx-plugin-mcp'
|
|
17
17
|
];
|
|
18
18
|
/**
|
|
19
19
|
* A single stdio MCP server entry, shared by agents that use the `mcpServers` config shape.
|
package/src/utils/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/mcp.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readJson, type Tree, writeJson } from '@nx/devkit';\nimport { updateToml } from './toml';\n\n/**\n * Name of the Nx Plugin for AWS MCP server, used as the key in each agent's config.\n */\nexport const NX_PLUGIN_MCP_SERVER_NAME = 'nx-plugin-for-aws';\n\n/**\n * Command used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_COMMAND = 'npx';\n\n/**\n * Arguments used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_ARGS = ['-y', '@aws/nx-plugin-mcp
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/mcp.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readJson, type Tree, writeJson } from '@nx/devkit';\nimport { updateToml } from './toml';\n\n/**\n * Name of the Nx Plugin for AWS MCP server, used as the key in each agent's config.\n */\nexport const NX_PLUGIN_MCP_SERVER_NAME = 'nx-plugin-for-aws';\n\n/**\n * Command used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_COMMAND = 'npx';\n\n/**\n * Arguments used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_ARGS = ['-y', '@aws/nx-plugin-mcp'];\n\n/**\n * A single stdio MCP server entry, shared by agents that use the `mcpServers` config shape.\n */\nconst stdioServerEntry = () => ({\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n});\n\n/**\n * Merge the Nx Plugin for AWS MCP server into a JSON config file under the given key,\n * preserving any other servers already configured. Creates the file if it does not exist.\n */\nconst mergeJsonMcpConfig = (\n tree: Tree,\n filePath: string,\n key: 'mcpServers' | 'servers',\n entry: Record<string, unknown>,\n) => {\n const config = tree.exists(filePath) ? readJson(tree, filePath) : {};\n config[key] = {\n ...config[key],\n [NX_PLUGIN_MCP_SERVER_NAME]: entry,\n };\n writeJson(tree, filePath, config);\n};\n\n/**\n * Configure the Nx Plugin for AWS MCP server across the project-level config locations\n * used by common coding agents, so agents working in the workspace can use it to scaffold\n * AWS projects with the Nx Plugin for AWS.\n *\n * Existing servers and unrelated config in each file are preserved.\n */\nexport const configureMcpServers = (tree: Tree) => {\n // Agents using the `mcpServers` config shape (Claude Code, Cursor, Kiro, Gemini CLI)\n const mcpServersFiles = [\n '.mcp.json', // Claude Code\n '.cursor/mcp.json', // Cursor\n '.kiro/settings/mcp.json', // Kiro\n '.gemini/settings.json', // Gemini CLI\n ];\n for (const filePath of mcpServersFiles) {\n mergeJsonMcpConfig(tree, filePath, 'mcpServers', stdioServerEntry());\n }\n\n // GitHub Copilot uses the `servers` key with an explicit `type`\n mergeJsonMcpConfig(tree, '.vscode/mcp.json', 'servers', {\n type: 'stdio',\n ...stdioServerEntry(),\n });\n\n // OpenAI Codex CLI uses TOML under the `mcp_servers` table\n const codexConfig = '.codex/config.toml';\n if (!tree.exists(codexConfig)) {\n tree.write(codexConfig, '');\n }\n updateToml(tree, codexConfig, (prev) => ({\n ...prev,\n mcp_servers: {\n ...(prev.mcp_servers as object),\n [NX_PLUGIN_MCP_SERVER_NAME]: {\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n },\n },\n }));\n};\n"],"names":["readJson","writeJson","updateToml","NX_PLUGIN_MCP_SERVER_NAME","NX_PLUGIN_MCP_SERVER_COMMAND","NX_PLUGIN_MCP_SERVER_ARGS","stdioServerEntry","command","args","mergeJsonMcpConfig","tree","filePath","key","entry","config","exists","configureMcpServers","mcpServersFiles","type","codexConfig","write","prev","mcp_servers"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,EAAaC,SAAS,QAAQ,aAAa;AAC5D,SAASC,UAAU,QAAQ,YAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,4BAA4B,oBAAoB;AAE7D;;CAEC,GACD,OAAO,MAAMC,+BAA+B,MAAM;AAElD;;CAEC,GACD,OAAO,MAAMC,4BAA4B;IAAC;IAAM;CAAqB,CAAC;AAEtE;;CAEC,GACD,MAAMC,mBAAmB,IAAO,CAAA;QAC9BC,SAASH;QACTI,MAAMH;IACR,CAAA;AAEA;;;CAGC,GACD,MAAMI,qBAAqB,CACzBC,MACAC,UACAC,KACAC;IAEA,MAAMC,SAASJ,KAAKK,MAAM,CAACJ,YAAYX,SAASU,MAAMC,YAAY,CAAC;IACnEG,MAAM,CAACF,IAAI,GAAG;QACZ,GAAGE,MAAM,CAACF,IAAI;QACd,CAACT,0BAA0B,EAAEU;IAC/B;IACAZ,UAAUS,MAAMC,UAAUG;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,sBAAsB,CAACN;IAClC,qFAAqF;IACrF,MAAMO,kBAAkB;QACtB;QACA;QACA;QACA;KACD;IACD,KAAK,MAAMN,YAAYM,gBAAiB;QACtCR,mBAAmBC,MAAMC,UAAU,cAAcL;IACnD;IAEA,gEAAgE;IAChEG,mBAAmBC,MAAM,oBAAoB,WAAW;QACtDQ,MAAM;QACN,GAAGZ,kBAAkB;IACvB;IAEA,2DAA2D;IAC3D,MAAMa,cAAc;IACpB,IAAI,CAACT,KAAKK,MAAM,CAACI,cAAc;QAC7BT,KAAKU,KAAK,CAACD,aAAa;IAC1B;IACAjB,WAAWQ,MAAMS,aAAa,CAACE,OAAU,CAAA;YACvC,GAAGA,IAAI;YACPC,aAAa;gBACX,GAAID,KAAKC,WAAW;gBACpB,CAACnB,0BAA0B,EAAE;oBAC3BI,SAASH;oBACTI,MAAMH;gBACR;YACF;QACF,CAAA;AACF,EAAE"}
|
package/src/utils/names.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* camelCase that first transliterates accents and strips any character that is
|
|
3
|
+
* not a valid identifier character, so inputs like `getFoo≠Bar` or `café` yield
|
|
4
|
+
* valid JS/TS identifiers rather than leaking the raw symbol into generated code.
|
|
5
|
+
*/
|
|
6
|
+
export declare const camelCase: (str: string) => string;
|
|
1
7
|
export declare const toClassName: (str?: string) => string;
|
|
2
8
|
export declare const toKebabCase: (str?: string) => string;
|
|
3
9
|
export declare const toSnakeCase: (str?: string) => string;
|
package/src/utils/names.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import
|
|
4
|
+
*/ import lodashCamelCase from "lodash.camelcase";
|
|
5
5
|
import deburr from "lodash.deburr";
|
|
6
|
+
/**
|
|
7
|
+
* camelCase that first transliterates accents and strips any character that is
|
|
8
|
+
* not a valid identifier character, so inputs like `getFoo≠Bar` or `café` yield
|
|
9
|
+
* valid JS/TS identifiers rather than leaking the raw symbol into generated code.
|
|
10
|
+
*/ export const camelCase = (str)=>lodashCamelCase(deburr(str ?? '').replace(/[^a-zA-Z0-9]+/g, ' '));
|
|
6
11
|
export const toClassName = (str)=>{
|
|
7
12
|
if (!str) {
|
|
8
13
|
return str;
|
package/src/utils/names.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/names.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/names.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport lodashCamelCase from 'lodash.camelcase';\nimport deburr from 'lodash.deburr';\n\n/**\n * camelCase that first transliterates accents and strips any character that is\n * not a valid identifier character, so inputs like `getFoo≠Bar` or `café` yield\n * valid JS/TS identifiers rather than leaking the raw symbol into generated code.\n */\nexport const camelCase = (str: string): string =>\n lodashCamelCase(deburr(str ?? '').replace(/[^a-zA-Z0-9]+/g, ' '));\n\nexport const toClassName = (str?: string): string => {\n if (!str) {\n return str;\n }\n const words = str.replace(/[^a-zA-Z0-9]/g, ' ').split(/\\s+/);\n return words\n .map((word, index) => {\n if (index === 0 && /^\\d/.test(word)) {\n return '_' + word;\n }\n return word.charAt(0).toUpperCase() + word.slice(1);\n })\n .join('');\n};\n\nexport const toKebabCase = (str?: string): string =>\n str?.split('/').map(kebabCase).join('/');\n\nexport const toSnakeCase = (str?: string): string =>\n str?.split('/').map(snakeCase).join('/');\n\nexport const upperFirst = (str: string): string =>\n str.charAt(0).toUpperCase() + str.slice(1);\n\nexport const pascalCase = (str: string): string => upperFirst(camelCase(str));\n\nexport const snakeCase = (str: string): string => {\n return (\n deburr(str)\n // Replace series of special characters with underscores\n .replace(/[^a-zA-Z0-9]+/g, '_')\n // Replace capital letters preceded by lowercase or numbers with underscore + lowercase\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n // Convert to lowercase\n .toLowerCase()\n // Remove leading/trailing underscores\n .replace(/^_+|_+$/g, '')\n );\n};\n\nexport const kebabCase = (str: string): string => {\n return (\n deburr(str)\n // Replace series of special characters with hyphens\n .replace(/[^a-zA-Z0-9]+/g, '-')\n // Replace capital letters preceded by lowercase or numbers with hyphen + lowercase\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n // Convert to lowercase\n .toLowerCase()\n // Remove leading/trailing hyphens\n .replace(/^-+|-+$/g, '')\n );\n};\n\n/**\n * Normalise a string to a PEP 503 distribution name.\n *\n * PEP 503 (https://peps.python.org/pep-0503/#normalized-names) defines the\n * canonical form of a Python project distribution name: lower-cased, with any\n * run of `.`, `_` or `-` collapsed to a single `-`. This is the name uv writes\n * into `uv.lock` and the form `@nxlv/python` expects when inferring workspace\n * dependency edges from `[project].dependencies` / `[tool.uv.sources]`.\n *\n * Importantly this is NOT kebab-case: it does not split on camelCase humps,\n * spaces or other punctuation, so a dotted nx id like `scope.my_lib` becomes\n * `scope-my-lib` (and only those three separators are touched).\n *\n * eg. `sojourner.agent_connection` -> `sojourner-agent-connection`\n */\nexport const normalizeDistributionName = (str: string): string =>\n str.toLowerCase().replace(/[._-]+/g, '-');\n\n// Convert a string to a dot notation string (eg. lambda_handler/my_handler.py -> lambda_handler.my_handler)\nexport const toDotNotation = (str: string): string =>\n str\n ?.replace(/^\\/|\\/$/g, '') // Remove leading/trailing slashes\n .replace(/\\.[^/.]+$/g, '') // Remove any file extensions\n .split('/')\n .filter(Boolean) // Remove empty segments (in case of double slashes)\n .join('.');\n"],"names":["lodashCamelCase","deburr","camelCase","str","replace","toClassName","words","split","map","word","index","test","charAt","toUpperCase","slice","join","toKebabCase","kebabCase","toSnakeCase","snakeCase","upperFirst","pascalCase","toLowerCase","normalizeDistributionName","toDotNotation","filter","Boolean"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,qBAAqB,mBAAmB;AAC/C,OAAOC,YAAY,gBAAgB;AAEnC;;;;CAIC,GACD,OAAO,MAAMC,YAAY,CAACC,MACxBH,gBAAgBC,OAAOE,OAAO,IAAIC,OAAO,CAAC,kBAAkB,MAAM;AAEpE,OAAO,MAAMC,cAAc,CAACF;IAC1B,IAAI,CAACA,KAAK;QACR,OAA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