@autobe/compiler 0.18.0 → 0.20.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.
Files changed (43) hide show
  1. package/lib/AutoBeTypeScriptCompiler.js +7 -8
  2. package/lib/AutoBeTypeScriptCompiler.js.map +1 -1
  3. package/lib/interface/AutoBeInterfaceCompiler.js +2 -2
  4. package/lib/interface/AutoBeInterfaceCompiler.js.map +1 -1
  5. package/lib/prisma/validatePrismaApplication.js +259 -73
  6. package/lib/prisma/validatePrismaApplication.js.map +1 -1
  7. package/lib/prisma/writePrismaApplication.js +1 -2
  8. package/lib/prisma/writePrismaApplication.js.map +1 -1
  9. package/lib/raw/AutoBeCompilerRealizeTemplate.js +4 -3
  10. package/lib/raw/AutoBeCompilerRealizeTemplate.js.map +1 -1
  11. package/lib/raw/AutoBeCompilerTestTemplate.js +1 -1
  12. package/lib/raw/nestjs.json +7 -7
  13. package/lib/raw/test.json +2 -2
  14. package/lib/realize/writeRealizeControllers.js +10 -3
  15. package/lib/realize/writeRealizeControllers.js.map +1 -1
  16. package/lib/test/AutoBeTestCompiler.js +7 -8
  17. package/lib/test/AutoBeTestCompiler.js.map +1 -1
  18. package/lib/utils/FilePrinter.js +11 -11
  19. package/lib/utils/FilePrinter.js.map +1 -1
  20. package/lib/utils/shrinkCompileResult.d.ts +3 -0
  21. package/lib/utils/shrinkCompileResult.js +17 -0
  22. package/lib/utils/shrinkCompileResult.js.map +1 -0
  23. package/package.json +14 -9
  24. package/src/AutoBeTypeScriptCompiler.ts +12 -13
  25. package/src/interface/AutoBeInterfaceCompiler.ts +3 -3
  26. package/src/prisma/validatePrismaApplication.ts +265 -79
  27. package/src/prisma/writePrismaApplication.ts +1 -2
  28. package/src/raw/AutoBeCompilerRealizeTemplate.ts +4 -3
  29. package/src/raw/AutoBeCompilerTestTemplate.ts +1 -1
  30. package/src/raw/nestjs.json +7 -7
  31. package/src/raw/test.json +2 -2
  32. package/src/realize/writeRealizeControllers.ts +38 -4
  33. package/src/test/AutoBeTestCompiler.ts +7 -8
  34. package/src/utils/FilePrinter.ts +10 -9
  35. package/src/utils/shrinkCompileResult.ts +16 -0
  36. package/lib/interface/createMigrateApplication.d.ts +0 -3
  37. package/lib/interface/createMigrateApplication.js +0 -15
  38. package/lib/interface/createMigrateApplication.js.map +0 -1
  39. package/lib/utils/MapUtil.d.ts +0 -3
  40. package/lib/utils/MapUtil.js +0 -16
  41. package/lib/utils/MapUtil.js.map +0 -1
  42. package/src/interface/createMigrateApplication.ts +0 -18
  43. package/src/utils/MapUtil.ts +0 -10
package/src/raw/test.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "node_modules/@nestia/e2e/lib/index.d.ts": "import * as e2e from \"./module\";\nexport default e2e;\nexport * from \"./module\";\n",
8
8
  "node_modules/@nestia/e2e/lib/internal/json_equal_to.d.ts": "export declare const json_equal_to: (exception: (key: string) => boolean) => <T>(x: T) => (y: T | null | undefined) => string[];\n",
9
9
  "node_modules/@nestia/e2e/lib/module.d.ts": "export * from \"./ArrayUtil\";\nexport * from \"./DynamicExecutor\";\nexport * from \"./GaffComparator\";\nexport * from \"./RandomGenerator\";\nexport * from \"./TestValidator\";\n",
10
- "node_modules/@nestia/e2e/package.json": "{\n \"name\": \"@nestia/e2e\",\n \"version\": \"7.3.3\",\n \"description\": \"E2E test utilify functions\",\n \"main\": \"lib/index.js\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"npm run build:main && npm run build:test\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"test\": \"node bin/test\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"keywords\": [\n \"e2e\",\n \"nestia\",\n \"nestjs\",\n \"test\",\n \"tdd\",\n \"utility\"\n ],\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.0.0\",\n \"@types/node\": \"^18.11.18\",\n \"@typescript-eslint/eslint-plugin\": \"^5.57.0\",\n \"@typescript-eslint/parser\": \"^5.57.0\",\n \"rimraf\": \"^6.0.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\n \"typescript-transform-paths\": \"^3.4.7\",\n \"typia\": \"^9.6.1\"\n },\n \"files\": [\n \"lib\",\n \"src\",\n \"README.md\",\n \"LICENSE\",\n \"package.json\"\n ]\n}",
10
+ "node_modules/@nestia/e2e/package.json": "{\n \"name\": \"@nestia/e2e\",\n \"version\": \"7.4.0\",\n \"description\": \"E2E test utilify functions\",\n \"main\": \"lib/index.js\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"npm run build:main && npm run build:test\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"test\": \"node bin/test\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"keywords\": [\n \"e2e\",\n \"nestia\",\n \"nestjs\",\n \"test\",\n \"tdd\",\n \"utility\"\n ],\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.0.0\",\n \"@types/node\": \"^18.11.18\",\n \"@typescript-eslint/eslint-plugin\": \"^5.57.0\",\n \"@typescript-eslint/parser\": \"^5.57.0\",\n \"rimraf\": \"^6.0.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\n \"typescript-transform-paths\": \"^3.4.7\",\n \"typia\": \"^9.6.1\"\n },\n \"files\": [\n \"lib\",\n \"src\",\n \"README.md\",\n \"LICENSE\",\n \"package.json\"\n ]\n}",
11
11
  "node_modules/@nestia/fetcher/lib/AesPkcs5.d.ts": "/**\n * Utility class for the AES-128/256 encryption.\n *\n * - AES-128/256\n * - CBC mode\n * - PKCS#5 Padding\n * - Base64 Encoding\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace AesPkcs5 {\n /**\n * Encrypt data\n *\n * @param data Target data\n * @param key Key value of the encryption.\n * @param iv Initializer Vector for the encryption\n * @returns Encrypted data\n */\n function encrypt(data: string, key: string, iv: string): string;\n /**\n * Decrypt data.\n *\n * @param data Target data\n * @param key Key value of the decryption.\n * @param iv Initializer Vector for the decryption\n * @returns Decrypted data.\n */\n function decrypt(data: string, key: string, iv: string): string;\n}\n",
