@abaplint/transpiler-cli 2.2.7 → 2.2.8

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 +2 -2
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -13205,7 +13205,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
13205
13205
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13206
13206
 
13207
13207
  "use strict";
13208
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DatabaseSetup = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst sqlite_database_schema_1 = __webpack_require__(/*! ./sqlite_database_schema */ \"./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js\");\r\nclass DatabaseSetup {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n return {\r\n schemas: {\r\n sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),\r\n hdb: [\"todo\"],\r\n pg: [\"todo\"],\r\n },\r\n insert: this.buildInsert(),\r\n };\r\n }\r\n ////////////////////\r\n buildInsert() {\r\n // note: avoid hitting maximum statement size by splitting into multiple statements\r\n const insert = [];\r\n // INSERT data\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.MessageClass) {\r\n insert.push(this.insertT100(obj));\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n insert.push(this.insertREPOSRC(obj));\r\n }\r\n }\r\n insert.push(this.insertT000());\r\n return insert;\r\n }\r\n insertREPOSRC(obj) {\r\n var _a;\r\n if (this.reg.getObject(\"TABL\", \"REPOSRC\") === undefined) {\r\n return \"\";\r\n }\r\n const name = obj.getName().toUpperCase();\r\n const raw = (_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getRaw();\r\n if (raw === undefined) {\r\n return \"\";\r\n }\r\n return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}');`;\r\n }\r\n insertT000() {\r\n const tabl = this.reg.getObject(\"TABL\", \"T000\");\r\n if (tabl === undefined) {\r\n return \"\";\r\n }\r\n const type = tabl.parseType(this.reg);\r\n if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {\r\n // todo, this should take the client number from the settings\r\n return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '');`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n insertT100(msag) {\r\n // ignore if T100 is unknown\r\n if (this.reg.getObject(\"TABL\", \"T100\") === undefined) {\r\n return \"\";\r\n }\r\n let ret = \"\";\r\n for (const m of msag.getMessages()) {\r\n ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}');`;\r\n }\r\n return ret;\r\n }\r\n escape(value) {\r\n let ret = value.replace(/\\'/g, \"''\");\r\n // statements are inside a javascript string stemplate\r\n ret = ret.replace(/\\\\/g, \"\\\\\\\\\");\r\n ret = ret.replace(/`/g, \"\\\\`\");\r\n return ret;\r\n }\r\n}\r\nexports.DatabaseSetup = DatabaseSetup;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/index.js?");
13208
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.DatabaseSetup = void 0;\r\n/* eslint-disable max-len */\r\nconst abaplint = __webpack_require__(/*! @abaplint/core */ \"./node_modules/@abaplint/core/build/src/index.js\");\r\nconst sqlite_database_schema_1 = __webpack_require__(/*! ./sqlite_database_schema */ \"./node_modules/@abaplint/transpiler/build/src/db/sqlite_database_schema.js\");\r\nclass DatabaseSetup {\r\n constructor(reg) {\r\n this.reg = reg;\r\n }\r\n run() {\r\n return {\r\n schemas: {\r\n sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),\r\n hdb: [\"todo\"],\r\n pg: [\"todo\"],\r\n },\r\n insert: this.buildInsert(),\r\n };\r\n }\r\n ////////////////////\r\n buildInsert() {\r\n // note: avoid hitting maximum statement size by splitting into multiple statements\r\n const insert = [];\r\n // INSERT data\r\n for (const obj of this.reg.getObjects()) {\r\n if (obj instanceof abaplint.Objects.MessageClass) {\r\n insert.push(this.insertT100(obj));\r\n }\r\n else if (obj instanceof abaplint.Objects.Class\r\n || obj instanceof abaplint.Objects.Interface) {\r\n insert.push(this.insertREPOSRC(obj));\r\n }\r\n }\r\n insert.push(this.insertT000());\r\n return insert;\r\n }\r\n insertREPOSRC(obj) {\r\n var _a;\r\n if (this.reg.getObject(\"TABL\", \"REPOSRC\") === undefined) {\r\n return \"\";\r\n }\r\n const name = obj.getName().toUpperCase();\r\n const raw = (_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getRaw();\r\n if (raw === undefined) {\r\n return \"\";\r\n }\r\n return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}');`;\r\n }\r\n insertT000() {\r\n const tabl = this.reg.getObject(\"TABL\", \"T000\");\r\n if (tabl === undefined) {\r\n return \"\";\r\n }\r\n const type = tabl.parseType(this.reg);\r\n if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {\r\n // todo, this should take the client number from the settings\r\n return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '');`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n insertT100(msag) {\r\n // ignore if T100 is unknown\r\n if (this.reg.getObject(\"TABL\", \"T100\") === undefined) {\r\n return \"\";\r\n }\r\n let ret = \"\";\r\n for (const m of msag.getMessages()) {\r\n ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}');`;\r\n }\r\n return ret;\r\n }\r\n escape(value) {\r\n let ret = value.replace(/\\'/g, \"''\");\r\n // statements are inside a javascript string stemplate\r\n ret = ret.replace(/\\\\/g, \"\\\\\\\\\");\r\n ret = ret.replace(/`/g, \"\\\\`\");\r\n ret = ret.replace(/\\${/g, \"\\\\${\");\r\n return ret;\r\n }\r\n}\r\nexports.DatabaseSetup = DatabaseSetup;\r\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack://@abaplint/transpiler-cli/./node_modules/@abaplint/transpiler/build/src/db/index.js?");
13209
13209
 
13210
13210
  /***/ }),
13211
13211
 
@@ -13216,7 +13216,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
13216
13216
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13217
13217
 
13218
13218
  "use strict";
13219
- 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 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().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?");
13219
+ 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 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().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?");
13220
13220
 
13221
13221
  /***/ }),
13222
13222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
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.2.7",
28
+ "@abaplint/transpiler": "^2.2.8",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",