@abaplint/transpiler-cli 2.3.102 → 2.3.103

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.
Files changed (2) hide show
  1. package/build/bundle.js +1 -1
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -13480,7 +13480,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
13480
13480
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13481
13481
 
13482
13482
  "use strict";
13483
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SQLiteDatabaseSchema = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass SQLiteDatabaseSchema {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n const statements = [];\r\n // CREATE TABLEs\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n && obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {\r\n statements.push(this.buildTABL(obj).trim());\r\n }\r\n }\r\n // CREATE VIEWs after TABLEs\r\n // todo: what if the view is based on another view?\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.View) {\r\n statements.push(this.buildVIEW(obj).trim());\r\n }\r\n }\r\n return statements;\r\n }\r\n //////////////////\r\n // https://www.sqlite.org/lang_createview.html\r\n buildVIEW(view) {\r\n const fields = view.getFields();\r\n const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => \"'\" + f.TABNAME.toLowerCase() + \"'.\" + f.FIELDNAME.toLowerCase() + \" AS \" + f.VIEWFIELD.toLowerCase()).join(\", \");\r\n let from = \"\";\r\n let previous = \"\";\r\n for (const j of view.getJoin() || []) {\r\n if (previous === \"\") {\r\n from += \"'\" + j.LTAB.toLowerCase() + \"' INNER JOIN '\" + j.RTAB.toLowerCase() + \"' ON '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n else if (previous === j.LTAB + \",\" + j.RTAB) {\r\n from += \" AND '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n else {\r\n from += \" INNER JOIN '\" + j.RTAB.toLowerCase() + \"' ON '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n previous = j.LTAB + \",\" + j.RTAB;\r\n }\r\n from = from.trim();\r\n return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\\n`;\r\n }\r\n buildTABL(tabl) {\r\n const type = tabl.parseType(this.reg);\r\n if (!(type instanceof abaplint.BasicTypes.StructureType)) {\r\n return \"\";\r\n }\r\n const fields = [];\r\n for (const field of type.getComponents()) {\r\n if (field.type instanceof abaplint.BasicTypes.StructureType) {\r\n // is a GROUP NAME\r\n continue;\r\n }\r\n fields.push(\"'\" + field.name.toLowerCase() + \"' \" + this.toType(field.type, field.name, tabl.getName()));\r\n }\r\n // assumption: all transparent tables have primary keys\r\n // add single quotes to field names to allow for keywords as field names\r\n const key = \", PRIMARY KEY(\" + tabl.listKeys(this.reg).map(e => \"'\" + e.toLowerCase() + \"'\").join(\",\") + \")\";\r\n return `CREATE TABLE '${tabl.getName().toLowerCase()}' (${fields.join(\", \")}${key});\\n`;\r\n }\r\n toType(type, fieldname, errorInfo) {\r\n if (type instanceof abaplint.BasicTypes.CharacterType) {\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.TimeType) {\r\n return `NCHAR(6)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.DateType) {\r\n return `NCHAR(8)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.NumericType) {\r\n // it will be fine, the runtime representation of numc is also text\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.StringType) {\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.XStringType) {\r\n // it will be fine, the runtime representation of xstring is also text\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.HexType) {\r\n return `NCHAR(${type.getLength() * 2})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.IntegerType) {\r\n return `INT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.FloatType\r\n || type instanceof abaplint.BasicTypes.FloatingPointType) {\r\n return `REAL`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.PackedType) {\r\n return `DECIMAL(${type.getLength()},${type.getDecimals()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.VoidType) {\r\n throw `Type of ${errorInfo}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is known, enable strict syntax checking`;\r\n }\r\n else {\r\n throw \"database_setup: \" + errorInfo + \"-\" + fieldname + \", todo toType handle: \" + type.constructor.name;\r\n }\r\n }\r\n}\r\nexports.SQLiteDatabaseSchema = SQLiteDatabaseSchema;\r\n//# sourceMappingURL=sqlite_database_schema.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js?");
13483
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SQLiteDatabaseSchema = void 0;\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nclass SQLiteDatabaseSchema {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n const statements = [];\r\n // CREATE TABLEs\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.Table\r\n && obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {\r\n statements.push(this.buildTABL(obj).trim());\r\n }\r\n }\r\n // CREATE VIEWs after TABLEs\r\n // todo: what if the view is based on another view?\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.View) {\r\n statements.push(this.buildVIEW(obj).trim());\r\n }\r\n }\r\n return statements;\r\n }\r\n //////////////////\r\n // https://www.sqlite.org/lang_createview.html\r\n buildVIEW(view) {\r\n const fields = view.getFields();\r\n const columns = fields === null || fields === void 0 ? void 0 : fields.map((f) => \"'\" + f.TABNAME.toLowerCase() + \"'.\" + f.FIELDNAME.toLowerCase() + \" AS \" + f.VIEWFIELD.toLowerCase()).join(\", \");\r\n let from = \"\";\r\n let previous = \"\";\r\n for (const j of view.getJoin() || []) {\r\n if (previous === \"\") {\r\n from += \"'\" + j.LTAB.toLowerCase() + \"' INNER JOIN '\" + j.RTAB.toLowerCase() + \"' ON '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n else if (previous === j.LTAB + \",\" + j.RTAB) {\r\n from += \" AND '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n else {\r\n from += \" INNER JOIN '\" + j.RTAB.toLowerCase() + \"' ON '\" + j.LTAB.toLowerCase() + \"'.\" + j.LFIELD.toLowerCase() + \" = '\" + j.RTAB.toLowerCase() + \"'.\" + j.RFIELD.toLowerCase();\r\n }\r\n previous = j.LTAB + \",\" + j.RTAB;\r\n }\r\n from = from.trim();\r\n return `CREATE VIEW '${view.getName().toLowerCase()}' AS SELECT ${columns} FROM ${from};\\n`;\r\n }\r\n buildTABL(tabl) {\r\n const type = tabl.parseType(this.reg);\r\n if (!(type instanceof abaplint.BasicTypes.StructureType)) {\r\n return \"\";\r\n }\r\n const fields = [];\r\n const fieldsRaw = [];\r\n for (const field of type.getComponents()) {\r\n if (field.type instanceof abaplint.BasicTypes.StructureType) {\r\n // is a GROUP NAME\r\n continue;\r\n }\r\n fieldsRaw.push(field.name.toLowerCase());\r\n fields.push(\"'\" + field.name.toLowerCase() + \"' \" + this.toType(field.type, field.name, tabl.getName()));\r\n }\r\n // assumption: all transparent tables have primary keys\r\n // add single quotes to field names to allow for keywords as field names\r\n const key = \", PRIMARY KEY(\" + tabl.listKeys(this.reg)\r\n .filter(e => fieldsRaw.includes(e.toLowerCase()))\r\n .map(e => \"'\" + e.toLowerCase() + \"'\").join(\",\") + \")\";\r\n return `CREATE TABLE '${tabl.getName().toLowerCase()}' (${fields.join(\", \")}${key});\\n`;\r\n }\r\n toType(type, fieldname, errorInfo) {\r\n if (type instanceof abaplint.BasicTypes.CharacterType) {\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.TimeType) {\r\n return `NCHAR(6)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.DateType) {\r\n return `NCHAR(8)`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.NumericType) {\r\n // it will be fine, the runtime representation of numc is also text\r\n return `NCHAR(${type.getLength()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.StringType) {\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.XStringType) {\r\n // it will be fine, the runtime representation of xstring is also text\r\n return `TEXT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.HexType) {\r\n return `NCHAR(${type.getLength() * 2})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.IntegerType) {\r\n return `INT`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.FloatType\r\n || type instanceof abaplint.BasicTypes.FloatingPointType) {\r\n return `REAL`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.PackedType) {\r\n return `DECIMAL(${type.getLength()},${type.getDecimals()})`;\r\n }\r\n else if (type instanceof abaplint.BasicTypes.VoidType) {\r\n throw `Type of ${errorInfo}-${fieldname} is VoidType(${type.getVoided()}), make sure the type is known, enable strict syntax checking`;\r\n }\r\n else {\r\n throw \"database_setup: \" + errorInfo + \"-\" + fieldname + \", todo toType handle: \" + type.constructor.name;\r\n }\r\n }\r\n}\r\nexports.SQLiteDatabaseSchema = SQLiteDatabaseSchema;\r\n//# sourceMappingURL=sqlite_database_schema.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js?");
13484
13484
 
13485
13485
  /***/ }),
13486
13486
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.3.102",
3
+ "version": "2.3.103",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,7 +25,7 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.3.102",
28
+ "@abaplint/transpiler": "^2.3.103",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",