12
12
  "node_modules/@nestia/fetcher/lib/EncryptedFetcher.d.ts": "import { IConnection } from \"./IConnection\";\nimport { IFetchRoute } from \"./IFetchRoute\";\nimport { IPropagation } from \"./IPropagation\";\n/**\n * Utility class for `fetch` functions used in `@nestia/sdk` with encryption.\n *\n * `EncryptedFetcher` is a utility class designed for SDK functions generated by\n * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote\n * HTTP API encrypted by AES-PKCS algorithm. In other words, this is a\n * collection of dedicated `fetch()` functions for `@nestia/sdk` with\n * encryption.\n *\n * For reference, `EncryptedFetcher` class being used only when target\n * controller method is encrypting body data by `@EncryptedRoute` or\n * `@EncryptedBody` decorators. If those decorators are not used,\n * {@link PlainFetcher} class would be used instead.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace EncryptedFetcher {\n /**\n * Fetch function only for `HEAD` method.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Nothing because of `HEAD` method\n */\n function fetch(connection: IConnection, route: IFetchRoute<\"HEAD\">): Promise<void>;\n /**\n * Fetch function only for `GET` method.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Response body data from the remote API\n */\n function fetch<Output>(connection: IConnection, route: IFetchRoute<\"GET\">): Promise<Output>;\n /**\n * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Response body data from the remote API\n */\n function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<\"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;\n function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<\"GET\" | \"HEAD\">): Promise<Output>;\n function propagate<Input, Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<\"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;\n}\n",
13
13
  "node_modules/@nestia/fetcher/lib/FormDataInput.d.ts": "/**\n * FormData input type.\n *\n * `FormDataInput<T>` is a type for the input of the `FormData` request, casting\n * `File` property value type as an union of `File` and\n * {@link FormDataInput.IFileProps}, especially for the React Native\n * environment.\n *\n * You know what? In the React Native environment, `File` class is not\n * supported. Therefore, when composing a `FormData` request, you have to put\n * the URI address of the local filesystem with file name and content type that\n * is represented by the {@link FormDataInput.IFileProps} type.\n *\n * This `FormDataInput<T>` type is designed for that purpose. If the property\n * value type is a `File` class, it converts it to an union type of `File` and\n * {@link FormDataInput.IFileProps} type. Also, if the property value type is an\n * array of `File` class, it converts it to an array of union type of `File` and\n * {@link FormDataInput.IFileProps} type too.\n *\n * Before | After ----------|------------------------ `boolean` | `boolean`\n * `bigint` | `bigint` `number` | `number` `string` | `string` `File` | `File \\|\n * IFileProps`\n *\n * @author Jeongho Nam - https://github.com/samchon\n * @template T Target object type.\n */\nexport type FormDataInput<T extends object> = T extends Array<any> ? never : T extends Function ? never : {\n [P in keyof T]: T[P] extends Array<infer U> ? FormDataInput.Value<U>[] : FormDataInput.Value<T[P]>;\n};\nexport declare namespace FormDataInput {\n /**\n * Value type of the `FormDataInput`.\n *\n * `Value<T>` is a type for the property value defined in the `FormDataInput`.\n *\n * If the original value type is a `File` class, `Value<T>` converts it to an\n * union type of `File` and {@link IFileProps} type which is a structured data\n * for the URI file location in the React Native environment.\n */\n type Value<T> = T extends File ? T | IFileProps : T;\n /**\n * Properties of a file.\n *\n * In the React Native, this `IFileProps` structured data can replace the\n * `File` class instance in the `FormData` request.\n *\n * Just put the {@link uri URI address} of the local file system with the\n * file's {@link name} and {@link type}. It would be casted to the `File` class\n * instance automatically in the `FormData` request.\n *\n * Note that, this `IFileProps` type works only in the React Native\n * environment. If you are developing a Web or NodeJS application, you have to\n * utilize the `File` class instance directly.\n */\n interface IFileProps {\n /**\n * URI address of the file.\n *\n * In the React Native, the URI address in the local file system can replace\n * the `File` class instance. If\n *\n * @format uri\n */\n uri: string;\n /** Name of the file. */\n name: string;\n /** Content type of the file. */\n type: string;\n }\n}\n",
