@abaplint/transpiler 1.8.38 → 2.0.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/build/src/db/database_setup_result.d.ts +8 -0
- package/build/src/db/database_setup_result.js +3 -0
- package/build/src/db/index.d.ts +10 -0
- package/build/src/db/index.js +59 -0
- package/build/src/{database_setup.d.ts → db/sqlite_database_schema.d.ts} +1 -3
- package/build/src/{database_setup.js → db/sqlite_database_schema.js} +4 -36
- package/build/src/index.js +2 -2
- package/build/src/statements/delete_database.js +1 -1
- package/build/src/statements/insert_database.js +1 -1
- package/build/src/statements/message.js +1 -1
- package/build/src/statements/modify_database.js +1 -1
- package/build/src/statements/select.js +1 -1
- package/build/src/types.d.ts +2 -1
- package/build/src/unit_test.d.ts +2 -1
- package/build/src/unit_test.js +11 -10
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { DatabaseSetupResult } from "./database_setup_result";
|
|
3
|
+
export declare class DatabaseSetup {
|
|
4
|
+
private readonly reg;
|
|
5
|
+
constructor(reg: abaplint.IRegistry);
|
|
6
|
+
run(): DatabaseSetupResult;
|
|
7
|
+
private buildInsert;
|
|
8
|
+
private t000Insert;
|
|
9
|
+
private messageClass;
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseSetup = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
5
|
+
const sqlite_database_schema_1 = require("./sqlite_database_schema");
|
|
6
|
+
class DatabaseSetup {
|
|
7
|
+
constructor(reg) {
|
|
8
|
+
this.reg = reg;
|
|
9
|
+
}
|
|
10
|
+
run() {
|
|
11
|
+
return {
|
|
12
|
+
schemas: {
|
|
13
|
+
sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),
|
|
14
|
+
hdb: "todo",
|
|
15
|
+
pg: "todo",
|
|
16
|
+
},
|
|
17
|
+
insert: this.buildInsert(),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
////////////////////
|
|
21
|
+
buildInsert() {
|
|
22
|
+
let insert = "";
|
|
23
|
+
// INSERT data
|
|
24
|
+
for (const obj of this.reg.getObjects()) {
|
|
25
|
+
if (obj instanceof abaplint.Objects.MessageClass) {
|
|
26
|
+
insert += this.messageClass(obj);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
insert += this.t000Insert();
|
|
30
|
+
return insert;
|
|
31
|
+
}
|
|
32
|
+
t000Insert() {
|
|
33
|
+
const obj = this.reg.getObject("TABL", "T000");
|
|
34
|
+
if (obj === undefined) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
const type = obj.parseType(this.reg);
|
|
38
|
+
if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length === 3) {
|
|
39
|
+
// todo, this should take the client number from the settings
|
|
40
|
+
return `INSERT INTO t000 VALUES ('123', '', '');\n`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
messageClass(msag) {
|
|
47
|
+
// ignore if T100 is unknown
|
|
48
|
+
if (this.reg.getObject("TABL", "T100") === undefined) {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
let ret = "";
|
|
52
|
+
for (const m of msag.getMessages()) {
|
|
53
|
+
ret += `INSERT INTO t100 VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${m.getMessage()}');\n`;
|
|
54
|
+
}
|
|
55
|
+
return ret;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.DatabaseSetup = DatabaseSetup;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as abaplint from "@abaplint/core";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class SQLiteDatabaseSchema {
|
|
3
3
|
private readonly reg;
|
|
4
4
|
constructor(reg: abaplint.IRegistry);
|
|
5
5
|
run(): string;
|
|
6
|
-
private t000Insert;
|
|
7
|
-
private messageClass;
|
|
8
6
|
private transparentTable;
|
|
9
7
|
private toType;
|
|
10
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SQLiteDatabaseSchema = void 0;
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
|
-
class
|
|
5
|
+
class SQLiteDatabaseSchema {
|
|
6
6
|
constructor(reg) {
|
|
7
7
|
this.reg = reg;
|
|
8
8
|
}
|
|
@@ -14,41 +14,9 @@ class DatabaseSetup {
|
|
|
14
14
|
ret += this.transparentTable(obj);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
// INSERT data
|
|
18
|
-
for (const obj of this.reg.getObjects()) {
|
|
19
|
-
if (obj instanceof abaplint.Objects.MessageClass) {
|
|
20
|
-
ret += this.messageClass(obj);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
ret += this.t000Insert();
|
|
24
17
|
return ret.trim();
|
|
25
18
|
}
|
|
26
19
|
//////////////////
|
|
27
|
-
t000Insert() {
|
|
28
|
-
const obj = this.reg.getObject("TABL", "T000");
|
|
29
|
-
if (obj === undefined) {
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
32
|
-
const type = obj.parseType(this.reg);
|
|
33
|
-
if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length === 3) {
|
|
34
|
-
// todo, this should take the client number from the settings
|
|
35
|
-
return `INSERT INTO t000 VALUES ('123', '', '');\n`;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
messageClass(msag) {
|
|
42
|
-
// ignore if T100 is unknown
|
|
43
|
-
if (this.reg.getObject("TABL", "T100") === undefined) {
|
|
44
|
-
return "";
|
|
45
|
-
}
|
|
46
|
-
let ret = "";
|
|
47
|
-
for (const m of msag.getMessages()) {
|
|
48
|
-
ret += `INSERT INTO t100 VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${m.getMessage()}');\n`;
|
|
49
|
-
}
|
|
50
|
-
return ret;
|
|
51
|
-
}
|
|
52
20
|
transparentTable(tabl) {
|
|
53
21
|
const type = tabl.parseType(this.reg);
|
|
54
22
|
if (!(type instanceof abaplint.BasicTypes.StructureType)) {
|
|
@@ -85,5 +53,5 @@ class DatabaseSetup {
|
|
|
85
53
|
}
|
|
86
54
|
}
|
|
87
55
|
}
|
|
88
|
-
exports.
|
|
89
|
-
//# sourceMappingURL=
|
|
56
|
+
exports.SQLiteDatabaseSchema = SQLiteDatabaseSchema;
|
|
57
|
+
//# sourceMappingURL=sqlite_database_schema.js.map
|
package/build/src/index.js
CHANGED
|
@@ -6,11 +6,11 @@ const validation_1 = require("./validation");
|
|
|
6
6
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } });
|
|
7
7
|
const unit_test_1 = require("./unit_test");
|
|
8
8
|
const keywords_1 = require("./keywords");
|
|
9
|
-
const database_setup_1 = require("./database_setup");
|
|
10
9
|
const handle_table_1 = require("./handle_table");
|
|
11
10
|
const handle_abap_1 = require("./handle_abap");
|
|
12
11
|
const handle_data_element_1 = require("./handle_data_element");
|
|
13
12
|
const handle_table_type_1 = require("./handle_table_type");
|
|
13
|
+
const db_1 = require("./db");
|
|
14
14
|
class Transpiler {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
this.options = options;
|
|
@@ -32,7 +32,7 @@ class Transpiler {
|
|
|
32
32
|
reg.parse();
|
|
33
33
|
new keywords_1.Keywords().handle(reg);
|
|
34
34
|
this.validate(reg);
|
|
35
|
-
const dbSetup = new
|
|
35
|
+
const dbSetup = new db_1.DatabaseSetup(reg).run();
|
|
36
36
|
const output = {
|
|
37
37
|
objects: [],
|
|
38
38
|
unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, (_a = this.options) === null || _a === void 0 ? void 0 : _a.skip, (_b = this.options) === null || _b === void 0 ? void 0 : _b.only),
|
|
@@ -12,7 +12,7 @@ class DeleteDatabaseTranspiler {
|
|
|
12
12
|
const ttab = traversal.traverse(tab);
|
|
13
13
|
options.push(`"table": ` + ttab.getCode());
|
|
14
14
|
}
|
|
15
|
-
return new chunk_1.Chunk(`abap.statements.deleteDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
15
|
+
return new chunk_1.Chunk(`await abap.statements.deleteDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.DeleteDatabaseTranspiler = DeleteDatabaseTranspiler;
|
|
@@ -12,7 +12,7 @@ class InsertDatabaseTranspiler {
|
|
|
12
12
|
const tvalues = traversal.traverse(values);
|
|
13
13
|
options.push(`"values": ` + tvalues.getCode());
|
|
14
14
|
}
|
|
15
|
-
return new chunk_1.Chunk(`abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
15
|
+
return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
|
|
@@ -55,7 +55,7 @@ class MessageTranspiler {
|
|
|
55
55
|
options.push("with: [" + w.join(",") + "]");
|
|
56
56
|
}
|
|
57
57
|
return new chunk_1.Chunk()
|
|
58
|
-
.append("abap.statements.message({", node, traversal)
|
|
58
|
+
.append("await abap.statements.message({", node, traversal)
|
|
59
59
|
.appendString(options.join(", "))
|
|
60
60
|
.append("});", node.getLastToken(), traversal);
|
|
61
61
|
}
|
|
@@ -12,7 +12,7 @@ class ModifyDatabaseTranspiler {
|
|
|
12
12
|
const ttab = traversal.traverse(tab);
|
|
13
13
|
options.push(`"table": ` + ttab.getCode());
|
|
14
14
|
}
|
|
15
|
-
return new chunk_1.Chunk(`abap.statements.modifyDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
15
|
+
return new chunk_1.Chunk(`await abap.statements.modifyDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.ModifyDatabaseTranspiler = ModifyDatabaseTranspiler;
|
|
@@ -22,7 +22,7 @@ class SelectTranspiler {
|
|
|
22
22
|
if (node.concatTokens().toUpperCase().startsWith("SELECT SINGLE ")) {
|
|
23
23
|
select += "LIMIT 1";
|
|
24
24
|
}
|
|
25
|
-
return new chunk_1.Chunk().append(`abap.statements.select(${target}, "${select.trim()}");`, node, traversal);
|
|
25
|
+
return new chunk_1.Chunk().append(`await abap.statements.select(${target}, "${select.trim()}");`, node, traversal);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
exports.SelectTranspiler = SelectTranspiler;
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Chunk } from "./chunk";
|
|
2
2
|
import * as abaplint from "@abaplint/core";
|
|
3
3
|
import { TestMethodList } from "./unit_test";
|
|
4
|
+
import { DatabaseSetupResult } from "./db/database_setup_result";
|
|
4
5
|
export interface IFile {
|
|
5
6
|
filename: string;
|
|
6
7
|
relative?: string;
|
|
@@ -16,7 +17,7 @@ export interface IOutput {
|
|
|
16
17
|
unitTestScript: string;
|
|
17
18
|
unitTestScriptOpen: string;
|
|
18
19
|
initializationScript: string;
|
|
19
|
-
databaseSetup:
|
|
20
|
+
databaseSetup: DatabaseSetupResult;
|
|
20
21
|
}
|
|
21
22
|
export interface IRequire {
|
|
22
23
|
name: string | undefined;
|
package/build/src/unit_test.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { DatabaseSetupResult } from "./db/database_setup_result";
|
|
2
3
|
export declare type TestMethodList = {
|
|
3
4
|
object: string;
|
|
4
5
|
class: string;
|
|
5
6
|
method: string;
|
|
6
7
|
}[];
|
|
7
8
|
export declare class UnitTest {
|
|
8
|
-
initializationScript(reg: abaplint.IRegistry, dbSetup:
|
|
9
|
+
initializationScript(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string): string;
|
|
9
10
|
unitTestScriptOpen(reg: abaplint.IRegistry, _skip?: TestMethodList, _only?: TestMethodList): string;
|
|
10
11
|
unitTestScript(reg: abaplint.IRegistry, skip?: TestMethodList, _only?: TestMethodList): string;
|
|
11
12
|
private buildImports;
|
package/build/src/unit_test.js
CHANGED
|
@@ -4,24 +4,25 @@ exports.UnitTest = void 0;
|
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
const abaplint = require("@abaplint/core");
|
|
6
6
|
class UnitTest {
|
|
7
|
-
// todo, move this somewhere else, its much more than just unit test relevant
|
|
7
|
+
// todo, move this method somewhere else, its much more than just unit test relevant
|
|
8
8
|
initializationScript(reg, dbSetup, extraSetup) {
|
|
9
9
|
let ret = `/* eslint-disable import/newline-after-import */
|
|
10
10
|
import runtime from "@abaplint/runtime";
|
|
11
11
|
global.abap = new runtime.ABAP();
|
|
12
12
|
${this.buildImports(reg)}
|
|
13
|
+
|
|
13
14
|
export async function initializeABAP() {\n`;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
15
|
+
ret += ` const sqlite = \`${dbSetup.schemas.sqlite}\`;\n`;
|
|
16
|
+
ret += ` const hdb = \`${dbSetup.schemas.hdb}\`;\n`;
|
|
17
|
+
ret += ` const pg = \`${dbSetup.schemas.pg}\`;\n`;
|
|
18
|
+
ret += ` const schemas = {sqlite, hdb, pg};\n`;
|
|
19
|
+
ret += ` const insert = \`${dbSetup.insert}\`;\n`;
|
|
20
20
|
if (extraSetup === undefined) {
|
|
21
|
-
ret += `// no
|
|
21
|
+
ret += `// no setup logic specified in config\n`;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
ret += ` await import("
|
|
24
|
+
ret += ` const {setup} = await import("${extraSetup}");\n` +
|
|
25
|
+
` await setup(global.abap, schemas, insert);\n`;
|
|
25
26
|
}
|
|
26
27
|
ret += `}`;
|
|
27
28
|
return ret;
|
|
@@ -190,7 +191,7 @@ run().then(() => {
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
list.sort();
|
|
193
|
-
return list.join("\n")
|
|
194
|
+
return list.join("\n");
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
exports.UnitTest = UnitTest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"compile": "tsc",
|
|
13
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
13
14
|
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
15
|
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
16
|
"test": "npm run compile && mocha"
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"author": "abaplint",
|
|
28
29
|
"license": "MIT",
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.
|
|
31
|
+
"@abaplint/core": "^2.87.0",
|
|
31
32
|
"source-map": "^0.7.3"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|