@autobe/compiler 0.9.1 → 0.10.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/AutoBeCompiler.d.ts +2 -1
- package/lib/AutoBeCompiler.js +2 -0
- package/lib/AutoBeCompiler.js.map +1 -1
- package/lib/AutoBeInterfaceCompiler.js +10 -127
- package/lib/AutoBeInterfaceCompiler.js.map +1 -1
- package/lib/AutoBePrismaCompiler.d.ts +2 -2
- package/lib/AutoBeTestCompiler.d.ts +8 -0
- package/lib/AutoBeTestCompiler.js +86 -0
- package/lib/AutoBeTestCompiler.js.map +1 -0
- package/lib/AutoBeTypeScriptCompiler.d.ts +2 -2
- package/lib/AutoBeTypeScriptCompiler.js +3 -3
- package/lib/AutoBeTypeScriptCompiler.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/interface/transformOpenApi.d.ts +3 -0
- package/lib/interface/transformOpenApi.js +56 -0
- package/lib/interface/transformOpenApi.js.map +1 -0
- package/lib/prisma/validatePrismaApplication.js +9 -9
- package/lib/prisma/validatePrismaApplication.js.map +1 -1
- package/lib/prisma/writePrismaApplication.js +3 -3
- package/lib/prisma/writePrismaApplication.js.map +1 -1
- package/lib/raw/AutoBeCompilerTemplate.d.ts +1 -0
- package/lib/raw/AutoBeCompilerTemplate.js +10 -0
- package/lib/raw/AutoBeCompilerTemplate.js.map +1 -0
- package/lib/raw/{external.json → nestjs.json} +67 -67
- package/lib/raw/test.json +1252 -0
- package/lib/test/programmers/AutoBeTestAccessorProgrammer.d.ts +8 -0
- package/lib/test/programmers/AutoBeTestAccessorProgrammer.js +19 -0
- package/lib/test/programmers/AutoBeTestAccessorProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestFunctionalProgrammer.d.ts +12 -0
- package/lib/test/programmers/AutoBeTestFunctionalProgrammer.js +29 -0
- package/lib/test/programmers/AutoBeTestFunctionalProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestLiteralProgrammer.d.ts +12 -0
- package/lib/test/programmers/AutoBeTestLiteralProgrammer.js +24 -0
- package/lib/test/programmers/AutoBeTestLiteralProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestOperatorProgrammer.d.ts +10 -0
- package/lib/test/programmers/AutoBeTestOperatorProgrammer.js +38 -0
- package/lib/test/programmers/AutoBeTestOperatorProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestPredicateProgrammer.d.ts +9 -0
- package/lib/test/programmers/AutoBeTestPredicateProgrammer.js +84 -0
- package/lib/test/programmers/AutoBeTestPredicateProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestRandomProgrammer.d.ts +14 -0
- package/lib/test/programmers/AutoBeTestRandomProgrammer.js +151 -0
- package/lib/test/programmers/AutoBeTestRandomProgrammer.js.map +1 -0
- package/lib/test/programmers/AutoBeTestStatementProgrammer.d.ts +11 -0
- package/lib/test/programmers/AutoBeTestStatementProgrammer.js +81 -0
- package/lib/test/programmers/AutoBeTestStatementProgrammer.js.map +1 -0
- package/lib/test/programmers/IAutoBeTestApiFunction.d.ts +5 -0
- package/lib/{raw/AutoBeCompilerConstants.js → test/programmers/IAutoBeTestApiFunction.js} +1 -1
- package/lib/test/programmers/IAutoBeTestApiFunction.js.map +1 -0
- package/lib/test/programmers/IAutoBeTestProgrammerContext.d.ts +9 -0
- package/lib/test/programmers/IAutoBeTestProgrammerContext.js +3 -0
- package/lib/test/programmers/IAutoBeTestProgrammerContext.js.map +1 -0
- package/lib/test/programmers/writeTestExpression.d.ts +4 -0
- package/lib/test/programmers/writeTestExpression.js +13 -0
- package/lib/test/programmers/writeTestExpression.js.map +1 -0
- package/lib/test/programmers/writeTestFunction.d.ts +2 -0
- package/lib/test/programmers/writeTestFunction.js +63 -0
- package/lib/test/programmers/writeTestFunction.js.map +1 -0
- package/lib/test/programmers/writeTestStatement.d.ts +4 -0
- package/lib/test/programmers/writeTestStatement.js +10 -0
- package/lib/test/programmers/writeTestStatement.js.map +1 -0
- package/lib/utils/FilePrinter.d.ts +10 -0
- package/lib/utils/FilePrinter.js +54 -0
- package/lib/utils/FilePrinter.js.map +1 -0
- package/package.json +10 -8
- package/src/AutoBeCompiler.ts +4 -0
- package/src/AutoBeInterfaceCompiler.ts +10 -135
- package/src/AutoBePrismaCompiler.ts +2 -2
- package/src/AutoBeTestCompiler.ts +95 -0
- package/src/AutoBeTypeScriptCompiler.ts +7 -7
- package/src/index.ts +3 -2
- package/src/interface/transformOpenApi.ts +54 -0
- package/src/prisma/validatePrismaApplication.ts +1 -1
- package/src/prisma/writePrismaApplication.ts +1 -1
- package/src/raw/AutoBeCompilerTemplate.ts +6 -0
- package/src/raw/{external.json → nestjs.json} +67 -67
- package/src/raw/test.json +1252 -0
- package/src/test/programmers/AutoBeTestAccessorProgrammer.ts +42 -0
- package/src/test/programmers/AutoBeTestFunctionalProgrammer.ts +87 -0
- package/src/test/programmers/AutoBeTestLiteralProgrammer.ts +65 -0
- package/src/test/programmers/AutoBeTestOperatorProgrammer.ts +84 -0
- package/src/test/programmers/AutoBeTestPredicateProgrammer.ts +127 -0
- package/src/test/programmers/AutoBeTestRandomProgrammer.ts +314 -0
- package/src/test/programmers/AutoBeTestStatementProgrammer.ts +154 -0
- package/src/test/programmers/IAutoBeTestApiFunction.ts +6 -0
- package/src/test/programmers/IAutoBeTestProgrammerContext.ts +11 -0
- package/src/test/programmers/writeTestExpression.ts +24 -0
- package/src/test/programmers/writeTestFunction.ts +100 -0
- package/src/test/programmers/writeTestStatement.ts +15 -0
- package/src/utils/FilePrinter.ts +56 -0
- package/lib/raw/AutoBeCompilerConstants.d.ts +0 -3
- package/lib/raw/AutoBeCompilerConstants.js.map +0 -1
- package/lib/utils/StringUtil.d.ts +0 -4
- package/lib/utils/StringUtil.js +0 -43
- package/lib/utils/StringUtil.js.map +0 -1
- package/src/raw/AutoBeCompilerConstants.ts +0 -3
- package/src/utils/StringUtil.ts +0 -45
package/lib/AutoBeCompiler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAutoBeCompiler, IAutoBeInterfaceCompiler, IAutoBePrismaCompiler, IAutoBeTypeScriptCompiler } from "@autobe/interface";
|
|
1
|
+
import { IAutoBeCompiler, IAutoBeInterfaceCompiler, IAutoBePrismaCompiler, IAutoBeTestCompiler, IAutoBeTypeScriptCompiler } from "@autobe/interface";
|
|
2
2
|
/**
|
|
3
3
|
* Comprehensive compilation infrastructure for the vibe coding pipeline.
|
|
4
4
|
*
|
|
@@ -25,4 +25,5 @@ export declare class AutoBeCompiler implements IAutoBeCompiler {
|
|
|
25
25
|
readonly prisma: IAutoBePrismaCompiler;
|
|
26
26
|
readonly interface: IAutoBeInterfaceCompiler;
|
|
27
27
|
readonly typescript: IAutoBeTypeScriptCompiler;
|
|
28
|
+
readonly test: IAutoBeTestCompiler;
|
|
28
29
|
}
|
package/lib/AutoBeCompiler.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AutoBeCompiler = void 0;
|
|
4
4
|
const AutoBeInterfaceCompiler_1 = require("./AutoBeInterfaceCompiler");
|
|
5
5
|
const AutoBePrismaCompiler_1 = require("./AutoBePrismaCompiler");
|
|
6
|
+
const AutoBeTestCompiler_1 = require("./AutoBeTestCompiler");
|
|
6
7
|
const AutoBeTypeScriptCompiler_1 = require("./AutoBeTypeScriptCompiler");
|
|
7
8
|
/**
|
|
8
9
|
* Comprehensive compilation infrastructure for the vibe coding pipeline.
|
|
@@ -31,6 +32,7 @@ class AutoBeCompiler {
|
|
|
31
32
|
this.prisma = new AutoBePrismaCompiler_1.AutoBePrismaCompiler();
|
|
32
33
|
this.interface = new AutoBeInterfaceCompiler_1.AutoBeInterfaceCompiler();
|
|
33
34
|
this.typescript = new AutoBeTypeScriptCompiler_1.AutoBeTypeScriptCompiler();
|
|
35
|
+
this.test = new AutoBeTestCompiler_1.AutoBeTestCompiler();
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
exports.AutoBeCompiler = AutoBeCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeCompiler.js","sourceRoot":"","sources":["../src/AutoBeCompiler.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AutoBeCompiler.js","sourceRoot":"","sources":["../src/AutoBeCompiler.ts"],"names":[],"mappings":";;;AAQA,uEAAoE;AACpE,iEAA8D;AAC9D,6DAA0D;AAC1D,yEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,cAAc;IAA3B;QACkB,WAAM,GAA0B,IAAI,2CAAoB,EAAE,CAAC;QAE3D,cAAS,GACvB,IAAI,iDAAuB,EAAE,CAAC;QAEhB,eAAU,GACxB,IAAI,mDAAwB,EAAE,CAAC;QAEjB,SAAI,GAAwB,IAAI,uCAAkB,EAAE,CAAC;IACvE,CAAC;CAAA;AAVD,wCAUC"}
|
|
@@ -8,17 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.AutoBeInterfaceCompiler = void 0;
|
|
13
|
+
const utils_1 = require("@autobe/utils");
|
|
16
14
|
const migrate_1 = require("@nestia/migrate");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const import2_1 = __importDefault(require("import2"));
|
|
20
|
-
const prettier_1 = require("prettier");
|
|
15
|
+
const transformOpenApi_1 = require("./interface/transformOpenApi");
|
|
16
|
+
const AutoBeCompilerTemplate_1 = require("./raw/AutoBeCompilerTemplate");
|
|
21
17
|
const ArrayUtil_1 = require("./utils/ArrayUtil");
|
|
18
|
+
const FilePrinter_1 = require("./utils/FilePrinter");
|
|
22
19
|
/**
|
|
23
20
|
* Custom Interface compiler that handles API specification and NestJS
|
|
24
21
|
* application generation.
|
|
@@ -45,7 +42,7 @@ const ArrayUtil_1 = require("./utils/ArrayUtil");
|
|
|
45
42
|
class AutoBeInterfaceCompiler {
|
|
46
43
|
compile(document) {
|
|
47
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const swagger =
|
|
45
|
+
const swagger = (0, transformOpenApi_1.transformOpenApiDocument)(document);
|
|
49
46
|
const migrate = new migrate_1.NestiaMigrateApplication(swagger);
|
|
50
47
|
const files = migrate.nest({
|
|
51
48
|
keyword: true,
|
|
@@ -56,140 +53,26 @@ class AutoBeInterfaceCompiler {
|
|
|
56
53
|
value: "Generated by AutoBE - https://github.com/wrtnlabs/autobe",
|
|
57
54
|
},
|
|
58
55
|
});
|
|
59
|
-
return Object.assign(Object.assign({}, Object.fromEntries(yield ArrayUtil_1.ArrayUtil.asyncMap(Object.entries(files), (_a) => __awaiter(this, [_a], void 0, function* ([key, value]) {
|
|
56
|
+
return Object.assign(Object.assign(Object.assign({}, Object.fromEntries(yield ArrayUtil_1.ArrayUtil.asyncMap(Object.entries(files), (_a) => __awaiter(this, [_a], void 0, function* ([key, value]) {
|
|
60
57
|
return [
|
|
61
58
|
key,
|
|
62
59
|
key.endsWith(".ts") && key.endsWith(".d.ts") === false
|
|
63
|
-
? yield beautify(value)
|
|
60
|
+
? yield FilePrinter_1.FilePrinter.beautify(value)
|
|
64
61
|
: value,
|
|
65
62
|
];
|
|
66
|
-
})))), { "packages/api/swagger.json": JSON.stringify(swagger, null, 2)
|
|
63
|
+
})))), { "packages/api/swagger.json": JSON.stringify(swagger, null, 2) }), AutoBeCompilerTemplate_1.AutoBeCompilerTemplate);
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
66
|
transform(document) {
|
|
70
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
return
|
|
68
|
+
return (0, transformOpenApi_1.transformOpenApiDocument)(document);
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
71
|
invert(document) {
|
|
75
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
return
|
|
73
|
+
return (0, utils_1.invertOpenApiDocument)(document);
|
|
77
74
|
});
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
exports.AutoBeInterfaceCompiler = AutoBeInterfaceCompiler;
|
|
81
|
-
function beautify(script) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
try {
|
|
84
|
-
return yield (0, prettier_1.format)(script, {
|
|
85
|
-
parser: "typescript",
|
|
86
|
-
plugins: [prettier_plugin_sort_imports_1.default, yield (0, import2_1.default)("prettier-plugin-jsdoc")],
|
|
87
|
-
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
|
|
88
|
-
importOrderSeparation: true,
|
|
89
|
-
importOrderSortSpecifiers: true,
|
|
90
|
-
importOrderParserPlugins: ["decorators-legacy", "typescript", "jsx"],
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch (_a) {
|
|
94
|
-
return script;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function transformDocument(route) {
|
|
99
|
-
var _a;
|
|
100
|
-
var _b;
|
|
101
|
-
const paths = {};
|
|
102
|
-
for (const op of route.operations) {
|
|
103
|
-
(_a = paths[_b = op.path]) !== null && _a !== void 0 ? _a : (paths[_b] = {});
|
|
104
|
-
paths[op.path][op.method] = {
|
|
105
|
-
summary: op.summary,
|
|
106
|
-
description: op.description,
|
|
107
|
-
parameters: op.parameters.map((p) => ({
|
|
108
|
-
name: p.name,
|
|
109
|
-
in: "path",
|
|
110
|
-
schema: p.schema,
|
|
111
|
-
description: p.description,
|
|
112
|
-
required: true,
|
|
113
|
-
})),
|
|
114
|
-
requestBody: op.requestBody
|
|
115
|
-
? {
|
|
116
|
-
content: {
|
|
117
|
-
"application/json": {
|
|
118
|
-
schema: {
|
|
119
|
-
$ref: `#.components/schemas/${op.requestBody.typeName}`,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
description: op.requestBody.description,
|
|
124
|
-
required: true,
|
|
125
|
-
}
|
|
126
|
-
: undefined,
|
|
127
|
-
responses: op.responseBody
|
|
128
|
-
? {
|
|
129
|
-
[op.method === "post" ? 201 : 200]: {
|
|
130
|
-
content: {
|
|
131
|
-
"application/json": {
|
|
132
|
-
schema: {
|
|
133
|
-
$ref: `#/components/schemas/${op.responseBody.typeName}`,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
description: op.responseBody.description,
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
: undefined,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return openapi_1.OpenApi.convert({
|
|
144
|
-
openapi: "3.1.0",
|
|
145
|
-
paths,
|
|
146
|
-
components: route.components,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function invertDocument(document) {
|
|
150
|
-
var _a, _b;
|
|
151
|
-
const app = openapi_1.HttpMigration.application(document);
|
|
152
|
-
return {
|
|
153
|
-
operations: app.routes
|
|
154
|
-
.filter((r) => r.query === null)
|
|
155
|
-
.map((r) => {
|
|
156
|
-
var _a, _b, _c, _d, _e, _f;
|
|
157
|
-
return ({
|
|
158
|
-
specification: empty("specification"),
|
|
159
|
-
method: r.method,
|
|
160
|
-
path: r.path,
|
|
161
|
-
summary: (_a = r.operation().summary) !== null && _a !== void 0 ? _a : empty("summary"),
|
|
162
|
-
description: (_b = r.operation().description) !== null && _b !== void 0 ? _b : empty("description"),
|
|
163
|
-
parameters: r.parameters.map((p) => {
|
|
164
|
-
var _a;
|
|
165
|
-
return ({
|
|
166
|
-
name: p.name,
|
|
167
|
-
description: (_a = p.parameter().description) !== null && _a !== void 0 ? _a : empty("description"),
|
|
168
|
-
schema: p.schema,
|
|
169
|
-
});
|
|
170
|
-
}),
|
|
171
|
-
requestBody: ((_c = r.body) === null || _c === void 0 ? void 0 : _c.type) === "application/json" &&
|
|
172
|
-
openapi_1.OpenApiTypeChecker.isReference(r.body.schema)
|
|
173
|
-
? {
|
|
174
|
-
description: (_d = r.body.description()) !== null && _d !== void 0 ? _d : empty("description"),
|
|
175
|
-
typeName: r.body.schema.$ref.split("/").pop(),
|
|
176
|
-
}
|
|
177
|
-
: null,
|
|
178
|
-
responseBody: ((_e = r.success) === null || _e === void 0 ? void 0 : _e.type) === "application/json" &&
|
|
179
|
-
openapi_1.OpenApiTypeChecker.isReference(r.success.schema)
|
|
180
|
-
? {
|
|
181
|
-
description: (_f = r.success.description()) !== null && _f !== void 0 ? _f : empty("description"),
|
|
182
|
-
typeName: r.success.schema.$ref.split("/").pop(),
|
|
183
|
-
}
|
|
184
|
-
: null,
|
|
185
|
-
});
|
|
186
|
-
}),
|
|
187
|
-
components: {
|
|
188
|
-
schemas: ((_b = (_a = document.components) === null || _a === void 0 ? void 0 : _a.schemas) !== null && _b !== void 0 ? _b : {}),
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function empty(key) {
|
|
193
|
-
return `Describe ${key} as much as possible with clear and concise words.`;
|
|
194
|
-
}
|
|
195
78
|
//# sourceMappingURL=AutoBeInterfaceCompiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeInterfaceCompiler.js","sourceRoot":"","sources":["../src/AutoBeInterfaceCompiler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AutoBeInterfaceCompiler.js","sourceRoot":"","sources":["../src/AutoBeInterfaceCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,yCAAsD;AACtD,6CAA2D;AAG3D,mEAAwE;AACxE,yEAAsE;AACtE,iDAA8C;AAC9C,qDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,uBAAuB;IACrB,OAAO,CAClB,QAAiC;;YAEjC,MAAM,OAAO,GAAsB,IAAA,2CAAwB,EAAC,QAAQ,CAAC,CAAC;YACtE,MAAM,OAAO,GAA6B,IAAI,kCAAwB,CACpE,OAAO,CACR,CAAC;YACF,MAAM,KAAK,GAA2B,OAAO,CAAC,IAAI,CAAC;gBACjD,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,GAAG,EAAE,IAAI;gBACT,MAAM,EAAE;oBACN,GAAG,EAAE,QAAQ;oBACb,KAAK,EAAE,0DAA0D;iBAClE;aACF,CAAC,CAAC;YACH,qDACK,MAAM,CAAC,WAAW,CACnB,MAAM,qBAAS,CAAC,QAAQ,CACtB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EACrB,KAAqB,EAAE,0CAAhB,CAAC,GAAG,EAAE,KAAK,CAAC;gBAAK,OAAA;oBACtB,GAAG;oBACH,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK;wBACpD,CAAC,CAAC,MAAM,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;wBACnC,CAAC,CAAC,KAAK;iBACV,CAAA;cAAA,CACF,CACF,KACD,2BAA2B,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAC1D,+CAAsB,EACzB;QACJ,CAAC;KAAA;IAEY,SAAS,CACpB,QAAiC;;YAEjC,OAAO,IAAA,2CAAwB,EAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;KAAA;IAEY,MAAM,CACjB,QAA2B;;YAE3B,OAAO,IAAA,6BAAqB,EAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;KAAA;CACF;AA7CD,0DA6CC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutoBePrisma, IAutoBePrismaCompiler, IAutoBePrismaCompilerProps,
|
|
1
|
+
import { AutoBePrisma, IAutoBePrismaCompileResult, IAutoBePrismaCompiler, IAutoBePrismaCompilerProps, IAutoBePrismaValidation } from "@autobe/interface";
|
|
2
2
|
/**
|
|
3
3
|
* Custom Prisma compiler that handles database schema validation and
|
|
4
4
|
* generation.
|
|
@@ -25,7 +25,7 @@ import { AutoBePrisma, IAutoBePrismaCompiler, IAutoBePrismaCompilerProps, IAutoB
|
|
|
25
25
|
* @author Samchon
|
|
26
26
|
*/
|
|
27
27
|
export declare class AutoBePrismaCompiler implements IAutoBePrismaCompiler {
|
|
28
|
-
compile(props: IAutoBePrismaCompilerProps): Promise<
|
|
28
|
+
compile(props: IAutoBePrismaCompilerProps): Promise<IAutoBePrismaCompileResult>;
|
|
29
29
|
validate(application: AutoBePrisma.IApplication): Promise<IAutoBePrismaValidation>;
|
|
30
30
|
write(application: AutoBePrisma.IApplication, dbms?: "postgres" | "sqlite"): Promise<Record<string, string>>;
|
|
31
31
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAutoBeTestCompiler, IAutoBeTestValidateProps, IAutoBeTestWriteProps, IAutoBeTypeScriptCompileProps, IAutoBeTypeScriptCompileResult } from "@autobe/interface";
|
|
2
|
+
import { IValidation } from "typia";
|
|
3
|
+
export declare class AutoBeTestCompiler implements IAutoBeTestCompiler {
|
|
4
|
+
compile(props: IAutoBeTypeScriptCompileProps): Promise<IAutoBeTypeScriptCompileResult>;
|
|
5
|
+
validate(props: IAutoBeTestValidateProps): Promise<IValidation.IError[] | null>;
|
|
6
|
+
write(props: IAutoBeTestWriteProps): Promise<string>;
|
|
7
|
+
getExternal(): Promise<Record<string, string>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AutoBeTestCompiler = void 0;
|
|
16
|
+
const utils_1 = require("@autobe/utils");
|
|
17
|
+
const embed_typescript_1 = require("embed-typescript");
|
|
18
|
+
const tstl_1 = require("tstl");
|
|
19
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
20
|
+
const transform_1 = __importDefault(require("typia/lib/transform"));
|
|
21
|
+
const test_json_1 = __importDefault(require("./raw/test.json"));
|
|
22
|
+
const writeTestFunction_1 = require("./test/programmers/writeTestFunction");
|
|
23
|
+
const FilePrinter_1 = require("./utils/FilePrinter");
|
|
24
|
+
class AutoBeTestCompiler {
|
|
25
|
+
compile(props) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
28
|
+
const alias = (_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT-api";
|
|
29
|
+
const compiler = new embed_typescript_1.EmbedTypeScript({
|
|
30
|
+
external: test_json_1.default,
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
target: typescript_1.default.ScriptTarget.ESNext,
|
|
33
|
+
module: typescript_1.default.ModuleKind.CommonJS,
|
|
34
|
+
downlevelIteration: true,
|
|
35
|
+
baseUrl: "./",
|
|
36
|
+
paths: {
|
|
37
|
+
[alias]: ["./src/api"],
|
|
38
|
+
[`${alias}/lib/*`]: ["./src/api/*"],
|
|
39
|
+
},
|
|
40
|
+
strict: true,
|
|
41
|
+
skipLibCheck: true,
|
|
42
|
+
esModuleInterop: true,
|
|
43
|
+
experimentalDecorators: true,
|
|
44
|
+
emitDecoratorMetadata: true,
|
|
45
|
+
},
|
|
46
|
+
transformers: (program, diagnostics) => ({
|
|
47
|
+
before: [
|
|
48
|
+
(0, transform_1.default)(program, {}, {
|
|
49
|
+
addDiagnostic: (input) => diagnostics.push(input),
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
return compiler.compile(props.files);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
validate(props) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const errors = [];
|
|
60
|
+
const endpoints = new tstl_1.HashMap(props.document.operations.map((op) => new tstl_1.Pair({
|
|
61
|
+
method: op.method,
|
|
62
|
+
path: op.path,
|
|
63
|
+
}, op)), utils_1.AutoBeEndpointComparator.hashCode, utils_1.AutoBeEndpointComparator.equals);
|
|
64
|
+
(0, utils_1.validateTestFunction)({
|
|
65
|
+
function: props.function,
|
|
66
|
+
document: props.document,
|
|
67
|
+
endpoints: endpoints,
|
|
68
|
+
errors,
|
|
69
|
+
});
|
|
70
|
+
return errors.length !== 0 ? errors : null;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
write(props) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const content = (0, writeTestFunction_1.writeTestFunction)(props);
|
|
76
|
+
return props.prettier === false ? content : FilePrinter_1.FilePrinter.beautify(content);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
getExternal() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return test_json_1.default;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.AutoBeTestCompiler = AutoBeTestCompiler;
|
|
86
|
+
//# sourceMappingURL=AutoBeTestCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoBeTestCompiler.js","sourceRoot":"","sources":["../src/AutoBeTestCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,yCAA+E;AAC/E,uDAAmD;AACnD,+BAAqC;AACrC,4DAA4B;AAE5B,oEAAiD;AAEjD,gEAA2C;AAC3C,4EAAyE;AACzE,qDAAkD;AAElD,MAAa,kBAAkB;IAChB,OAAO,CAClB,KAAoC;;;YAEpC,MAAM,KAAK,GAAW,MAAA,KAAK,CAAC,OAAO,mCAAI,2BAA2B,CAAC;YACnE,MAAM,QAAQ,GAAoB,IAAI,kCAAe,CAAC;gBACpD,QAAQ,EAAE,mBAAsC;gBAChD,eAAe,EAAE;oBACf,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;oBAC9B,MAAM,EAAE,oBAAE,CAAC,UAAU,CAAC,QAAQ;oBAC9B,kBAAkB,EAAE,IAAI;oBACxB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE;wBACL,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC;wBACtB,CAAC,GAAG,KAAK,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC;qBACpC;oBACD,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,IAAI;oBAClB,eAAe,EAAE,IAAI;oBACrB,sBAAsB,EAAE,IAAI;oBAC5B,qBAAqB,EAAE,IAAI;iBAC5B;gBACD,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;oBACvC,MAAM,EAAE;wBACN,IAAA,mBAAc,EACZ,OAAO,EACP,EAAE,EACF;4BACE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;yBAClD,CACF;qBACF;iBACF,CAAC;aACH,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,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;CACF;AA3ED,gDA2EC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAutoBeTypeScriptCompileProps, IAutoBeTypeScriptCompileResult, IAutoBeTypeScriptCompiler } from "@autobe/interface";
|
|
2
2
|
/**
|
|
3
3
|
* Official TypeScript compiler for final code validation and quality assurance.
|
|
4
4
|
*
|
|
@@ -25,6 +25,6 @@ import { IAutoBeTypeScriptCompiler, IAutoBeTypeScriptCompilerProps, IAutoBeTypeS
|
|
|
25
25
|
* @author Samchon
|
|
26
26
|
*/
|
|
27
27
|
export declare class AutoBeTypeScriptCompiler implements IAutoBeTypeScriptCompiler {
|
|
28
|
-
compile(props:
|
|
28
|
+
compile(props: IAutoBeTypeScriptCompileProps): Promise<IAutoBeTypeScriptCompileResult>;
|
|
29
29
|
getExternal(location: string): Promise<string | undefined>;
|
|
30
30
|
}
|
|
@@ -17,7 +17,7 @@ const transform_1 = __importDefault(require("@nestia/core/lib/transform"));
|
|
|
17
17
|
const embed_typescript_1 = require("embed-typescript");
|
|
18
18
|
const typescript_1 = __importDefault(require("typescript"));
|
|
19
19
|
const transform_2 = __importDefault(require("typia/lib/transform"));
|
|
20
|
-
const
|
|
20
|
+
const nestjs_json_1 = __importDefault(require("./raw/nestjs.json"));
|
|
21
21
|
/**
|
|
22
22
|
* Official TypeScript compiler for final code validation and quality assurance.
|
|
23
23
|
*
|
|
@@ -49,7 +49,7 @@ class AutoBeTypeScriptCompiler {
|
|
|
49
49
|
var _a, _b;
|
|
50
50
|
const alias = (_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT-api";
|
|
51
51
|
const compiler = new embed_typescript_1.EmbedTypeScript({
|
|
52
|
-
external:
|
|
52
|
+
external: nestjs_json_1.default,
|
|
53
53
|
compilerOptions: {
|
|
54
54
|
target: typescript_1.default.ScriptTarget.ESNext,
|
|
55
55
|
module: typescript_1.default.ModuleKind.CommonJS,
|
|
@@ -82,7 +82,7 @@ class AutoBeTypeScriptCompiler {
|
|
|
82
82
|
getExternal(location) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
84
|
var _a;
|
|
85
|
-
return (_a =
|
|
85
|
+
return (_a = nestjs_json_1.default[location]) !== null && _a !== void 0 ? _a : undefined;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeTypeScriptCompiler.js","sourceRoot":"","sources":["../src/AutoBeTypeScriptCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2EAA6D;AAC7D,uDAAmD;AACnD,4DAA4B;AAC5B,oEAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"AutoBeTypeScriptCompiler.js","sourceRoot":"","sources":["../src/AutoBeTypeScriptCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2EAA6D;AAC7D,uDAAmD;AACnD,4DAA4B;AAC5B,oEAAiD;AAEjD,oEAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,wBAAwB;IACtB,OAAO,CAClB,KAAoC;;;YAEpC,MAAM,KAAK,GAAW,MAAA,KAAK,CAAC,OAAO,mCAAI,2BAA2B,CAAC;YACnE,MAAM,QAAQ,GAAoB,IAAI,kCAAe,CAAC;gBACpD,QAAQ,EAAE,qBAAwC;gBAClD,eAAe,EAAE;oBACf,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;oBAC9B,MAAM,EAAE,oBAAE,CAAC,UAAU,CAAC,QAAQ;oBAC9B,kBAAkB,EAAE,IAAI;oBACxB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE;wBACL,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC;wBACtB,CAAC,GAAG,KAAK,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC;qBACpC;oBACD,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,IAAI;oBAClB,eAAe,EAAE,IAAI;oBACrB,sBAAsB,EAAE,IAAI;oBAC5B,qBAAqB,EAAE,IAAI;iBAC5B;gBACD,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;oBACvC,MAAM,EAAE;wBACN,IAAA,mBAAc,EACZ,OAAO,EACP,EAAE,EACF;4BACE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;yBAClD,CACF;wBACD,IAAA,mBAAmB,EACjB,OAAO,EACP,EAAE,EACF;4BACE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;yBAClD,CACF;qBACF;iBACF,CAAC;aACH,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,iCAClB,KAAK,CAAC,KAAK,GACX,CAAC,MAAA,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAC,EACvB,CAAC;QACL,CAAC;KAAA;IAEY,WAAW,CAAC,QAAgB;;;YACvC,OAAO,MAAC,qBAAyC,CAAC,QAAQ,CAAC,mCAAI,SAAS,CAAC;QAC3E,CAAC;KAAA;CACF;AAlDD,4DAkDC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./AutoBeCompiler";
|
|
2
|
-
export * from "./AutoBeTypeScriptCompiler";
|
|
3
|
-
export * from "./AutoBeInterfaceCompiler";
|
|
4
2
|
export * from "./AutoBePrismaCompiler";
|
|
3
|
+
export * from "./AutoBeInterfaceCompiler";
|
|
4
|
+
export * from "./AutoBeTestCompiler";
|
|
5
|
+
export * from "./AutoBeTypeScriptCompiler";
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AutoBeCompiler"), exports);
|
|
18
|
-
__exportStar(require("./AutoBeTypeScriptCompiler"), exports);
|
|
19
|
-
__exportStar(require("./AutoBeInterfaceCompiler"), exports);
|
|
20
18
|
__exportStar(require("./AutoBePrismaCompiler"), exports);
|
|
19
|
+
__exportStar(require("./AutoBeInterfaceCompiler"), exports);
|
|
20
|
+
__exportStar(require("./AutoBeTestCompiler"), exports);
|
|
21
|
+
__exportStar(require("./AutoBeTypeScriptCompiler"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,yDAAuC;AACvC,4DAA0C;AAC1C,uDAAqC;AACrC,6DAA2C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformOpenApiDocument = transformOpenApiDocument;
|
|
4
|
+
const openapi_1 = require("@samchon/openapi");
|
|
5
|
+
function transformOpenApiDocument(document) {
|
|
6
|
+
var _a;
|
|
7
|
+
var _b;
|
|
8
|
+
const paths = {};
|
|
9
|
+
for (const op of document.operations) {
|
|
10
|
+
(_a = paths[_b = op.path]) !== null && _a !== void 0 ? _a : (paths[_b] = {});
|
|
11
|
+
paths[op.path][op.method] = {
|
|
12
|
+
summary: op.summary,
|
|
13
|
+
description: op.description,
|
|
14
|
+
parameters: op.parameters.map((p) => ({
|
|
15
|
+
name: p.name,
|
|
16
|
+
in: "path",
|
|
17
|
+
schema: p.schema,
|
|
18
|
+
description: p.description,
|
|
19
|
+
required: true,
|
|
20
|
+
})),
|
|
21
|
+
requestBody: op.requestBody
|
|
22
|
+
? {
|
|
23
|
+
content: {
|
|
24
|
+
"application/json": {
|
|
25
|
+
schema: {
|
|
26
|
+
$ref: `#.components/schemas/${op.requestBody.typeName}`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
description: op.requestBody.description,
|
|
31
|
+
required: true,
|
|
32
|
+
}
|
|
33
|
+
: undefined,
|
|
34
|
+
responses: op.responseBody
|
|
35
|
+
? {
|
|
36
|
+
[op.method === "post" ? 201 : 200]: {
|
|
37
|
+
content: {
|
|
38
|
+
"application/json": {
|
|
39
|
+
schema: {
|
|
40
|
+
$ref: `#/components/schemas/${op.responseBody.typeName}`,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
description: op.responseBody.description,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
: undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return openapi_1.OpenApi.convert({
|
|
51
|
+
openapi: "3.1.0",
|
|
52
|
+
paths,
|
|
53
|
+
components: document.components,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=transformOpenApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformOpenApi.js","sourceRoot":"","sources":["../../src/interface/transformOpenApi.ts"],"names":[],"mappings":";;AAGA,4DAkDC;AApDD,8CAAwD;AAExD,SAAgB,wBAAwB,CACtC,QAAiC;;;IAEjC,MAAM,KAAK,GAAkC,EAAE,CAAC;IAChD,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACrC,MAAA,KAAK,MAAC,EAAE,CAAC,IAAI,qCAAb,KAAK,OAAc,EAAE,EAAC;QACtB,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG;YAC1B,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACpC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,EAAE,EAAE,MAAM;gBACV,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YACH,WAAW,EAAE,EAAE,CAAC,WAAW;gBACzB,CAAC,CAAC;oBACE,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,wBAAwB,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE;6BACxD;yBACF;qBACF;oBACD,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW;oBACvC,QAAQ,EAAE,IAAI;iBACf;gBACH,CAAC,CAAC,SAAS;YACb,SAAS,EAAE,EAAE,CAAC,YAAY;gBACxB,CAAC,CAAC;oBACE,CAAC,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;wBAClC,OAAO,EAAE;4BACP,kBAAkB,EAAE;gCAClB,MAAM,EAAE;oCACN,IAAI,EAAE,wBAAwB,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;iCACzD;6BACF;yBACF;wBACD,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW;qBACzC;iBACF;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;IACD,OAAO,iBAAO,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,OAAO;QAChB,KAAK;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU;KACP,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validatePrismaApplication = validatePrismaApplication;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
4
5
|
const tstl_1 = require("tstl");
|
|
5
6
|
const MapUtil_1 = require("../utils/MapUtil");
|
|
6
|
-
const StringUtil_1 = require("../utils/StringUtil");
|
|
7
7
|
function validatePrismaApplication(application) {
|
|
8
8
|
const dict = new Map(application.files
|
|
9
9
|
.map((file, fi) => file.models.map((model, mi) => [
|
|
@@ -136,7 +136,7 @@ function validateDuplicatedFields(dict, model, accessor) {
|
|
|
136
136
|
path: `${accessor}.plainFields[${i}].name`,
|
|
137
137
|
table: model.name,
|
|
138
138
|
field: field.name,
|
|
139
|
-
message:
|
|
139
|
+
message: utils_1.StringUtil.trim `
|
|
140
140
|
There's a same named table in the application.
|
|
141
141
|
|
|
142
142
|
Check whether the field has been designed for denormalization
|
|
@@ -191,7 +191,7 @@ function validateDuplicatedIndexes(model, accessor) {
|
|
|
191
191
|
path: `${accessor}.uniqueIndexes[${i}].fieldNames[0]`,
|
|
192
192
|
table: model.name,
|
|
193
193
|
field: null,
|
|
194
|
-
message:
|
|
194
|
+
message: utils_1.StringUtil.trim `
|
|
195
195
|
Duplicated unique index found (${subset[0]}).
|
|
196
196
|
|
|
197
197
|
You have defined an unique index that is already included,
|
|
@@ -207,7 +207,7 @@ function validateDuplicatedIndexes(model, accessor) {
|
|
|
207
207
|
path: `${accessor}.uniqueIndexes[${i}].fieldNames`,
|
|
208
208
|
table: model.name,
|
|
209
209
|
field: null,
|
|
210
|
-
message:
|
|
210
|
+
message: utils_1.StringUtil.trim `
|
|
211
211
|
Subset unique index found (${subset.join(", ")}).
|
|
212
212
|
|
|
213
213
|
You have defined an unique index with multiple fields,
|
|
@@ -230,7 +230,7 @@ function validateDuplicatedIndexes(model, accessor) {
|
|
|
230
230
|
path: `${accessor}.plainIndexes[${i}].fieldNames`,
|
|
231
231
|
table: model.name,
|
|
232
232
|
field: null,
|
|
233
|
-
message:
|
|
233
|
+
message: utils_1.StringUtil.trim `
|
|
234
234
|
Superset plain index found (${y.fieldNames.join(", ")}).
|
|
235
235
|
|
|
236
236
|
You have defined a plain index with multiple fields,
|
|
@@ -248,7 +248,7 @@ function validateDuplicatedIndexes(model, accessor) {
|
|
|
248
248
|
path: `${accessor}.ginIndexes[].fieldName`,
|
|
249
249
|
table: model.name,
|
|
250
250
|
field: null,
|
|
251
|
-
message:
|
|
251
|
+
message: utils_1.StringUtil.trim `
|
|
252
252
|
Duplicated GIN index found.
|
|
253
253
|
|
|
254
254
|
GIN index can only be used once per field.
|
|
@@ -314,7 +314,7 @@ function validateIndexes(model, accessor) {
|
|
|
314
314
|
path: `${accessor}.ginIndexes[${i}].fieldName`,
|
|
315
315
|
table: model.name,
|
|
316
316
|
field: null,
|
|
317
|
-
message:
|
|
317
|
+
message: utils_1.StringUtil.trim `
|
|
318
318
|
GIN index can only be used on string typed field.
|
|
319
319
|
However, the target field ${gin.fieldName} does not exist
|
|
320
320
|
in the {@link plainFields}.
|
|
@@ -325,7 +325,7 @@ function validateIndexes(model, accessor) {
|
|
|
325
325
|
path: `${accessor}.ginIndexes[${i}].fieldName`,
|
|
326
326
|
table: model.name,
|
|
327
327
|
field: model.plainFields[pIndex].name,
|
|
328
|
-
message:
|
|
328
|
+
message: utils_1.StringUtil.trim `
|
|
329
329
|
GIN index can only be used on string typed field.
|
|
330
330
|
However, the target field ${gin.fieldName} is not string,
|
|
331
331
|
but ${model.plainFields[pIndex].type}.
|
|
@@ -358,7 +358,7 @@ function validateReferences(model, accessor, dict) {
|
|
|
358
358
|
path: `${accessor}.foreignFields[${i}].relation.targetModel`,
|
|
359
359
|
table: model.name,
|
|
360
360
|
field: field.name,
|
|
361
|
-
message:
|
|
361
|
+
message: utils_1.StringUtil.trim `
|
|
362
362
|
Cross-reference dependency detected between models.
|
|
363
363
|
|
|
364
364
|
- accessor of opposite side: application.files[${target.fileIndex}].models[${target.modelIndex}].foreignFields[${j}].relation.targetModel
|