@@ -22,7 +22,7 @@
22
22
  "node_modules/@nestia/fetcher/lib/PlainFetcher.d.ts": "import { IConnection } from \"./IConnection\";\nimport { IFetchRoute } from \"./IFetchRoute\";\nimport { IPropagation } from \"./IPropagation\";\n/**\n * Utility class for `fetch` functions used in `@nestia/sdk`.\n *\n * `PlainFetcher` is a utility class designed for SDK functions generated by\n * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote\n * HTTP sever API. In other words, this is a collection of dedicated `fetch()`\n * functions for `@nestia/sdk`.\n *\n * For reference, `PlainFetcher` class does not encrypt or decrypt the body data\n * at all. It just delivers plain data without any post processing. If you've\n * defined a controller method through `@EncryptedRoute` or `@EncryptedBody`\n * decorator, then {@liink EncryptedFetcher} class would be used instead.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace PlainFetcher {\n /**\n * Fetch function only for `HEAD` method.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Nothing because of `HEAD` method\n */\n function fetch(connection: IConnection, route: IFetchRoute<\"HEAD\">): Promise<void>;\n /**\n * Fetch function only for `GET` method.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Response body data from the remote API\n */\n function fetch<Output>(connection: IConnection, route: IFetchRoute<\"GET\">): Promise<Output>;\n /**\n * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.\n *\n * @param connection Connection information for the remote HTTP server\n * @param route Route information about the target API\n * @returns Response body data from the remote API\n */\n function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<\"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;\n function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<\"GET\" | \"HEAD\">): Promise<Output>;\n function propagate<Input, Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<\"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\">, input?: Input, stringify?: (input: Input) => string): Promise<Output>;\n}\n",
23
23
  "node_modules/@nestia/fetcher/lib/index.d.ts": "export * from \"./FormDataInput\";\nexport * from \"./HttpError\";\nexport * from \"./IConnection\";\nexport * from \"./IEncryptionPassword\";\nexport * from \"./IFetchEvent\";\nexport * from \"./IFetchRoute\";\nexport * from \"./IPropagation\";\n",
24
24
  "node_modules/@nestia/fetcher/lib/internal/FetcherBase.d.ts": "export {};\n",
