@nestia/migrate 14.3.0 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/NestiaMigrateApplication.mjs.map +1 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs.map +1 -1
- package/lib/archivers/NestiaMigrateFileArchiver.mjs.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
- package/lib/bundles/NEST_TEMPLATE.mjs.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
- package/lib/bundles/SDK_TEMPLATE.mjs.map +1 -1
- package/lib/executable/NestiaMigrateCommander.mjs.map +1 -1
- package/lib/executable/NestiaMigrateInquirer.mjs.map +1 -1
- package/lib/executable/TemplateBundleCache.mjs.map +1 -1
- package/lib/executable/bundle.mjs.map +1 -1
- package/lib/executable/migrate.mjs.map +1 -1
- package/lib/factories/ExpressionFactory.mjs.map +1 -1
- package/lib/factories/IdentifierFactory.mjs.map +1 -1
- package/lib/factories/LiteralFactory.mjs.map +1 -1
- package/lib/factories/StatementFactory.mjs.map +1 -1
- package/lib/factories/SupportedStringFormats.mjs.map +1 -1
- package/lib/factories/TypeFactory.mjs.map +1 -1
- package/lib/factories/TypeLiteralFactory.mjs.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/internal/ts.mjs.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/package.mjs +1 -1
- package/lib/programmers/NestiaMigrateApiFileProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateDtoProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateE2eProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateNestProgrammer.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs.map +1 -1
- package/lib/utils/FilePrinter.mjs.map +1 -1
- package/lib/utils/MapUtil.mjs.map +1 -1
- package/lib/utils/PathTemplate.mjs.map +1 -1
- package/lib/utils/RequestBody.mjs.map +1 -1
- package/lib/utils/StringUtil.mjs.map +1 -1
- package/lib/utils/SuccessStatus.mjs.map +1 -1
- package/package.json +5 -5
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiFunctionProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiFunctionProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateApiFunctionProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute, OpenApi } from \"@typia/interface\";\nimport { NamingConvention } from \"@typia/utils\";\n\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { StatementFactory } from \"../factories/StatementFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { RequestBody } from \"../utils/RequestBody\";\nimport { SuccessStatus } from \"../utils/SuccessStatus\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the function of one route in the SDK.\n *\n * @evidence contracts/common.md#principled-implementation The function has the connection parameter, the path, query, header, and body parameters in positional or keyword form, and its body calls the plain or the encrypted fetcher, or the simulator when the connection asks for it, and copies response headers when the description asks.\n * @evidence contracts/common.md#clear-and-simple-design One entry function, one public parameter builder shared with the simulation programmer, and private helpers for the body and the header directives.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route and the configuration, and the header directives are read from the documented tags.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateApiFunctionProgrammer {\n /**\n * The input of one function: the configuration, the components, the importer,\n * and the route.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the function generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IContext {\n /** Calling convention and optional generated features for this operation. */\n config: INestiaMigrateConfig;\n\n /** Component schemas used to resolve DTO references. */\n components: OpenApi.IComponents;\n\n /** File-local import collector shared with the surrounding file writer. */\n importer: NestiaMigrateImportProgrammer;\n\n /** Analyzed operation, with the accessor chosen for this generation. */\n route: IHttpMigrateRoute;\n }\n\n /**\n * Returns the exported async function declaration of the route, with its\n * description.\n *\n * @evidence contracts/common.md#principled-implementation The function name is the last accessor segment, the return type is the namespace's response type or void, and the description comes from the route comment with the path, the accessor, and the author tag.\n * @evidence contracts/common.md#clear-and-simple-design One expression over the private parts.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the accessor.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (ctx: IContext): ts.FunctionDeclaration =>\n FilePrinter.description(\n factory.createFunctionDeclaration(\n [\n factory.createModifier(SyntaxKind.ExportKeyword),\n factory.createModifier(SyntaxKind.AsyncKeyword),\n ],\n undefined,\n ctx.route.accessor.at(-1)!,\n undefined,\n writeParameterDeclarations(ctx),\n factory.createTypeReferenceNode(\"Promise\", [\n factory.createTypeReferenceNode(\n ctx.route.success === null\n ? \"void\"\n : `${ctx.route.accessor.at(-1)!}.Response`,\n ),\n ]),\n factory.createBlock(writeBody(ctx), true),\n ),\n writeDescription(ctx.config, ctx.route),\n );\n\n /**\n * Returns the parameters of the function: the connection first, then either\n * one `props` parameter in keyword mode or the path, query, and body\n * parameters in positional mode.\n *\n * @evidence contracts/common.md#principled-implementation The connection type carries the route's header type when it has one, keyword mode adds `props` only when there is something to pass, and an optional body is marked optional.\n * @evidence contracts/common.md#clear-and-simple-design One function with the two modes as two returns.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The shape follows the configuration.\n * @evidence contracts/common.md#meaningful-documentation The comment states the two modes.\n */\n export const writeParameterDeclarations = (\n ctx: IContext,\n connectionName?: string,\n ): ts.ParameterDeclaration[] => {\n const connection: ts.ParameterDeclaration = IdentifierFactory.parameter(\n connectionName ?? \"connection\",\n factory.createTypeReferenceNode(\n ctx.importer.external({\n type: \"instance\",\n library: \"@nestia/fetcher\",\n name: \"IConnection\",\n }),\n ctx.route.headers\n ? [\n factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Headers`,\n ),\n ]\n : undefined,\n ),\n );\n if (ctx.config.keyword === true) {\n const isProps: boolean =\n ctx.route.parameters.length > 0 ||\n !!ctx.route.query ||\n !!ctx.route.body;\n if (isProps === false) return [connection];\n return [\n connection,\n factory.createParameterDeclaration(\n undefined,\n undefined,\n \"props\",\n undefined,\n factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Props`,\n ),\n ),\n ];\n }\n return [\n connection,\n ...ctx.route.parameters.map((p) =>\n IdentifierFactory.parameter(\n p.key,\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: p.schema,\n }),\n ),\n ),\n ...(ctx.route.query\n ? [\n IdentifierFactory.parameter(\n ctx.route.query.key,\n factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Query`,\n ),\n ),\n ]\n : []),\n ...(ctx.route.body\n ? [\n IdentifierFactory.parameter(\n ctx.route.body.key,\n factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Body`,\n ),\n RequestBody.optional(ctx.route)\n ? factory.createToken(SyntaxKind.QuestionToken)\n : undefined,\n ),\n ]\n : []),\n ];\n };\n\n const writeDescription = (\n config: INestiaMigrateConfig,\n route: IHttpMigrateRoute,\n ): string => {\n const comment: string = route.comment();\n return [\n config.keyword === true\n ? comment.split(\"@param \").join(\"@param props.\")\n : comment,\n `@path ${route.emendedPath}`,\n `@accessor api.functional.${route.accessor.join(\".\")}`,\n `@${config.author?.tag ?? \"nestia\"} ${config.author?.value ?? \"Generated by Nestia - https://github.com/samchon/nestia\"}`,\n ].join(\"\\n\");\n };\n\n const writeBody = (ctx: IContext): ts.Statement[] => {\n const encrypted: boolean = !!ctx.route.success?.[\"x-nestia-encrypted\"];\n const contentType: string = ctx.route.body?.type ?? \"application/json\";\n\n const property = (key: string): ts.Expression =>\n ctx.config.keyword === true\n ? IdentifierFactory.access(factory.createIdentifier(\"props\"), key)\n : factory.createIdentifier(key);\n const fetch = () =>\n factory.createAwaitExpression(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"instance\",\n library: encrypted\n ? \"@nestia/fetcher/lib/EncryptedFetcher\"\n : `@nestia/fetcher`,\n name: encrypted ? \"EncryptedFetcher\" : \"PlainFetcher\",\n }),\n ),\n \"fetch\",\n ),\n undefined,\n [\n contentType && contentType !== \"multipart/form-data\"\n ? factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n factory.createIdentifier(\"connection\"),\n ),\n factory.createPropertyAssignment(\n \"headers\",\n factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n IdentifierFactory.access(\n factory.createIdentifier(\"connection\"),\n \"headers\",\n ),\n ),\n factory.createPropertyAssignment(\n factory.createStringLiteral(\"Content-Type\"),\n factory.createStringLiteral(contentType),\n ),\n ],\n true,\n ),\n ),\n ],\n true,\n )\n : factory.createIdentifier(\"connection\"),\n factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n IdentifierFactory.access(\n factory.createIdentifier(ctx.route.accessor.at(-1)!),\n \"METADATA\",\n ),\n ),\n factory.createPropertyAssignment(\n \"path\",\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(ctx.route.accessor.at(-1)!),\n \"path\",\n ),\n undefined,\n getArguments(ctx, false),\n ),\n ),\n // the fetcher reads only 200, 201, and this status as success\n factory.createPropertyAssignment(\n \"status\",\n ((status) =>\n status === null\n ? factory.createNull()\n : factory.createNumericLiteral(status))(\n SuccessStatus.of(ctx.route),\n ),\n ),\n ],\n true,\n ),\n ...(ctx.route.body ? [property(ctx.route.body.key)] : []),\n ],\n ),\n );\n\n const value: ts.Expression =\n ctx.config.simulate !== true\n ? fetch()\n : factory.createConditionalExpression(\n factory.createStrictEquality(\n factory.createTrue(),\n factory.createIdentifier(\"connection.simulate\"),\n ),\n undefined,\n factory.createCallExpression(\n factory.createIdentifier(\n `${ctx.route.accessor.at(-1)!}.simulate`,\n ),\n [],\n [\n factory.createIdentifier(\"connection\"),\n ...getArguments(ctx, true),\n ],\n ),\n undefined,\n fetch(),\n );\n const headers: Array<IAssignHeader | ISetHeader> = getHeaders(\n ctx.route.comment(),\n );\n if (headers.length === 0) return [factory.createReturnStatement(value)];\n return [\n StatementFactory.constant({\n name: \"output\",\n type: factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Response`,\n ),\n value,\n }),\n factory.createExpressionStatement(\n factory.createBinaryExpression(\n factory.createIdentifier(\"connection.headers\"),\n factory.createToken(SyntaxKind.QuestionQuestionEqualsToken),\n factory.createObjectLiteralExpression([]),\n ),\n ),\n ...headers.map((h) =>\n factory.createExpressionStatement(\n h.type === \"assign\"\n ? factory.createCallExpression(\n factory.createIdentifier(\"Object.assign\"),\n undefined,\n [\n factory.createIdentifier(\"connection.headers\"),\n factory.createIdentifier(`output.${h.accessor}`),\n ],\n )\n : factory.createBinaryExpression(\n factory.createIdentifier(\n `connection.headers${\n NamingConvention.variable(h.property)\n ? `.${h.property}`\n : `[${JSON.stringify(h.property)}]`\n }`,\n ),\n factory.createToken(SyntaxKind.EqualsToken),\n factory.createIdentifier(`output.${h.accessor}`),\n ),\n ),\n ),\n factory.createReturnStatement(factory.createIdentifier(\"output\")),\n ];\n };\n\n const getArguments = (ctx: IContext, body: boolean): ts.Expression[] => {\n if (\n ctx.route.parameters.length === 0 &&\n ctx.route.query === null &&\n (body === false || ctx.route.body === null)\n )\n return [];\n else if (ctx.config.keyword === true)\n return [factory.createIdentifier(\"props\")];\n return [\n ...ctx.route.parameters.map((p) => factory.createIdentifier(p.key)),\n ...(ctx.route.query\n ? [factory.createIdentifier(ctx.route.query.key)]\n : []),\n ...(body && ctx.route.body\n ? [factory.createIdentifier(ctx.route.body.key)]\n : []),\n ];\n };\n\n const getHeaders = (\n description: string,\n ): Array<IAssignHeader | ISetHeader> => {\n const directives: Array<IAssignHeader | ISetHeader> = [];\n for (const line of description.split(\"\\n\").map((l) => l.trim())) {\n const setHeaderTag: string | undefined = [\n \"@setHeader \",\n \"@setHeaders \",\n ].find((tag) => line.startsWith(tag));\n if (setHeaderTag !== undefined) {\n const parts: string[] = line\n .substring(setHeaderTag.length)\n .trim()\n .split(/\\s+/);\n if (parts.length >= 2)\n directives.push({\n type: \"set\",\n accessor: parts[0]!,\n property: parts[1]!,\n });\n } else if (line.startsWith(\"@assignHeaders \")) {\n const accessor: string = line\n .substring(\"@assignHeaders \".length)\n .trim();\n if (accessor.length !== 0)\n directives.push({\n type: \"assign\",\n accessor,\n });\n }\n }\n return directives;\n };\n}\n\ninterface IAssignHeader {\n type: \"assign\";\n accessor: string;\n}\ninterface ISetHeader {\n type: \"set\";\n accessor: string;\n property: string;\n}\n"],"mappings":";;;;;;;;;AAsBO,IAAA;;8CAiCiB,QACpB,YAAY,YACV,QAAQ,0BACN,CACE,QAAQ,eAAe,WAAW,aAAa,GAC/C,QAAQ,eAAe,WAAW,YAAY,CAChD,GACA,KAAA,GACA,IAAI,MAAM,SAAS,GAAG,EAAE,GACxB,KAAA,GACA,2BAA2B,GAAG,GAC9B,QAAQ,wBAAwB,WAAW,CACzC,QAAQ,wBACN,IAAI,MAAM,YAAY,OAClB,SACA,GAAG,IAAI,MAAM,SAAS,GAAG,EAAE,EAAG,UACpC,CACF,CAAC,GACD,QAAQ,YAAY,UAAU,GAAG,GAAG,IAAI,CAC1C,GACA,iBAAiB,IAAI,QAAQ,IAAI,KAAK,CACxC;CAYK,MAAM,6BAAA,oCAAA,8BACX,KACA,mBAC8B;EAC9B,MAAM,aAAsC,kBAAkB,UAC5D,kBAAkB,cAClB,QAAQ,wBACN,IAAI,SAAS,SAAS;GACpB,MAAM;GACN,SAAS;GACT,MAAM;EACR,CAAC,GACD,IAAI,MAAM,UACN,CACE,QAAQ,wBACN,GAAG,IAAI,MAAM,SAAS,GAAG,EAAE,EAAG,SAChC,CACF,IACA,KAAA,CACN,CACF;EACA,IAAI,IAAI,OAAO,YAAY,MAAM;GAK/B,KAHE,IAAI,MAAM,WAAW,SAAS,KAC9B,CAAC,CAAC,IAAI,MAAM,SACZ,CAAC,CAAC,IAAI,MAAM,UACE,OAAO,OAAO,CAAC,UAAU;GACzC,OAAO,CACL,YACA,QAAQ,2BACN,KAAA,GACA,KAAA,GACA,SACA,KAAA,GACA,QAAQ,wBACN,GAAG,IAAI,MAAM,SAAS,GAAG,EAAE,EAAG,OAChC,CACF,CACF;EACF;EACA,OAAO;GACL;GACA,GAAG,IAAI,MAAM,WAAW,KAAK,MAC3B,kBAAkB,UAChB,EAAE,KACF,8BAA8B,MAAM;I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IAAI,MAAM,KAAK,GAAG,CAAC,IAC7C,CAAC;EACP;CACF;CAEA,MAAM,cACJ,gBACsC;EACtC,MAAM,aAAgD,CAAC;EACvD,KAAK,MAAM,QAAQ,YAAY,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC,GAAG;GAC/D,MAAM,eAAmC,CACvC,eACA,cACF,CAAC,CAAC,MAAM,QAAQ,KAAK,WAAW,GAAG,CAAC;GACpC,IAAI,iBAAiB,KAAA,GAAW;IAC9B,MAAM,QAAkB,KACrB,UAAU,aAAa,MAAM,CAAC,CAC9B,KAAK,CAAC,CACN,MAAM,KAAK;IACd,IAAI,MAAM,UAAU,GAClB,WAAW,KAAK;KACd,MAAM;KACN,UAAU,MAAM;KAChB,UAAU,MAAM;IAClB,CAAC;GACL,OAAO,IAAI,KAAK,WAAW,iBAAiB,GAAG;IAC7C,MAAM,WAAmB,KACtB,UAAU,EAAwB,CAAC,CACnC,KAAK;IACR,IAAI,SAAS,WAAW,GACtB,WAAW,KAAK;KACd,MAAM;KACN;IACF,CAAC;GACL;EACF;EACA,OAAO;CACT;GACD,uCAAA,qCAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiNamespaceProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiNamespaceProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateApiNamespaceProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute } from \"@typia/interface\";\nimport { OpenApi } from \"typia\";\n\nimport { ExpressionFactory } from \"../factories/ExpressionFactory\";\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { LiteralFactory } from \"../factories/LiteralFactory\";\nimport { TypeFactory } from \"../factories/TypeFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { PathTemplate } from \"../utils/PathTemplate\";\nimport { RequestBody } from \"../utils/RequestBody\";\nimport { NestiaMigrateApiSimulationProgrammer } from \"./NestiaMigrateApiSimulationProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the namespace that accompanies the function of a route: its types,\n * its metadata, its path builder, and, in simulation mode, its simulator.\n *\n * @evidence contracts/common.md#principled-implementation The namespace declares the `Props`, `Query`, `Body`, `Headers`, and `Response` types from the schemas, the route metadata the fetcher reads, the `path` function that fills the parameters into the template, and the simulator members.\n * @evidence contracts/common.md#clear-and-simple-design One entry function, one public path-call builder shared with the simulation programmer, and private helpers per member.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route and the configuration.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateApiNamespaceProgrammer {\n /**\n * The input of one namespace: the configuration, the components, the\n * importer, and the route.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the namespace generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IContext {\n /** Calling convention and optional generated features for this operation. */\n config: INestiaMigrateConfig;\n\n /** Component schemas used to resolve DTO references. */\n components: OpenApi.IComponents;\n\n /** File-local import collector shared with the surrounding file writer. */\n importer: NestiaMigrateImportProgrammer;\n\n /** Analyzed operation, with the accessor chosen for this generation. */\n route: IHttpMigrateRoute;\n }\n\n /**\n * Returns the namespace declaration of a route.\n *\n * @evidence contracts/common.md#principled-implementation The members are written in a fixed order: types, metadata, path function, and the random and simulate members when simulation is enabled.\n * @evidence contracts/common.md#clear-and-simple-design One function composing the private writers.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The members follow the configuration.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (ctx: IContext): ts.ModuleDeclaration => {\n const types: ts.TypeAliasDeclaration[] = writeTypes(ctx);\n return factory.createModuleDeclaration(\n [factory.createToken(SyntaxKind.ExportKeyword)],\n factory.createIdentifier(ctx.route.accessor.at(-1)!),\n factory.createModuleBlock([\n ...types,\n ...(types.length ? [FilePrinter.newLine()] : []),\n writeMetadata(ctx),\n FilePrinter.newLine(),\n writePathFunction(ctx),\n ...(ctx.config.simulate === true\n ? [\n NestiaMigrateApiSimulationProgrammer.random(ctx),\n NestiaMigrateApiSimulationProgrammer.simulate(ctx),\n ]\n : []),\n ]),\n NodeFlags.Namespace,\n );\n };\n\n /**\n * Returns the call expression of the route's `path` function with the\n * arguments the configuration selects.\n *\n * @evidence contracts/common.md#principled-implementation In keyword mode the arguments are the `props` object and otherwise the path and query parameters in order, so the same call is valid in both modes.\n * @evidence contracts/common.md#clear-and-simple-design One function shared by the simulator and the namespace.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The arguments follow the configuration.\n * @evidence contracts/common.md#meaningful-documentation The comment states the two argument forms.\n */\n export const writePathCallExpression = (\n config: INestiaMigrateConfig,\n route: IHttpMigrateRoute,\n ) =>\n factory.createCallExpression(\n factory.createIdentifier(`${route.accessor.at(-1)!}.path`),\n undefined,\n route.parameters.length === 0 && route.query === null\n ? []\n : config.keyword === true\n ? [factory.createIdentifier(\"props\")]\n : [...route.parameters, ...(route.query ? [route.query] : [])].map(\n (p) => factory.createIdentifier(p.key),\n ),\n );\n\n const writeTypes = (ctx: IContext): ts.TypeAliasDeclaration[] => {\n const array: ts.TypeAliasDeclaration[] = [];\n const declare = (name: string, type: ts.TypeNode) =>\n array.push(\n factory.createTypeAliasDeclaration(\n [factory.createModifier(SyntaxKind.ExportKeyword)],\n name,\n undefined,\n type,\n ),\n );\n if (\n ctx.config.keyword === true &&\n (ctx.route.parameters.length > 0 || ctx.route.query || ctx.route.body)\n )\n declare(\n \"Props\",\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: {\n type: \"object\",\n properties: Object.fromEntries([\n ...ctx.route.parameters.map((p) => [\n p.key,\n {\n ...p.schema,\n description: p.parameter().description,\n },\n ]),\n ...(ctx.route.query\n ? [\n [\n ctx.route.query.key,\n {\n ...ctx.route.query.schema,\n title: ctx.route.query.title(),\n description: ctx.route.query.description(),\n },\n ],\n ]\n : []),\n ...(ctx.route.body\n ? [\n [\n ctx.route.body.key,\n {\n ...ctx.route.body.schema,\n description: ctx.route.body.description(),\n },\n ],\n ]\n : []),\n ]),\n required: [\n ...ctx.route.parameters.map((p) => p.key),\n ...(ctx.route.query ? [ctx.route.query.key] : []),\n ...(ctx.route.body && RequestBody.optional(ctx.route) === false\n ? [ctx.route.body.key]\n : []),\n ],\n },\n }),\n );\n if (ctx.route.headers)\n declare(\n \"Headers\",\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.headers.schema,\n }),\n );\n if (ctx.route.query)\n declare(\n \"Query\",\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.query.schema,\n }),\n );\n if (ctx.route.body)\n declare(\n \"Body\",\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.body.schema,\n }),\n );\n if (ctx.route.success)\n declare(\n \"Response\",\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.success.schema,\n }),\n );\n return array;\n };\n\n const writeMetadata = (ctx: IContext): ts.VariableStatement =>\n constant(\n \"METADATA\",\n factory.createAsExpression(\n factory.createObjectLiteralExpression(\n [\n factory.createPropertyAssignment(\n \"method\",\n factory.createStringLiteral(ctx.route.method.toUpperCase()),\n ),\n factory.createPropertyAssignment(\n \"path\",\n factory.createStringLiteral(getPath(ctx.route)),\n ),\n factory.createPropertyAssignment(\n \"request\",\n ctx.route.body\n ? LiteralFactory.write({\n type: ctx.route.body.type,\n encrypted: !!ctx.route.body[\"x-nestia-encrypted\"],\n })\n : factory.createNull(),\n ),\n factory.createPropertyAssignment(\n \"response\",\n ctx.route.method.toUpperCase() !== \"HEAD\"\n ? LiteralFactory.write({\n type: ctx.route.success?.type ?? \"application/json\",\n encrypted: !!ctx.route.success?.[\"x-nestia-encrypted\"],\n })\n : factory.createNull(),\n ),\n ...(ctx.route.success?.type === \"application/x-www-form-urlencoded\"\n ? [\n factory.createPropertyAssignment(\n \"parseQuery\",\n factory.createCallExpression(\n factory.createIdentifier(\n `${ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n })}.http.createAssertQuery`,\n ),\n [\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.success.schema,\n }),\n ],\n undefined,\n ),\n ),\n ]\n : []),\n ],\n true,\n ),\n factory.createTypeReferenceNode(factory.createIdentifier(\"const\")),\n ),\n );\n\n const writePathFunction = (ctx: IContext): ts.VariableStatement => {\n const empty: boolean =\n ctx.route.parameters.length === 0 && ctx.route.query === null;\n const property = (key: string) =>\n ctx.config.keyword === true\n ? IdentifierFactory.access(factory.createIdentifier(\"props\"), key)\n : factory.createIdentifier(key);\n const out = (body: ts.ConciseBody) =>\n constant(\n \"path\",\n factory.createArrowFunction(\n [],\n [],\n empty\n ? []\n : ctx.config.keyword === true\n ? [\n IdentifierFactory.parameter(\n \"props\",\n ctx.route.body\n ? factory.createTypeReferenceNode(\"Omit\", [\n factory.createTypeReferenceNode(\"Props\"),\n factory.createLiteralTypeNode(\n factory.createStringLiteral(ctx.route.body.key),\n ),\n ])\n : factory.createTypeReferenceNode(\"Props\"),\n ),\n ]\n : [\n ...ctx.route.parameters.map((p) =>\n IdentifierFactory.parameter(\n p.key,\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: p.schema,\n }),\n ),\n ),\n ...(ctx.route.query\n ? [\n IdentifierFactory.parameter(\n ctx.route.query.key,\n factory.createTypeReferenceNode(\n `${ctx.route.accessor.at(-1)!}.Query`,\n ),\n ),\n ]\n : []),\n ],\n undefined,\n undefined,\n body,\n ),\n );\n const template = () => {\n // the document's template delimits each parameter; the emended path's\n // `:id.json` would not tell the name from the literal after it\n const segments: PathTemplate.ISegment[] = PathTemplate.segments(\n ctx.route,\n );\n if (segments.every((segment) => segment.type === \"literal\"))\n return factory.createStringLiteral(getPath(ctx.route));\n const literals: string[] = [\"\"];\n const parameters: IHttpMigrateRoute.IParameter[] = [];\n for (const segment of segments)\n if (segment.type === \"literal\")\n literals[literals.length - 1] += segment.value;\n else {\n parameters.push(segment.parameter);\n literals.push(\"\");\n }\n return factory.createTemplateExpression(\n factory.createTemplateHead(literals[0]!),\n parameters.map((parameter, i) =>\n factory.createTemplateSpan(\n // URI-encoded, \"null\" when nullish, and a dot segment refused\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"instance\",\n library: \"@nestia/fetcher\",\n name: \"PathParameter\",\n }),\n ),\n \"encode\",\n ),\n undefined,\n [\n factory.createStringLiteral(parameter.key),\n property(parameter.key),\n ],\n ),\n (i !== parameters.length - 1\n ? factory.createTemplateMiddle\n : factory.createTemplateTail)(literals[i + 1]!),\n ),\n ),\n );\n };\n if (!ctx.route.query) return out(template());\n\n const computeName = (str: string): string =>\n ctx.route.parameters.find((p) => p.key === str) !== undefined\n ? computeName(\"_\" + str)\n : str;\n const variables: string = computeName(\"variables\");\n return out(\n factory.createBlock(\n [\n local({\n name: variables,\n type: \"URLSearchParams\",\n expression: factory.createNewExpression(\n factory.createIdentifier(\"URLSearchParams\"),\n [],\n [],\n ),\n }),\n factory.createForOfStatement(\n undefined,\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createArrayBindingPattern([\n factory.createBindingElement(\n undefined,\n undefined,\n factory.createIdentifier(\"key\"),\n undefined,\n ),\n factory.createBindingElement(\n undefined,\n undefined,\n factory.createIdentifier(\"value\"),\n undefined,\n ),\n ]),\n undefined,\n undefined,\n undefined,\n ),\n ],\n NodeFlags.Const,\n ),\n factory.createCallExpression(\n factory.createIdentifier(\"Object.entries\"),\n undefined,\n [\n factory.createAsExpression(\n property(ctx.route.query.key),\n TypeFactory.keyword(\"any\"),\n ),\n ],\n ),\n factory.createIfStatement(\n factory.createStrictEquality(\n factory.createIdentifier(\"undefined\"),\n factory.createIdentifier(\"value\"),\n ),\n factory.createContinueStatement(),\n factory.createIfStatement(\n factory.createCallExpression(\n factory.createIdentifier(\"Array.isArray\"),\n undefined,\n [factory.createIdentifier(\"value\")],\n ),\n factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier(\"value\"),\n factory.createIdentifier(\"forEach\"),\n ),\n undefined,\n [\n factory.createArrowFunction(\n undefined,\n undefined,\n [IdentifierFactory.parameter(\"elem\")],\n undefined,\n undefined,\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(variables),\n \"append\",\n ),\n undefined,\n [\n factory.createIdentifier(\"key\"),\n factory.createCallExpression(\n factory.createIdentifier(\"String\"),\n undefined,\n [factory.createIdentifier(\"elem\")],\n ),\n ],\n ),\n ),\n ],\n ),\n ),\n factory.createExpressionStatement(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(variables),\n \"set\",\n ),\n undefined,\n [\n factory.createIdentifier(\"key\"),\n factory.createCallExpression(\n factory.createIdentifier(\"String\"),\n undefined,\n [factory.createIdentifier(\"value\")],\n ),\n ],\n ),\n ),\n ),\n ),\n ),\n local({\n name: \"location\",\n type: \"string\",\n expression: template(),\n }),\n factory.createReturnStatement(\n factory.createConditionalExpression(\n factory.createStrictEquality(\n ExpressionFactory.number(0),\n IdentifierFactory.access(\n factory.createIdentifier(variables),\n \"size\",\n ),\n ),\n undefined,\n factory.createIdentifier(\"location\"),\n undefined,\n factory.createTemplateExpression(factory.createTemplateHead(\"\"), [\n factory.createTemplateSpan(\n factory.createIdentifier(\"location\"),\n factory.createTemplateMiddle(\"?\"),\n ),\n factory.createTemplateSpan(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(variables),\n \"toString\",\n ),\n undefined,\n undefined,\n ),\n factory.createTemplateTail(\"\"),\n ),\n ]),\n ),\n ),\n ],\n true,\n ),\n );\n };\n}\n\nconst constant = (name: string, expression: ts.Expression) =>\n factory.createVariableStatement(\n [factory.createModifier(SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n name,\n undefined,\n undefined,\n expression,\n ),\n ],\n NodeFlags.Const,\n ),\n );\n\nconst getPath = (route: IHttpMigrateRoute) =>\n (route.emendedPath.startsWith(\"/\") ? \"\" : \"/\") + route.emendedPath;\n\nconst local = (props: {\n name: string;\n type: string;\n expression: ts.Expression;\n}) =>\n factory.createVariableStatement(\n [],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n props.name,\n undefined,\n factory.createTypeReferenceNode(props.type),\n props.expression,\n ),\n ],\n NodeFlags.Const,\n ),\n );\n"],"mappings":";;;;;;;;;;;AA0BO,IAAA;;+CAgCiB,QAAwC;EAC5D,MAAM,QAAmC,WAAW,GAAG;EACvD,OAAO,QAAQ,wBACb,CAAC,QAAQ,YAAY,WAAW,aAAa,CAAC,GAC9C,QAAQ,iBAAiB,IAAI,MAAM,SAAS,GAAG,EAAE,CAAE,GACnD,QAAQ,kBAAkB;GACxB,GAAG;GACH,GAAI,MAAM,SAAS,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC;GAC9C,cAAc,GAAG;GACjB,YAAY,QAAQ;GACpB,kBAAkB,GAAG;GACrB,GAAI,IAAI,OAAO,aAAa,OACxB,CACE,qCAAqC,OAAO,GAAG,GAC/C,qCAAqC,SAAS,GAAG,CACnD,IACA,CAAC;EACP,CAAC,GACD,UAAU,SAC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A,UAAU,KACZ,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateApiProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\nimport { HashMap, hash } from \"tstl\";\n\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateContext } from \"../structures/INestiaMigrateContext\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { NestiaMigrateApiFileProgrammer } from \"./NestiaMigrateApiFileProgrammer\";\nimport { NestiaMigrateDtoProgrammer } from \"./NestiaMigrateDtoProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\n\n/**\n * Generates the functional API files and, for an SDK project, the DTO structure\n * files.\n *\n * @evidence contracts/common.md#principled-implementation Routes are grouped by namespace path in a hash map, each parent namespace is given its child, and each namespace becomes one `index.ts`; the DTO files are written per top-level component name.\n * @evidence contracts/common.md#clear-and-simple-design One entry function and two private helpers for the DTO files.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the accessors of the routes.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateApiProgrammer {\n /**\n * Returns the map from file path to content of the functional API, with the\n * DTO files for an SDK project.\n *\n * @evidence contracts/common.md#principled-implementation The grouping creates every ancestor namespace so that each level has an index, and the paths differ between the two modes only by their root.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the accessors.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (ctx: INestiaMigrateContext): Record<string, string> => {\n const dict: HashMap<string[], NestiaMigrateApiFileProgrammer.IProps> =\n new HashMap(\n (x) => hash(x.join(\".\")),\n (x, y) => x.length === y.length && x.join(\".\") === y.join(\".\"),\n );\n dict.take([], () => ({\n config: ctx.config,\n components: ctx.application.document().components,\n namespace: [],\n routes: [],\n children: new Set(),\n }));\n for (const route of ctx.application.routes) {\n const namespace: string[] = route.accessor.slice(0, -1);\n let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(\n namespace,\n () => ({\n config: ctx.config,\n components: ctx.application.document().components,\n namespace,\n routes: [],\n children: new Set(),\n }),\n );\n last.routes.push(route);\n namespace.forEach((_s, i, array) => {\n const partial: string[] = namespace.slice(0, array.length - i - 1);\n const props: NestiaMigrateApiFileProgrammer.IProps = dict.take(\n partial,\n () => ({\n config: ctx.config,\n components: ctx.application.document().components,\n namespace: partial,\n children: new Set(),\n routes: [],\n }),\n );\n props.children.add(last.namespace.at(-1)!);\n last = props;\n });\n }\n\n // DO GENERATE\n const files: Record<string, string> = Object.fromEntries(\n dict.toJSON().map(({ second: value }) => [\n `${ctx.mode === \"nest\" ? \"packages/api/src\" : \"src\"}/functional/${[...value.namespace, \"index.ts\"].join(\"/\")}`,\n FilePrinter.write({\n statements: NestiaMigrateApiFileProgrammer.write({\n ...value,\n config: ctx.config,\n components: ctx.application.document().components,\n }),\n }),\n ]),\n );\n if (ctx.mode === \"sdk\")\n for (const [key, value] of NestiaMigrateDtoProgrammer.compose({\n config: ctx.config,\n components: ctx.application.document().components,\n }).entries())\n files[`src/structures/${key}.ts`] = FilePrinter.write({\n statements: writeDtoFile(key, value),\n });\n return files;\n };\n\n const writeDtoFile = (\n key: string,\n modulo: NestiaMigrateDtoProgrammer.IModule,\n ): ts.Statement[] => {\n const importer = new NestiaMigrateImportProgrammer();\n const statements: ts.Statement[] = iterate(importer, modulo);\n if (statements.length === 0) return [];\n return [\n ...importer.toStatements((name) => `./${name}`, key),\n ...(importer.empty() ? [] : [FilePrinter.newLine()]),\n ...statements,\n ];\n };\n\n const iterate = (\n importer: NestiaMigrateImportProgrammer,\n modulo: NestiaMigrateDtoProgrammer.IModule,\n ): ts.Statement[] => {\n const output: ts.Statement[] = [];\n if (modulo.programmer !== null) output.push(modulo.programmer(importer));\n if (modulo.children.size !== 0) {\n const internal: ts.Statement[] = [];\n for (const child of modulo.children.values())\n internal.push(...iterate(importer, child));\n output.push(\n factory.createModuleDeclaration(\n [factory.createModifier(SyntaxKind.ExportKeyword)],\n factory.createIdentifier(modulo.name),\n factory.createModuleBlock(internal),\n NodeFlags.Namespace,\n ),\n );\n }\n output.push(FilePrinter.newLine());\n return output;\n };\n}\n"],"mappings":";;;;;;;AAmBO,IAAA;;sCAUiB,QAAuD;EAC3E,MAAM,OACJ,IAAI,SACD,MAAM,KAAK,EAAE,KAAK,GAAG,CAAC,IACtB,GAAG,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,GAAG,CAC/D;EACF,KAAK,KAAK,CAAC,UAAU;GACnB,QAAQ,IAAI;GACZ,YAAY,IAAI,YAAY,SAAS,CAAC,CAAC;GACvC,WAAW,CAAC;GACZ,QAAQ,CAAC;GACT,0BAAU,IAAI,IAAI;EACpB,EAAE;EACF,KAAK,MAAM,SAAS,IAAI,YAAY,QAAQ;GAC1C,MAAM,YAAsB,MAAM,SAAS,MAAM,GAAG,EAAE;GACtD,IAAI,OAA8C,KAAK,KACrD,kBACO;IACL,QAAQ,IAAI;IACZ,YAAY,IAAI,YAAY,SAAS,CAAC,CAAC;IACvC;IACA,QAAQ,CAAC;IACT,0BAAU,IAAI,IAAI;GACpB,EACF;GACA,KAAK,OAAO,KAAK,KAAK;GACtB,UAAU,SAAS,IAAI,GAAG,UAAU;IAClC,MAAM,UAAoB,UAAU,MAAM,GAAG,MAAM,SAAS,IAAI,CAAC;IACjE,MAAM,QAA+C,KAAK,KACxD,gBACO;KACL,QAAQ,IAAI;KACZ,YAAY,IAAI,YAAY,SAAS,CAAC,CAAC;KACvC,WAAW;KACX,0BAAU,IAAI,IAAI;KAClB,QAAQ,CAAC;IACX,EACF;IACA,MAAM,SAAS,IAAI,KAAK,UAA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AC3C,OAAO,KACL,QAAQ,wBACN,CAAC,QAAQ,eAAe,WAAW,aAAa,CAAC,GACjD,QAAQ,iBAAiB,OAAO,IAAI,GACpC,QAAQ,kBAAkB,QAAQ,GAClC,UAAU,SACZ,CACF;EACF;EACA,OAAO,KAAK,YAAY,QAAQ,CAAC;EACjC,OAAO;CACT;GACD,+BAAA,6BAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiSimulationProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiSimulationProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateApiSimulationProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute } from \"@typia/interface\";\nimport { OpenApi } from \"typia\";\n\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { StatementFactory } from \"../factories/StatementFactory\";\nimport { TypeFactory } from \"../factories/TypeFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { NestiaMigrateApiFunctionProgrammer } from \"./NestiaMigrateApiFunctionProgrammer\";\nimport { NestiaMigrateApiNamespaceProgrammer } from \"./NestiaMigrateApiNamespaceProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the mockup simulator members of a route: a random response and a\n * simulate function that validates the request first.\n *\n * @evidence contracts/common.md#principled-implementation The random member calls `typia.random` for the response type, and the simulate function validates the parameters, query, body, and headers with `typia.assert` through the fetcher's simulator, so an invalid simulated request throws the error the real server answers.\n * @evidence contracts/common.md#clear-and-simple-design Two public functions and one private assertion writer.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The simulation follows the schemas of the route.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateApiSimulationProgrammer {\n /**\n * The input of the simulation members: the configuration, the components, the\n * importer, and the route.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IContext {\n /** Calling convention and optional generated features for this operation. */\n config: INestiaMigrateConfig;\n\n /** Component schemas used to resolve DTO references. */\n components: OpenApi.IComponents;\n\n /** File-local import collector shared with the surrounding file writer. */\n importer: NestiaMigrateImportProgrammer;\n\n /** Analyzed operation, with the accessor chosen for this generation. */\n route: IHttpMigrateRoute;\n }\n\n /**\n * Returns the `random` constant: a function that returns a random value of\n * the response type.\n *\n * @evidence contracts/common.md#principled-implementation The response schema is written as a type and given to `typia.random`, and a route without a response uses `void`.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The value is produced by typia at run time.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const random = (ctx: IContext) => {\n const output = ctx.route.success\n ? NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.success.schema,\n })\n : TypeFactory.keyword(\"void\");\n return constant(\n \"random\",\n factory.createArrowFunction(\n undefined,\n undefined,\n [],\n output,\n undefined,\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n }),\n ),\n \"random\",\n ),\n [output],\n undefined,\n ),\n ),\n );\n };\n\n /**\n * Returns the `simulate` constant: a function with the route's parameters\n * that validates the request and returns a random response.\n *\n * @evidence contracts/common.md#principled-implementation The parameters are those of the real function, the assertions run first, and an unused connection is renamed so the compiler does not report it.\n * @evidence contracts/common.md#clear-and-simple-design One expression over the shared parameter builder.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The validation is generated from the same schemas as the real function's types.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const simulate = (ctx: IContext): ts.VariableStatement => {\n const caller = () =>\n factory.createCallExpression(\n factory.createIdentifier(\"random\"),\n undefined,\n undefined,\n );\n return constant(\n \"simulate\",\n factory.createArrowFunction(\n undefined,\n undefined,\n NestiaMigrateApiFunctionProgrammer.writeParameterDeclarations(\n ctx,\n ctx.route.parameters.length === 0 &&\n ctx.route.query === null &&\n ctx.route.body === null &&\n ctx.route.headers === null\n ? \"_connection\"\n : undefined,\n ),\n factory.createTypeReferenceNode(\n ctx.route.success ? \"Response\" : \"void\",\n ),\n undefined,\n factory.createBlock(\n [...assert(ctx), factory.createReturnStatement(caller())],\n true,\n ),\n ),\n );\n };\n\n const assert = (ctx: IContext): ts.Statement[] => {\n const property = (key: string) =>\n ctx.config.keyword === true\n ? IdentifierFactory.access(factory.createIdentifier(\"props\"), key)\n : factory.createIdentifier(key);\n const parameters = [\n ...ctx.route.parameters.map((p) => ({\n category: \"param\",\n name: p.key,\n schema: NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: p.schema,\n }),\n })),\n ...(ctx.route.query\n ? [\n {\n category: \"query\",\n name: ctx.route.query.key,\n schema: NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.query.schema,\n }),\n },\n ]\n : []),\n ...(ctx.route.body\n ? [\n {\n category: \"body\",\n name: ctx.route.body.key,\n schema: NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.body.schema,\n }),\n },\n ]\n : []),\n // the headers travel in the connection, validated as the server does\n ...(ctx.route.headers\n ? [\n {\n category: \"headers\",\n name: ctx.route.headers.key,\n schema: NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.headers.schema,\n }),\n },\n ]\n : []),\n ];\n if (parameters.length === 0) return [];\n\n const validator = StatementFactory.constant({\n name: \"assert\",\n value: factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"instance\",\n library: `@nestia/fetcher`,\n name: \"NestiaSimulator\",\n }),\n ),\n \"assert\",\n ),\n undefined,\n [\n factory.createObjectLiteralExpression(\n [\n factory.createPropertyAssignment(\n \"method\",\n factory.createIdentifier(\"METADATA.method\"),\n ),\n factory.createPropertyAssignment(\n \"host\",\n factory.createIdentifier(\"connection.host\"),\n ),\n factory.createPropertyAssignment(\n \"path\",\n NestiaMigrateApiNamespaceProgrammer.writePathCallExpression(\n ctx.config,\n ctx.route,\n ),\n ),\n factory.createPropertyAssignment(\n \"contentType\",\n factory.createStringLiteral(\n ctx.route.success?.type ?? \"application/json\",\n ),\n ),\n ],\n true,\n ),\n ],\n ),\n });\n const individual: ts.Statement[] = parameters\n .map((p) =>\n factory.createCallExpression(\n (() => {\n const base = IdentifierFactory.access(\n factory.createIdentifier(\"assert\"),\n p.category,\n );\n if (p.category !== \"param\") return base;\n return factory.createCallExpression(base, undefined, [\n factory.createStringLiteral(p.name),\n ]);\n })(),\n undefined,\n [\n factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n undefined,\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n }),\n ),\n \"assert\",\n ),\n // `connection.headers` is typed optional with optional\n // members, so the headers name their own type to be checked\n p.category === \"headers\" ? [p.schema] : undefined,\n [\n p.category === \"headers\"\n ? factory.createIdentifier(\"connection.headers\")\n : property(p.name),\n ],\n ),\n ),\n ],\n ),\n )\n .map(factory.createExpressionStatement) as ts.Statement[];\n // the SDK fetches without propagation, so an invalid simulated request\n // throws its HttpError as the real one does, instead of answering a\n // propagation object in place of the response\n return [validator, ...individual];\n };\n}\n\nconst constant = (name: string, expression: ts.Expression) =>\n factory.createVariableStatement(\n [factory.createModifier(SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createIdentifier(name),\n undefined,\n undefined,\n expression,\n ),\n ],\n NodeFlags.Const,\n ),\n );\n"],"mappings":";;;;;;;;AAuBO,IAAA;;iDAiCkB,QAAkB;EACvC,MAAM,SAAS,IAAI,MAAM,UACrB,8BAA8B,MAAM;GAClC,YAAY,IAAI;GAChB,UAAU,IAAI;GACd,QAAQ,IAAI,MAAM,QAAQ;EAC5B,CAAC,IACD,YAAY,QAAQ,MAAM;EAC9B,OAAO,SACL,UACA,QAAQ,oBACN,KAAA,GACA,KAAA,GACA,CAAC,GACD,QACA,KAAA,GACA,QAAQ,qBACN,kBAAkB,OAChB,QAAQ,iBACN,IAAI,SAAS,SAAS;GACpB,MAAM;GACN,SAAS;GACT,MAAM;EACR,CAAC,CACH,GACA,QACF,GACA,CAAC,MAAM,GACP,KAAA,CACF,CACF,CACF;CACF;mDAWyB,QAAwC;EAC/D,MAAM,eACJ,QAAQ,qBACN,QAAQ,iBAAiB,QAAQ,GACjC,KAAA,GACA,KAAA,CACF;EACF,OAAO,SACL,YACA,QAAQ,oBACN,KAAA,GACA,KAAA,GACA,mCAAmC,2BACjC,KACA,IAAI,MAAM,WAAW,WAAW,KAC9B,IAAI,MAAM,UAAU,QACpB,IAAI,MAAM,SAAS,QACnB,IAAI,MAAM,YAAY,OACpB,gBACA,KAAA,CACN,GACA,QAAQ,wBACN,IAAI,MAAM,UAAU,aAAa,MACnC,GACA,KAAA,GACA,QAAQ,YACN,CAAC,GAAG,OAAO,GAAG,GAAG,QAAQ,sBAAsB,OAAO,CAAC,CAAC,GACxD,IACF,CACF,CACF;CACF;CAEA,MAAM,UAAU,QAAkC;EAChD,MAAM,YAAY,QAChB,IAAI,OAAO,YAAY,OACnB,kBAAkB,OAAO,QAAQ,iBAAiB,OAAO,GAAG,GAAG,IAC/D,QAAQ,iBAAiB,GAAG;EAClC,MAAM,aAAa;G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A,QAAQ,oBACN,IAAI,MAAM,SAAS,QAAQ,kBAC7B,CACF;GACF,GACA,IACF,CACF,CACF;EACF,CAkDgB,GAAG,GAjDgB,WAChC,KAAK,MACJ,QAAQ,4BACC;GACL,MAAM,OAAO,kBAAkB,OAC7B,QAAQ,iBAAiB,QAAQ,GACjC,EAAE,QACJ;GACA,IAAI,EAAE,aAAa,SAAS,OAAO;GACnC,OAAO,QAAQ,qBAAqB,MAAM,KAAA,GAAW,CACnD,QAAQ,oBAAoB,EAAE,IAAI,CACpC,CAAC;EACH,EAAA,CAAG,GACH,KAAA,GACA,CACE,QAAQ,oBACN,KAAA,GACA,KAAA,GACA,CAAC,GACD,KAAA,GACA,KAAA,GACA,QAAQ,qBACN,kBAAkB,OAChB,QAAQ,iBACN,IAAI,SAAS,SAAS;GACpB,MAAM;GACN,SAAS;GACT,MAAM;EACR,CAAC,CACH,GACA,QACF,GAGA,EAAE,aAAa,YAAY,CAAC,EAAE,MAAM,IAAI,KAAA,GACxC,CACE,EAAE,aAAa,YACX,QAAQ,iBAAiB,oBAAoB,IAC7C,SAAS,EAAE,IAAI,CACrB,CACF,CACF,CACF,CACF,CACF,CAAC,CACA,IAAI,QAAQ,yBAIgB,CAAC;CAClC;GACD,yCAAA,uCAAA,CAAA,EAAD;AAEA,MAAM,YAAY,MAAc,eAC9B,QAAQ,wBACN,CAAC,QAAQ,eAAe,WAAW,aAAa,CAAC,GACjD,QAAQ,8BACN,CACE,QAAQ,0BACN,QAAQ,iBAAiB,IAAI,GAC7B,KAAA,GACA,KAAA,GACA,UACF,CACF,GACA,UAAU,KACZ,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiStartProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiStartProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateApiStartProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute } from \"@typia/interface\";\n\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { StatementFactory } from \"../factories/StatementFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateContext } from \"../structures/INestiaMigrateContext\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { NestiaMigrateE2eFunctionProgrammer } from \"./NestiaMigrateE2eFileProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\n\n/**\n * Generates the `test/start.ts` of an SDK project: a small program that calls\n * one API function.\n *\n * @evidence contracts/common.md#principled-implementation The program builds a connection from the global test settings and the first server of the document, adds the simulate flag when requested, and calls the first route the way the generated e2e tests do, so one command can check that the SDK and a server agree.\n * @evidence contracts/common.md#clear-and-simple-design One entry function and private helpers for the connection, the main function, and the starter.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The route is the first one, so the same document always generates the same file.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateApiStartProgrammer {\n /**\n * Returns the `test/start.ts` file of an SDK project.\n *\n * @evidence contracts/common.md#principled-implementation The file imports what the body uses, defines `main`, and starts it, exiting with a failure status when it rejects.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The content derives from the document.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (\n context: INestiaMigrateContext,\n ): Record<string, string> => {\n const importer: NestiaMigrateImportProgrammer =\n new NestiaMigrateImportProgrammer();\n // the first route, so the same document always generates the same file\n const route: IHttpMigrateRoute | undefined = context.application.routes[0];\n const main: ts.VariableStatement = writeMain(context, importer, route);\n const statements: ts.Statement[] = [\n ...importer.toStatements(\n (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,\n ),\n FilePrinter.newLine(),\n ...(route === undefined\n ? []\n : [\n factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n undefined,\n undefined,\n factory.createNamedImports([\n factory.createImportSpecifier(\n false,\n undefined,\n factory.createIdentifier(\"TestGlobal\"),\n ),\n ]),\n ),\n factory.createStringLiteral(\"./TestGlobal\"),\n ),\n FilePrinter.newLine(),\n ]),\n main,\n factory.createExpressionStatement(writeStarter()),\n ];\n return {\n \"test/start.ts\": FilePrinter.write({ statements }),\n };\n };\n\n const writeMain = (\n ctx: INestiaMigrateContext,\n importer: NestiaMigrateImportProgrammer,\n route: IHttpMigrateRoute | undefined,\n ): ts.VariableStatement =>\n StatementFactory.constant({\n name: \"main\",\n value: factory.createArrowFunction(\n [factory.createToken(SyntaxKind.AsyncKeyword)],\n undefined,\n [],\n undefined,\n undefined,\n factory.createBlock(\n [\n ...(route === undefined\n ? []\n : [\n writeConnection(ctx, importer),\n ...NestiaMigrateE2eFunctionProgrammer.writeBody({\n config: ctx.config,\n components: ctx.application.document().components,\n importer,\n route,\n }),\n ]),\n ],\n true,\n ),\n ),\n });\n\n const writeConnection = (\n ctx: INestiaMigrateContext,\n importer: NestiaMigrateImportProgrammer,\n ): ts.VariableStatement =>\n factory.createVariableStatement(\n undefined,\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n \"connection\",\n undefined,\n factory.createTypeReferenceNode(\n factory.createQualifiedName(\n factory.createIdentifier(\n importer.external({\n type: \"default\",\n library: \"@ORGANIZATION/PROJECT-api\",\n name: \"api\",\n }),\n ),\n factory.createIdentifier(\"IConnection\"),\n ),\n ),\n factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier(\"TestGlobal\"),\n \"connection\",\n ),\n undefined,\n undefined,\n ),\n ),\n ...(ctx.application.document().servers?.[0]?.url?.length\n ? [\n factory.createPropertyAssignment(\n \"host\",\n factory.createStringLiteral(\n ctx.application.document().servers![0]!.url,\n ),\n ),\n ]\n : []),\n ...(ctx.config.simulate === true\n ? [\n factory.createPropertyAssignment(\n \"simulate\",\n factory.createTrue(),\n ),\n ]\n : []),\n ],\n true,\n ),\n ),\n ],\n NodeFlags.Const,\n ),\n );\n\n const writeStarter = (): ts.CallExpression =>\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createCallExpression(\n factory.createIdentifier(\"main\"),\n undefined,\n undefined,\n ),\n \"catch\",\n ),\n undefined,\n [\n factory.createArrowFunction(\n undefined,\n undefined,\n [IdentifierFactory.parameter(\"exp\")],\n undefined,\n undefined,\n factory.createBlock(\n [\n factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier(\"console\"),\n \"log\",\n ),\n undefined,\n [factory.createIdentifier(\"exp\")],\n ),\n ),\n factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier(\"process\"),\n \"exit\",\n ),\n undefined,\n [\n factory.createPrefixMinus(\n factory.createNumericLiteral(\"1\"),\n ),\n ],\n ),\n ),\n ],\n true,\n ),\n ),\n ],\n );\n}\n"],"mappings":";;;;;;;AAoBO,IAAA;;2CAUH,YAC2B;EAC3B,MAAM,WACJ,IAAI,8BAA8B;EAEpC,MAAM,QAAuC,QAAQ,YAAY,OAAO;EACxE,MAAM,OAA6B,UAAU,SAAS,UAAU,KAAK;EACrE,MAAM,aAA6B;GACjC,GAAG,SAAS,cACT,SAAS,4CAA4C,MACxD;GACA,YAAY,QAAQ;GACpB,GAAI,UAAU,KAAA,IACV,CAAC,IACD,CACE,QAAQ,wBACN,KAAA,GACA,QAAQ,mBACN,KAAA,GACA,KAAA,GACA,QAAQ,mBAAmB,CACzB,QAAQ,sBACN,OACA,KAAA,GACA,QAAQ,iBAAiB,YAAY,CACvC,CACF,CAAC,CACH,GACA,QAAQ,oBAAoB,cAAc,CAC5C,GACA,YAAY,QAAQ,CACtB;GACJ;GACA,QAAQ,0BAA0B,aAAa,CAAC;EAClD;EACA,OAAO,EACL,iBAAiB,YAAY,MAAM,EAAE,WAAW,CAAC,EACnD;C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,oBACN,KAAA,GACA,KAAA,GACA,CAAC,kBAAkB,UAAU,KAAK,CAAC,GACnC,KAAA,GACA,KAAA,GACA,QAAQ,YACN,CACE,QAAQ,0BACN,QAAQ,qBACN,QAAQ,+BACN,QAAQ,iBAAiB,SAAS,GAClC,KACF,GACA,KAAA,GACA,CAAC,QAAQ,iBAAiB,KAAK,CAAC,CAClC,CACF,GACA,QAAQ,0BACN,QAAQ,qBACN,QAAQ,+BACN,QAAQ,iBAAiB,SAAS,GAClC,MACF,GACA,KAAA,GACA,CACE,QAAQ,kBACN,QAAQ,qBAAqB,GAAG,CAClC,CACF,CACF,CACF,CACF,GACA,IACF,CACF,CACF,CACF;GACH,oCAAA,kCAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateDtoProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateDtoProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateDtoProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\nimport { OpenApi } from \"@typia/interface\";\nimport { IPointer } from \"tstl\";\n\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { MapUtil } from \"../utils/MapUtil\";\nimport { StringUtil } from \"../utils/StringUtil\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the DTO type aliases from the component schemas.\n *\n * @evidence contracts/common.md#principled-implementation Each component name is normalized into a valid dotted name, the dots become nested namespaces, and each schema becomes an exported type alias with its description and its tags as a comment.\n * @evidence contracts/common.md#clear-and-simple-design One public function and private builders for the module tree and the alias.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names derive from the schema names.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateDtoProgrammer {\n /**\n * A node of the DTO namespace tree: its name, its children, and the writer of\n * its alias, or `null` for a namespace without a type of its own.\n *\n * @evidence contracts/common.md#principled-implementation The tree mirrors the dotted names of the schemas, so a namespace exists exactly when a name passes through it.\n * @evidence contracts/common.md#clear-and-simple-design A three-member record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment states the meaning of each member.\n */\n export interface IModule {\n name: string;\n\n /** Child segments of qualified schema names, preserving insertion order. */\n children: Map<string, IModule>;\n\n /** Alias writer for a schema at this node, or null for a namespace alone. */\n programmer:\n | null\n | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);\n }\n\n /**\n * Returns the root of the DTO tree: a map from the first name segment to its\n * module.\n *\n * @evidence contracts/common.md#principled-implementation Each schema key is split on slashes, its segments are escaped into valid identifiers and joined, and the result is inserted along its dotted path.\n * @evidence contracts/common.md#clear-and-simple-design One function over one insertion helper.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the document.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const compose = (props: {\n /** Calling convention and optional generated features for this operation. */\n config: INestiaMigrateConfig;\n\n /** Component schemas used to resolve DTO references. */\n components: OpenApi.IComponents;\n }): Map<string, IModule> => {\n const dict: Map<string, IModule> = new Map();\n for (const [key, value] of Object.entries(props.components.schemas ?? {})) {\n const emendedKey: string = key\n .split(\"/\")\n .filter((str) => str.length !== 0)\n .map(StringUtil.escapeNonVariable)\n .join(\"\");\n prepare(dict)(emendedKey)((importer) =>\n writeAlias(props.config)(props.components)(importer)(emendedKey, value),\n );\n }\n return dict;\n };\n\n const prepare =\n (dict: Map<string, IModule>) =>\n (name: string) =>\n (\n programmer: (\n importer: NestiaMigrateImportProgrammer,\n ) => ts.TypeAliasDeclaration,\n ) => {\n const accessors: string[] = name.split(\".\");\n const modulo: IPointer<IModule> = { value: null! };\n\n accessors.forEach((acc, i) => {\n modulo.value = MapUtil.take(dict)(acc)(() => ({\n name: acc,\n children: new Map(),\n programmer: null,\n }));\n if (i === accessors.length - 1) modulo.value.programmer = programmer;\n dict = modulo.value.children;\n });\n return modulo!;\n };\n\n const writeAlias =\n (config: INestiaMigrateConfig) =>\n (components: OpenApi.IComponents) =>\n (importer: NestiaMigrateImportProgrammer) =>\n (key: string, value: OpenApi.IJsonSchema) =>\n FilePrinter.description(\n factory.createTypeAliasDeclaration(\n [factory.createToken(SyntaxKind.ExportKeyword)],\n key.split(\".\").at(-1)!,\n [],\n NestiaMigrateSchemaProgrammer.write({\n components,\n importer,\n schema: value,\n }),\n ),\n writeComment(config)(value, key.indexOf(\".\") === -1),\n );\n}\n\nconst writeComment =\n (config: INestiaMigrateConfig) =>\n (schema: OpenApi.IJsonSchema, top: boolean): string => {\n // PLUGIN PROPERTIES (x-) AS JSDOC TAGS\n //\n // Mirror NestiaMigrateSchemaProgrammer: emit every `x-` extension property\n // whose value is a primitive as an `@x-key value` JSDoc tag, so the plugin\n // metadata survives the swagger -> DTO round trip.\n const plugins: string[] = [];\n for (const [key, value] of Object.entries(schema))\n if (key.startsWith(\"x-\") && isExtensionValue(value))\n plugins.push(`@${key} ${String(value)}`);\n return [\n ...(schema.description?.length ? [schema.description] : []),\n ...(schema.description?.length &&\n (schema.title !== undefined ||\n schema.deprecated === true ||\n plugins.length !== 0)\n ? [\"\"]\n : []),\n ...(schema.title !== undefined ? [`@title ${schema.title}`] : []),\n ...(schema.deprecated === true ? [`@deprecated`] : []),\n ...plugins,\n ...(top\n ? [\n `@${config.author?.tag ?? \"nestia\"} ${config.author?.value ?? \"Generated by Nestia - https://github.com/samchon/nestia\"}`,\n ]\n : []),\n ].join(\"\\n\");\n };\n\nconst isExtensionValue = (value: unknown): value is boolean | number | string =>\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\";\n"],"mappings":";;;;;;AAoBO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AM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAC9C,IAAI,IAAI,WAAW,IAAI,KAAK,iBAAiB,KAAK,GAChD,QAAQ,KAAK,IAAI,IAAI,GAAG,OAAO,KAAK,GAAG;CAC3C,OAAO;EACL,GAAI,OAAO,aAAa,SAAS,CAAC,OAAO,WAAW,IAAI,CAAC;EACzD,GAAI,OAAO,aAAa,WACvB,OAAO,UAAU,KAAA,KAChB,OAAO,eAAe,QACtB,QAAQ,WAAW,KACjB,CAAC,EAAE,IACH,CAAC;EACL,GAAI,OAAO,UAAU,KAAA,IAAY,CAAC,UAAU,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,eAAe,OAAO,CAAC,aAAa,IAAI,CAAC;EACpD,GAAG;EACH,GAAI,MACA,CACE,IAAI,OAAO,QAAQ,OAAO,SAAS,GAAG,OAAO,QAAQ,SAAS,2DAChE,IACA,CAAC;CACP,CAAC,CAAC,KAAK,IAAI;AACb;AAEF,MAAM,oBAAoB,UACxB,OAAO,UAAU,aACjB,OAAO,UAAU,YACjB,OAAO,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateE2eFileProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateE2eFileProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateE2eFileProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute } from \"@typia/interface\";\nimport { OpenApi } from \"typia\";\n\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { LiteralFactory } from \"../factories/LiteralFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the e2e test function of one route.\n *\n * @evidence contracts/common.md#principled-implementation The function calls the route through the SDK with random arguments made by `typia.random`, including generated headers, and asserts the response with `typia.assert`, so the test checks that the server's answer matches the declared type.\n * @evidence contracts/common.md#clear-and-simple-design One entry function, one public body writer shared with the start programmer, and a private call writer.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The arguments are drawn at run time, and no route is special-cased.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateE2eFunctionProgrammer {\n /**\n * The input of one test function: the configuration, the components, the\n * importer, and the route.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IContext {\n /** Calling convention and optional generated features for this operation. */\n config: INestiaMigrateConfig;\n\n /** Component schemas used to resolve DTO references. */\n components: OpenApi.IComponents;\n\n /** File-local import collector shared with the surrounding file writer. */\n importer: NestiaMigrateImportProgrammer;\n\n /** Analyzed operation, with the accessor chosen for this generation. */\n route: IHttpMigrateRoute;\n }\n\n /**\n * Returns the exported async test function of a route, named `test_api_`\n * followed by its accessor.\n *\n * @evidence contracts/common.md#principled-implementation The name joins `test`, `api`, and the accessor with underscores, so it is unique for a route and matches the prefix that the e2e executor discovers.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The name derives from the accessor.\n * @evidence contracts/common.md#meaningful-documentation The comment states the naming rule.\n */\n export const write = (ctx: IContext): ts.FunctionDeclaration =>\n factory.createFunctionDeclaration(\n [\n factory.createModifier(SyntaxKind.ExportKeyword),\n factory.createModifier(SyntaxKind.AsyncKeyword),\n ],\n undefined,\n [\"test\", \"api\", ...ctx.route.accessor].join(\"_\"),\n undefined,\n [\n IdentifierFactory.parameter(\n \"connection\",\n factory.createTypeReferenceNode(\n factory.createQualifiedName(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"@ORGANIZATION/PROJECT-api\",\n name: \"api\",\n }),\n ),\n factory.createIdentifier(\"IConnection\"),\n ),\n ),\n ),\n ],\n undefined,\n factory.createBlock(writeBody(ctx), true),\n );\n\n /**\n * Returns the statements of the test body: the call with random arguments and\n * the type assertion of its output.\n *\n * @evidence contracts/common.md#principled-implementation The call expression follows the parameter mode of the configuration, and the output is typed by the response schema when there is one.\n * @evidence contracts/common.md#clear-and-simple-design One function shared with the start programmer.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The body follows the route.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const writeBody = (ctx: IContext): ts.Statement[] => [\n factory.createVariableStatement(\n [],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n \"output\",\n undefined,\n ctx.route.success\n ? NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.success.schema,\n })\n : undefined,\n factory.createAwaitExpression(writeCallExpressionn(ctx)),\n ),\n ],\n NodeFlags.Const,\n ),\n ),\n factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createPropertyAccessExpression(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n }),\n ),\n \"assert\",\n ),\n undefined,\n [factory.createIdentifier(\"output\")],\n ),\n ),\n ];\n\n const writeCallExpressionn = (ctx: IContext): ts.CallExpression => {\n const fetch = factory.createPropertyAccessExpression(\n factory.createIdentifier(\"api.functional\"),\n factory.createIdentifier(ctx.route.accessor.join(\".\")),\n );\n const random = factory.createPropertyAccessExpression(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n }),\n ),\n \"random\",\n );\n // the route's headers travel in the connection, as the server requires\n const connection: ts.Expression = ctx.route.headers\n ? factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n factory.createIdentifier(\"connection\"),\n ),\n factory.createPropertyAssignment(\n \"headers\",\n factory.createObjectLiteralExpression(\n [\n factory.createSpreadAssignment(\n factory.createIdentifier(\"connection.headers\"),\n ),\n factory.createSpreadAssignment(\n factory.createCallExpression(\n random,\n [\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.headers.schema,\n }),\n ],\n undefined,\n ),\n ),\n ],\n true,\n ),\n ),\n ],\n true,\n )\n : factory.createIdentifier(\"connection\");\n if (\n ctx.route.parameters.length === 0 &&\n ctx.route.query === null &&\n ctx.route.body === null\n )\n return factory.createCallExpression(fetch, undefined, [connection]);\n if (ctx.config.keyword === true)\n return factory.createCallExpression(fetch, undefined, [\n connection,\n LiteralFactory.write(\n Object.fromEntries(\n [...ctx.route.parameters, ctx.route.query, ctx.route.body]\n .filter((x) => x !== null)\n .map(({ key, schema: value }) => [\n key,\n factory.createCallExpression(\n random,\n [\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: value,\n }),\n ],\n undefined,\n ),\n ]),\n ),\n ),\n ]);\n return factory.createCallExpression(fetch, undefined, [\n connection,\n ...[...ctx.route.parameters, ctx.route.query, ctx.route.body]\n .filter((p) => !!p)\n .map((p) =>\n factory.createCallExpression(\n random,\n [\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: p.schema,\n }),\n ],\n undefined,\n ),\n ),\n ]);\n };\n}\n"],"mappings":";;;;;AAmBO,IAAA;;8CAiCiB,QACpB,QAAQ,0BACN,CACE,QAAQ,eAAe,WAAW,aAAa,GAC/C,QAAQ,eAAe,WAAW,YAAY,CAChD,GACA,KAAA,GACA;EAAC;EAAQ;EAAO,GAAG,IAAI,MAAM;CAAQ,CAAC,CAAC,KAAK,GAAG,GAC/C,KAAA,GACA,CACE,kBAAkB,UAChB,cACA,QAAQ,wBACN,QAAQ,oBACN,QAAQ,iBACN,IAAI,SAAS,SAA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AI,MAAM,QAAQ;EAC5B,CAAC,CACH,GACA,KAAA,CACF,CACF,CACF,GACA,IACF,CACF,CACF,GACA,IACF,IACA,QAAQ,iBAAiB,YAAY;EACzC,IACE,IAAI,MAAM,WAAW,WAAW,KAChC,IAAI,MAAM,UAAU,QACpB,IAAI,MAAM,SAAS,MAEnB,OAAO,QAAQ,qBAAqB,OAAO,KAAA,GAAW,CAAC,UAAU,CAAC;EACpE,IAAI,IAAI,OAAO,YAAY,MACzB,OAAO,QAAQ,qBAAqB,OAAO,KAAA,GAAW,CACpD,YACA,eAAe,MACb,OAAO,YACL;GAAC,GAAG,IAAI,MAAM;GAAY,IAAI,MAAM;GAAO,IAAI,MAAM;EAAI,CAAC,CACvD,QAAQ,MAAM,MAAM,IAAI,CAAC,CACzB,KAAK,EAAE,KAAK,QAAQ,YAAY,CAC/B,KACA,QAAQ,qBACN,QACA,CACE,8BAA8B,MAAM;GAClC,YAAY,IAAI;GAChB,UAAU,IAAI;GACd,QAAQ;EACV,CAAC,CACH,GACA,KAAA,CACF,CACF,CAAC,CACL,CACF,CACF,CAAC;EACH,OAAO,QAAQ,qBAAqB,OAAO,KAAA,GAAW,CACpD,YACA,GAAG;GAAC,GAAG,IAAI,MAAM;GAAY,IAAI,MAAM;GAAO,IAAI,MAAM;EAAI,CAAC,CAC1D,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,CAClB,KAAK,MACJ,QAAQ,qBACN,QACA,CACE,8BAA8B,MAAM;GAClC,YAAY,IAAI;GAChB,UAAU,IAAI;GACd,QAAQ,EAAE;EACZ,CAAC,CACH,GACA,KAAA,CACF,CACF,CACJ,CAAC;CACH;GACD,uCAAA,qCAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateE2eProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateE2eProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateE2eProgrammer.ts"],"sourcesContent":["import { IHttpMigrateRoute, OpenApi } from \"@typia/interface\";\n\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { INestiaMigrateContext } from \"../structures/INestiaMigrateContext\";\nimport { INestiaMigrateFile } from \"../structures/INestiaMigrateFile\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { NestiaMigrateE2eFunctionProgrammer } from \"./NestiaMigrateE2eFileProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\n\n/**\n * Generates the e2e test files, one per route.\n *\n * @evidence contracts/common.md#principled-implementation Each route becomes a file whose path depends on the mode and whose imports are resolved through the package name for a monorepo and through the built library path otherwise.\n * @evidence contracts/common.md#clear-and-simple-design One public function and one private file writer.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the accessors.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateE2eProgrammer {\n /**\n * Returns the map from file path to content of the e2e tests.\n *\n * @evidence contracts/common.md#principled-implementation The file name is `test_api_` plus the accessor, so each route has exactly one file.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the accessors.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (ctx: INestiaMigrateContext): Record<string, string> =>\n Object.fromEntries(\n ctx.application.routes\n .map((r) =>\n writeFile(\n ctx.mode,\n ctx.config,\n ctx.application.document().components,\n r,\n ),\n )\n .map((r) => [`${r.location}/${r.file}`, r.content]),\n );\n\n const writeFile = (\n mode: INestiaMigrateContext[\"mode\"],\n config: INestiaMigrateConfig,\n components: OpenApi.IComponents,\n route: IHttpMigrateRoute,\n ): INestiaMigrateFile => {\n const importer: NestiaMigrateImportProgrammer =\n new NestiaMigrateImportProgrammer();\n const func: ts.FunctionDeclaration =\n NestiaMigrateE2eFunctionProgrammer.write({\n config,\n components,\n importer,\n route,\n });\n const statements: ts.Statement[] = [\n // The monorepo template consumes the api workspace package through its\n // package name, while the single-package sdk template keeps resolving\n // the built `lib` paths through tsconfig path mappings.\n ...importer.toStatements((name) =>\n mode === \"nest\"\n ? \"@ORGANIZATION/PROJECT-api\"\n : `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,\n ),\n FilePrinter.newLine(),\n func,\n ];\n return {\n location:\n mode === \"nest\"\n ? `packages/backend/test/features/api`\n : `test/features/api`,\n file: `${[\"test\", \"api\", ...route.accessor].join(\"_\")}.ts`,\n content: FilePrinter.write({ statements }),\n };\n };\n}\n"],"mappings":";;;;AAkBO,IAAA;;sCASiB,QACpB,OAAO,YACL,IAAI,YAAY,OACb,KAAK,MACJ,UACE,IAAI,MACJ,IAAI,QACJ,IAAI,YAAY,SAAS,CAAC,CAAC,YAC3B,CACF,CACF,CAAC,CACA,KAAK,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CACtD;CAEF,MAAM,aACJ,MACA,QACA,YACA,UACuB;EACvB,MAAM,WACJ,IAAI,8BAA8B;EACpC,MAAM,OACJ,mCAAmC,MAAM;GACvC;GACA;GACA;GACA;EACF,CAAC;EACH,MAAM,aAA6B;GAIjC,GAAG,SAAS,cAAc,SACxB,SAAS,SACL,8BACA,4CAA4C,MAClD;GACA,YAAY,QAAQ;GACpB;EACF;EACA,OAAO;GACL,UACE,SAAS,SACL,uCACA;GACN,MAAM,GAAG;IAAC;IAAQ;IAAO,GAAG,MAAM;GAAQ,CAAC,CAAC,KAAK,GAAG,EAAE;GACtD,SAAS,YAAY,MAAM,EAAE,WAAW,CAAC;EAC3C;CACF;GACD,+BAAA,6BAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateImportProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateImportProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"sourcesContent":["import { type EntityName, SyntaxKind, factory } from \"@ttsc/factory\";\n\nimport { TypeLiteralFactory } from \"../factories/TypeLiteralFactory\";\nimport ts from \"../internal/ts\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { MapUtil } from \"../utils/MapUtil\";\n\n/**\n * Collects the imports that generated code needs and turns them into import\n * statements.\n *\n * @evidence contracts/common.md#principled-implementation External imports are grouped by library into one clause with an optional default and a set of named instances, DTO imports are grouped by module specifier and emitted type-only, and a DTO is never imported into its own file.\n * @evidence contracts/common.md#clear-and-simple-design One class with two collections and one emitter; the tag helper builds `typia.tags` references.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The imports follow the code that asks for them.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport class NestiaMigrateImportProgrammer {\n private external_: Map<string, IClause> = new Map();\n private dtos_: Set<string> = new Set();\n\n public constructor() {}\n\n /**\n * Reports whether no import has been requested.\n *\n * @evidence contracts/common.md#principled-implementation The importer is empty exactly when both collections are empty.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the state.\n * @evidence contracts/common.md#meaningful-documentation The comment states the meaning.\n */\n public empty(): boolean {\n return this.external_.size === 0 && this.dtos_.size === 0;\n }\n\n /**\n * Requests an import from a library and returns the local name to use.\n *\n * The returned name is the first segment of the requested name, so a nested\n * name such as `tags.Type` imports `tags`.\n *\n * @evidence contracts/common.md#principled-implementation A default import replaces the clause's default and an instance import adds a named import, and the first segment of a dotted name is what the code refers to.\n * @evidence contracts/common.md#clear-and-simple-design One function over one map.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The library and the name come from the caller.\n * @evidence contracts/common.md#meaningful-documentation The comment states the returned name.\n */\n public external(props: MigrateImportProgrammer.IProps): string {\n const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({\n default: null,\n instances: new Set(),\n }));\n const name: string = props.name.split(\".\")[0]!;\n if (props.type === \"default\") clause.default = props.name;\n else clause.instances.add(name);\n return name;\n }\n\n /**\n * Requests a DTO import and returns a reference to it, qualified by a\n * namespace when one is given.\n *\n * @evidence contracts/common.md#principled-implementation The DTO is recorded by the first segment of its dotted name, which is the file that exports it, and the returned reference keeps the full name, with the namespace prepended when one is given.\n * @evidence contracts/common.md#clear-and-simple-design One function over one set.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The name comes from the caller.\n * @evidence contracts/common.md#meaningful-documentation The comment states the reference.\n */\n public dto(name: string, namespace?: string): ts.TypeReferenceNode {\n const segments: string[] = name.split(\".\");\n this.dtos_.add(segments[0]!);\n return factory.createTypeReferenceNode(\n namespace?.length\n ? segments.reduce<EntityName>(\n (left, segment) =>\n factory.createQualifiedName(\n left,\n factory.createIdentifier(segment),\n ),\n factory.createIdentifier(namespace),\n )\n : name,\n );\n }\n\n /**\n * Requests the `typia` tags import and returns a reference to a tag with an\n * optional literal argument.\n *\n * @evidence contracts/common.md#principled-implementation The argument is converted to a literal type, so `Minimum<3>` is written as a type reference with the literal.\n * @evidence contracts/common.md#clear-and-simple-design One function delegating the literal building.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The tag name and the argument come from the caller.\n * @evidence contracts/common.md#meaningful-documentation The comment states the reference.\n */\n public tag(type: string, arg?: any): ts.TypeReferenceNode {\n const instance: string = this.external({\n type: \"instance\",\n library: \"typia\",\n name: \"tags\",\n });\n return factory.createTypeReferenceNode(\n `${instance}.${type}`,\n arg === undefined ? [] : [TypeLiteralFactory.generate(arg)],\n );\n }\n\n /**\n * Returns the import statements: the external imports, a blank line when both\n * kinds exist, and the type-only DTO imports.\n *\n * @evidence contracts/common.md#principled-implementation DTO names are grouped by the specifier that `dtoPath` returns, a name equal to the current file is skipped so a file never imports itself, and package specifiers merge into one clause.\n * @evidence contracts/common.md#clear-and-simple-design One function with two emit sections.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The specifier rule is the caller's.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result and the self-import rule.\n */\n public toStatements(\n dtoPath: (name: string) => string,\n current?: string,\n ): ts.Statement[] {\n // Group the DTO references by their resolved module specifier: relative\n // specifiers stay one-import-per-file, while package specifiers (e.g. the\n // monorepo's `@ORGANIZATION/PROJECT-api`) merge into a single clause.\n const modules: Map<string, string[]> = new Map();\n for (const name of this.dtos_)\n if (current === undefined || name !== current.split(\".\")[0])\n MapUtil.take(modules)(dtoPath(name))(() => []).push(name);\n return [\n ...[...this.external_.entries()].map(([library, props]) =>\n factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n undefined,\n props.default !== null\n ? factory.createIdentifier(props.default)\n : undefined,\n props.instances.size\n ? factory.createNamedImports(\n [...props.instances].map((i) =>\n factory.createImportSpecifier(\n false,\n undefined,\n factory.createIdentifier(i),\n ),\n ),\n )\n : undefined,\n ),\n factory.createStringLiteral(library),\n ),\n ),\n ...(this.external_.size && this.dtos_.size\n ? [FilePrinter.newLine()]\n : []),\n ...[...modules.entries()].map(([specifier, names]) =>\n factory.createImportDeclaration(\n undefined,\n // DTO files declare pure types, and generated code references them\n // only in type positions — keep the clause type-only so emitted\n // JS never loads the DTO module at runtime.\n factory.createImportClause(\n SyntaxKind.TypeKeyword,\n undefined,\n factory.createNamedImports(\n names.map((name) =>\n factory.createImportSpecifier(\n false,\n undefined,\n factory.createIdentifier(name),\n ),\n ),\n ),\n ),\n factory.createStringLiteral(specifier),\n ),\n ),\n ];\n }\n}\n/**\n * Types of the importer: the properties of an external import request.\n *\n * @evidence contracts/common.md#principled-implementation The record names the import kind, the library, and the name.\n * @evidence contracts/common.md#clear-and-simple-design One namespace with one interface.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It contains types only.\n * @evidence contracts/common.md#meaningful-documentation The comment names its content.\n */\nexport namespace MigrateImportProgrammer {\n /**\n * An external import request: `default` or `instance`, the library, and the\n * name.\n *\n * @evidence contracts/common.md#principled-implementation The kind selects between the default clause and a named import.\n * @evidence contracts/common.md#clear-and-simple-design A three-field record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment states each field.\n */\n export interface IProps {\n /** Select the default export or a named import. */\n type: \"default\" | \"instance\";\n\n /** Module specifier emitted in the import declaration. */\n library: string;\n\n /** Requested binding; named imports use its leading dotted segment. */\n name: string;\n }\n}\ninterface IClause {\n default: string | null;\n instances: Set<string>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,gCAAb,MAA2C;CAIzC,cAAqB;mCAHqB,IAAI,IAAI;+BACrB,IAAI,IAAI;CAEf;;;;;;;;;CAUtB,QAAwB;EACtB,OAAO,KAAK,UAAU,SAAS,KAAK,KAAK,MAAM,SAAS;CAC1D;;;;;;;;;;;;CAaA,SAAgB,OAA+C;EAC7D,MAAM,SAAkB,QAAQ,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ;GACzE,SAAS;GACT,2BAAW,IAAI,IAAI;EACrB,EAAE;EACF,MAAM,OAAe,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC;EAC3C,IAAI,MAAM,SAAS,WAAW,OAAO,UAAU,MAAM;OAChD,OAAO,UAAU,IAAI,IAAI;EAC9B,OAAO;CACT;;;;;;;;;;CAWA,IAAW,MAAc,WAA0C;EACjE,MAAM,WAAqB,KAAK,MAAM,GAAG;EACzC,KAAK,MAAM,IAAI,SAAS,EAAG;EAC3B,OAAO,QAAQ,wBACb,WAAW,SACP,SAAS,QACN,MAAM,YACL,QAAQ,oBACN,MACA,QAAQ,iBAAiB,OAAO,CAClC,GACF,QAAQ,iBAAiB,SAAS,CACpC,IACA,IACN;CACF;;;;;;;;;;CAWA,IAAW,MAAc,KAAiC;EACxD,MAAM,WAAmB,KAAK,SAAS;GACrC,MAAM;GACN,SAAS;GACT,MAAM;EACR,CAAC;EACD,OAAO,QAAQ,wBACb,GAAG,SAAS,GAAG,QACf,QAAQ,KAAA,IAA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3,"file":"NestiaMigrateNestControllerProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateNestControllerProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\nimport { OpenApi } from \"@typia/interface\";\n\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { INestiaMigrateController } from \"../structures/INestiaMigrateController\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateNestMethodProgrammer } from \"./NestiaMigrateNestMethodProgrammer\";\n\n/**\n * Generates the source of one NestJS controller.\n *\n * @evidence contracts/common.md#principled-implementation The controller class is decorated with `@Controller` and its path, each route becomes a method written by the configured method programmer or the default one, and the DTO types are imported by package name because they live in the API package.\n * @evidence contracts/common.md#clear-and-simple-design One function; the method programmer is replaceable through the configuration.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The replaceable programmer is a documented extension point.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateNestControllerProgrammer {\n /**\n * The input of one controller: the configuration, the components, and the\n * controller.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IProps {\n /** Generation options and an optional controller-method writer. */\n config: INestiaMigrateConfig;\n\n /** Schemas needed by generated controller method types. */\n components: OpenApi.IComponents;\n\n /** Controller name, router prefix and grouped operations. */\n controller: INestiaMigrateController;\n }\n\n /**\n * Returns the statements of a controller file.\n *\n * @evidence contracts/common.md#principled-implementation Blank lines separate the methods, and the imports come first.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The content follows the controller.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (props: IProps): ts.Statement[] => {\n const importer: NestiaMigrateImportProgrammer =\n new NestiaMigrateImportProgrammer();\n const $class = factory.createClassDeclaration(\n [\n factory.createDecorator(\n factory.createCallExpression(\n factory.createIdentifier(\n importer.external({\n type: \"instance\",\n library: \"@nestjs/common\",\n name: \"Controller\",\n }),\n ),\n [],\n [factory.createStringLiteral(props.controller.path)],\n ),\n ),\n factory.createToken(SyntaxKind.ExportKeyword),\n ],\n props.controller.name,\n [],\n [],\n props.controller.routes\n .map((route, index) => [\n ...(index !== 0 ? [FilePrinter.newLine() as any] : []),\n (\n props.config.programmer?.controllerMethod ??\n NestiaMigrateNestMethodProgrammer.write\n )({\n config: props.config,\n components: props.components,\n controller: props.controller,\n importer,\n route,\n }),\n ])\n .flat(),\n );\n return [\n // Controllers live in the backend workspace package while the DTO\n // structures belong to the api package, so the types must be imported\n // through the package name instead of a relative path.\n ...importer.toStatements(() => \"@ORGANIZATION/PROJECT-api\"),\n ...(importer.empty() ? [] : [FilePrinter.newLine()]),\n $class,\n ];\n };\n}\n"],"mappings":";;;;;AAkBO,IAAA;;iDA6BiB,UAAkC;EACtD,MAAM,WACJ,IAAI,8BAA8B;EACpC,MAAM,SAAS,QAAQ,uBACrB,CACE,QAAQ,gBACN,QAAQ,qBACN,QAAQ,iBACN,SAAS,SAAS;GAChB,MAAM;GACN,SAAS;GACT,MAAM;EACR,CAAC,CACH,GACA,CAAC,GACD,CAAC,QAAQ,oBAAoB,MAAM,WAAW,IAAI,CAAC,CACrD,CACF,GACA,QAAQ,YAAY,WAAW,aAAa,CAC9C,GACA,MAAM,WAAW,MACjB,CAAC,GACD,CAAC,GACD,MAAM,WAAW,OACd,KAAK,OAAO,UAAU,CACrB,GAAI,UAAU,IAAI,CAAC,YAAY,QAAQ,CAAQ,IAAI,CAAC,IAElD,MAAM,OAAO,YAAY,oBACzB,kCAAkC,MAAA,CAClC;GACA,QAAQ,MAAM;GACd,YAAY,MAAM;GAClB,YAAY,MAAM;GAClB;GACA;EACF,CAAC,CACH,CAAC,CAAC,CACD,KAAK,CACV;EACA,OAAO;GAIL,GAAG,SAAS,mBAAmB,2BAA2B;GAC1D,GAAI,SAAS,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,QAAQ,CAAC;GAClD;EACF;CACF;GACD,0CAAA,wCAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateNestMethodProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateNestMethodProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateNestMethodProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\nimport { IHttpMigrateRoute } from \"@typia/interface\";\nimport { OpenApi } from \"typia\";\n\nimport { NestiaMigrateControllerAnalyzer } from \"../analyzers/NestiaMigrateControllerAnalyzer\";\nimport { ExpressionFactory } from \"../factories/ExpressionFactory\";\nimport { IdentifierFactory } from \"../factories/IdentifierFactory\";\nimport { LiteralFactory } from \"../factories/LiteralFactory\";\nimport { TypeFactory } from \"../factories/TypeFactory\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateConfig } from \"../structures/INestiaMigrateConfig\";\nimport { INestiaMigrateController } from \"../structures/INestiaMigrateController\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { RequestBody } from \"../utils/RequestBody\";\nimport { StringUtil } from \"../utils/StringUtil\";\nimport { SuccessStatus } from \"../utils/SuccessStatus\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateSchemaProgrammer } from \"./NestiaMigrateSchemaProgrammer\";\n\n/**\n * Generates the controller method of one route.\n *\n * @evidence contracts/common.md#principled-implementation The method carries `TypedRoute`, `TypedException`, `HumanRoute`, and example decorators as the route requires, one parameter per path, header, query, and body input with the matching typed decorator, and a body that mentions each parameter and returns `typia.random` of the response type.\n * @evidence contracts/common.md#clear-and-simple-design One entry function and private writers for the description, the decorators, and the parameters.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route; the body is a stub that returns random data because the document does not define the behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateNestMethodProgrammer {\n /**\n * The input of one method: the configuration, the components, the importer,\n * the controller, and the route.\n *\n * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.\n * @evidence contracts/common.md#clear-and-simple-design A flat record.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.\n */\n export interface IContext {\n /** Generation options, including the author tag used on the handler. */\n config: INestiaMigrateConfig;\n\n /** Component schemas referenced by request and response types. */\n components: OpenApi.IComponents;\n\n /** Controller-file import collector shared by all its methods. */\n importer: NestiaMigrateImportProgrammer;\n\n /** Controller prefix removed from this operation's router path. */\n controller: INestiaMigrateController;\n\n /** Analyzed operation supplying method, schemas and examples. */\n route: IHttpMigrateRoute;\n }\n\n /**\n * Returns the method declaration of a route.\n *\n * @evidence contracts/common.md#principled-implementation The decorators and the parameters follow the route's HTTP method, path relative to the controller, and inputs.\n * @evidence contracts/common.md#clear-and-simple-design One function composing the private writers.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The method follows the route.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (ctx: IContext): ts.MethodDeclaration => {\n const output: ts.TypeNode = ctx.route.success\n ? NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: ctx.route.success.schema,\n })\n : TypeFactory.keyword(\"void\");\n\n const method: ts.MethodDeclaration = factory.createMethodDeclaration(\n [\n ...writeMethodDecorators(ctx),\n factory.createToken(SyntaxKind.PublicKeyword),\n factory.createToken(SyntaxKind.AsyncKeyword),\n ],\n undefined,\n ctx.route.accessor.at(-1)!,\n undefined,\n undefined,\n writeParameters(ctx),\n factory.createTypeReferenceNode(\"Promise\", [output]),\n factory.createBlock(\n [\n ...[\n ...ctx.route.parameters.map((p) => p.key),\n ...(ctx.route.headers ? [\"headers\"] : []),\n ...(ctx.route.query ? [\"query\"] : []),\n ...(ctx.route.body ? [\"body\"] : []),\n ].map((str) =>\n factory.createExpressionStatement(factory.createIdentifier(str)),\n ),\n factory.createReturnStatement(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"typia\",\n name: \"typia\",\n }),\n ),\n \"random\",\n ),\n [output],\n undefined,\n ),\n ),\n ],\n true,\n ),\n );\n return FilePrinter.description(\n method,\n writeDescription(ctx.config, ctx.route),\n );\n };\n\n const writeDescription = (\n config: INestiaMigrateConfig,\n method: IHttpMigrateRoute,\n ): string =>\n [\n method.comment(),\n `@${config.author?.tag ?? \"nestia\"} ${config.author?.value ?? \"Generated by Nestia - https://github.com/samchon/nestia\"}`,\n ].join(\"\\n\");\n\n const writeMethodDecorators = (ctx: IContext): ts.Decorator[] => {\n const external = (lib: string, instance: string): ts.Identifier =>\n factory.createIdentifier(\n ctx.importer.external({\n type: \"instance\",\n library: lib,\n name: instance,\n }),\n );\n\n // EXAMPLES\n const decorators: ts.Decorator[] = [];\n if (ctx.route.success)\n decorators.push(\n ...writeExampleDecorators(\"Response\")(ctx.importer)(\n ctx.route.success.media(),\n ),\n );\n\n // HUMAN-ONLY\n if (ctx.route.operation()[\"x-samchon-human\"] === true)\n decorators.push(\n factory.createDecorator(\n factory.createCallExpression(\n external(\"@nestia/core\", \"HumanRoute\"),\n undefined,\n undefined,\n ),\n ),\n );\n\n // ROUTER\n const localPath: string = NestiaMigrateControllerAnalyzer.routePath(\n ctx.route,\n )\n .slice(ctx.controller.path.length)\n .split(\"/\")\n .filter((str) => !!str.length)\n .join(\"/\");\n const router = (instance: string) =>\n factory.createDecorator(\n factory.createCallExpression(\n IdentifierFactory.access(\n external(\"@nestia/core\", instance),\n StringUtil.capitalize(ctx.route.method),\n ),\n [],\n localPath.length\n ? [factory.createStringLiteral(localPath)]\n : undefined,\n ),\n );\n // a vanilla NestJS method decorator, relative to the controller like the\n // nestia ones: the document's full path would be joined onto the\n // controller's again\n const nest = (method: string) =>\n factory.createDecorator(\n factory.createCallExpression(\n external(\"@nestjs/common\", method),\n [],\n localPath.length\n ? [factory.createStringLiteral(localPath)]\n : undefined,\n ),\n );\n if (ctx.route.success?.[\"x-nestia-encrypted\"])\n decorators.push(router(\"EncryptedRoute\"));\n else if (ctx.route.success?.type === \"text/plain\")\n decorators.push(nest(StringUtil.capitalize(ctx.route.method)));\n else if (ctx.route.success?.type === \"application/x-www-form-urlencoded\")\n decorators.push(router(\"TypedQuery\"));\n else if (ctx.route.method === \"head\") decorators.push(nest(\"Head\"));\n else if (\n ctx.route.success === null ||\n ctx.route.success?.type === \"application/json\"\n )\n decorators.push(router(\"TypedRoute\"));\n // NestJS answers 201 for POST and 200 otherwise\n const status: number | null = SuccessStatus.of(ctx.route);\n if (status !== null && status !== SuccessStatus.nest(ctx.route))\n decorators.push(\n factory.createDecorator(\n factory.createCallExpression(\n external(\"@nestjs/common\", \"HttpCode\"),\n undefined,\n [ExpressionFactory.number(status)],\n ),\n ),\n );\n for (const [key, value] of Object.entries(ctx.route.exceptions ?? {}))\n decorators.push(\n factory.createDecorator(\n factory.createCallExpression(\n external(\"@nestia/core\", \"TypedException\"),\n [\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: value.schema,\n }),\n ],\n [\n isNaN(Number(key))\n ? factory.createStringLiteral(key)\n : ExpressionFactory.number(Number(key)),\n ...(value.response().description?.length\n ? [factory.createStringLiteral(value.response().description!)]\n : []),\n ],\n ),\n ),\n );\n return decorators;\n };\n\n const writeParameters = (ctx: IContext): ts.ParameterDeclaration[] => [\n ...ctx.route.parameters.map((p) =>\n factory.createParameterDeclaration(\n [\n ...writeExampleDecorators(\"Parameter\")(ctx.importer)(p.parameter()),\n factory.createDecorator(\n factory.createCallExpression(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"instance\",\n library: \"@nestia/core\",\n name: \"TypedParam\",\n }),\n ),\n undefined,\n [factory.createStringLiteral(p.key)],\n ),\n ),\n ],\n undefined,\n p.key,\n undefined,\n NestiaMigrateSchemaProgrammer.write({\n components: ctx.components,\n importer: ctx.importer,\n schema: p.schema,\n }),\n ),\n ),\n ...(ctx.route.headers\n ? [\n writeDtoParameter({\n method: \"TypedHeaders\",\n variable: \"headers\",\n arguments: [],\n })(ctx.components)(ctx.importer)({\n required: true,\n schema: ctx.route.headers.schema,\n example: ctx.route.headers.example(),\n examples: ctx.route.headers.examples(),\n }),\n ]\n : []),\n ...(ctx.route.query\n ? [\n writeDtoParameter({\n method: \"TypedQuery\",\n variable: \"query\",\n arguments: [],\n })(ctx.components)(ctx.importer)({\n required: true,\n schema: ctx.route.query.schema,\n example: ctx.route.query.example(),\n examples: ctx.route.query.examples(),\n }),\n ]\n : []),\n ...(ctx.route.body\n ? [\n writeDtoParameter({\n method: ctx.route.body[\"x-nestia-encrypted\"]\n ? \"EncryptedBody\"\n : ctx.route.body.type === \"application/json\"\n ? \"TypedBody\"\n : ctx.route.body.type === \"application/x-www-form-urlencoded\"\n ? [\"TypedQuery\", \"Body\"]\n : ctx.route.body.type === \"text/plain\"\n ? \"PlainBody\"\n : ctx.route.body.type === \"multipart/form-data\"\n ? [\"TypedFormData\", \"Body\"]\n : \"TypedBody\",\n variable: \"body\",\n arguments:\n ctx.route.body.type === \"multipart/form-data\"\n ? [\n factory.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n undefined,\n factory.createCallExpression(\n factory.createIdentifier(\n ctx.importer.external({\n type: \"default\",\n library: \"multer\",\n name: \"Multer\",\n }),\n ),\n undefined,\n undefined,\n ),\n ),\n ]\n : [],\n })(ctx.components)(ctx.importer)({\n schema: ctx.route.body.schema,\n required: RequestBody.optional(ctx.route) === false,\n example: ctx.route.body.media().example,\n examples: ctx.route.body.media().examples,\n }),\n ]\n : []),\n ];\n\n const writeDtoParameter =\n (accessor: {\n method: string | [string, string];\n variable: string;\n arguments: ts.Expression[];\n }) =>\n (components: OpenApi.IComponents) =>\n (importer: NestiaMigrateImportProgrammer) =>\n (props: {\n schema: OpenApi.IJsonSchema;\n required: boolean;\n example?: any;\n examples?: Record<string, any>;\n }): ts.ParameterDeclaration => {\n const instance = factory.createIdentifier(\n importer.external({\n type: \"instance\",\n library: \"@nestia/core\",\n name:\n typeof accessor.method === \"string\"\n ? accessor.method\n : accessor.method[0],\n }),\n );\n return factory.createParameterDeclaration(\n [\n ...writeExampleDecorators(\"Parameter\")(importer)(props),\n factory.createDecorator(\n factory.createCallExpression(\n typeof accessor.method === \"string\"\n ? instance\n : IdentifierFactory.access(instance, accessor.method[1]),\n undefined,\n accessor.arguments,\n ),\n ),\n ],\n undefined,\n accessor.variable,\n props.required === false\n ? factory.createToken(SyntaxKind.QuestionToken)\n : undefined,\n NestiaMigrateSchemaProgrammer.write({\n components,\n importer,\n schema: props.schema,\n }),\n );\n };\n\n const writeExampleDecorators =\n (kind: \"Response\" | \"Parameter\") =>\n (importer: NestiaMigrateImportProgrammer) =>\n (media: {\n example?: any;\n examples?: Record<string, any>;\n }): ts.Decorator[] => [\n ...(media.example !== undefined\n ? [\n factory.createDecorator(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n importer.external({\n type: \"instance\",\n library: \"@nestia/core\",\n name: \"SwaggerExample\",\n }),\n ),\n kind,\n ),\n [],\n [LiteralFactory.write(media.example)],\n ),\n ),\n ]\n : []),\n ...Object.entries(media.examples ?? {}).flatMap(([key, example]) => {\n const value: { value: unknown } | null = exampleValue(example);\n if (value === null) return [];\n return factory.createDecorator(\n factory.createCallExpression(\n IdentifierFactory.access(\n factory.createIdentifier(\n importer.external({\n type: \"instance\",\n library: \"@nestia/core\",\n name: \"SwaggerExample\",\n }),\n ),\n kind,\n ),\n [],\n [\n factory.createStringLiteral(key),\n LiteralFactory.write(value.value),\n ],\n ),\n );\n }),\n ];\n}\n\n/**\n * The value a named example stands for, or `null` when it names none.\n *\n * OpenAPI names examples with Example Objects, whose `value` (or, since 3.2,\n * `dataValue`) holds the value, and a `$ref` to one arrives resolved. Documents\n * from earlier nestia versions held the values themselves, so an object is read\n * as an Example Object only when it is one: it has one of the value fields, and\n * every other key is an Example Object field or an extension. A raw value of\n * exactly that shape is ambiguous and is read as an Example Object, as a\n * conforming document means it. An Example Object that only points at its value\n * (`externalValue`) or only serializes it (`serializedValue`) gives\n * `SwaggerExample` nothing to hold.\n */\nconst exampleValue = (example: unknown): { value: unknown } | null => {\n if (isExampleObject(example) === false) return { value: example };\n const record = example as Record<string, unknown>;\n if (Object.prototype.hasOwnProperty.call(record, \"value\"))\n return { value: record.value };\n if (Object.prototype.hasOwnProperty.call(record, \"dataValue\"))\n return { value: record.dataValue };\n return null;\n};\n\nconst isExampleObject = (example: unknown): boolean =>\n typeof example === \"object\" &&\n example !== null &&\n Array.isArray(example) === false &&\n VALUE_KEYS.some((key) =>\n Object.prototype.hasOwnProperty.call(example, key),\n ) &&\n Object.keys(example).every(\n (key) =>\n VALUE_KEYS.includes(key) ||\n key === \"summary\" ||\n key === \"description\" ||\n key.startsWith(\"x-\"),\n );\n\nconst VALUE_KEYS: string[] = [\n \"value\",\n \"dataValue\",\n \"serializedValue\",\n \"externalValue\",\n];\n"],"mappings":";;;;;;;;;;;;AA2BO,IAAA;;6CAmCiB,QAAwC;EAC5D,MAAM,SAAsB,IAAI,MAAM,UAClC,8BAA8B,MAAM;GAClC,YAAY,IAAI;GAChB,UAAU,IAAI;GACd,QAAQ,IAAI,MAAM,QAAQ;EAC5B,CAAC,IACD,YAAY,QAAQ,MAAM;EAE9B,MAAM,SAA+B,QAAQ,wBAC3C;GACE,GAAG,sBAAsB,GAAG;GAC5B,QAAQ,YAAY,WAAW,aAAa;GAC5C,QAAQ,YAAY,WAAW,YAAY;EAC7C,GACA,KAAA,GACA,IAA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,MAAM,gBAAgB,YAAgD;CACpE,IAAI,gBAAgB,OAAO,MAAM,OAAO,OAAO,EAAE,OAAO,QAAQ;CAChE,MAAM,SAAS;CACf,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,OAAO,GACtD,OAAO,EAAE,OAAO,OAAO,MAAM;CAC/B,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,WAAW,GAC1D,OAAO,EAAE,OAAO,OAAO,UAAU;CACnC,OAAO;AACT;AAEA,MAAM,mBAAmB,YACvB,OAAO,YAAY,YACnB,YAAY,QACZ,MAAM,QAAQ,OAAO,MAAM,SAC3B,WAAW,MAAM,QACf,OAAO,UAAU,eAAe,KAAK,SAAS,GAAG,CACnD,KACA,OAAO,KAAK,OAAO,CAAC,CAAC,OAClB,QACC,WAAW,SAAS,GAAG,KACvB,QAAQ,aACR,QAAQ,iBACR,IAAI,WAAW,IAAI,CACvB;AAEF,MAAM,aAAuB;CAC3B;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateNestModuleProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateNestModuleProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateNestModuleProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\n\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateController } from \"../structures/INestiaMigrateController\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\n\n/**\n * Generates the NestJS module that lists the controllers.\n *\n * @evidence contracts/common.md#principled-implementation The module imports every controller from its location and lists them in the `controllers` array of a decorated class.\n * @evidence contracts/common.md#clear-and-simple-design One function and one private import builder.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The controllers follow the analysis.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateNestModuleProgrammer {\n /**\n * Returns the statements of the module file.\n *\n * @evidence contracts/common.md#principled-implementation The import paths turn the `src/` prefix of a controller location into `./`, so the module can import from its own directory.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the controllers.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (\n controllers: INestiaMigrateController[],\n ): ts.Statement[] => [\n $import(\"@nestjs/common\")(\"Module\"),\n ...(controllers.length ? [FilePrinter.newLine()] : []),\n ...controllers.map((c) =>\n $import(`${c.location.replace(\"src/\", \"./\")}/${c.name}`)(c.name),\n ),\n ...(controllers.length ? [FilePrinter.newLine()] : []),\n factory.createClassDeclaration(\n [\n factory.createDecorator(\n factory.createCallExpression(\n factory.createIdentifier(\"Module\"),\n undefined,\n [\n factory.createObjectLiteralExpression(\n [\n factory.createPropertyAssignment(\n factory.createIdentifier(\"controllers\"),\n factory.createArrayLiteralExpression(\n controllers.map((c) => factory.createIdentifier(c.name)),\n true,\n ),\n ),\n ],\n true,\n ),\n ],\n ),\n ),\n factory.createToken(SyntaxKind.ExportKeyword),\n ],\n \"MyModule\",\n undefined,\n undefined,\n [],\n ),\n ];\n}\n\nconst $import = (file: string) => (instance: string) =>\n factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n undefined,\n undefined,\n factory.createNamedImports([\n factory.createImportSpecifier(\n false,\n undefined,\n factory.createIdentifier(instance),\n ),\n ]),\n ),\n factory.createStringLiteral(file),\n );\n"],"mappings":";;;AAcO,IAAA;;6CAUH,gBACmB;EACnB,QAAQ,gBAAgB,CAAC,CAAC,QAAQ;EAClC,GAAI,YAAY,SAAS,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC;EACpD,GAAG,YAAY,KAAK,MAClB,QAAQ,GAAG,EAAE,SAAS,QAAQ,QAAQ,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CACjE;EACA,GAAI,YAAY,SAAS,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC;EACpD,QAAQ,uBACN,CACE,QAAQ,gBACN,QAAQ,qBACN,QAAQ,iBAAiB,QAAQ,GACjC,KAAA,GACA,CACE,QAAQ,8BACN,CACE,QAAQ,yBACN,QAAQ,iBAAiB,aAAa,GACtC,QAAQ,6BACN,YAAY,KAAK,MAAM,QAAQ,iBAAiB,EAAE,IAAI,CAAC,GACvD,IACF,CACF,CACF,GACA,IACF,CACF,CACF,CACF,GACA,QAAQ,YAAY,WAAW,aAAa,CAC9C,GACA,YACA,KAAA,GACA,KAAA,GACA,CAAC,CACH;CACF;GACD,sCAAA,oCAAA,CAAA,EAAD;AAEA,MAAM,WAAW,UAAkB,aACjC,QAAQ,wBACN,KAAA,GACA,QAAQ,mBACN,KAAA,GACA,KAAA,GACA,QAAQ,mBAAmB,CACzB,QAAQ,sBACN,OACA,KAAA,GACA,QAAQ,iBAAiB,QAAQ,CACnC,CACF,CAAC,CACH,GACA,QAAQ,oBAAoB,IAAI,CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateNestProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateNestProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateNestProgrammer.ts"],"sourcesContent":["import { NodeFlags, SyntaxKind, factory } from \"@ttsc/factory\";\n\nimport { NestiaMigrateControllerAnalyzer } from \"../analyzers/NestiaMigrateControllerAnalyzer\";\nimport ts from \"../internal/ts\";\nimport { INestiaMigrateContext } from \"../structures/INestiaMigrateContext\";\nimport { INestiaMigrateController } from \"../structures/INestiaMigrateController\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { NestiaMigrateDtoProgrammer } from \"./NestiaMigrateDtoProgrammer\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\nimport { NestiaMigrateNestControllerProgrammer } from \"./NestiaMigrateNestControllerProgrammer\";\nimport { NestiaMigrateNestModuleProgrammer } from \"./NestiaMigrateNestModuleProgrammer\";\n\n/**\n * Generates the NestJS side of a monorepo project: the module, the controllers,\n * and the DTO structures.\n *\n * @evidence contracts/common.md#principled-implementation The controllers come from the analyzer, each DTO tree becomes a structure file, and a barrel file re-exports every non-empty structure file so the template's module keeps working.\n * @evidence contracts/common.md#clear-and-simple-design One public function and private helpers for the DTO files and the barrel.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the analysis.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateNestProgrammer {\n /**\n * Returns the map from file path to content of the NestJS files.\n *\n * @evidence contracts/common.md#principled-implementation The barrel is computed from the generated structure files, sorted by name, so its content is deterministic.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the document.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (\n context: INestiaMigrateContext,\n ): Record<string, string> => {\n const controllers: INestiaMigrateController[] =\n NestiaMigrateControllerAnalyzer.analyze(context.application.routes);\n const statements: [string, ts.Statement[]][] = [\n [\n \"packages/backend/src/MyModule.ts\",\n NestiaMigrateNestModuleProgrammer.write(controllers),\n ],\n ...controllers.map(\n (c) =>\n [\n `packages/backend/${c.location}/${c.name}.ts`,\n NestiaMigrateNestControllerProgrammer.write({\n config: context.config,\n components: context.application.document().components,\n controller: c,\n }),\n ] satisfies [string, ts.Statement[]],\n ),\n ...[\n ...NestiaMigrateDtoProgrammer.compose({\n config: context.config,\n components: context.application.document().components,\n }).entries(),\n ].map(\n ([key, value]) =>\n [\n `packages/api/src/structures/${key}.ts`,\n writeDtoFile(key, value),\n ] satisfies [string, ts.Statement[]],\n ),\n ];\n const files: Record<string, string> = Object.fromEntries(\n statements.map(([key, value]) => [\n key,\n FilePrinter.write({ statements: value }),\n ]),\n );\n // The template's `packages/api/src/module.ts` re-exports the DTO types\n // through `export * from \"./structures\"`, so the generated structure files\n // need a barrel replacing the one deleted from the bundled template.\n files[\"packages/api/src/structures/index.ts\"] = writeDtoBarrel(files);\n return files;\n };\n\n const writeDtoBarrel = (files: Record<string, string>): string => {\n const prefix: string = \"packages/api/src/structures/\";\n const names: string[] = Object.entries(files)\n .filter(\n ([key, content]) =>\n key.startsWith(prefix) && key.endsWith(\".ts\") && content.length !== 0,\n )\n .map(([key]) => key.slice(prefix.length, -\".ts\".length))\n .sort();\n if (names.length === 0) return \"export {};\\n\";\n return names.map((name) => `export * from \"./${name}\";\\n`).join(\"\");\n };\n\n const writeDtoFile = (\n key: string,\n modulo: NestiaMigrateDtoProgrammer.IModule,\n ): ts.Statement[] => {\n const importer = new NestiaMigrateImportProgrammer();\n const statements: ts.Statement[] = iterate(importer)(modulo);\n if (statements.length === 0) return [];\n\n return [\n ...importer.toStatements((name) => `./${name}`, key),\n ...(importer.empty() ? [] : [FilePrinter.newLine()]),\n ...statements,\n ];\n };\n\n const iterate =\n (importer: NestiaMigrateImportProgrammer) =>\n (modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {\n const output: ts.Statement[] = [];\n if (modulo.programmer !== null) output.push(modulo.programmer(importer));\n if (modulo.children.size) {\n const internal: ts.Statement[] = [];\n for (const child of modulo.children.values())\n internal.push(...iterate(importer)(child));\n output.push(\n factory.createModuleDeclaration(\n [factory.createModifier(SyntaxKind.ExportKeyword)],\n factory.createIdentifier(modulo.name),\n factory.createModuleBlock(internal),\n NodeFlags.Namespace,\n ),\n );\n }\n output.push(FilePrinter.newLine());\n return output;\n };\n}\n"],"mappings":";;;;;;;;AAqBO,IAAA;;uCAUH,YAC2B;EAC3B,MAAM,cACJ,gCAAgC,QAAQ,QAAQ,YAAY,MAAM;EACpE,MAAM,aAAyC;GAC7C,CACE,oCACA,kCAAkC,MAAM,WAAW,CACrD;GACA,GAAG,YAAY,KACZ,MACC,CACE,oBAAoB,EAAE,SAAS,GAAG,EAAE,KAAK,MACzC,sCAAsC,MAAM;IAC1C,QAAQ,QAAQ;IAChB,YAAY,QAAQ,YAAY,SAAS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AO,KAAK,OAAO,WAAW,QAAQ,CAAC;EACvE,IAAI,OAAO,SAAS,MAAM;GACxB,MAAM,WAA2B,CAAC;GAClC,KAAK,MAAM,SAAS,OAAO,SAAS,OAAO,GACzC,SAAS,KAAK,GAAG,QAAQ,QAAQ,CAAC,CAAC,KAAK,CAAC;GAC3C,OAAO,KACL,QAAQ,wBACN,CAAC,QAAQ,eAAe,WAAW,aAAa,CAAC,GACjD,QAAQ,iBAAiB,OAAO,IAAI,GACpC,QAAQ,kBAAkB,QAAQ,GAClC,UAAU,SACZ,CACF;EACF;EACA,OAAO,KAAK,YAAY,QAAQ,CAAC;EACjC,OAAO;CACT;GACH,gCAAA,8BAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateSchemaProgrammer.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NestiaMigrateSchemaProgrammer.mjs","names":[],"sources":["../../src/programmers/NestiaMigrateSchemaProgrammer.ts"],"sourcesContent":["import { SyntaxKind, factory } from \"@ttsc/factory\";\nimport { NamingConvention, OpenApiTypeChecker } from \"@typia/utils\";\nimport type { OpenApi } from \"typia\";\n\nimport { SUPPORTED_STRING_FORMATS } from \"../factories/SupportedStringFormats\";\nimport { TypeFactory } from \"../factories/TypeFactory\";\nimport ts from \"../internal/ts\";\nimport { FilePrinter } from \"../utils/FilePrinter\";\nimport { StringUtil } from \"../utils/StringUtil\";\nimport { NestiaMigrateImportProgrammer } from \"./NestiaMigrateImportProgrammer\";\n\n/**\n * Generates the TypeScript type of an OpenAPI schema.\n *\n * @evidence contracts/common.md#principled-implementation The schema kind is decided by the type checker of `@typia/utils`, and each kind becomes a type: constants as literal types, numbers, integers, and strings with their constraints as `typia.tags` intersections, arrays, tuples, objects, references, and unions, with `any` for an unknown schema.\n * @evidence contracts/common.md#clear-and-simple-design One entry function that dispatches to one private writer per kind.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch follows the schema kinds of OpenAPI, and no schema name is special-cased.\n * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.\n */\nexport namespace NestiaMigrateSchemaProgrammer {\n /* -----------------------------------------------------------\n FACADE\n ----------------------------------------------------------- */\n /**\n * Returns the type node of a schema.\n *\n * @evidence contracts/common.md#principled-implementation An unknown schema is `any`, a `oneOf` becomes a TypeScript union, integer formats outside the supported four use the migration default `int64`, a binary string becomes `File`, and known string formats become typia tags. TypeScript unions do not encode oneOf exclusivity, and unsupported formats impose no generated constraint.\n * @evidence contracts/common.md#clear-and-simple-design One function with an ordered chain of schema kind tests.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts Schema-kind dispatch applies uniformly; the int64 fallback and supported-format table are generator policies rather than constraints supplied by the document.\n * @evidence contracts/common.md#meaningful-documentation The comment states the result.\n */\n export const write = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema;\n }): ts.TypeNode => {\n // CONSIDER ANY TYPE CASE\n const union: ts.TypeNode[] = [];\n if (OpenApiTypeChecker.isUnknown(props.schema))\n return TypeFactory.keyword(\"any\");\n\n // ITERATION\n const type: ts.TypeNode = (() => {\n // ATOMIC\n if (OpenApiTypeChecker.isConstant(props.schema))\n return writeConstant({\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isBoolean(props.schema))\n return writeBoolean();\n else if (OpenApiTypeChecker.isInteger(props.schema))\n return writeInteger({\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isNumber(props.schema))\n return writeNumber({\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isString(props.schema))\n return writeString({\n importer: props.importer,\n schema: props.schema,\n });\n // INSTANCES\n else if (OpenApiTypeChecker.isArray(props.schema))\n return writeArray({\n components: props.components,\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isTuple(props.schema))\n return writeTuple({\n components: props.components,\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isObject(props.schema))\n return writeObject({\n components: props.components,\n importer: props.importer,\n schema: props.schema,\n });\n else if (OpenApiTypeChecker.isReference(props.schema))\n return writeReference({\n importer: props.importer,\n schema: props.schema,\n });\n // UNION\n else if (OpenApiTypeChecker.isOneOf(props.schema))\n return writeUnion({\n components: props.components,\n importer: props.importer,\n elements: props.schema.oneOf,\n });\n else if (OpenApiTypeChecker.isNull(props.schema))\n return createNode(\"null\");\n else return TypeFactory.keyword(\"any\");\n })();\n union.push(type);\n\n // DETERMINE\n if (union.length === 0) return TypeFactory.keyword(\"any\");\n else if (union.length === 1) return union[0]!;\n return factory.createUnionTypeNode(union);\n };\n\n /* -----------------------------------------------------------\n ATOMICS\n ----------------------------------------------------------- */\n const writeConstant = (props: {\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IConstant;\n }): ts.TypeNode => {\n return factory.createLiteralTypeNode(\n typeof props.schema.const === \"boolean\"\n ? props.schema.const === true\n ? factory.createTrue()\n : factory.createFalse()\n : typeof props.schema.const === \"number\"\n ? props.schema.const < 0\n ? factory.createPrefixUnaryExpression(\n SyntaxKind.MinusToken,\n factory.createNumericLiteral(-props.schema.const),\n )\n : factory.createNumericLiteral(props.schema.const)\n : factory.createStringLiteral(props.schema.const),\n );\n };\n\n const writeBoolean = (): ts.TypeNode => TypeFactory.keyword(\"boolean\");\n\n const writeInteger = (props: {\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IInteger;\n }): ts.TypeNode =>\n writeNumeric({\n factory: () => [\n TypeFactory.keyword(\"number\"),\n props.importer.tag(\"Type\", integerType(props.schema)),\n ],\n importer: props.importer,\n schema: props.schema,\n });\n\n /**\n * The typia integer type admitting what the schema admits: its own `format`\n * when it names one typia has, else `int64`, as an integer schema without a\n * format admits any integer.\n */\n const integerType = (\n schema: OpenApi.IJsonSchema.IInteger,\n ): \"int32\" | \"uint32\" | \"int64\" | \"uint64\" => {\n const format: unknown = (schema as { format?: unknown }).format;\n return format === \"int32\" ||\n format === \"uint32\" ||\n format === \"int64\" ||\n format === \"uint64\"\n ? format\n : \"int64\";\n };\n\n const writeNumber = (props: {\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.INumber;\n }): ts.TypeNode =>\n writeNumeric({\n factory: () => [TypeFactory.keyword(\"number\")],\n importer: props.importer,\n schema: props.schema,\n });\n\n const writeNumeric = (props: {\n factory: () => ts.TypeNode[];\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IInteger | OpenApi.IJsonSchema.INumber;\n }): ts.TypeNode => {\n const intersection: ts.TypeNode[] = props.factory();\n if (props.schema.default !== undefined)\n intersection.push(props.importer.tag(\"Default\", props.schema.default));\n // the emended schema holds each bound as a number, as OpenAPI 3.1 does;\n // an OpenAPI 3.0 boolean `exclusiveMinimum` is converted into that form\n if (props.schema.minimum !== undefined)\n intersection.push(props.importer.tag(\"Minimum\", props.schema.minimum));\n if (typeof props.schema.exclusiveMinimum === \"number\")\n intersection.push(\n props.importer.tag(\"ExclusiveMinimum\", props.schema.exclusiveMinimum),\n );\n if (props.schema.maximum !== undefined)\n intersection.push(props.importer.tag(\"Maximum\", props.schema.maximum));\n if (typeof props.schema.exclusiveMaximum === \"number\")\n intersection.push(\n props.importer.tag(\"ExclusiveMaximum\", props.schema.exclusiveMaximum),\n );\n if (props.schema.multipleOf !== undefined)\n intersection.push(\n props.importer.tag(\"MultipleOf\", props.schema.multipleOf),\n );\n return intersection.length === 1\n ? intersection[0]!\n : factory.createIntersectionTypeNode(intersection);\n };\n\n const writeString = (props: {\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IString;\n }): ts.TypeNode => {\n if (props.schema.format === \"binary\")\n return factory.createTypeReferenceNode(\"File\");\n\n const intersection: ts.TypeNode[] = [TypeFactory.keyword(\"string\")];\n if (props.schema.default !== undefined)\n intersection.push(props.importer.tag(\"Default\", props.schema.default));\n if (props.schema.minLength !== undefined)\n intersection.push(\n props.importer.tag(\"MinLength\", props.schema.minLength),\n );\n if (props.schema.maxLength !== undefined)\n intersection.push(\n props.importer.tag(\"MaxLength\", props.schema.maxLength),\n );\n if (props.schema.pattern !== undefined)\n intersection.push(props.importer.tag(\"Pattern\", props.schema.pattern));\n if (\n props.schema.format !== undefined &&\n SUPPORTED_STRING_FORMATS.has(props.schema.format)\n )\n intersection.push(props.importer.tag(\"Format\", props.schema.format));\n if (props.schema.contentMediaType !== undefined)\n intersection.push(\n props.importer.tag(\"ContentMediaType\", props.schema.contentMediaType),\n );\n return intersection.length === 1\n ? intersection[0]!\n : factory.createIntersectionTypeNode(intersection);\n };\n\n /* -----------------------------------------------------------\n INSTANCES\n ----------------------------------------------------------- */\n const writeArray = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IArray;\n }): ts.TypeNode => {\n const intersection: ts.TypeNode[] = [\n factory.createArrayTypeNode(\n write({\n components: props.components,\n importer: props.importer,\n schema: props.schema.items,\n }),\n ),\n ];\n if (props.schema.minItems !== undefined)\n intersection.push(props.importer.tag(\"MinItems\", props.schema.minItems));\n if (props.schema.maxItems !== undefined)\n intersection.push(props.importer.tag(\"MaxItems\", props.schema.maxItems));\n if (props.schema.uniqueItems === true)\n intersection.push(props.importer.tag(\"UniqueItems\"));\n return intersection.length === 1\n ? intersection[0]!\n : factory.createIntersectionTypeNode(intersection);\n };\n\n const writeTuple = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.ITuple;\n }): ts.TypeNode =>\n factory.createTupleTypeNode([\n ...props.schema.prefixItems.map((item) =>\n write({\n components: props.components,\n importer: props.importer,\n schema: item,\n }),\n ),\n ...(typeof props.schema.additionalItems === \"object\" &&\n props.schema.additionalItems !== null\n ? [\n factory.createRestTypeNode(\n factory.createArrayTypeNode(\n write({\n components: props.components,\n importer: props.importer,\n schema: props.schema.additionalItems,\n }),\n ),\n ),\n ]\n : props.schema.additionalItems === true\n ? [\n factory.createRestTypeNode(\n factory.createArrayTypeNode(\n factory.createKeywordTypeNode(SyntaxKind.AnyKeyword),\n ),\n ),\n ]\n : []),\n ]);\n\n const writeObject = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IObject;\n }): ts.TypeNode => {\n const regular = () =>\n factory.createTypeLiteralNode(\n Object.entries(props.schema.properties ?? [])\n .map(([key, value], index) => [\n ...(index !== 0 &&\n (!!value.title?.length || !!value.description?.length)\n ? [factory.createIdentifier(\"\\n\") as any]\n : []),\n writeRegularProperty({\n components: props.components,\n importer: props.importer,\n required: props.schema.required ?? [],\n key,\n value,\n }),\n ])\n .flat(),\n );\n const dynamic = () =>\n factory.createTypeLiteralNode([\n writeDynamicProperty({\n components: props.components,\n importer: props.importer,\n schema: props.schema.additionalProperties as OpenApi.IJsonSchema,\n }),\n ]);\n // `properties` is a record, which has no length\n return Object.keys(props.schema.properties ?? {}).length !== 0 &&\n typeof props.schema.additionalProperties === \"object\"\n ? factory.createIntersectionTypeNode([regular(), dynamic()])\n : typeof props.schema.additionalProperties === \"object\"\n ? dynamic()\n : regular();\n };\n\n const writeRegularProperty = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n required: string[];\n key: string;\n value: OpenApi.IJsonSchema;\n }) => {\n const valueTypeNode: ts.TypeNode = write({\n components: props.components,\n importer: props.importer,\n schema: props.value,\n });\n return FilePrinter.description(\n factory.createPropertySignature(\n props.value.readOnly\n ? [factory.createToken(SyntaxKind.ReadonlyKeyword)]\n : undefined,\n NamingConvention.variable(props.key)\n ? factory.createIdentifier(props.key)\n : factory.createStringLiteral(props.key),\n props.required.includes(props.key)\n ? undefined\n : factory.createToken(SyntaxKind.QuestionToken),\n props.required.includes(props.key)\n ? valueTypeNode\n : ts.isUnionTypeNode(valueTypeNode)\n ? factory.createUnionTypeNode([\n ...(valueTypeNode.types ?? []),\n factory.createTypeReferenceNode(\"undefined\"),\n ])\n : factory.createUnionTypeNode([\n valueTypeNode,\n factory.createTypeReferenceNode(\"undefined\"),\n ]),\n ),\n writeComment(props.value),\n );\n };\n\n const writeDynamicProperty = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema;\n }) =>\n FilePrinter.description(\n factory.createIndexSignature(\n undefined,\n [\n factory.createParameterDeclaration(\n undefined,\n undefined,\n factory.createIdentifier(\"key\"),\n undefined,\n TypeFactory.keyword(\"string\"),\n ),\n ],\n write(props),\n ),\n writeComment(props.schema),\n );\n\n const writeReference = (props: {\n importer: NestiaMigrateImportProgrammer;\n schema: OpenApi.IJsonSchema.IReference;\n }): ts.TypeReferenceNode | ts.KeywordTypeNode => {\n if (props.schema.$ref.startsWith(\"#/components/schemas\") === false)\n return TypeFactory.keyword(\"any\");\n const name: string = props.schema.$ref\n .split(\"/\")\n .slice(3)\n .filter((str) => str.length !== 0)\n .map(StringUtil.escapeNonVariable)\n .join(\"\");\n if (name === \"\") return TypeFactory.keyword(\"any\");\n return props.importer.dto(name);\n };\n\n /* -----------------------------------------------------------\n UNIONS\n ----------------------------------------------------------- */\n const writeUnion = (props: {\n components: OpenApi.IComponents;\n importer: NestiaMigrateImportProgrammer;\n elements: OpenApi.IJsonSchema[];\n }): ts.UnionTypeNode =>\n factory.createUnionTypeNode(\n props.elements.map((schema) =>\n write({\n components: props.components,\n importer: props.importer,\n schema,\n }),\n ),\n );\n}\nconst createNode = (text: string) => factory.createTypeReferenceNode(text);\n\nconst writeComment = (schema: OpenApi.IJsonSchema): string => {\n interface IPlugin {\n key: string;\n value: undefined | string | number | boolean;\n }\n const plugins: IPlugin[] = [];\n if (schema.title !== undefined)\n plugins.push({\n key: \"title\",\n value: schema.title,\n });\n if (schema.deprecated === true)\n plugins.push({\n key: \"deprecated\",\n value: undefined,\n });\n for (const [key, value] of Object.entries(schema))\n if (key.startsWith(\"x-\") && isExtensionValue(value))\n plugins.push({\n key,\n value,\n });\n return [\n ...(schema.description?.length\n ? [eraseCommentTags(schema.description)]\n : []),\n ...(schema.description?.length && plugins.length !== 0 ? [\"\"] : []),\n ...plugins.map((p) =>\n p.value === undefined ? `@${p.key}` : `@${p.key} ${String(p.value)}`,\n ),\n ].join(\"\\n\");\n};\n\nconst isExtensionValue = (value: unknown): value is boolean | number | string =>\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\";\n\nconst eraseCommentTags = (description: string): string => {\n const lines: string[] = description.split(\"\\n\");\n return lines\n .filter((s) => COMMENT_TAGS.every((tag) => !s.includes(tag)))\n .join(\"\\n\");\n};\n\nconst COMMENT_TAGS = [\n // string\n \"@format\",\n \"@pattern\",\n \"@length\",\n \"@minLength\",\n \"@maxLength\",\n \"@contentMediaType\",\n // number\n \"@type\",\n \"@minimum\",\n \"@maximum\",\n \"@exclusiveMinimum\",\n \"@exclusiveMaximum\",\n \"@multipleOf\",\n // array\n \"@items\",\n \"@minItems\",\n \"@maxItems\",\n \"@uniqueItems\",\n];\n"],"mappings":";;;;;;;;AAmBO,IAAA;;CAYE,MAAM,QAAA,+BAAA,SAAS,UAIH;EAEjB,MAAM,QAAuB,CAAC;EAC9B,IAAI,mBAAmB,UAAU,MAAM,MAAM,GAC3C,OAAO,YAAY,QAAQ,KAAK;EAGlC,MAAM,cAA2B;GAE/B,IAAI,mBAAmB,WAAW,MAAM,MAAM,GAC5C,OAAO,cAAc;IACnB,UAAU,MAAM;IAChB,QAAQ,MAAM;GAChB,CAAC;QACE,IAAI,mBAAmB,UAAU,MAAM,MAAM,GAChD,OAAO,aAAa;QACjB,IAAI,mBAAmB,UAAU,MAAM,MAAM,GAChD,OAAO,aAAa;IAClB,UAAU,MAAM;IAChB,QAAQ,MAAM;GAChB,CAAC;QACE,IAAI,mBAAmB,SAAS,MAAM,MAAM,GAC/C,OAAO,YAAY;IACjB,UAAU,MAAM;IAChB,QAAQ,MAAM;GACh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IAAI;AACb;AAEA,MAAM,oBAAoB,UACxB,OAAO,UAAU,aACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAEnB,MAAM,oBAAoB,gBAAgC;CAExD,OADwB,YAAY,MAAM,IAC/B,CAAC,CACT,QAAQ,MAAM,aAAa,OAAO,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAC5D,KAAK,IAAI;AACd;AAEA,MAAM,eAAe;CAEnB;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePrinter.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"FilePrinter.mjs","names":[],"sources":["../../src/utils/FilePrinter.ts"],"sourcesContent":["import {\n SyntaxKind,\n TsPrinter,\n addSyntheticLeadingComment,\n factory,\n} from \"@ttsc/factory\";\n\nimport ts from \"../internal/ts\";\n\n/**\n * Helpers that turn statements and comments into file text.\n *\n * @evidence contracts/common.md#principled-implementation The namespace attaches a JSDoc comment to a node, builds a blank line, and prints a file from statements.\n * @evidence contracts/common.md#clear-and-simple-design Three small functions.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The comment text is escaped so it cannot end the comment early.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport namespace FilePrinter {\n /**\n * Attaches a JSDoc comment made from the text to the node, and leaves the\n * node alone when the text is empty.\n *\n * @evidence contracts/common.md#principled-implementation Line endings are normalized, each line is prefixed, and every comment terminator in the text is replaced by an escaped form, so a description can never end the comment early and inject code.\n * @evidence contracts/common.md#clear-and-simple-design One function with an early return.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The escaping applies to every line.\n * @evidence contracts/common.md#meaningful-documentation The comment states the empty case and the escaping.\n */\n export const description = <Node extends ts.Node>(\n node: Node,\n comment: string,\n ): Node => {\n if (comment.length === 0) return node;\n addSyntheticLeadingComment(\n node,\n SyntaxKind.MultiLineCommentTrivia,\n [\n \"*\",\n ...comment\n .split(\"\\r\\n\")\n .join(\"\\n\")\n .split(\"\\n\")\n .map(\n (str) =>\n ` * ${str.split(\"*/\").join(\"*\\\\\\\\/\").split(\"*\\\\/\").join(\"*\\\\\\\\/\")}`,\n ),\n \"\",\n ].join(\"\\n\"),\n true,\n );\n return node;\n };\n\n /**\n * Builds a statement that prints as a blank line.\n *\n * @evidence contracts/common.md#principled-implementation The printer emits the identifier text as it is, so an identifier holding a newline produces an empty line between statements.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is the way the printer offers to space statements.\n * @evidence contracts/common.md#meaningful-documentation The comment states what the statement prints.\n */\n export const newLine = () =>\n factory.createExpressionStatement(factory.createIdentifier(\"\\n\"));\n\n /**\n * Prints the statements as a file, with an optional text at the top.\n *\n * @evidence contracts/common.md#principled-implementation The statements are printed by the factory package's printer, so the output is the source of the syntax tree.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It prints what it is given.\n * @evidence contracts/common.md#meaningful-documentation The comment states the top text.\n */\n export const write = (props: {\n statements: ts.Statement[];\n top?: string;\n }): string =>\n (props.top ?? \"\") + new TsPrinter().printFile(undefined, props.statements);\n}\n"],"mappings":";;AAiBO,IAAA;;6BAWH,MACA,YACS;EACT,IAAI,QAAQ,WAAW,GAAG,OAAO;EACjC,2BACE,MACA,WAAW,wBACX;GACE;GACA,GAAG,QACA,MAAM,MAAM,CAAC,CACb,KAAK,IAAI,CAAC,CACV,MAAM,IAAI,CAAC,CACX,KACE,QACC,MAAM,IAAI,MAAM,IAAI,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,KAAK,QAAQ,GACpE;GACF;EACF,CAAC,CAAC,KAAK,IAAI,GACX,IACF;EACA,OAAO;CACT;8BAWE,QAAQ,0BAA0B,QAAQ,iBAAiB,IAAI,CAAC;uBAU5C,WAInB,MAAM,OAAO,MAAM,IAAI,UAAU,CAAC,CAAC,UAAU,KAAA,GAAW,MAAM,UAAU;GAC5E,gBAAA,cAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapUtil.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"MapUtil.mjs","names":[],"sources":["../../src/utils/MapUtil.ts"],"sourcesContent":["/**\n * Helpers for maps.\n *\n * @evidence contracts/common.md#principled-implementation The namespace holds the get-or-create helper.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport namespace MapUtil {\n /**\n * Returns the value of a key, creating and storing it with the generator when\n * the key is absent.\n *\n * @evidence contracts/common.md#principled-implementation Presence is tested with `has`, so a stored falsy value is returned and not created again, and the generator runs once per key.\n * @evidence contracts/common.md#clear-and-simple-design One check, one generator call, and one store.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The stored value is returned as it is.\n * @evidence contracts/common.md#meaningful-documentation The comment states when the generator runs.\n */\n export const take =\n <Key, T>(dict: Map<Key, T>) =>\n (key: Key) =>\n (generator: () => T): T => {\n if (dict.has(key)) return dict.get(key) as T;\n\n const value: T = generator();\n dict.set(key, value);\n return value;\n };\n}\n"],"mappings":";AAQO,IAAA;;kBAWM,UACR,SACA,cAA0B;EACzB,IAAI,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,IAAI,GAAG;EAEtC,MAAM,QAAW,UAAU;EAC3B,KAAK,IAAI,KAAK,KAAK;EACnB,OAAO;CACT;GACH,YAAA,UAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTemplate.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PathTemplate.mjs","names":[],"sources":["../../src/utils/PathTemplate.ts"],"sourcesContent":["import { IHttpMigrateRoute } from \"@typia/interface\";\n\n/**\n * Splits a route path template into literal and parameter segments.\n *\n * @evidence contracts/common.md#principled-implementation The namespace scans the template for `{name}` placeholders and matches each with the route's parameter of that name.\n * @evidence contracts/common.md#clear-and-simple-design One type and one function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The scan is by the template syntax.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport namespace PathTemplate {\n /**\n * A segment of a path: a literal text or a parameter.\n *\n * @evidence contracts/common.md#principled-implementation The union is discriminated by `type`, so a consumer handles each case once.\n * @evidence contracts/common.md#clear-and-simple-design A two-member union.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.\n * @evidence contracts/common.md#meaningful-documentation The comment names the two cases.\n */\n export type ISegment =\n | { type: \"literal\"; value: string }\n | { type: \"param\"; parameter: IHttpMigrateRoute.IParameter };\n\n /**\n * The route's path as literal text and path parameters, in order, read from\n * the document's own template (`/files/{id}.json`), whose braces delimit each\n * parameter name. The emended path (`/files/:id.json`) cannot be split back:\n * its `:id.json` could name `id` or `id.json`, and a name such as `item-id`\n * would read as `item` followed by `-id`. It always starts with `/`, as the\n * emended path does. A placeholder without a matching route parameter remains\n * literal text; adjacent literals are merged.\n *\n * @evidence contracts/common.md#principled-implementation The scan uses a regular expression over the placeholders and joins the text between them, and merging adjacent literals keeps the segment list minimal.\n * @evidence contracts/common.md#clear-and-simple-design One function with one helper for merging.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It never drops text of the template.\n * @evidence contracts/common.md#meaningful-documentation The comment states the merging and the unmatched placeholder rule.\n */\n export const segments = (route: IHttpMigrateRoute): ISegment[] => {\n const path: string = route.path.startsWith(\"/\")\n ? route.path\n : `/${route.path}`;\n const output: ISegment[] = [];\n const literal = (value: string): void => {\n if (value.length === 0) return;\n const last: ISegment | undefined = output[output.length - 1];\n if (last?.type === \"literal\") last.value += value;\n else output.push({ type: \"literal\", value });\n };\n let cursor: number = 0;\n for (const match of path.matchAll(/\\{([^{}]+)\\}/g)) {\n literal(path.slice(cursor, match.index));\n cursor = match.index! + match[0].length;\n const parameter: IHttpMigrateRoute.IParameter | undefined =\n route.parameters.find((p) => p.name === match[1]);\n if (parameter === undefined) literal(match[0]);\n else output.push({ type: \"param\", parameter });\n }\n literal(path.slice(cursor));\n return output;\n };\n}\n"],"mappings":";AAUO,IAAA;;2BA2BoB,UAAyC;EAChE,MAAM,OAAe,MAAM,KAAK,WAAW,GAAG,IAC1C,MAAM,OACN,IAAI,MAAM;EACd,MAAM,SAAqB,CAAC;EAC5B,MAAM,WAAW,UAAwB;GACvC,IAAI,MAAM,WAAW,GAAG;GACxB,MAAM,OAA6B,OAAO,OAAO,SAAS;GAC1D,IAAI,MAAM,SAAS,WAAW,KAAK,SAAS;QACvC,OAAO,KAAK;IAAE,MAAM;IAAW;GAAM,CAAC;EAC7C;EACA,IAAI,SAAiB;EACrB,KAAK,MAAM,SAAS,KAAK,SAAS,eAAe,GAAG;GAClD,QAAQ,KAAK,MAAM,QAAQ,MAAM,KAAK,CAAC;GACvC,SAAS,MAAM,QAAS,MAAM,EAAE,CAAC;GACjC,MAAM,YACJ,MAAM,WAAW,MAAM,MAAM,EAAE,SAAS,MAAM,EAAE;GAClD,IAAI,cAAc,KAAA,GAAW,QAAQ,MAAM,EAAE;QACxC,OAAO,KAAK;IAAE,MAAM;IAAS;GAAU,CAAC;EAC/C;EACA,QAAQ,KAAK,MAAM,MAAM,CAAC;EAC1B,OAAO;CACT;GACD,iBAAA,eAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestBody.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"RequestBody.mjs","names":[],"sources":["../../src/utils/RequestBody.ts"],"sourcesContent":["import { IHttpMigrateRoute } from \"@typia/interface\";\n\n/**\n * Helpers about the request body of a route.\n *\n * @evidence contracts/common.md#principled-implementation The namespace holds the optional-body predicate.\n * @evidence contracts/common.md#clear-and-simple-design One function.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport namespace RequestBody {\n /**\n * Whether the route's body may be omitted: a JSON or text body the document\n * does not require. The SDK's positional and keyword functions and the Nest\n * controller all read this one rule.\n *\n * @evidence contracts/common.md#principled-implementation The requirement flag is read from the operation and only an explicit `false` makes the body optional.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the document.\n * @evidence contracts/common.md#meaningful-documentation The comment states the condition.\n */\n export const optional = (route: IHttpMigrateRoute): boolean =>\n route.body !== null &&\n (route.body.type === \"application/json\" ||\n route.body.type === \"text/plain\") &&\n route.operation().requestBody?.required === false;\n}\n"],"mappings":";AAUO,IAAA;;0BAWoB,UACvB,MAAM,SAAS,SACd,MAAM,KAAK,SAAS,sBACnB,MAAM,KAAK,SAAS,iBACtB,MAAM,UAAU,CAAC,CAAC,aAAa,aAAa;GAC/C,gBAAA,cAAA,CAAA,EAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringUtil.mjs","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"StringUtil.mjs","names":[],"sources":["../../src/utils/StringUtil.ts"],"sourcesContent":["/**\n * String helpers that turn arbitrary text into valid identifiers and names.\n *\n * Identifier escaping traverses the input with a fixed punctuation table and\n * Unicode-aware per-segment replacements; total work and intermediate storage\n * scale with encoded output length.\n *\n * @evidence contracts/common.md#principled-implementation The namespace holds the capitalization, path segment normalization, and identifier escaping rules used by the generators.\n * @evidence contracts/common.md#clear-and-simple-design Three functions and private tables of reserved words and replacements.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The tables are the language's reserved words and a fixed replacement of punctuation.\n * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.\n */\nexport namespace StringUtil {\n /**\n * Upper-cases the first character and lower-cases the rest; an empty string\n * stays empty.\n *\n * One leading-character conversion and one remainder conversion cost O(N) in\n * the input length.\n *\n * @evidence contracts/common.md#principled-implementation The first character is transformed alone and the remainder is lower-cased, so the result is a normalized word.\n * @evidence contracts/common.md#clear-and-simple-design One expression.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts It applies to every input.\n * @evidence contracts/common.md#meaningful-documentation The comment states the rule and the empty case.\n */\n export const capitalize = (str: string): string =>\n str.length === 0 ? str : str[0]!.toUpperCase() + str.slice(1).toLowerCase();\n\n /**\n * Splits a path by slashes and normalizes each non-empty segment into a name.\n *\n * The path is split once and each segment normalized with a fixed number of\n * transformations: O(N) total text work and output storage.\n *\n * @evidence contracts/common.md#principled-implementation Each segment loses dots and dashes, a reserved word or a leading digit gets an underscore prefix, and empty segments are dropped.\n * @evidence contracts/common.md#clear-and-simple-design One expression over the private normalizer.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The rules apply to every segment.\n * @evidence contracts/common.md#meaningful-documentation The comment states the normalization.\n */\n export const splitWithNormalization = (path: string) =>\n path\n .split(\"/\")\n .map((str) => normalize(str.trim()))\n .filter((str) => !!str.length);\n\n /**\n * Escapes a string into a valid, possibly qualified, name.\n *\n * A dot separates the segments of a qualified name, so each segment is\n * escaped as one identifier. Punctuation is replaced by a word such as\n * `_at_`, any other character an identifier cannot hold by its code point, a\n * reserved word or a segment that cannot start an identifier gets an\n * underscore prefix, and an empty segment is `_empty_`. The last segment\n * names a type, so it is also prefixed when it is a predefined type name.\n *\n * A fixed punctuation table traverses the text before per-segment Unicode\n * escaping. Work scales linearly with the encoded text length for the fixed\n * table; expanded code-point spellings are retained only in the returned\n * string.\n *\n * @evidence contracts/common.md#principled-implementation Whitespace at the edges is trimmed and the punctuation table is applied in its fixed order over the whole string; the string is then split at the dots, which stay as the namespace separators the DTO tree reads, and every segment is made an identifier by the ECMAScript rule: characters outside `ID_Continue` become their code point, and a reserved word, a predefined type name in the last segment or a segment not starting with `ID_Start`, `_` or `$` is prefixed with an underscore, so each segment is a valid identifier even where the punctuation table does not cover its characters.\n * @evidence contracts/common.md#clear-and-simple-design One function over one segment helper and three private tables of reserved words, predefined type names and replacements.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts No schema name is special-cased; the fixed punctuation table and Unicode identifier rules apply to every segment.\n * @evidence contracts/common.md#meaningful-documentation The comment states the segment rule, the replacements, the prefixes and the empty case.\n */\n export const escapeNonVariable = (str: string): string => {\n str = str.trim();\n for (const [before, after] of VARIABLE_REPLACERS)\n str = str.split(before).join(after);\n if (str === \"\") return \"_empty_\";\n const segments: string[] = str.split(\".\");\n return segments\n .map((segment, index) =>\n escapeSegment(segment, index === segments.length - 1),\n )\n .join(\".\");\n };\n}\n\nconst escape = (str: string): string => {\n str = str.trim();\n if (RESERVED.has(str)) return `_${str}`;\n else if (str.length !== 0 && \"0\" <= str[0]! && str[0]! <= \"9\")\n str = `_${str}`;\n return str;\n};\n\n// One identifier. The patterns are built at run time because the property\n// escapes need a newer script target than the one this package compiles to.\nconst NON_IDENTIFIER_PART: RegExp = new RegExp(\"[^\\\\p{ID_Continue}]\", \"gu\");\nconst IDENTIFIER_START: RegExp = new RegExp(\"^[\\\\p{ID_Start}_$]\", \"u\");\n\nconst escapeSegment = (segment: string, type: boolean): string => {\n segment = segment.replace(\n NON_IDENTIFIER_PART,\n (char) => `_u${char.codePointAt(0)!.toString(16)}_`,\n );\n if (segment.length === 0) return \"_empty_\";\n return RESERVED.has(segment) ||\n (type && TYPE_NAMES.has(segment)) ||\n IDENTIFIER_START.test(segment) === false\n ? `_${segment}`\n : segment;\n};\n\nconst normalize = (str: string): string =>\n escape(str.split(\".\").join(\"_\").split(\"-\").join(\"_\"));\n\nconst TYPE_NAMES: Set<string> = new Set([\n \"any\",\n \"bigint\",\n \"boolean\",\n \"never\",\n \"number\",\n \"object\",\n \"string\",\n \"symbol\",\n \"undefined\",\n \"unknown\",\n]);\n\nconst RESERVED: Set<string> = new Set([\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"interface\",\n \"let\",\n \"module\",\n \"new\",\n \"null\",\n \"package\",\n \"public\",\n \"private\",\n \"protected\",\n \"return\",\n \"static\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nconst VARIABLE_REPLACERS: [string, string][] = [\n [\"`\", \"_backquote_\"],\n [\"!\", \"_exclamation_\"],\n [\"@\", \"_at_\"],\n [\"#\", \"_hash_\"],\n [\"$\", \"_dollar_\"],\n [\"%\", \"_percent_\"],\n [\"^\", \"_caret_\"],\n [\"&\", \"_and_\"],\n [\"*\", \"_star_\"],\n [\"(\", \"_lparen_\"],\n [\")\", \"_rparen_\"],\n [\"-\", \"_\"],\n [\"+\", \"_plus_\"],\n [\"|\", \"_or_\"],\n [\"{\", \"_blt_\"],\n [\"}\", \"_bgt_\"],\n [\"<\", \"_lt_\"],\n [\">\", \"_gt_\"],\n [\"[\", \"_alt_\"],\n [\"]\", \"_agt_\"],\n [\",\", \"_comma_\"],\n [\"'\", \"_singlequote_\"],\n ['\"', \"_doublequote_\"],\n [\" \", \"_space_\"],\n [\"?\", \"_question_\"],\n [\":\", \"_colon_\"],\n [\";\", \"_semicolon_\"],\n [\"...\", \"_rest_\"],\n];\n"],"mappings":";AAYO,IAAA;;2BAasB,QACzB,IAAI,WAAW,IAAI,MAAM,IAAI,EAAE,CAAE,YAAY,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY;uCAarC,SACrC,KACG,MAAM,GAAG,CAAC,CACV,KAAK,QAAQ,UAAU,IAAI,KAAK,CAAC,CAAC,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