@abaplint/transpiler-cli 2.7.89 → 2.7.91
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/LICENSE +21 -0
- package/build/bundle.js +141 -48
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Lars Hvam Petersen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/build/bundle.js
CHANGED
|
@@ -69631,8 +69631,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
69631
69631
|
exports.DatabaseSetup = void 0;
|
|
69632
69632
|
/* eslint-disable max-len */
|
|
69633
69633
|
const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
69634
|
-
const sqlite_database_schema_1 = __webpack_require__(/*! ./sqlite_database_schema */ "./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js");
|
|
69635
|
-
const pg_database_schema_1 = __webpack_require__(/*! ./pg_database_schema */ "./node_modules/@abaplint/transpiler/build/src/db/pg_database_schema.js");
|
|
69634
|
+
const sqlite_database_schema_1 = __webpack_require__(/*! ./schema_generation/sqlite_database_schema */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/sqlite_database_schema.js");
|
|
69635
|
+
const pg_database_schema_1 = __webpack_require__(/*! ./schema_generation/pg_database_schema */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/pg_database_schema.js");
|
|
69636
|
+
const snowflake_database_schema_1 = __webpack_require__(/*! ./schema_generation/snowflake_database_schema */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/snowflake_database_schema.js");
|
|
69636
69637
|
/////////////////////////
|
|
69637
69638
|
// NOTES
|
|
69638
69639
|
/////////////////////////
|
|
@@ -69645,14 +69646,33 @@ class DatabaseSetup {
|
|
|
69645
69646
|
run(options) {
|
|
69646
69647
|
return {
|
|
69647
69648
|
schemas: {
|
|
69648
|
-
sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg)
|
|
69649
|
+
sqlite: this.driver(new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg)),
|
|
69649
69650
|
hdb: ["todo"],
|
|
69650
|
-
pg: new pg_database_schema_1.PGDatabaseSchema(this.reg)
|
|
69651
|
+
pg: this.driver(new pg_database_schema_1.PGDatabaseSchema(this.reg)),
|
|
69652
|
+
snowflake: this.driver(new snowflake_database_schema_1.SnowflakeDatabaseSchema(this.reg)),
|
|
69651
69653
|
},
|
|
69652
69654
|
insert: this.buildInsert(options),
|
|
69653
69655
|
};
|
|
69654
69656
|
}
|
|
69655
69657
|
////////////////////
|
|
69658
|
+
driver(schemaGenerator) {
|
|
69659
|
+
const statements = [];
|
|
69660
|
+
// CREATE TABLEs
|
|
69661
|
+
for (const obj of this.reg.getObjects()) {
|
|
69662
|
+
if (obj instanceof abaplint.Objects.Table
|
|
69663
|
+
&& obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {
|
|
69664
|
+
statements.push(schemaGenerator.buildTABL(obj).trim());
|
|
69665
|
+
}
|
|
69666
|
+
}
|
|
69667
|
+
// CREATE VIEWs after TABLEs
|
|
69668
|
+
// todo: what if the view is based on another view?
|
|
69669
|
+
for (const obj of this.reg.getObjects()) {
|
|
69670
|
+
if (obj instanceof abaplint.Objects.View) {
|
|
69671
|
+
statements.push(schemaGenerator.buildVIEW(obj).trim());
|
|
69672
|
+
}
|
|
69673
|
+
}
|
|
69674
|
+
return statements;
|
|
69675
|
+
}
|
|
69656
69676
|
buildInsert(options) {
|
|
69657
69677
|
// note: avoid hitting maximum statement size by splitting into multiple statements
|
|
69658
69678
|
const insert = [];
|
|
@@ -69723,10 +69743,10 @@ exports.DatabaseSetup = DatabaseSetup;
|
|
|
69723
69743
|
|
|
69724
69744
|
/***/ }),
|
|
69725
69745
|
|
|
69726
|
-
/***/ "./node_modules/@abaplint/transpiler/build/src/db/pg_database_schema.js":
|
|
69727
|
-
|
|
69728
|
-
!*** ./node_modules/@abaplint/transpiler/build/src/db/pg_database_schema.js ***!
|
|
69729
|
-
|
|
69746
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/pg_database_schema.js":
|
|
69747
|
+
/*!************************************************************************************************!*\
|
|
69748
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/db/schema_generation/pg_database_schema.js ***!
|
|
69749
|
+
\************************************************************************************************/
|
|
69730
69750
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
69731
69751
|
|
|
69732
69752
|
"use strict";
|
|
@@ -69738,26 +69758,6 @@ class PGDatabaseSchema {
|
|
|
69738
69758
|
constructor(reg) {
|
|
69739
69759
|
this.reg = reg;
|
|
69740
69760
|
}
|
|
69741
|
-
run() {
|
|
69742
|
-
const statements = [];
|
|
69743
|
-
// CREATE TABLEs
|
|
69744
|
-
for (const obj of this.reg.getObjects()) {
|
|
69745
|
-
if (obj instanceof abaplint.Objects.Table
|
|
69746
|
-
&& obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {
|
|
69747
|
-
statements.push(this.buildTABL(obj).trim());
|
|
69748
|
-
}
|
|
69749
|
-
}
|
|
69750
|
-
// CREATE VIEWs after TABLEs
|
|
69751
|
-
// todo: what if the view is based on another view?
|
|
69752
|
-
for (const obj of this.reg.getObjects()) {
|
|
69753
|
-
if (obj instanceof abaplint.Objects.View) {
|
|
69754
|
-
statements.push(this.buildVIEW(obj).trim());
|
|
69755
|
-
}
|
|
69756
|
-
}
|
|
69757
|
-
return statements;
|
|
69758
|
-
}
|
|
69759
|
-
//////////////////
|
|
69760
|
-
// https://www.sqlite.org/lang_createview.html
|
|
69761
69761
|
buildVIEW(view) {
|
|
69762
69762
|
const fields = view.getFields();
|
|
69763
69763
|
let firstTabname = "";
|
|
@@ -69854,40 +69854,133 @@ exports.PGDatabaseSchema = PGDatabaseSchema;
|
|
|
69854
69854
|
|
|
69855
69855
|
/***/ }),
|
|
69856
69856
|
|
|
69857
|
-
/***/ "./node_modules/@abaplint/transpiler/build/src/db/
|
|
69858
|
-
|
|
69859
|
-
!*** ./node_modules/@abaplint/transpiler/build/src/db/
|
|
69860
|
-
|
|
69857
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/snowflake_database_schema.js":
|
|
69858
|
+
/*!*******************************************************************************************************!*\
|
|
69859
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/db/schema_generation/snowflake_database_schema.js ***!
|
|
69860
|
+
\*******************************************************************************************************/
|
|
69861
69861
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
69862
69862
|
|
|
69863
69863
|
"use strict";
|
|
69864
69864
|
|
|
69865
69865
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
69866
|
-
exports.
|
|
69866
|
+
exports.SnowflakeDatabaseSchema = void 0;
|
|
69867
69867
|
const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
69868
|
-
class
|
|
69868
|
+
class SnowflakeDatabaseSchema {
|
|
69869
69869
|
constructor(reg) {
|
|
69870
69870
|
this.reg = reg;
|
|
69871
69871
|
}
|
|
69872
|
-
|
|
69873
|
-
const
|
|
69874
|
-
|
|
69875
|
-
|
|
69876
|
-
|
|
69877
|
-
|
|
69878
|
-
|
|
69872
|
+
buildVIEW(view) {
|
|
69873
|
+
const fields = view.getFields();
|
|
69874
|
+
let firstTabname = "";
|
|
69875
|
+
const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => {
|
|
69876
|
+
firstTabname = "'" + f.TABNAME.toLowerCase() + "'";
|
|
69877
|
+
return firstTabname + "." + f.FIELDNAME.toLowerCase() + " AS " + f.VIEWFIELD.toLowerCase();
|
|
69878
|
+
}).join(", ");
|
|
69879
|
+
let from = "";
|
|
69880
|
+
let previous = "";
|
|
69881
|
+
for (const j of view.getJoin() || []) {
|
|
69882
|
+
if (previous === "") {
|
|
69883
|
+
from += "'" + j.LTAB.toLowerCase() + "' INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
|
|
69884
|
+
}
|
|
69885
|
+
else if (previous === j.LTAB + "," + j.RTAB) {
|
|
69886
|
+
from += " AND '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
|
|
69879
69887
|
}
|
|
69888
|
+
else {
|
|
69889
|
+
from += " INNER JOIN '" + j.RTAB.toLowerCase() + "' ON '" + j.LTAB.toLowerCase() + "'." + j.LFIELD.toLowerCase() + " = '" + j.RTAB.toLowerCase() + "'." + j.RFIELD.toLowerCase();
|
|
69890
|
+
}
|
|
69891
|
+
previous = j.LTAB + "," + j.RTAB;
|
|
69880
69892
|
}
|
|
69881
|
-
|
|
69882
|
-
|
|
69883
|
-
|
|
69884
|
-
|
|
69885
|
-
|
|
69893
|
+
from = from.trim();
|
|
69894
|
+
if (from === "") {
|
|
69895
|
+
from = firstTabname;
|
|
69896
|
+
}
|
|
69897
|
+
return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\n`;
|
|
69898
|
+
}
|
|
69899
|
+
buildTABL(tabl) {
|
|
69900
|
+
const type = tabl.parseType(this.reg);
|
|
69901
|
+
if (!(type instanceof abaplint.BasicTypes.StructureType)) {
|
|
69902
|
+
return "";
|
|
69903
|
+
}
|
|
69904
|
+
const fields = [];
|
|
69905
|
+
const fieldsRaw = [];
|
|
69906
|
+
for (const field of type.getComponents()) {
|
|
69907
|
+
if (field.type instanceof abaplint.BasicTypes.StructureType) {
|
|
69908
|
+
// is a GROUP NAME
|
|
69909
|
+
continue;
|
|
69886
69910
|
}
|
|
69911
|
+
fieldsRaw.push(field.name.toLowerCase());
|
|
69912
|
+
fields.push("\"" + field.name.toLowerCase() + "\" " + this.toType(field.type, field.name, tabl.getName()));
|
|
69887
69913
|
}
|
|
69888
|
-
|
|
69914
|
+
// assumption: all transparent tables have primary keys
|
|
69915
|
+
// add single quotes to field names to allow for keywords as field names
|
|
69916
|
+
const key = ", PRIMARY KEY(" + tabl.listKeys(this.reg)
|
|
69917
|
+
.filter(e => fieldsRaw.includes(e.toLowerCase()))
|
|
69918
|
+
.map(e => "\"" + e.toLowerCase() + "\"").join(",") + ")";
|
|
69919
|
+
return `CREATE TABLE "${tabl.getName().toLowerCase()}" (${fields.join(", ")}${key});\n`;
|
|
69920
|
+
}
|
|
69921
|
+
// https://docs.snowflake.com/en/sql-reference/collation
|
|
69922
|
+
toType(type, fieldname, errorInfo) {
|
|
69923
|
+
if (type instanceof abaplint.BasicTypes.CharacterType) {
|
|
69924
|
+
return `NCHAR(${type.getLength()}) COLLATE 'rtrim'`;
|
|
69925
|
+
}
|
|
69926
|
+
else if (type instanceof abaplint.BasicTypes.TimeType) {
|
|
69927
|
+
return `NCHAR(6)`;
|
|
69928
|
+
}
|
|
69929
|
+
else if (type instanceof abaplint.BasicTypes.DateType) {
|
|
69930
|
+
return `NCHAR(8)`;
|
|
69931
|
+
}
|
|
69932
|
+
else if (type instanceof abaplint.BasicTypes.NumericType) {
|
|
69933
|
+
// it will be fine, the runtime representation of numc is also text
|
|
69934
|
+
return `NCHAR(${type.getLength()})`;
|
|
69935
|
+
}
|
|
69936
|
+
else if (type instanceof abaplint.BasicTypes.StringType) {
|
|
69937
|
+
return `TEXT`;
|
|
69938
|
+
}
|
|
69939
|
+
else if (type instanceof abaplint.BasicTypes.XStringType) {
|
|
69940
|
+
// it will be fine, the runtime representation of xstring is also text
|
|
69941
|
+
return `TEXT`;
|
|
69942
|
+
}
|
|
69943
|
+
else if (type instanceof abaplint.BasicTypes.HexType) {
|
|
69944
|
+
return `NCHAR(${type.getLength() * 2})`;
|
|
69945
|
+
}
|
|
69946
|
+
else if (type instanceof abaplint.BasicTypes.IntegerType) {
|
|
69947
|
+
return `INT`;
|
|
69948
|
+
}
|
|
69949
|
+
else if (type instanceof abaplint.BasicTypes.FloatType
|
|
69950
|
+
|| type instanceof abaplint.BasicTypes.FloatingPointType) {
|
|
69951
|
+
return `REAL`;
|
|
69952
|
+
}
|
|
69953
|
+
else if (type instanceof abaplint.BasicTypes.PackedType) {
|
|
69954
|
+
return `DECIMAL(${type.getLength()},${type.getDecimals()})`;
|
|
69955
|
+
}
|
|
69956
|
+
else if (type instanceof abaplint.BasicTypes.VoidType) {
|
|
69957
|
+
throw `Type of ${errorInfo}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is known, enable strict syntax checking`;
|
|
69958
|
+
}
|
|
69959
|
+
else {
|
|
69960
|
+
throw "database_setup: " + errorInfo + "-" + fieldname + ", todo toType handle: " + type.constructor.name;
|
|
69961
|
+
}
|
|
69962
|
+
}
|
|
69963
|
+
}
|
|
69964
|
+
exports.SnowflakeDatabaseSchema = SnowflakeDatabaseSchema;
|
|
69965
|
+
//# sourceMappingURL=snowflake_database_schema.js.map
|
|
69966
|
+
|
|
69967
|
+
/***/ }),
|
|
69968
|
+
|
|
69969
|
+
/***/ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/sqlite_database_schema.js":
|
|
69970
|
+
/*!****************************************************************************************************!*\
|
|
69971
|
+
!*** ./node_modules/@abaplint/transpiler/build/src/db/schema_generation/sqlite_database_schema.js ***!
|
|
69972
|
+
\****************************************************************************************************/
|
|
69973
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
69974
|
+
|
|
69975
|
+
"use strict";
|
|
69976
|
+
|
|
69977
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
69978
|
+
exports.SQLiteDatabaseSchema = void 0;
|
|
69979
|
+
const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
|
|
69980
|
+
class SQLiteDatabaseSchema {
|
|
69981
|
+
constructor(reg) {
|
|
69982
|
+
this.reg = reg;
|
|
69889
69983
|
}
|
|
69890
|
-
//////////////////
|
|
69891
69984
|
// https://www.sqlite.org/lang_createview.html
|
|
69892
69985
|
buildVIEW(view) {
|
|
69893
69986
|
const fields = view.getFields();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.91",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"author": "abaplint",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@abaplint/transpiler": "^2.7.
|
|
29
|
+
"@abaplint/transpiler": "^2.7.91",
|
|
30
30
|
"@types/glob": "^7.2.0",
|
|
31
31
|
"glob": "=7.2.0",
|
|
32
32
|
"@types/progress": "^2.0.5",
|