25
- "node_modules/@nestia/fetcher/package.json": "{\n \"name\": \"@nestia/fetcher\",\n \"version\": \"7.3.3\",\n \"description\": \"Fetcher library of Nestia SDK\",\n \"main\": \"lib/index.js\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"rimraf lib && tsc\",\n \"dev\": \"tsc -p tsconfig.test.json --watch\",\n \"eslint\": \"eslint src\",\n \"eslint:fix\": \"eslint src --fix\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"keywords\": [\n \"nestia\",\n \"fetcher\",\n \"sdk\"\n ],\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"dependencies\": {\n \"@samchon/openapi\": \"^4.5.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^18.11.14\",\n \"@typescript-eslint/eslint-plugin\": \"^5.46.1\",\n \"@typescript-eslint/parser\": \"^5.46.1\",\n \"rimraf\": \"^6.0.1\",\n \"typescript\": \"~5.9.2\"\n },\n \"files\": [\n \"README.md\",\n \"LICENSE\",\n \"package.json\",\n \"lib\",\n \"src\"\n ]\n}",
25
+ "node_modules/@nestia/fetcher/package.json": "{\n \"name\": \"@nestia/fetcher\",\n \"version\": \"7.4.0\",\n \"description\": \"Fetcher library of Nestia SDK\",\n \"main\": \"lib/index.js\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"rimraf lib && tsc\",\n \"dev\": \"tsc -p tsconfig.test.json --watch\",\n \"eslint\": \"eslint src\",\n \"eslint:fix\": \"eslint src --fix\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"keywords\": [\n \"nestia\",\n \"fetcher\",\n \"sdk\"\n ],\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"dependencies\": {\n \"@samchon/openapi\": \"^4.5.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^18.11.14\",\n \"@typescript-eslint/eslint-plugin\": \"^5.46.1\",\n \"@typescript-eslint/parser\": \"^5.46.1\",\n \"rimraf\": \"^6.0.1\",\n \"typescript\": \"~5.9.2\"\n },\n \"files\": [\n \"README.md\",\n \"LICENSE\",\n \"package.json\",\n \"lib\",\n \"src\"\n ]\n}",
26
26
  "node_modules/@samchon/openapi/lib/HttpLlm.d.ts": "import { OpenApi } from \"./OpenApi\";\nimport { OpenApiV3 } from \"./OpenApiV3\";\nimport { OpenApiV3_1 } from \"./OpenApiV3_1\";\nimport { SwaggerV2 } from \"./SwaggerV2\";\nimport { IHttpConnection } from \"./structures/IHttpConnection\";\nimport { IHttpLlmApplication } from \"./structures/IHttpLlmApplication\";\nimport { IHttpLlmFunction } from \"./structures/IHttpLlmFunction\";\nimport { IHttpResponse } from \"./structures/IHttpResponse\";\nimport { ILlmFunction } from \"./structures/ILlmFunction\";\nimport { ILlmSchema } from \"./structures/ILlmSchema\";\n/**\n * LLM function calling application composer from OpenAPI document.\n *\n * `HttpLlm` is a module for composing LLM (Large Language Model) function\n * calling application from the {@link OpenApi.IDocument OpenAPI document}, and\n * also for LLM function call execution and parameter merging.\n *\n * At first, you can construct the LLM function calling application by the\n * {@link HttpLlm.application HttpLlm.application()} function. And then the LLM\n * has selected a {@link IHttpLlmFunction function} to call and composes its\n * arguments, you can execute the function by\n * {@link HttpLlm.execute HttpLlm.execute()} or\n * {@link HttpLlm.propagate HttpLlm.propagate()}.\n *\n * By the way, if you have configured the\n * {@link IHttpLlmApplication.IOptions.separate} option to separate the\n * parameters into human and LLM sides, you can merge these human and LLM sides'\n * parameters into one through\n * {@link HttpLlm.mergeParameters HttpLlm.mergeParameters()} before the actual\n * LLM function call execution.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace HttpLlm {\n /**\n * Properties for the LLM function calling application composer.\n *\n * @template Model Target LLM model\n */\n interface IApplicationProps<Model extends ILlmSchema.Model> {\n /** Target LLM model. */\n model: Model;\n /** OpenAPI document to convert. */\n document: OpenApi.IDocument | SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument;\n /** Options for the LLM function calling schema conversion. */\n options?: Partial<IHttpLlmApplication.IOptions<Model>>;\n }\n /**\n * Convert OpenAPI document to LLM function calling application.\n *\n * Converts {@link OpenApi.IDocument OpenAPI document} or\n * {@link IHttpMigrateApplication migrated application} to the\n * {@link IHttpLlmApplication LLM function calling application}. Every\n * {@link OpenApi.IOperation API operations} in the OpenAPI document are\n * converted to the {@link IHttpLlmFunction LLM function} type, and they would\n * be used for the LLM function calling.\n *\n * If you have configured the {@link IHttpLlmApplication.IOptions.separate}\n * option, every parameters in the {@link IHttpLlmFunction} would be separated\n * into both human and LLM sides. In that case, you can merge these human and\n * LLM sides' parameters into one through {@link HttpLlm.mergeParameters}\n * before the actual LLM function call execution.\n *\n * Additionally, if you have configured the\n * {@link IHttpLlmApplication.IOptions.keyword} as `true`, the number of\n * {@link IHttpLlmFunction.parameters} are always 1 and the first parameter\n * type is always {@link ILlmSchemaV3.IObject}. I recommend this option because\n * LLM can understand the keyword arguments more easily.\n *\n * @param props Properties for composition\n * @returns LLM function calling application\n */\n const application: <Model extends ILlmSchema.Model>(props: IApplicationProps<Model>) => IHttpLlmApplication<Model>;\n /** Properties for the LLM function call. */\n interface IFetchProps<Model extends ILlmSchema.Model> {\n /** Application of the LLM function calling. */\n application: IHttpLlmApplication<Model>;\n /** LLM function schema to call. */\n function: IHttpLlmFunction<ILlmSchema.Model>;\n /** Connection info to the HTTP server. */\n connection: IHttpConnection;\n /** Input arguments for the function call. */\n input: object;\n }\n /**\n * Execute the LLM function call.\n *\n * `HttmLlm.execute()` is a function executing the target\n * {@link OpenApi.IOperation API endpoint} with with the connection information\n * and arguments composed by Large Language Model like OpenAI (+human\n * sometimes).\n *\n * By the way, if you've configured the\n * {@link IHttpLlmApplication.IOptions.separate}, so that the parameters are\n * separated to human and LLM sides, you have to merge these humand and LLM\n * sides' parameters into one through {@link HttpLlm.mergeParameters}\n * function.\n *\n * About the {@link IHttpLlmApplication.IOptions.keyword} option, don't worry\n * anything. This `HttmLlm.execute()` function will automatically recognize\n * the keyword arguments and convert them to the proper sequence.\n *\n * For reference, if the target API endpoinnt responds none 200/201 status,\n * this would be considered as an error and the {@link HttpError} would be\n * thrown. Otherwise you don't want such rule, you can use the\n * {@link HttpLlm.propagate} function instead.\n *\n * @param props Properties for the LLM function call\n * @returns Return value (response body) from the API endpoint\n * @throws HttpError when the API endpoint responds none 200/201 status\n */\n const execute: <Model extends ILlmSchema.Model>(props: IFetchProps<Model>) => Promise<unknown>;\n /**\n * Propagate the LLM function call.\n *\n * `HttmLlm.propagate()` is a function propagating the target\n * {@link OpenApi.IOperation API endpoint} with with the connection information\n * and arguments composed by Large Language Model like OpenAI (+human\n * sometimes).\n *\n * By the way, if you've configured the\n * {@link IHttpLlmApplication.IOptions.separate}, so that the parameters are\n * separated to human and LLM sides, you have to merge these humand and LLM\n * sides' parameters into one through {@link HttpLlm.mergeParameters}\n * function.\n *\n * About the {@link IHttpLlmApplication.IOptions.keyword} option, don't worry\n * anything. This `HttmLlm.propagate()` function will automatically recognize\n * the keyword arguments and convert them to the proper sequence.\n *\n * For reference, the propagation means always returning the response from the\n * API endpoint, even if the status is not 200/201. This is useful when you\n * want to handle the response by yourself.\n *\n * @param props Properties for the LLM function call\n * @returns Response from the API endpoint\n * @throws Error only when the connection is failed\n */\n const propagate: <Model extends ILlmSchema.Model>(props: IFetchProps<Model>) => Promise<IHttpResponse>;\n /** Properties for the parameters' merging. */\n interface IMergeProps<Model extends ILlmSchema.Model> {\n /** Metadata of the target function. */\n function: ILlmFunction<Model>;\n /** Arguments composed by the LLM. */\n llm: object | null;\n /** Arguments composed by the human. */\n human: object | null;\n }\n /**\n * Merge the parameters.\n *\n * If you've configured the {@link IHttpLlmApplication.IOptions.separate}\n * option, so that the parameters are separated to human and LLM sides, you\n * can merge these humand and LLM sides' parameters into one through this\n * `HttpLlm.mergeParameters()` function before the actual LLM function call\n * wexecution.\n *\n * On contrary, if you've not configured the\n * {@link IHttpLlmApplication.IOptions.separate} option, this function would\n * throw an error.\n *\n * @param props Properties for the parameters' merging\n * @returns Merged parameter values\n */\n const mergeParameters: <Model extends ILlmSchema.Model>(props: IMergeProps<Model>) => object;\n /**\n * Merge two values.\n *\n * If both values are objects, then combines them in the properties level.\n *\n * Otherwise, returns the latter value if it's not null, otherwise the former\n * value.\n *\n * - `return (y ?? x)`\n *\n * @param x Value X to merge\n * @param y Value Y to merge\n * @returns Merged value\n */\n const mergeValue: (x: unknown, y: unknown) => unknown;\n}\n",
