@abaplint/transpiler 2.11.47 → 2.11.48

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.
@@ -7,8 +7,4 @@ export declare class DatabaseSetup {
7
7
  run(options?: ITranspilerOptions | undefined): DatabaseSetupResult;
8
8
  private driver;
9
9
  private buildInsert;
10
- private insertREPOSRC;
11
- private insertT000;
12
- private insertT100;
13
- private escape;
14
10
  }
@@ -5,6 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const sqlite_database_schema_1 = require("./schema_generation/sqlite_database_schema");
6
6
  const pg_database_schema_1 = require("./schema_generation/pg_database_schema");
7
7
  const snowflake_database_schema_1 = require("./schema_generation/snowflake_database_schema");
8
+ const populate_tables_1 = require("./populate_tables");
8
9
  /////////////////////////
9
10
  // NOTES
10
11
  /////////////////////////
@@ -48,66 +49,31 @@ class DatabaseSetup {
48
49
  buildInsert(options) {
49
50
  // note: avoid hitting maximum statement size by splitting into multiple statements
50
51
  const insert = [];
52
+ const populateTables = new populate_tables_1.PopulateTables(this.reg);
51
53
  // INSERT data
52
54
  for (const obj of this.reg.getObjects()) {
53
55
  if (obj instanceof abaplint.Objects.MessageClass) {
54
- insert.push(...this.insertT100(obj));
56
+ insert.push(...populateTables.insertT100(obj));
55
57
  }
56
58
  else if (obj instanceof abaplint.Objects.Class
57
59
  || obj instanceof abaplint.Objects.Interface) {
58
- if (options?.skipReposrc !== true) {
59
- insert.push(this.insertREPOSRC(obj));
60
+ if (options?.populateTables?.reposrc !== false) {
61
+ insert.push(populateTables.insertREPOSRC(obj));
62
+ }
63
+ if (options?.populateTables?.seosubco !== false) {
64
+ insert.push(...populateTables.insertSEOSUBCO(obj));
65
+ }
66
+ if (options?.populateTables?.seosubcodf !== false) {
67
+ insert.push(...populateTables.insertSEOSUBCODF(obj));
68
+ }
69
+ if (options?.populateTables?.seosubcotx !== false) {
70
+ insert.push(...populateTables.insertSEOSUBCOTX(obj));
60
71
  }
61
72
  }
62
73
  }
63
- insert.push(this.insertT000());
74
+ insert.push(populateTables.insertT000());
64
75
  return insert;
65
76
  }
66
- insertREPOSRC(obj) {
67
- if (this.reg.getObject("TABL", "REPOSRC") === undefined) {
68
- return "";
69
- }
70
- const name = obj.getName().toUpperCase();
71
- const raw = obj.getMainABAPFile()?.getRaw();
72
- if (raw === undefined) {
73
- return "";
74
- }
75
- return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name.padEnd(40, " ")}', '${this.escape(raw)}');`;
76
- }
77
- insertT000() {
78
- const tabl = this.reg.getObject("TABL", "T000");
79
- if (tabl === undefined) {
80
- return "";
81
- }
82
- const type = tabl.parseType(this.reg);
83
- if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {
84
- // todo, this should take the client number from the settings
85
- return `INSERT INTO t000 ('mandt', 'cccategory', 'ccnocliind') VALUES ('123', '', '');`;
86
- }
87
- else {
88
- return "";
89
- }
90
- }
91
- insertT100(msag) {
92
- // ignore if T100 is unknown
93
- const obj = this.reg.getObject("TABL", "T100");
94
- if (obj === undefined) {
95
- return [];
96
- }
97
- const ret = [];
98
- for (const m of msag.getMessages()) {
99
- ret.push(`INSERT INTO "t100" ("sprsl", "arbgb", "msgnr", "text") VALUES ('E', '${msag.getName().padEnd(20, " ")}', '${m.getNumber()}', '${this.escape(m.getMessage().padEnd(73, " "))}');`);
100
- }
101
- return ret;
102
- }
103
- escape(value) {
104
- let ret = value.replace(/\'/g, "''");
105
- // statements are inside a javascript string stemplate
106
- ret = ret.replace(/\\/g, "\\\\");
107
- ret = ret.replace(/`/g, "\\`");
108
- ret = ret.replace(/\${/g, "\\${");
109
- return ret;
110
- }
111
77
  }
112
78
  exports.DatabaseSetup = DatabaseSetup;
113
79
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ export declare class PopulateTables {
3
+ private readonly hasREPOSRC;
4
+ private readonly hasSEOSUBCO;
5
+ private readonly hasSEOSUBCODF;
6
+ private readonly hasSEOSUBCOTX;
7
+ private readonly hasT000;
8
+ private readonly hasT100;
9
+ constructor(reg: abaplint.IRegistry);
10
+ insertREPOSRC(obj: abaplint.Objects.Class | abaplint.Objects.Interface): string;
11
+ insertT100(msag: abaplint.Objects.MessageClass): string[];
12
+ insertSEOSUBCO(obj: abaplint.Objects.Class | abaplint.Objects.Interface): string[];
13
+ insertSEOSUBCODF(obj: abaplint.Objects.Class | abaplint.Objects.Interface): string[];
14
+ insertSEOSUBCOTX(obj: abaplint.Objects.Class | abaplint.Objects.Interface): string[];
15
+ insertT000(): string;
16
+ private escape;
17
+ }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PopulateTables = void 0;
4
+ class PopulateTables {
5
+ hasREPOSRC;
6
+ hasSEOSUBCO;
7
+ hasSEOSUBCODF;
8
+ hasSEOSUBCOTX;
9
+ hasT000;
10
+ hasT100;
11
+ constructor(reg) {
12
+ this.hasREPOSRC = reg.getObject("TABL", "REPOSRC") !== undefined;
13
+ this.hasSEOSUBCO = reg.getObject("TABL", "SEOSUBCO") !== undefined;
14
+ this.hasSEOSUBCODF = reg.getObject("TABL", "SEOSUBCODF") !== undefined;
15
+ this.hasSEOSUBCOTX = reg.getObject("TABL", "SEOSUBCOTX") !== undefined;
16
+ this.hasT000 = reg.getObject("TABL", "T000") !== undefined;
17
+ this.hasT100 = reg.getObject("TABL", "T100") !== undefined;
18
+ }
19
+ insertREPOSRC(obj) {
20
+ if (!this.hasREPOSRC) {
21
+ return "";
22
+ }
23
+ const name = obj.getName().toUpperCase();
24
+ const raw = obj.getMainABAPFile()?.getRaw();
25
+ if (raw === undefined) {
26
+ return "";
27
+ }
28
+ return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name.padEnd(40, " ")}', '${this.escape(raw)}');`;
29
+ }
30
+ insertT100(msag) {
31
+ // ignore if T100 is unknown
32
+ if (!this.hasT100) {
33
+ return [];
34
+ }
35
+ const ret = [];
36
+ for (const m of msag.getMessages()) {
37
+ ret.push(`INSERT INTO "t100" ("sprsl", "arbgb", "msgnr", "text") VALUES ('E', '${msag.getName().padEnd(20, " ")}', '${m.getNumber()}', '${this.escape(m.getMessage().padEnd(73, " "))}');`);
38
+ }
39
+ return ret;
40
+ }
41
+ insertSEOSUBCO(obj) {
42
+ const def = obj.getDefinition();
43
+ const ret = [];
44
+ if (def === undefined || !this.hasSEOSUBCO) {
45
+ return [];
46
+ }
47
+ for (const method of def.getMethodDefinitions().getAll()) {
48
+ for (const parameter of method.getParameters().getAll()) {
49
+ ret.push(`INSERT INTO "seosubco" ("clsname", "cmpname", "sconame") VALUES ('${obj.getName()}', '${method.getName()}', '${parameter.getName()}');`);
50
+ }
51
+ }
52
+ return ret;
53
+ }
54
+ insertSEOSUBCODF(obj) {
55
+ const def = obj.getDefinition();
56
+ const ret = [];
57
+ if (def === undefined || !this.hasSEOSUBCODF) {
58
+ return [];
59
+ }
60
+ for (const method of def.getMethodDefinitions().getAll()) {
61
+ let editorder = 0;
62
+ const optionalParameters = method.getParameters().getOptional();
63
+ for (const parameter of method.getParameters().getAll()) {
64
+ editorder++;
65
+ let pardecltyp = "";
66
+ if (parameter.getMeta().includes("importing" /* abaplint.IdentifierMeta.MethodImporting */)) {
67
+ pardecltyp = "0";
68
+ }
69
+ else if (parameter.getMeta().includes("changing" /* abaplint.IdentifierMeta.MethodChanging */)) {
70
+ pardecltyp = "2";
71
+ }
72
+ else if (parameter.getMeta().includes("returning" /* abaplint.IdentifierMeta.MethodReturning */)) {
73
+ pardecltyp = "3";
74
+ }
75
+ else if (parameter.getMeta().includes("exporting" /* abaplint.IdentifierMeta.MethodExporting */)) {
76
+ pardecltyp = "1";
77
+ }
78
+ const paroptionl = optionalParameters.includes(parameter.getName()) ? "X" : " ";
79
+ ret.push(`INSERT INTO "seosubcodf" ("clsname", "cmpname", "sconame", "version", "editorder", "pardecltyp", "type", "paroptionl") VALUES ('${obj.getName()}', '${method.getName()}', '${parameter.getName()}', 'A', ${editorder}, '${pardecltyp}', '${parameter.getType().getQualifiedName()}', '${paroptionl}');`);
80
+ }
81
+ }
82
+ return ret;
83
+ }
84
+ insertSEOSUBCOTX(obj) {
85
+ const def = obj.getDefinition();
86
+ const ret = [];
87
+ if (def === undefined || !this.hasSEOSUBCOTX) {
88
+ return [];
89
+ }
90
+ for (const method of def.getMethodDefinitions().getAll()) {
91
+ ret.push(`INSERT INTO "seosubcotx" ("clsname", "cmpname", "langu", "descript") VALUES ('${obj.getName()}', '${method.getName()}', 'E', 'todo');`);
92
+ }
93
+ return ret;
94
+ }
95
+ insertT000() {
96
+ if (!this.hasT000) {
97
+ return "";
98
+ }
99
+ // todo, this should take the client number from the settings
100
+ return `INSERT INTO t000 ('mandt', 'cccategory', 'ccnocliind') VALUES ('123', '', '');`;
101
+ }
102
+ escape(value) {
103
+ let ret = value.replace(/\'/g, "''");
104
+ // statements are inside a javascript string stemplate
105
+ ret = ret.replace(/\\/g, "\\\\");
106
+ ret = ret.replace(/`/g, "\\`");
107
+ ret = ret.replace(/\${/g, "\\${");
108
+ return ret;
109
+ }
110
+ }
111
+ exports.PopulateTables = PopulateTables;
112
+ //# sourceMappingURL=populate_tables.js.map
@@ -57,8 +57,17 @@ export interface ITranspilerOptions {
57
57
  extraSetup?: string;
58
58
  /** list of keywords to rename, if not supplied default will be used */
59
59
  keywords?: string[];
60
- /** dont insert into REPOSRC */
61
- skipReposrc?: boolean;
60
+ /** populate tables, all tables are populated if undefined and they exist */
61
+ populateTables?: {
62
+ /** insert into REPOSRC, skips if equals false */
63
+ reposrc?: boolean;
64
+ /** insert into SEOSUBCO, skips if equals false */
65
+ seosubco?: boolean;
66
+ /** insert into SEOSUBCODF, skips if equals false */
67
+ seosubcodf?: boolean;
68
+ /** insert into SEOSUBCOTX, skips if equals false */
69
+ seosubcotx?: boolean;
70
+ };
62
71
  /** ignore source map */
63
72
  ignoreSourceMap?: boolean;
64
73
  /** import programs */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.11.47",
3
+ "version": "2.11.48",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",