@autobe/compiler 0.19.1 → 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.
- package/lib/AutoBeTypeScriptCompiler.js +7 -8
- package/lib/AutoBeTypeScriptCompiler.js.map +1 -1
- package/lib/raw/AutoBeCompilerRealizeTemplate.js +1 -1
- package/lib/raw/AutoBeCompilerRealizeTemplate.js.map +1 -1
- package/lib/realize/writeRealizeControllers.js +7 -1
- package/lib/realize/writeRealizeControllers.js.map +1 -1
- package/lib/test/AutoBeTestCompiler.js +7 -8
- package/lib/test/AutoBeTestCompiler.js.map +1 -1
- package/lib/utils/shrinkCompileResult.d.ts +3 -0
- package/lib/utils/shrinkCompileResult.js +17 -0
- package/lib/utils/shrinkCompileResult.js.map +1 -0
- package/package.json +9 -5
- package/src/AutoBeTypeScriptCompiler.ts +12 -13
- package/src/raw/AutoBeCompilerRealizeTemplate.ts +1 -1
- package/src/realize/writeRealizeControllers.ts +35 -1
- package/src/test/AutoBeTestCompiler.ts +7 -8
- package/src/utils/shrinkCompileResult.ts +16 -0
|
@@ -14,11 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AutoBeTypeScriptCompiler = void 0;
|
|
16
16
|
const transform_1 = __importDefault(require("@nestia/core/lib/transform"));
|
|
17
|
-
const
|
|
17
|
+
const embed_eslint_1 = require("embed-eslint");
|
|
18
18
|
const typescript_1 = __importDefault(require("typescript"));
|
|
19
19
|
const transform_2 = __importDefault(require("typia/lib/transform"));
|
|
20
20
|
const nestjs_json_1 = __importDefault(require("./raw/nestjs.json"));
|
|
21
21
|
const FilePrinter_1 = require("./utils/FilePrinter");
|
|
22
|
+
const shrinkCompileResult_1 = require("./utils/shrinkCompileResult");
|
|
22
23
|
/**
|
|
23
24
|
* Official TypeScript compiler for final code validation and quality assurance.
|
|
24
25
|
*
|
|
@@ -49,7 +50,7 @@ class AutoBeTypeScriptCompiler {
|
|
|
49
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
51
|
var _a, _b;
|
|
51
52
|
const alias = (_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT-api";
|
|
52
|
-
const compiler = new
|
|
53
|
+
const compiler = new embed_eslint_1.EmbedEsLint({
|
|
53
54
|
external: nestjs_json_1.default,
|
|
54
55
|
compilerOptions: {
|
|
55
56
|
target: typescript_1.default.ScriptTarget.ESNext,
|
|
@@ -77,13 +78,11 @@ class AutoBeTypeScriptCompiler {
|
|
|
77
78
|
}),
|
|
78
79
|
],
|
|
79
80
|
}),
|
|
81
|
+
rules: {
|
|
82
|
+
"no-floating-promises": "error",
|
|
83
|
+
},
|
|
80
84
|
});
|
|
81
|
-
|
|
82
|
-
return result.type === "success"
|
|
83
|
-
? { type: "success" }
|
|
84
|
-
: result.type === "failure"
|
|
85
|
-
? { type: "failure", diagnostics: result.diagnostics }
|
|
86
|
-
: { type: "exception", error: result.error };
|
|
85
|
+
return (0, shrinkCompileResult_1.shrinkCompileResult)(compiler.compile(Object.assign(Object.assign({}, props.files), ((_b = props.prisma) !== null && _b !== void 0 ? _b : {}))));
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
getExternal(location) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeTypeScriptCompiler.js","sourceRoot":"","sources":["../src/AutoBeTypeScriptCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2EAA6D;AAC7D
|
|
1
|
+
{"version":3,"file":"AutoBeTypeScriptCompiler.js","sourceRoot":"","sources":["../src/AutoBeTypeScriptCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2EAA6D;AAC7D,+CAA2C;AAC3C,4DAA4B;AAC5B,oEAAiD;AAEjD,oEAA+C;AAC/C,qDAAkD;AAClD,qEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;GAwB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CAAC,MAAM,mCAAI,EAAE,CAAC,EACvB,CACH,CAAC;QACJ,CAAC;KAAA;IAEY,WAAW,CAAC,QAAgB;;;YACvC,OAAO,MAAC,qBAAyC,CAAC,QAAQ,CAAC,mCAAI,SAAS,CAAC;QAC3E,CAAC;KAAA;IAEM,QAAQ,CAAC,MAAc;QAC5B,OAAO,yBAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AA5DD,4DA4DC"}
|
|
@@ -6,7 +6,7 @@ exports.AutoBeCompilerRealizeTemplate = {
|
|
|
6
6
|
".gitignore": "bin/\ndist/\nlib/\nnode_modules/\n\nprisma/migrations\nprisma/schema/migrations\nprisma/bbs.db\n\n*.DS_Store\npackage-lock.json\npnpm-lock.yaml\n.npmrc",
|
|
7
7
|
"package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:prisma && npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:env\": \"ts-node build/env.ts\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:prisma\": \"prisma generate --schema prisma/schema\",\n \"build:swagger\": \"nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && npm run build:env && npm run build:prisma\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"AGPL-3.0\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.4.0\",\n \"@nestia/e2e\": \"^7.4.0\",\n \"@nestia/sdk\": \"^7.4.0\",\n \"@nestjs/cli\": \"^11.0.7\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/bcryptjs\": \"^3.0.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/jsonwebtoken\": \"^9.0.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"fastify\": \"^5.4.0\",\n \"nestia\": \"^7.4.0\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"prisma-markdown\": \"^3.0.1\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.4.0\",\n \"@nestia/fetcher\": \"^7.4.0\",\n \"@nestjs/common\": \"^11.1.3\",\n \"@nestjs/core\": \"^11.1.3\",\n \"@nestjs/platform-express\": \"^11.1.3\",\n \"@nestjs/platform-fastify\": \"^11.1.3\",\n \"@prisma/client\": \"^6.11.1\",\n \"bcryptjs\": \"^3.0.2\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"prisma\": \"^6.11.1\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.7.1\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}\n",
|
|
8
8
|
"src/MyGlobal.ts": "import { PrismaClient } from \"@prisma/client\";\nimport crypto from \"crypto\";\nimport dotenv from \"dotenv\";\nimport dotenvExpand from \"dotenv-expand\";\nimport { Singleton } from \"tstl\";\nimport typia from \"typia\";\n\n/* eslint-disable */\nexport class MyGlobal {\n public static readonly prisma: PrismaClient = new PrismaClient();\n public static testing: boolean = false;\n public static get env(): MyGlobal.IEnvironments {\n return environments.get();\n }\n\n /**\n * Common password utilities for consistent authentication Uses native crypto\n * module for password hashing\n */\n public static readonly password = {\n // Fixed salt for password hashing (consistent across all operations)\n FIXED_SALT: \"autobe-fixed-salt-2024\",\n\n /**\n * Hash a plain password using crypto.pbkdf2 All authentication operations\n * (join, login) MUST use this method\n *\n * @param plainPassword - The plain text password to hash\n * @returns The hashed password as hex string\n */\n async hash(plainPassword: string): Promise<string> {\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(\n plainPassword,\n this.FIXED_SALT,\n 10000,\n 64,\n \"sha512\",\n (err: Error | null, derivedKey: Buffer) => {\n if (err) reject(err);\n else resolve(derivedKey.toString(\"hex\"));\n },\n );\n });\n },\n\n /**\n * Verify a plain password against a hashed password Login operations MUST\n * use this method for password verification\n *\n * @param plainPassword - The plain text password to verify\n * @param hashedPassword - The hashed password from database\n * @returns True if passwords match, false otherwise\n */\n async verify(\n plainPassword: string,\n hashedPassword: string,\n ): Promise<boolean> {\n const hash = await this.hash(plainPassword);\n return hash === hashedPassword;\n },\n };\n}\nexport namespace MyGlobal {\n export interface IEnvironments {\n API_PORT: `${number}`;\n\n /** JWT Secret Key. */\n JWT_SECRET_KEY: string;\n }\n}\nconst environments = new Singleton(() => {\n const env = dotenv.config();\n dotenvExpand.expand(env);\n return typia.assert<MyGlobal.IEnvironments>(process.env);\n});\n",
|
|
9
|
-
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n
|
|
9
|
+
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n\n // PARSE TOKEN\n try {\n if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === true\n ) {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } else {\n const token = props.request.headers.authorization;\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n }\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n",
|
|
10
10
|
"src/setup/MySetupWizard.ts": "import cp from \"child_process\";\n\nimport { MyConfiguration } from \"../MyConfiguration\";\nimport { MyGlobal } from \"../MyGlobal\";\n\nexport namespace MySetupWizard {\n export async function schema(): Promise<void> {\n if (MyGlobal.testing === false)\n throw new Error(\n \"Error on SetupWizard.schema(): unable to reset database in non-test mode.\",\n );\n const execute = (type: string) => (argv: string) =>\n cp.execSync(`npx prisma migrate ${type} --schema=prisma/schema ${argv}`, {\n stdio: \"ignore\",\n cwd: MyConfiguration.ROOT,\n });\n execute(\"reset\")(\"--force\");\n execute(\"dev\")(\"--name init\");\n }\n\n export async function seed(): Promise<void> {}\n}\n",
|
|
11
11
|
"src/util/toISOStringSafe.ts": "import { tags } from \"typia\";\n\n/**\n * Transforms a value that is either a Date or a string into an ISO 8601\n * formatted string. If it's already a string, it assumes it's already in ISO\n * format.\n */\nexport function toISOStringSafe(\n value: Date | (string & tags.Format<\"date-time\">),\n): string & tags.Format<\"date-time\"> {\n if (value instanceof Date) {\n return value.toISOString() as string & tags.Format<\"date-time\">;\n }\n return value;\n}\n",
|
|
12
12
|
"test/servant.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport { Driver, WorkerServer } from \"tgrid\";\n\nimport { MyBackend } from \"../src/MyBackend\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { IAutoBeRealizeTestConfig } from \"./autobe/compiler/IAutoBeRealizeTestConfig\";\nimport { IAutoBeRealizeTestListener } from \"./autobe/compiler/IAutoBeRealizeTestListener\";\nimport { IAutoBeRealizeTestOperation } from \"./autobe/compiler/IAutoBeRealizeTestOperation\";\nimport { IAutoBeRealizeTestResult } from \"./autobe/compiler/IAutoBeRealizeTestResult\";\nimport { IAutoBeRealizeTestService } from \"./autobe/compiler/IAutoBeRealizeTestService\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\n\nclass AutoBeRealizeTestService implements IAutoBeRealizeTestService {\n public constructor(\n private readonly listener: Driver<IAutoBeRealizeTestListener>,\n ) {}\n\n public async execute(\n config: IAutoBeRealizeTestConfig,\n ): Promise<IAutoBeRealizeTestResult> {\n const start: Date = new Date();\n const operations: IAutoBeRealizeTestOperation[] = [];\n await TestAutomation.execute({\n open: async (): Promise<MyBackend> => {\n const backend: MyBackend = new MyBackend();\n await backend.open();\n return backend;\n },\n close: (backend: MyBackend): Promise<void> => backend.close(),\n options: {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n },\n onComplete: (exec: DynamicExecutor.IExecution): void => {\n const op: IAutoBeRealizeTestOperation = {\n name: exec.name,\n location: exec.location,\n value: exec.value,\n error: exec.error,\n started_at: exec.started_at,\n completed_at: exec.completed_at,\n };\n this.listener.onOperation(op).catch(() => {});\n operations.push(op);\n },\n onReset: (): void => {\n this.listener.onReset().catch(() => {});\n },\n });\n return {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n operations,\n started_at: start.toISOString(),\n completed_at: new Date().toISOString(),\n };\n }\n}\n\nconst main = async (): Promise<void> => {\n const worker: WorkerServer<\n null,\n IAutoBeRealizeTestService,\n IAutoBeRealizeTestListener\n > = new WorkerServer();\n const listener: Driver<IAutoBeRealizeTestListener> = worker.getDriver();\n const service: AutoBeRealizeTestService = new AutoBeRealizeTestService(\n listener,\n );\n\n MyGlobal.testing = true;\n await worker.open(service);\n};\nmain().catch((error) => {\n console.log(error);\n process.exit(-1);\n});\n",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeCompilerRealizeTemplate.js","sourceRoot":"","sources":["../../src/raw/AutoBeCompilerRealizeTemplate.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAA2B;IACnE,YAAY,EAAE,oDAAoD;IAClE,YAAY,EAAE,yJAAyJ;IACvK,cAAc,EAAE,kmJAAkmJ;IAClnJ,iBAAiB,EAAE,yzEAAyzE;IAC50E,yCAAyC,EAAE,
|
|
1
|
+
{"version":3,"file":"AutoBeCompilerRealizeTemplate.js","sourceRoot":"","sources":["../../src/raw/AutoBeCompilerRealizeTemplate.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAA2B;IACnE,YAAY,EAAE,oDAAoD;IAClE,YAAY,EAAE,yJAAyJ;IACvK,cAAc,EAAE,kmJAAkmJ;IAClnJ,iBAAiB,EAAE,yzEAAyzE;IAC50E,yCAAyC,EAAE,0/BAA0/B;IACriC,4BAA4B,EAAE,iuBAAiuB;IAC/vB,6BAA6B,EAAE,ydAAyd;IACxf,iBAAiB,EAAE,uqFAAuqF;IAC1rF,eAAe,EAAE,uvZAAuvZ;IACxwZ,qDAAqD,EAAE,wlMAAwlM;IAC/oM,kDAAkD,EAAE,uoGAAuoG;IAC3rG,kDAAkD,EAAE,w6KAAw6K;IAC59K,oDAAoD,EAAE,wgKAAwgK;IAC9jK,mDAAmD,EAAE,gpKAAgpK;CACtsK,CAAC"}
|
|
@@ -57,6 +57,12 @@ const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, fun
|
|
|
57
57
|
: [
|
|
58
58
|
typescript_1.default.factory.createObjectLiteralExpression(inputArguments.map((name) => typescript_1.default.factory.createShorthandPropertyAssignment(name)), true),
|
|
59
59
|
]);
|
|
60
|
+
const tryCatch = typescript_1.default.factory.createTryStatement(typescript_1.default.factory.createBlock([
|
|
61
|
+
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createAwaitExpression(call)),
|
|
62
|
+
], true), typescript_1.default.factory.createCatchClause(typescript_1.default.factory.createVariableDeclaration(typescript_1.default.factory.createIdentifier("error"), undefined, undefined, undefined), typescript_1.default.factory.createBlock([
|
|
63
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("console.log"), undefined, [typescript_1.default.factory.createIdentifier("error")])),
|
|
64
|
+
typescript_1.default.factory.createThrowStatement(typescript_1.default.factory.createIdentifier("error")),
|
|
65
|
+
], true)), undefined);
|
|
60
66
|
return typescript_1.default.factory.updateMethodDeclaration(method, method.modifiers, method.asteriskToken, method.name, method.questionToken, method.typeParameters, auth
|
|
61
67
|
? [
|
|
62
68
|
typescript_1.default.factory.createParameterDeclaration([
|
|
@@ -78,7 +84,7 @@ const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, fun
|
|
|
78
84
|
})), undefined),
|
|
79
85
|
...method.parameters,
|
|
80
86
|
]
|
|
81
|
-
: method.parameters, method.type, typescript_1.default.factory.createBlock([
|
|
87
|
+
: method.parameters, method.type, typescript_1.default.factory.createBlock([tryCatch]));
|
|
82
88
|
},
|
|
83
89
|
},
|
|
84
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRealizeControllers.js","sourceRoot":"","sources":["../../src/realize/writeRealizeControllers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,yCAAyD;AACzD,6CAA2D;AAC3D,yHAAsH;AACtH,gDAAwB;AACxB,4DAA4B;AAE5B,kDAA+C;AAC/C,sDAAmD;AAE5C,MAAM,uBAAuB,GAAG,CACrC,KAAoC,EACH,EAAE;IACnC,MAAM,GAAG,GAA6B,IAAI,kCAAwB,CAChE,IAAA,gCAAwB,EAAC,KAAK,CAAC,QAAQ,CAA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CAAC,CAAC,CAAC;4BAClB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;yBACxB,CAAC,CACH,EACD,SAAS,CACV;wBACD,GAAG,MAAM,CAAC,UAAU;qBACrB;oBACH,CAAC,CAAC,MAAM,CAAC,UAAU,EACrB,MAAM,CAAC,IAAI,EACX,oBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CACnC,CAAC;YACJ,CAAC;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAuB,MAAM,qBAAS,CAAC,QAAQ,CAC1D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CACtC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACnC,EACD,KAAqB,EAAE,4CAAhB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAK,OAAA,CAAC,GAAG,EAAE,MAAM,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA,GAAA,CACjE,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAhKW,QAAA,uBAAuB,2BAgKlC"}
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AutoBeTestCompiler = void 0;
|
|
16
16
|
const utils_1 = require("@autobe/utils");
|
|
17
|
-
const
|
|
17
|
+
const embed_eslint_1 = require("embed-eslint");
|
|
18
18
|
const tstl_1 = require("tstl");
|
|
19
19
|
const typescript_1 = __importDefault(require("typescript"));
|
|
20
20
|
const transform_1 = __importDefault(require("typia/lib/transform"));
|
|
@@ -22,13 +22,14 @@ const AutoBeCompilerInterfaceTemplate_1 = require("../raw/AutoBeCompilerInterfac
|
|
|
22
22
|
const AutoBeCompilerTestTemplate_1 = require("../raw/AutoBeCompilerTestTemplate");
|
|
23
23
|
const test_json_1 = __importDefault(require("../raw/test.json"));
|
|
24
24
|
const FilePrinter_1 = require("../utils/FilePrinter");
|
|
25
|
+
const shrinkCompileResult_1 = require("../utils/shrinkCompileResult");
|
|
25
26
|
const writeTestFunction_1 = require("./programmers/writeTestFunction");
|
|
26
27
|
class AutoBeTestCompiler {
|
|
27
28
|
compile(props) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
30
|
var _a;
|
|
30
31
|
const alias = (_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT-api";
|
|
31
|
-
const compiler = new
|
|
32
|
+
const compiler = new embed_eslint_1.EmbedEsLint({
|
|
32
33
|
external: test_json_1.default,
|
|
33
34
|
compilerOptions: {
|
|
34
35
|
target: typescript_1.default.ScriptTarget.ESNext,
|
|
@@ -53,13 +54,11 @@ class AutoBeTestCompiler {
|
|
|
53
54
|
}),
|
|
54
55
|
],
|
|
55
56
|
}),
|
|
57
|
+
rules: {
|
|
58
|
+
"no-floating-promises": "error",
|
|
59
|
+
},
|
|
56
60
|
});
|
|
57
|
-
|
|
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 (0, shrinkCompileResult_1.shrinkCompileResult)(compiler.compile(props.files));
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
64
|
validate(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeTestCompiler.js","sourceRoot":"","sources":["../../src/test/AutoBeTestCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,yCAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"AutoBeTestCompiler.js","sourceRoot":"","sources":["../../src/test/AutoBeTestCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA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CAAC,CAAC;QAC5D,CAAC;KAAA;IAEY,QAAQ,CACnB,KAA+B;;YAE/B,MAAM,MAAM,GAAyB,EAAE,CAAC;YACxC,MAAM,SAAS,GAGX,IAAI,cAAO,CACb,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAC3B,CAAC,EAAE,EAAE,EAAE,CACL,IAAI,WAAI,CACN;gBACE,MAAM,EAAE,EAAE,CAAC,MAAM;gBACjB,IAAI,EAAE,EAAE,CAAC,IAAI;aACd,EACD,EAAE,CACH,CACJ,EACD,gCAAwB,CAAC,QAAQ,EACjC,gCAAwB,CAAC,MAAM,CAChC,CAAC;YACF,IAAA,4BAAoB,EAAC;gBACnB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS,EAAE,SAAS;gBACpB,MAAM;aACP,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7C,CAAC;KAAA;IAEY,KAAK,CAAC,KAA4B;;YAC7C,MAAM,OAAO,GAAW,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;YACjD,OAAO,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5E,CAAC;KAAA;IAEY,WAAW;;YACtB,OAAO,mBAAsC,CAAC;QAChD,CAAC;KAAA;IAEY,WAAW;;YACtB,uCACK,iEAA+B,GAC/B,uDAA0B,EAC7B;QACJ,CAAC;KAAA;CACF;AAtFD,gDAsFC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shrinkCompileResult = void 0;
|
|
4
|
+
const shrinkCompileResult = (result) => {
|
|
5
|
+
if (result.type === "exception")
|
|
6
|
+
return result;
|
|
7
|
+
else if (result.type === "success")
|
|
8
|
+
return {
|
|
9
|
+
type: "success",
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
type: "failure",
|
|
13
|
+
diagnostics: result.diagnostics,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.shrinkCompileResult = shrinkCompileResult;
|
|
17
|
+
//# sourceMappingURL=shrinkCompileResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shrinkCompileResult.js","sourceRoot":"","sources":["../../src/utils/shrinkCompileResult.ts"],"names":[],"mappings":";;;AAGO,MAAM,mBAAmB,GAAG,CACjC,MAA8B,EACE,EAAE;IAClC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC;SAC1C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAChC,OAAO;YACL,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,OAAO;QACL,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
"@nestia/migrate": "^7.4.0",
|
|
18
18
|
"@samchon/openapi": "^4.7.1",
|
|
19
19
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
21
|
+
"@typescript-eslint/parser": "^8.40.0",
|
|
22
|
+
"embed-eslint": "^2.0.1",
|
|
20
23
|
"embed-prisma": "^1.1.0",
|
|
21
|
-
"embed-typescript": "^
|
|
24
|
+
"embed-typescript": "^2.0.1",
|
|
25
|
+
"eslint": "^9.34.0",
|
|
22
26
|
"import2": "^1.0.3",
|
|
23
27
|
"prettier": "^3.5.3",
|
|
24
28
|
"prettier-plugin-jsdoc": "^1.3.2",
|
|
@@ -26,9 +30,9 @@
|
|
|
26
30
|
"tgrid": "^1.2.0",
|
|
27
31
|
"tstl": "^3.0.0",
|
|
28
32
|
"typia": "^9.7.1",
|
|
29
|
-
"@autobe/filesystem": "^0.
|
|
30
|
-
"@autobe/interface": "^0.
|
|
31
|
-
"@autobe/utils": "^0.
|
|
33
|
+
"@autobe/filesystem": "^0.20.0",
|
|
34
|
+
"@autobe/interface": "^0.20.0",
|
|
35
|
+
"@autobe/utils": "^0.20.0"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/node": "^22.15.3",
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
IAutoBeTypeScriptCompiler,
|
|
5
5
|
} from "@autobe/interface";
|
|
6
6
|
import nestiaCoreTransform from "@nestia/core/lib/transform";
|
|
7
|
-
import {
|
|
7
|
+
import { EmbedEsLint } from "embed-eslint";
|
|
8
8
|
import ts from "typescript";
|
|
9
9
|
import typiaTransform from "typia/lib/transform";
|
|
10
10
|
|
|
11
11
|
import NestJSExternal from "./raw/nestjs.json";
|
|
12
12
|
import { FilePrinter } from "./utils/FilePrinter";
|
|
13
|
+
import { shrinkCompileResult } from "./utils/shrinkCompileResult";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Official TypeScript compiler for final code validation and quality assurance.
|
|
@@ -41,7 +42,7 @@ export class AutoBeTypeScriptCompiler implements IAutoBeTypeScriptCompiler {
|
|
|
41
42
|
props: IAutoBeTypeScriptCompileProps,
|
|
42
43
|
): Promise<IAutoBeTypeScriptCompileResult> {
|
|
43
44
|
const alias: string = props.package ?? "@ORGANIZATION/PROJECT-api";
|
|
44
|
-
const compiler:
|
|
45
|
+
const compiler: EmbedEsLint = new EmbedEsLint({
|
|
45
46
|
external: NestJSExternal as Record<string, string>,
|
|
46
47
|
compilerOptions: {
|
|
47
48
|
target: ts.ScriptTarget.ESNext,
|
|
@@ -77,18 +78,16 @@ export class AutoBeTypeScriptCompiler implements IAutoBeTypeScriptCompiler {
|
|
|
77
78
|
),
|
|
78
79
|
],
|
|
79
80
|
}),
|
|
81
|
+
rules: {
|
|
82
|
+
"no-floating-promises": "error",
|
|
83
|
+
},
|
|
80
84
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return result.type === "success"
|
|
88
|
-
? { type: "success" }
|
|
89
|
-
: result.type === "failure"
|
|
90
|
-
? { type: "failure", diagnostics: result.diagnostics }
|
|
91
|
-
: { type: "exception", error: result.error };
|
|
85
|
+
return shrinkCompileResult(
|
|
86
|
+
compiler.compile({
|
|
87
|
+
...props.files,
|
|
88
|
+
...(props.prisma ?? {}),
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
public async getExternal(location: string): Promise<string | undefined> {
|
|
@@ -3,7 +3,7 @@ export const AutoBeCompilerRealizeTemplate: Record<string, string> = {
|
|
|
3
3
|
".gitignore": "bin/\ndist/\nlib/\nnode_modules/\n\nprisma/migrations\nprisma/schema/migrations\nprisma/bbs.db\n\n*.DS_Store\npackage-lock.json\npnpm-lock.yaml\n.npmrc",
|
|
4
4
|
"package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:prisma && npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:env\": \"ts-node build/env.ts\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:prisma\": \"prisma generate --schema prisma/schema\",\n \"build:swagger\": \"nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && npm run build:env && npm run build:prisma\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"AGPL-3.0\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.4.0\",\n \"@nestia/e2e\": \"^7.4.0\",\n \"@nestia/sdk\": \"^7.4.0\",\n \"@nestjs/cli\": \"^11.0.7\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/bcryptjs\": \"^3.0.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/jsonwebtoken\": \"^9.0.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"fastify\": \"^5.4.0\",\n \"nestia\": \"^7.4.0\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"prisma-markdown\": \"^3.0.1\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.4.0\",\n \"@nestia/fetcher\": \"^7.4.0\",\n \"@nestjs/common\": \"^11.1.3\",\n \"@nestjs/core\": \"^11.1.3\",\n \"@nestjs/platform-express\": \"^11.1.3\",\n \"@nestjs/platform-fastify\": \"^11.1.3\",\n \"@prisma/client\": \"^6.11.1\",\n \"bcryptjs\": \"^3.0.2\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"prisma\": \"^6.11.1\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.7.1\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}\n",
|
|
5
5
|
"src/MyGlobal.ts": "import { PrismaClient } from \"@prisma/client\";\nimport crypto from \"crypto\";\nimport dotenv from \"dotenv\";\nimport dotenvExpand from \"dotenv-expand\";\nimport { Singleton } from \"tstl\";\nimport typia from \"typia\";\n\n/* eslint-disable */\nexport class MyGlobal {\n public static readonly prisma: PrismaClient = new PrismaClient();\n public static testing: boolean = false;\n public static get env(): MyGlobal.IEnvironments {\n return environments.get();\n }\n\n /**\n * Common password utilities for consistent authentication Uses native crypto\n * module for password hashing\n */\n public static readonly password = {\n // Fixed salt for password hashing (consistent across all operations)\n FIXED_SALT: \"autobe-fixed-salt-2024\",\n\n /**\n * Hash a plain password using crypto.pbkdf2 All authentication operations\n * (join, login) MUST use this method\n *\n * @param plainPassword - The plain text password to hash\n * @returns The hashed password as hex string\n */\n async hash(plainPassword: string): Promise<string> {\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(\n plainPassword,\n this.FIXED_SALT,\n 10000,\n 64,\n \"sha512\",\n (err: Error | null, derivedKey: Buffer) => {\n if (err) reject(err);\n else resolve(derivedKey.toString(\"hex\"));\n },\n );\n });\n },\n\n /**\n * Verify a plain password against a hashed password Login operations MUST\n * use this method for password verification\n *\n * @param plainPassword - The plain text password to verify\n * @param hashedPassword - The hashed password from database\n * @returns True if passwords match, false otherwise\n */\n async verify(\n plainPassword: string,\n hashedPassword: string,\n ): Promise<boolean> {\n const hash = await this.hash(plainPassword);\n return hash === hashedPassword;\n },\n };\n}\nexport namespace MyGlobal {\n export interface IEnvironments {\n API_PORT: `${number}`;\n\n /** JWT Secret Key. */\n JWT_SECRET_KEY: string;\n }\n}\nconst environments = new Singleton(() => {\n const env = dotenv.config();\n dotenvExpand.expand(env);\n return typia.assert<MyGlobal.IEnvironments>(process.env);\n});\n",
|
|
6
|
-
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n
|
|
6
|
+
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n\n // PARSE TOKEN\n try {\n if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === true\n ) {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } else {\n const token = props.request.headers.authorization;\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n }\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n",
|
|
7
7
|
"src/setup/MySetupWizard.ts": "import cp from \"child_process\";\n\nimport { MyConfiguration } from \"../MyConfiguration\";\nimport { MyGlobal } from \"../MyGlobal\";\n\nexport namespace MySetupWizard {\n export async function schema(): Promise<void> {\n if (MyGlobal.testing === false)\n throw new Error(\n \"Error on SetupWizard.schema(): unable to reset database in non-test mode.\",\n );\n const execute = (type: string) => (argv: string) =>\n cp.execSync(`npx prisma migrate ${type} --schema=prisma/schema ${argv}`, {\n stdio: \"ignore\",\n cwd: MyConfiguration.ROOT,\n });\n execute(\"reset\")(\"--force\");\n execute(\"dev\")(\"--name init\");\n }\n\n export async function seed(): Promise<void> {}\n}\n",
|
|
8
8
|
"src/util/toISOStringSafe.ts": "import { tags } from \"typia\";\n\n/**\n * Transforms a value that is either a Date or a string into an ISO 8601\n * formatted string. If it's already a string, it assumes it's already in ISO\n * format.\n */\nexport function toISOStringSafe(\n value: Date | (string & tags.Format<\"date-time\">),\n): string & tags.Format<\"date-time\"> {\n if (value instanceof Date) {\n return value.toISOString() as string & tags.Format<\"date-time\">;\n }\n return value;\n}\n",
|
|
9
9
|
"test/servant.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport { Driver, WorkerServer } from \"tgrid\";\n\nimport { MyBackend } from \"../src/MyBackend\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { IAutoBeRealizeTestConfig } from \"./autobe/compiler/IAutoBeRealizeTestConfig\";\nimport { IAutoBeRealizeTestListener } from \"./autobe/compiler/IAutoBeRealizeTestListener\";\nimport { IAutoBeRealizeTestOperation } from \"./autobe/compiler/IAutoBeRealizeTestOperation\";\nimport { IAutoBeRealizeTestResult } from \"./autobe/compiler/IAutoBeRealizeTestResult\";\nimport { IAutoBeRealizeTestService } from \"./autobe/compiler/IAutoBeRealizeTestService\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\n\nclass AutoBeRealizeTestService implements IAutoBeRealizeTestService {\n public constructor(\n private readonly listener: Driver<IAutoBeRealizeTestListener>,\n ) {}\n\n public async execute(\n config: IAutoBeRealizeTestConfig,\n ): Promise<IAutoBeRealizeTestResult> {\n const start: Date = new Date();\n const operations: IAutoBeRealizeTestOperation[] = [];\n await TestAutomation.execute({\n open: async (): Promise<MyBackend> => {\n const backend: MyBackend = new MyBackend();\n await backend.open();\n return backend;\n },\n close: (backend: MyBackend): Promise<void> => backend.close(),\n options: {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n },\n onComplete: (exec: DynamicExecutor.IExecution): void => {\n const op: IAutoBeRealizeTestOperation = {\n name: exec.name,\n location: exec.location,\n value: exec.value,\n error: exec.error,\n started_at: exec.started_at,\n completed_at: exec.completed_at,\n };\n this.listener.onOperation(op).catch(() => {});\n operations.push(op);\n },\n onReset: (): void => {\n this.listener.onReset().catch(() => {});\n },\n });\n return {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n operations,\n started_at: start.toISOString(),\n completed_at: new Date().toISOString(),\n };\n }\n}\n\nconst main = async (): Promise<void> => {\n const worker: WorkerServer<\n null,\n IAutoBeRealizeTestService,\n IAutoBeRealizeTestListener\n > = new WorkerServer();\n const listener: Driver<IAutoBeRealizeTestListener> = worker.getDriver();\n const service: AutoBeRealizeTestService = new AutoBeRealizeTestService(\n listener,\n );\n\n MyGlobal.testing = true;\n await worker.open(service);\n};\nmain().catch((error) => {\n console.log(error);\n process.exit(-1);\n});\n",
|
|
@@ -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([
|
|
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 {
|
|
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:
|
|
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
|
-
|
|
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(
|
|
@@ -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
|
+
};
|