27
27
  "node_modules/@samchon/openapi/lib/HttpMigration.d.ts": "import { OpenApi } from \"./OpenApi\";\nimport { OpenApiV3 } from \"./OpenApiV3\";\nimport { OpenApiV3_1 } from \"./OpenApiV3_1\";\nimport { SwaggerV2 } from \"./SwaggerV2\";\nimport { IHttpConnection } from \"./structures/IHttpConnection\";\nimport { IHttpMigrateApplication } from \"./structures/IHttpMigrateApplication\";\nimport { IHttpMigrateRoute } from \"./structures/IHttpMigrateRoute\";\nimport { IHttpResponse } from \"./structures/IHttpResponse\";\n/**\n * HTTP migration application composer from OpenAPI document.\n *\n * `HttpMigration` is a module for composing HTTP migration application from the\n * {@link OpenApi.IDocument OpenAPI document}. It is designed for helping the\n * OpenAPI generator libraries, which converts\n * {@link OpenApi.IOperation OpenAPI operations} to an RPC (Remote Procedure\n * Call) function.\n *\n * The key feature of the `HttpModule` is the {@link HttpMigration.application}\n * function. It converts the {@link OpenApi.IOperation OpenAPI operations} to the\n * {@link IHttpMigrateRoute HTTP migration route}, and it normalizes the OpenAPI\n * operations to the RPC function calling suitable route structure.\n *\n * The other functions, {@link HttpMigration.execute} and\n * {@link HttpMigration.propagate}, are for executing the HTTP request to the\n * HTTP server. The {@link HttpMigration.execute} function returns the response\n * body from the API endpoint when the status code is `200` or `201`. Otherwise,\n * it throws an {@link HttpError} when the status code is not `200` or `201`. The\n * {@link HttpMigration.propagate} function returns the response information from\n * the API endpoint, including the status code, headers, and response body.\n *\n * The {@link HttpLlm} module is a good example utilizing this `HttpMigration`\n * module for composing RPC function calling application. The {@link HttpLlm}\n * module composes LLM (Large Language Model) function calling application from\n * the OpenAPI document bypassing through the {@link IHttpLlmApplication} type.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace HttpMigration {\n /**\n * Convert HTTP migration application from OpenAPI document.\n *\n * `HttpMigration.application()` is a function converting the\n * {@link OpenApi.IDocument OpenAPI document} and its\n * {@link OpenApi.IOperation operations} to the\n * {@link IHttpMigrateApplication HTTP migration application}.\n *\n * The HTTP migration application is designed for helping the OpenAPI\n * generator libraries, which converts OpenAPI operations to an RPC (Remote\n * Procedure Call) function. To support the OpenAPI generator libraries,\n * {@link IHttpMigrateRoute} takes below normalization rules:\n *\n * - Path parameters are separated to atomic level.\n * - Query parameters are binded into one object.\n * - Header parameters are binded into one object.\n * - Allow only below HTTP methods\n *\n * - `head`\n * - `get`\n * - `post`\n * - `put`\n * - `patch`\n * - `delete`\n * - Allow only below content media types\n *\n * - `application/json`\n * - `application/x-www-form-urlencoded`\n * - `multipart/form-data`\n * - `text/plain`\n *\n * If there're some {@link OpenApi.IOperation API operations} which canont\n * adjust the above rules or there're some logically insensible, these\n * operation would be failed to migrate and registered into the\n * {@link IHttpMigrateApplication.errors}.\n *\n * @param document OpenAPI document to migrate.\n * @returns Migrated application.\n */\n const application: (document: OpenApi.IDocument | SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument) => IHttpMigrateApplication;\n /** Properties for the request to the HTTP server. */\n interface IFetchProps {\n /** Connection info to the HTTP server. */\n connection: IHttpConnection;\n /** Route information for the migration. */\n route: IHttpMigrateRoute;\n /**\n * Path parameters.\n *\n * Path parameters with sequenced array or key-value paired object.\n */\n parameters: Array<string | number | boolean | bigint | null> | Record<string, string | number | boolean | bigint | null>;\n /** Query parameters as a key-value paired object. */\n query?: object | undefined;\n /** Request body data. */\n body?: object | undefined;\n }\n /**\n * Execute the HTTP request.\n *\n * `HttpMigration.execute()` is a function executing the HTTP request to the\n * HTTP server.\n *\n * It returns the response body from the API endpoint when the status code is\n * `200` or `201`. Otherwise, it throws an {@link HttpError} when the status\n * code is not `200` or `201`.\n *\n * If you want to get more information than the response body, or get the\n * detailed response information even when the status code is `200` or `201`,\n * use the {@link HttpMigration.propagate} function instead.\n *\n * @param props Properties for the request.\n * @returns Return value (response body) from the API endpoint.\n * @throws HttpError when the API endpoint responds none 200/201 status.\n */\n const execute: (props: IFetchProps) => Promise<unknown>;\n /**\n * Propagate the HTTP request.\n *\n * `HttpMigration.propagate()` is a function propagating the request to the\n * HTTP server.\n *\n * It returns the response information from the API endpoint, including the\n * status code, headers, and response body.\n *\n * Even if the status code is not `200` or `201`, this function would return\n * the response information. By the way, if the connection to the HTTP server\n * is failed, this function would throw an {@link Error}.\n *\n * @param props Properties for the request.\n * @returns Response from the API endpoint.\n * @throws Error when the connection is failed.\n */\n const propagate: (props: IFetchProps) => Promise<IHttpResponse>;\n}\n",
