@graf-research/adf-codegen-model-typeorm 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/exec.d.ts +2 -0
- package/dist/exec.js +1 -13
- package/dist/index.d.ts +20 -0
- package/package.json +4 -4
package/dist/exec.d.ts
ADDED
package/dist/exec.js
CHANGED
@@ -15,7 +15,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
17
17
|
const adf_core_1 = require("@graf-research/adf-core");
|
18
|
-
const axios_1 = __importDefault(require("axios"));
|
19
18
|
const _1 = require(".");
|
20
19
|
const url_regex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
21
20
|
if (!process.argv[2]) {
|
@@ -27,18 +26,7 @@ if (!process.argv[3]) {
|
|
27
26
|
exec(process.argv[2], process.argv[3]);
|
28
27
|
function exec(input_file_or_url, out_folder) {
|
29
28
|
return __awaiter(this, void 0, void 0, function* () {
|
30
|
-
|
31
|
-
if (url_regex.test(input_file_or_url)) {
|
32
|
-
console.log(`downloading file '${input_file_or_url}'...`);
|
33
|
-
const response = yield axios_1.default.get(input_file_or_url, { responseType: 'text' });
|
34
|
-
code = response.data;
|
35
|
-
console.log(`download complete.`);
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
const readFromFile = (f) => new Promise((resolve, reject) => fs_1.default.readFile(f, 'utf-8', (err, data) => err ? reject(err) : resolve(data)));
|
39
|
-
code = yield readFromFile(input_file_or_url);
|
40
|
-
}
|
41
|
-
const result = (0, adf_core_1.parse)(code);
|
29
|
+
const result = yield (0, adf_core_1.parse)(input_file_or_url);
|
42
30
|
const typeorm_model = _1.TypeORMModel.compile([...result.list_table, ...result.list_enum]);
|
43
31
|
for (const f of typeorm_model.enum.files) {
|
44
32
|
writeFiles(f, out_folder);
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Model } from "@graf-research/adf-core";
|
2
|
+
export declare namespace TypeORMModel {
|
3
|
+
type MapModelNameFilePath = {
|
4
|
+
[key: string]: string;
|
5
|
+
};
|
6
|
+
interface CodegenFileOutput {
|
7
|
+
filename: string;
|
8
|
+
content: string;
|
9
|
+
}
|
10
|
+
interface ItemOutput {
|
11
|
+
files: CodegenFileOutput[];
|
12
|
+
map: MapModelNameFilePath;
|
13
|
+
}
|
14
|
+
interface Output {
|
15
|
+
table: ItemOutput;
|
16
|
+
enum: ItemOutput;
|
17
|
+
}
|
18
|
+
function compile(list_model: Model.Item[]): Output;
|
19
|
+
function sqlTypeToJSType(type: Model.CommonSQLType.Types): string;
|
20
|
+
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graf-research/adf-codegen-model-typeorm",
|
3
|
-
"version": "0.0.
|
4
|
-
"main": "index.js",
|
3
|
+
"version": "0.0.4",
|
4
|
+
"main": "dist/index.js",
|
5
5
|
"scripts": {
|
6
6
|
"build": "rm -rf dist && tsc",
|
7
7
|
"start": "node dist",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"adf-codegen-model-typeorm": "dist/exec.js"
|
13
13
|
},
|
14
14
|
"files": [
|
15
|
-
"dist
|
15
|
+
"dist",
|
16
16
|
"package.json"
|
17
17
|
],
|
18
18
|
"keywords": [],
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"typescript": "^5.6.3"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"@graf-research/adf-core": "^0.0.
|
29
|
+
"@graf-research/adf-core": "^0.0.6",
|
30
30
|
"axios": "^1.7.7",
|
31
31
|
"lodash": "^4.17.21"
|
32
32
|
}
|