28
28
  "node_modules/@samchon/openapi/lib/McpLlm.d.ts": "import { ILlmSchema } from \"./structures/ILlmSchema\";\nimport { IMcpLlmApplication } from \"./structures/IMcpLlmApplication\";\nimport { IMcpTool } from \"./structures/IMcpTool\";\n/**\n * Application of LLM function calling from MCP document.\n *\n * `McpLlm` is a module for composing LLM (Large Language Model) function\n * calling application from MCP (Model Context Protocol) document.\n *\n * The reasons why `@samchon/openapi` recommends to use the function calling\n * feature instead of directly using the\n * [`mcp_servers`](https://openai.github.io/openai-agents-python/mcp/#using-mcp-servers)\n * property of LLM API are:\n *\n * - Model Specification: {@link ILlmSchema}\n * - Validation Feedback: {@link IMcpLlmFunction.validate}\n * - Selector agent for reducing context: [Agentica > Orchestration\n * Strategy](https://wrtnlabs.io/agentica/docs/concepts/function-calling/#orchestration-strategy)\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport declare namespace McpLlm {\n /**\n * Properties for the LLM function calling application composer.\n *\n * @template Model Target LLM model\n */\n interface IApplicationProps<Model extends ILlmSchema.Model> {\n /** Target LLM model. */\n model: Model;\n /**\n * List of tools.\n *\n * A list of tools defined in the MCP (Model Context Protocol) document.\n *\n * It is better to validate the tools using the\n * [`typia.assert<T>()`](https://typia.io/docs/validate/assert) function for\n * type safety.\n */\n tools: Array<IMcpTool>;\n /** Options for the LLM function calling schema conversion. */\n options?: Partial<IMcpLlmApplication.IOptions<Model>>;\n }\n /**\n * Convert MCP document to LLM function calling application.\n *\n * Converts MCP (Model Context Protocol) to LLM (Large Language Model)\n * function calling application.\n *\n * The reasons why `@samchon/openapi` recommends using the function calling\n * feature instead of directly using the\n * [`mcp_servers`](https://openai.github.io/openai-agents-python/mcp/#using-mcp-servers)\n * property of LLM API are:\n *\n * - **Model Specification**: {@link ILlmSchema}\n * - **Validation Feedback**: {@link IMcpLlmFunction.validate}\n * - **Selector agent for reducing context**: [Agentica > Orchestration\n * Strategy](https://wrtnlabs.io/agentica/docs/concepts/function-calling/#orchestration-strategy)\n *\n * @param props Properties for composition\n * @returns LLM function calling application\n */\n const application: <Model extends ILlmSchema.Model>(props: IApplicationProps<Model>) => IMcpLlmApplication<Model>;\n}\n",
@@ -4,20 +4,20 @@ import {
4
4
  AutoBeRealizeFunction,
5
5
  IAutoBeRealizeControllerProps,
6
6
  } from "@autobe/interface";
7
+ import { transformOpenApiDocument } from "@autobe/utils";
7
8
  import { NestiaMigrateApplication } from "@nestia/migrate";
8
9
  import { NestiaMigrateNestMethodProgrammer } from "@nestia/migrate/lib/programmers/NestiaMigrateNestMethodProgrammer";
9
10
  import path from "path";
10
11
  import ts from "typescript";
11
12
 
12
- import { createMigrateApplication } from "../interface/createMigrateApplication";
13
13
  import { ArrayUtil } from "../utils/ArrayUtil";
14
14
  import { FilePrinter } from "../utils/FilePrinter";
15
15
 
16
16
  export const writeRealizeControllers = async (
17
17
  props: IAutoBeRealizeControllerProps,
18
18
  ): Promise<Record<string, string>> => {
19
- const app: NestiaMigrateApplication = createMigrateApplication(
20
- props.document,
19
+ const app: NestiaMigrateApplication = new NestiaMigrateApplication(
20
+ transformOpenApiDocument(props.document),
21
21
  );
22
22
  const result: Record<string, string> = app.nest({
23
23
  simulate: false,
@@ -73,6 +73,40 @@ export const writeRealizeControllers = async (
73
73
  ),
74
74
  ],
75
75
  );
76
+ const tryCatch = ts.factory.createTryStatement(
77
+ ts.factory.createBlock(
78
+ [
79
+ ts.factory.createReturnStatement(
80
+ ts.factory.createAwaitExpression(call),
81
+ ),
82
+ ],
83
+ true,
84
+ ),
85
+ ts.factory.createCatchClause(
86
+ ts.factory.createVariableDeclaration(
87
+ ts.factory.createIdentifier("error"),
88
+ undefined,
89
+ undefined,
90
+ undefined,
91
+ ),
92
+ ts.factory.createBlock(
93
+ [
94
+ ts.factory.createExpressionStatement(
95
+ ts.factory.createCallExpression(
96
+ ts.factory.createIdentifier("console.log"),
97
+ undefined,
98
+ [ts.factory.createIdentifier("error")],
99
+ ),
100
+ ),
101
+ ts.factory.createThrowStatement(
102
+ ts.factory.createIdentifier("error"),
103
+ ),
104
+ ],
105
+ true,
106
+ ),
107
+ ),
108
+ undefined,
109
+ );
76
110
  return ts.factory.updateMethodDeclaration(
77
111
  method,
78
112
  method.modifiers,
@@ -126,7 +160,7 @@ export const writeRealizeControllers = async (
126
160
  ]
127
161
  : method.parameters,
128
162
  method.type,
129
- ts.factory.createBlock([ts.factory.createReturnStatement(call)]),
163
+ ts.factory.createBlock([tryCatch]),
130
164
  );
131
165
  },
132
166
  },
@@ -7,7 +7,7 @@ import {
7
7
  IAutoBeTypeScriptCompileResult,
8
8
  } from "@autobe/interface";
9
9
  import { AutoBeEndpointComparator, validateTestFunction } from "@autobe/utils";
10
- import { EmbedTypeScript, IEmbedTypeScriptResult } from "embed-typescript";
10
+ import { EmbedEsLint } from "embed-eslint";
11
11
  import { HashMap, Pair } from "tstl";
12
12
  import ts from "typescript";
13
13
  import { IValidation } from "typia";
@@ -17,6 +17,7 @@ import { AutoBeCompilerInterfaceTemplate } from "../raw/AutoBeCompilerInterfaceT
17
17
  import { AutoBeCompilerTestTemplate } from "../raw/AutoBeCompilerTestTemplate";
18
18
  import TestExternal from "../raw/test.json";
19
19
  import { FilePrinter } from "../utils/FilePrinter";
20
+ import { shrinkCompileResult } from "../utils/shrinkCompileResult";
20
21
  import { writeTestFunction } from "./programmers/writeTestFunction";
21
22
 
22
23
  export class AutoBeTestCompiler implements IAutoBeTestCompiler {
@@ -24,7 +25,7 @@ export class AutoBeTestCompiler implements IAutoBeTestCompiler {
24
25
  props: IAutoBeTypeScriptCompileProps,
25
26
  ): Promise<IAutoBeTypeScriptCompileResult> {
26
27
  const alias: string = props.package ?? "@ORGANIZATION/PROJECT-api";
27
- const compiler: EmbedTypeScript = new EmbedTypeScript({
28
+ const compiler: EmbedEsLint = new EmbedEsLint({
28
29
  external: TestExternal as Record<string, string>,
29
30
  compilerOptions: {
30
31
  target: ts.ScriptTarget.ESNext,
@@ -53,13 +54,11 @@ export class AutoBeTestCompiler implements IAutoBeTestCompiler {
53
54
  ),
54
55
  ],
55
56
  }),
57
+ rules: {
58
+ "no-floating-promises": "error",
59
+ },
56
60
  });
57
- const result: IEmbedTypeScriptResult = await compiler.compile(props.files);
58
- return result.type === "success"
59
- ? { type: "success" }
60
- : result.type === "failure"
61
- ? { type: "failure", diagnostics: result.diagnostics }
62
- : { type: "exception", error: result.error };
61
+ return shrinkCompileResult(compiler.compile(props.files));
63
62
  }
64
63
 
65
64
  public async validate(
@@ -1,5 +1,6 @@
1
- import { ESLint } from "eslint";
2
- import ImportOrderPlugin from "eslint-plugin-perfectionist";
1
+ import sortImport from "@trivago/prettier-plugin-sort-imports";
2
+ import import2 from "import2";
3
+ import { format } from "prettier";
3
4
  import ts from "typescript";
4
5
 
5
6
  export namespace FilePrinter {
@@ -40,14 +41,14 @@ export namespace FilePrinter {
40
41
 
41
42
  export const beautify = async (script: string): Promise<string> => {
42
43
  try {
43
- const lint = new ESLint({
44
- fix: true,
45
- plugins: {
46
- ImportOrderPlugin,
47
- },
44
+ return await format(script, {
45
+ parser: "typescript",
46
+ plugins: [sortImport, await import2("prettier-plugin-jsdoc")],
47
+ importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
48
+ importOrderSeparation: true,
49
+ importOrderSortSpecifiers: true,
50
+ importOrderParserPlugins: ["decorators-legacy", "typescript", "jsx"],
48
51
  });
49
- const results = await lint.lintText(script).then((v) => v.at(0));
50
- return results?.output ?? script;
51
52
  } catch {
52
53
  return script;
53
54
  }
@@ -0,0 +1,16 @@
1
+ import { IAutoBeTypeScriptCompileResult } from "@autobe/interface";
2
+ import { IEmbedTypeScriptResult } from "embed-typescript";
3
+
4
+ export const shrinkCompileResult = (
5
+ result: IEmbedTypeScriptResult,
6
+ ): IAutoBeTypeScriptCompileResult => {
7
+ if (result.type === "exception") return result;
8
+ else if (result.type === "success")
9
+ return {
10
+ type: "success",
11
+ };
12
+ return {
13
+ type: "failure",
14
+ diagnostics: result.diagnostics,
15
+ };
16
+ };
@@ -1,3 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { NestiaMigrateApplication } from "@nestia/migrate";
3
- export declare const createMigrateApplication: (document: AutoBeOpenApi.IDocument) => NestiaMigrateApplication;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMigrateApplication = void 0;
4
- const utils_1 = require("@autobe/utils");
5
- const migrate_1 = require("@nestia/migrate");
6
- const createMigrateApplication = (document) => {
7
- const migrate = new migrate_1.NestiaMigrateApplication((0, utils_1.transformOpenApiDocument)(document));
8
- migrate.getData().routes.forEach((r) => {
9
- // @todo -> must be optimized
10
- r.accessor[r.accessor.length - 1] = document.operations.find((o) => o.path === r.path && o.method === r.method).name;
11
- });
12
- return migrate;
13
- };
14
- exports.createMigrateApplication = createMigrateApplication;
15
- //# sourceMappingURL=createMigrateApplication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMigrateApplication.js","sourceRoot":"","sources":["../../src/interface/createMigrateApplication.ts"],"names":[],"mappings":";;;AACA,yCAAyD;AACzD,6CAA2D;AAEpD,MAAM,wBAAwB,GAAG,CACtC,QAAiC,EACP,EAAE;IAC5B,MAAM,OAAO,GAA6B,IAAI,kCAAwB,CACpE,IAAA,gCAAwB,EAAC,QAAQ,CAAC,CACnC,CAAC;IACF,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrC,6BAA6B;QAC7B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAC1D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CACjD,CAAC,IAAI,CAAC;IACV,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAbW,QAAA,wBAAwB,4BAanC"}
@@ -1,3 +0,0 @@
1
- export declare namespace MapUtil {
2
- function take<K, V>(map: Map<K, V>, key: K, value: () => V): V;
3
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapUtil = void 0;
4
- var MapUtil;
5
- (function (MapUtil) {
6
- function take(map, key, value) {
7
- if (map.has(key)) {
8
- return map.get(key);
9
- }
10
- const newValue = value();
11
- map.set(key, newValue);
12
- return newValue;
13
- }
14
- MapUtil.take = take;
15
- })(MapUtil || (exports.MapUtil = MapUtil = {}));
16
- //# sourceMappingURL=MapUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapUtil.js","sourceRoot":"","sources":["../../src/utils/MapUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,OAAO,CASvB;AATD,WAAiB,OAAO;IACtB,SAAgB,IAAI,CAAO,GAAc,EAAE,GAAM,EAAE,KAAc;QAC/D,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAM,CAAC;QAC3B,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAPe,YAAI,OAOnB,CAAA;AACH,CAAC,EATgB,OAAO,uBAAP,OAAO,QASvB"}
@@ -1,18 +0,0 @@
1
- import { AutoBeOpenApi } from "@autobe/interface";
2
- import { transformOpenApiDocument } from "@autobe/utils";
3
- import { NestiaMigrateApplication } from "@nestia/migrate";
4
-
5
- export const createMigrateApplication = (
6
- document: AutoBeOpenApi.IDocument,
7
- ): NestiaMigrateApplication => {
8
- const migrate: NestiaMigrateApplication = new NestiaMigrateApplication(
9
- transformOpenApiDocument(document),
10
- );
11
- migrate.getData().routes.forEach((r) => {
12
- // @todo -> must be optimized
13
- r.accessor[r.accessor.length - 1] = document.operations.find(
14
- (o) => o.path === r.path && o.method === r.method,
15
- )!.name;
16
- });
17
- return migrate;
18
- };
@@ -1,10 +0,0 @@
1
- export namespace MapUtil {
2
- export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
3
- if (map.has(key)) {
4
- return map.get(key) as V;
5
- }
6
- const newValue = value();
7
- map.set(key, newValue);
8
- return newValue;
9
- }
10
- }