@abaplint/transpiler-cli 2.13.33 → 2.13.35

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 (3) hide show
  1. package/build/bundle.js +276 -112
  2. package/package.json +3 -3
  3. package/schema.json +235 -0
package/build/bundle.js CHANGED
@@ -264,6 +264,7 @@ const path = __importStar(__webpack_require__(/*! path */ "path"));
264
264
  const glob = __importStar(__webpack_require__(/*! glob */ "./node_modules/glob/glob.js"));
265
265
  const childProcess = __importStar(__webpack_require__(/*! child_process */ "child_process"));
266
266
  const os = __importStar(__webpack_require__(/*! os */ "os"));
267
+ const module_1 = __webpack_require__(/*! module */ "module");
267
268
  const progress_1 = __importDefault(__webpack_require__(/*! progress */ "./node_modules/progress/index.js"));
268
269
  const Transpiler = __importStar(__webpack_require__(/*! @abaplint/transpiler */ "./node_modules/@abaplint/transpiler/build/src/index.js"));
269
270
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
@@ -355,9 +356,28 @@ async function writeObjects(outputFiles, config, outputFolder, files) {
355
356
  }
356
357
  await file_operations_1.FileOperations.writeFiles(filesToWrite);
357
358
  }
359
+ const PLUGIN_MODULE = "@abaplint/transpiler-extras";
360
+ function loadPlugin() {
361
+ // createRequire so the plugin resolves from the project consuming the CLI, also after webpacking
362
+ const projectRequire = (0, module_1.createRequire)(path.join(process.cwd(), "package.json"));
363
+ try {
364
+ projectRequire.resolve(PLUGIN_MODULE);
365
+ }
366
+ catch {
367
+ // plugin package not installed
368
+ return undefined;
369
+ }
370
+ const plugin = projectRequire(PLUGIN_MODULE).plugin;
371
+ if (plugin === undefined) {
372
+ throw new Error(PLUGIN_MODULE + " does not export a plugin");
373
+ }
374
+ console.log("Plugin loaded: " + PLUGIN_MODULE + ", object types: " + plugin.objectTypes().join(", "));
375
+ console.log("Note this requires license for commercial use");
376
+ return plugin;
377
+ }
358
378
  async function build(config, files) {
359
379
  const libFiles = await loadLib(config);
360
- const t = new Transpiler.Transpiler(config.options);
380
+ const t = new Transpiler.Transpiler(config.options, loadPlugin());
361
381
  const reg = new abaplint.Registry();
362
382
  for (const f of files) {
363
383
  reg.addFile(new abaplint.MemoryFile(f.filename, f.contents));
@@ -3296,6 +3316,9 @@ class ExpandMacros {
3296
3316
  this.globalMacros = globalMacros;
3297
3317
  this.reg = reg;
3298
3318
  }
3319
+ listMacroNames() {
3320
+ return this.macros.listMacroNames();
3321
+ }
3299
3322
  find(statements, file, clear = true) {
3300
3323
  var _a, _b, _c;
3301
3324
  let nameToken = undefined;
@@ -3349,7 +3372,7 @@ class ExpandMacros {
3349
3372
  for (const statement of statements) {
3350
3373
  const type = statement.get();
3351
3374
  if (type instanceof _statement_1.Unknown || type instanceof _statement_1.MacroCall) {
3352
- const macroName = this.findName(statement.getTokens());
3375
+ const macroName = ExpandMacros.findName(statement.getTokens());
3353
3376
  if (macroName && this.macros.isMacro(macroName)) {
3354
3377
  const filename = this.macros.getMacroFilename(macroName);
3355
3378
  if (filename) {
@@ -3441,7 +3464,7 @@ class ExpandMacros {
3441
3464
  }
3442
3465
  return result;
3443
3466
  }
3444
- findName(tokens) {
3467
+ static findName(tokens) {
3445
3468
  let macroName = undefined;
3446
3469
  let previous = undefined;
3447
3470
  for (const i of tokens) {
@@ -3497,40 +3520,40 @@ function commonDerivedTypes() {
3497
3520
  const entity = (0, combi_1.alt)(_1.TypeName, _1.EntityAssociation);
3498
3521
  // more-specific keyword phrases (e.g. "FAILED LATE") must precede less-specific ones ("FAILED")
3499
3522
  return [
3500
- (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("FAILED LATE", entity)),
3501
- (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("MAPPED LATE", entity)),
3502
- (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("REPORTED LATE", entity)),
3503
- (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("FAILED EARLY", entity)),
3504
- (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("MAPPED EARLY", entity)),
3505
- (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("REPORTED EARLY", entity)),
3506
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FAILED", entity)),
3507
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("MAPPED", entity)),
3508
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("REPORTED", entity)),
3509
- (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("FUNCTION IMPORT", entity)),
3510
- (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("FUNCTION RESULT", entity)),
3511
- (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("ACTION RESULT", entity)),
3512
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION KEY", entity)),
3513
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION REQUEST", entity)),
3514
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION RESULT", entity)),
3515
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES KEY", entity)),
3516
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES REQUEST", entity)),
3517
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES RESULT", entity)),
3518
- (0, combi_1.ver)(version_1.Release.v780, (0, combi_1.seq)("AUTHORIZATION RESULT", entity)),
3519
- (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("AUTHORIZATION KEY", entity)),
3520
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FEATURES RESULT", entity)),
3521
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FEATURES KEY", entity)),
3522
- (0, combi_1.ver)(version_1.Release.v780, (0, combi_1.seq)("PERMISSIONS KEY", entity)),
3523
+ (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("FAILED LATE", entity), { also: combi_1.AlsoIn.OpenABAP }),
3524
+ (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("MAPPED LATE", entity), { also: combi_1.AlsoIn.OpenABAP }),
3525
+ (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("REPORTED LATE", entity), { also: combi_1.AlsoIn.OpenABAP }),
3526
+ (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("FAILED EARLY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3527
+ (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("MAPPED EARLY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3528
+ (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("REPORTED EARLY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3529
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FAILED", entity), { also: combi_1.AlsoIn.OpenABAP }),
3530
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("MAPPED", entity), { also: combi_1.AlsoIn.OpenABAP }),
3531
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("REPORTED", entity), { also: combi_1.AlsoIn.OpenABAP }),
3532
+ (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("FUNCTION IMPORT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3533
+ (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("FUNCTION RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3534
+ (0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("ACTION RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3535
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION KEY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3536
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION REQUEST", entity), { also: combi_1.AlsoIn.OpenABAP }),
3537
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE AUTHORIZATION RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3538
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES KEY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3539
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES REQUEST", entity), { also: combi_1.AlsoIn.OpenABAP }),
3540
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("INSTANCE FEATURES RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3541
+ (0, combi_1.ver)(version_1.Release.v780, (0, combi_1.seq)("AUTHORIZATION RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3542
+ (0, combi_1.ver)(version_1.Release.v781, (0, combi_1.seq)("AUTHORIZATION KEY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3543
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FEATURES RESULT", entity), { also: combi_1.AlsoIn.OpenABAP }),
3544
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("FEATURES KEY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3545
+ (0, combi_1.ver)(version_1.Release.v780, (0, combi_1.seq)("PERMISSIONS KEY", entity), { also: combi_1.AlsoIn.OpenABAP }),
3523
3546
  (0, combi_1.seq)("READ IMPORT", entity),
3524
3547
  (0, combi_1.seq)("READ RESULT", entity),
3525
- (0, combi_1.ver)(version_1.Release.v915, (0, combi_1.seq)("READ CHANGES", entity)),
3548
+ (0, combi_1.ver)(version_1.Release.v915, (0, combi_1.seq)("READ CHANGES", entity), { also: combi_1.AlsoIn.OpenABAP }),
3526
3549
  (0, combi_1.seq)("CREATE", entity),
3527
3550
  (0, combi_1.seq)("DELETE", entity),
3528
3551
  (0, combi_1.seq)("UPDATE", entity),
3529
- (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("LOCK", entity)),
3530
- (0, combi_1.ver)(version_1.Release.v775, (0, combi_1.seq)("KEY OF", entity)),
3531
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("DETERMINATION", entity)),
3532
- (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("VALIDATION", entity)),
3533
- (0, combi_1.ver)(version_1.Release.v778, (0, combi_1.seq)("CHANGE", entity)),
3552
+ (0, combi_1.ver)(version_1.Release.v777, (0, combi_1.seq)("LOCK", entity), { also: combi_1.AlsoIn.OpenABAP }),
3553
+ (0, combi_1.ver)(version_1.Release.v775, (0, combi_1.seq)("KEY OF", entity), { also: combi_1.AlsoIn.OpenABAP }),
3554
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("DETERMINATION", entity), { also: combi_1.AlsoIn.OpenABAP }),
3555
+ (0, combi_1.ver)(version_1.Release.v776, (0, combi_1.seq)("VALIDATION", entity), { also: combi_1.AlsoIn.OpenABAP }),
3556
+ (0, combi_1.ver)(version_1.Release.v778, (0, combi_1.seq)("CHANGE", entity), { also: combi_1.AlsoIn.OpenABAP }),
3534
3557
  ];
3535
3558
  }
3536
3559
  function derivedTypesAlt(...extra) {
@@ -11222,7 +11245,7 @@ class TypeTable extends combi_1.Expression {
11222
11245
  const typetable = (0, combi_1.alt)(generic, (0, combi_1.seq)(normal1, (0, combi_1.alt)((0, combi_1.opt)((0, combi_1.per)(header, initial, (0, combi_1.plusPrio)(type_table_key_1.TypeTableKey))), (0, combi_1.seq)((0, combi_1.plus)(type_table_key_1.TypeTableKey), (0, combi_1.optPrio)(initial))), (0, combi_1.optPrio)("VALUE IS INITIAL")));
11223
11246
  const occurs = (0, combi_1.seq)("OCCURS", (0, combi_1.altPrio)(_1.Integer, field_chain_1.FieldChain));
11224
11247
  const entity = (0, combi_1.alt)(_1.TypeName, _1.EntityAssociation);
11225
- const derivedTypes = (0, _derived_types_1.derivedTypesAlt)((0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("ACTION IMPORT", entity)), (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("READ LINK", entity)), (0, combi_1.ver)(version_1.Release.v787, (0, combi_1.seq)("EVENT", entity)));
11248
+ const derivedTypes = (0, _derived_types_1.derivedTypesAlt)((0, combi_1.ver)(version_1.Release.v773, (0, combi_1.seq)("ACTION IMPORT", entity), { also: combi_1.AlsoIn.OpenABAP }), (0, combi_1.ver)(version_1.Release.v774, (0, combi_1.seq)("READ LINK", entity), { also: combi_1.AlsoIn.OpenABAP }), (0, combi_1.ver)(version_1.Release.v787, (0, combi_1.seq)("EVENT", entity), { also: combi_1.AlsoIn.OpenABAP }));
11226
11249
  const derived = (0, combi_1.ver)(version_1.Release.v770, (0, combi_1.seq)("TABLE FOR", derivedTypes, (0, combi_1.optPrio)("VALUE IS INITIAL")), { also: combi_1.AlsoIn.OpenABAP });
11227
11250
  const oldType = (0, combi_1.seq)((0, combi_1.opt)("REF TO"), _1.TypeName, (0, combi_1.alt)((0, combi_1.seq)(occurs, (0, combi_1.opt)(header)), header));
11228
11251
  const oldLike = (0, combi_1.seq)((0, combi_1.opt)("REF TO"), field_chain_1.FieldChain, (0, combi_1.alt)((0, combi_1.seq)(occurs, (0, combi_1.opt)(header)), header));
@@ -48125,6 +48148,105 @@ exports.ArtifactsABAP = ArtifactsABAP;
48125
48148
 
48126
48149
  /***/ },
48127
48150
 
48151
+ /***/ "./node_modules/@abaplint/core/build/src/abap/cross_include_macros.js"
48152
+ /*!****************************************************************************!*\
48153
+ !*** ./node_modules/@abaplint/core/build/src/abap/cross_include_macros.js ***!
48154
+ \****************************************************************************/
48155
+ (__unused_webpack_module, exports, __webpack_require__) {
48156
+
48157
+ "use strict";
48158
+
48159
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
48160
+ exports.CrossIncludeMacros = void 0;
48161
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
48162
+ const program_1 = __webpack_require__(/*! ../objects/program */ "./node_modules/@abaplint/core/build/src/objects/program.js");
48163
+ const _statement_1 = __webpack_require__(/*! ./2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
48164
+ const expand_macros_1 = __webpack_require__(/*! ./2_statements/expand_macros */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expand_macros.js");
48165
+ const include_graph_1 = __webpack_require__(/*! ../utils/include_graph */ "./node_modules/@abaplint/core/build/src/utils/include_graph.js");
48166
+ // Macros can be defined in one include and used in a sibling include, connected
48167
+ // via the main program. Objects are parsed in isolation, so the sibling include
48168
+ // initially ends up with Unknown statements. This second pass finds the main
48169
+ // program(s) for such includes, collects the macro definitions visible there,
48170
+ // and re-parses the include with the macro names as extra global macros.
48171
+ class CrossIncludeMacros {
48172
+ constructor(reg) {
48173
+ this.reg = reg;
48174
+ }
48175
+ run() {
48176
+ const candidates = this.findCandidates();
48177
+ if (candidates.length === 0) {
48178
+ return;
48179
+ }
48180
+ const graph = new include_graph_1.IncludeGraph(this.reg);
48181
+ const config = this.reg.getConfig();
48182
+ const globalMacros = config.getSyntaxSetttings().globalMacros || [];
48183
+ for (const prog of candidates) {
48184
+ const mains = this.findMains(graph, prog);
48185
+ if (mains.size === 0) {
48186
+ continue;
48187
+ }
48188
+ const expand = new expand_macros_1.ExpandMacros(globalMacros, config.getRelease(), this.reg, config.getLanguageVersion());
48189
+ for (const main of mains) {
48190
+ for (const file of main.getABAPFiles()) {
48191
+ // find() follows INCLUDE statements, so this collects macros from the full include chain
48192
+ expand.find([...file.getStatements()], file, false);
48193
+ }
48194
+ }
48195
+ const macroNames = expand.listMacroNames();
48196
+ if (this.matchesUnknown(prog, new Set(macroNames))) {
48197
+ prog.setDirty();
48198
+ prog.parse(config.getRelease(), macroNames, this.reg, config.getLanguageVersion());
48199
+ }
48200
+ }
48201
+ }
48202
+ //////////////////////////////
48203
+ findCandidates() {
48204
+ const ret = [];
48205
+ for (const obj of this.reg.getObjects()) {
48206
+ if (!(obj instanceof program_1.Program) || obj.isInclude() === false) {
48207
+ continue;
48208
+ }
48209
+ for (const file of obj.getABAPFiles()) {
48210
+ if (file.getStatements().some(s => s.get() instanceof _statement_1.Unknown)) {
48211
+ ret.push(obj);
48212
+ break;
48213
+ }
48214
+ }
48215
+ }
48216
+ return ret;
48217
+ }
48218
+ findMains(graph, prog) {
48219
+ var _a;
48220
+ const ret = new Set();
48221
+ const filename = (_a = prog.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getFilename();
48222
+ for (const mainFilename of graph.listMainForInclude(filename)) {
48223
+ const file = this.reg.getFileByName(mainFilename);
48224
+ const obj = file ? this.reg.findObjectForFile(file) : undefined;
48225
+ if (obj instanceof _abap_object_1.ABAPObject) {
48226
+ ret.add(obj);
48227
+ }
48228
+ }
48229
+ return ret;
48230
+ }
48231
+ matchesUnknown(prog, macroNames) {
48232
+ for (const file of prog.getABAPFiles()) {
48233
+ for (const s of file.getStatements()) {
48234
+ if (s.get() instanceof _statement_1.Unknown) {
48235
+ const name = expand_macros_1.ExpandMacros.findName(s.getTokens());
48236
+ if (name !== undefined && macroNames.has(name.toUpperCase())) {
48237
+ return true;
48238
+ }
48239
+ }
48240
+ }
48241
+ }
48242
+ return false;
48243
+ }
48244
+ }
48245
+ exports.CrossIncludeMacros = CrossIncludeMacros;
48246
+ //# sourceMappingURL=cross_include_macros.js.map
48247
+
48248
+ /***/ },
48249
+
48128
48250
  /***/ "./node_modules/@abaplint/core/build/src/abap/nodes/_abstract_node.js"
48129
48251
  /*!****************************************************************************!*\
48130
48252
  !*** ./node_modules/@abaplint/core/build/src/abap/nodes/_abstract_node.js ***!
@@ -68807,6 +68929,7 @@ const ddic_references_1 = __webpack_require__(/*! ./ddic_references */ "./node_m
68807
68929
  const rules_runner_1 = __webpack_require__(/*! ./rules_runner */ "./node_modules/@abaplint/core/build/src/rules_runner.js");
68808
68930
  const msag_references_1 = __webpack_require__(/*! ./msag_references */ "./node_modules/@abaplint/core/build/src/msag_references.js");
68809
68931
  const macro_references_1 = __webpack_require__(/*! ./macro_references */ "./node_modules/@abaplint/core/build/src/macro_references.js");
68932
+ const cross_include_macros_1 = __webpack_require__(/*! ./abap/cross_include_macros */ "./node_modules/@abaplint/core/build/src/abap/cross_include_macros.js");
68810
68933
  // todo, this should really be an instance in case there are multiple Registry'ies
68811
68934
  class ParsingPerformance {
68812
68935
  static clear() {
@@ -68872,7 +68995,7 @@ class Registry {
68872
68995
  }
68873
68996
  static abaplintVersion() {
68874
68997
  // magic, see build script "version.js"
68875
- return "2.119.55";
68998
+ return "2.119.56";
68876
68999
  }
68877
69000
  getDDICReferences() {
68878
69001
  return this.ddicReferences;
@@ -69096,6 +69219,7 @@ class Registry {
69096
69219
  for (const o of this.getObjects()) {
69097
69220
  this.parsePrivate(o);
69098
69221
  }
69222
+ new cross_include_macros_1.CrossIncludeMacros(this).run();
69099
69223
  new find_global_definitions_1.FindGlobalDefinitions(this).run();
69100
69224
  return this;
69101
69225
  }
@@ -69113,6 +69237,7 @@ class Registry {
69113
69237
  if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {
69114
69238
  ParsingPerformance.output();
69115
69239
  }
69240
+ new cross_include_macros_1.CrossIncludeMacros(this).run();
69116
69241
  new find_global_definitions_1.FindGlobalDefinitions(this).run(input === null || input === void 0 ? void 0 : input.progress);
69117
69242
  return this;
69118
69243
  }
@@ -106033,13 +106158,15 @@ var __importStar = (this && this.__importStar) || (function () {
106033
106158
  };
106034
106159
  })();
106035
106160
  Object.defineProperty(exports, "__esModule", ({ value: true }));
106036
- exports.Transpiler = exports.UnknownTypesEnum = exports.config = void 0;
106161
+ exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config = void 0;
106037
106162
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
106038
106163
  const validation_1 = __webpack_require__(/*! ./validation */ "./node_modules/@abaplint/transpiler/build/src/validation.js");
106039
106164
  Object.defineProperty(exports, "config", ({ enumerable: true, get: function () { return validation_1.config; } }));
106040
106165
  const unit_test_1 = __webpack_require__(/*! ./unit_test */ "./node_modules/@abaplint/transpiler/build/src/unit_test.js");
106041
106166
  const types_1 = __webpack_require__(/*! ./types */ "./node_modules/@abaplint/transpiler/build/src/types.js");
106042
106167
  Object.defineProperty(exports, "UnknownTypesEnum", ({ enumerable: true, get: function () { return types_1.UnknownTypesEnum; } }));
106168
+ const chunk_1 = __webpack_require__(/*! ./chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
106169
+ Object.defineProperty(exports, "Chunk", ({ enumerable: true, get: function () { return chunk_1.Chunk; } }));
106043
106170
  const db_1 = __webpack_require__(/*! ./db */ "./node_modules/@abaplint/transpiler/build/src/db/index.js");
106044
106171
  const handle_table_1 = __webpack_require__(/*! ./handlers/handle_table */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_table.js");
106045
106172
  const handle_abap_1 = __webpack_require__(/*! ./handlers/handle_abap */ "./node_modules/@abaplint/transpiler/build/src/handlers/handle_abap.js");
@@ -106056,8 +106183,10 @@ const handle_fugr_1 = __webpack_require__(/*! ./handlers/handle_fugr */ "./node_
106056
106183
  const initialization_1 = __webpack_require__(/*! ./initialization */ "./node_modules/@abaplint/transpiler/build/src/initialization.js");
106057
106184
  class Transpiler {
106058
106185
  options;
106059
- constructor(options) {
106186
+ plugin;
106187
+ constructor(options, plugin) {
106060
106188
  this.options = options;
106189
+ this.plugin = plugin;
106061
106190
  if (this.options === undefined) {
106062
106191
  this.options = {};
106063
106192
  }
@@ -106075,15 +106204,17 @@ class Transpiler {
106075
106204
  reg.parse();
106076
106205
  this.validate(reg);
106077
106206
  const dbSetup = new db_1.DatabaseSetup(reg).run(this.options);
106207
+ this.plugin?.amendDatabaseSetup?.(dbSetup, reg, this.options || {});
106078
106208
  const output = {
106079
106209
  objects: [],
106080
106210
  unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, this.options?.skip),
106081
106211
  unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, this.options?.skip),
106082
- initializationScript: new initialization_1.Initialization().script(reg, dbSetup, this.options),
106083
- initializationScript2: new initialization_1.Initialization().script(reg, dbSetup, this.options, true),
106212
+ initializationScript: "",
106213
+ initializationScript2: "",
106084
106214
  databaseSetup: dbSetup,
106085
106215
  reg: reg,
106086
106216
  };
106217
+ const pluginOutputs = [];
106087
106218
  progress?.set(reg.getObjectCount().total, "Building");
106088
106219
  for (const obj of reg.getObjects()) {
106089
106220
  await progress?.tick("Building, " + obj.getName());
@@ -106123,12 +106254,22 @@ class Transpiler {
106123
106254
  else if (obj instanceof abaplint.Objects.MessageClass) {
106124
106255
  output.objects.push(...new handle_msag_1.HandleMSAG().runObject(obj, reg));
106125
106256
  }
106257
+ else if (this.plugin !== undefined) {
106258
+ const handled = this.plugin.handleObject(obj, reg, this.options || {});
106259
+ if (handled !== undefined) {
106260
+ output.objects.push(...handled);
106261
+ pluginOutputs.push(...handled);
106262
+ }
106263
+ }
106126
106264
  }
106265
+ // after the object loop, plugin output files are imported by the initialization scripts
106266
+ output.initializationScript = new initialization_1.Initialization().script(reg, dbSetup, this.options, false, pluginOutputs);
106267
+ output.initializationScript2 = new initialization_1.Initialization().script(reg, dbSetup, this.options, true, pluginOutputs);
106127
106268
  return output;
106128
106269
  }
106129
106270
  // ///////////////////////////////
106130
106271
  validate(reg) {
106131
- const issues = new validation_1.Validation(this.options).run(reg);
106272
+ const issues = new validation_1.Validation(this.options, this.plugin).run(reg);
106132
106273
  if (issues.length > 0) {
106133
106274
  const messages = issues.map(i => i.getKey() + ", " +
106134
106275
  i.getMessage() + ", " +
@@ -106195,7 +106336,7 @@ function escapeNamespaceFilename(filename) {
106195
106336
  return filename.replace(/\//g, "%23");
106196
106337
  }
106197
106338
  class Initialization {
106198
- script(reg, dbSetup, options, useImport) {
106339
+ script(reg, dbSetup, options, useImport, pluginOutputs) {
106199
106340
  let ret = "";
106200
106341
  if (useImport === true) {
106201
106342
  ret = `/* eslint-disable import/newline-after-import */
@@ -106238,13 +106379,13 @@ globalThis.abap = new runtime.ABAP();\n`;
106238
106379
  }
106239
106380
  ret += `}\n\n`;
106240
106381
  ret += `await initializeABAP();\n\n`;
106241
- ret += `${this.buildImports(reg, useImport, options)}`;
106382
+ ret += `${this.buildImports(reg, useImport, options, pluginOutputs)}`;
106242
106383
  if (options?.setup?.postFunction !== undefined) {
106243
106384
  ret += `\n\nawait setup.${options?.setup?.postFunction}();\n`;
106244
106385
  }
106245
106386
  return ret;
106246
106387
  }
106247
- buildImports(reg, useImport, options) {
106388
+ buildImports(reg, useImport, options, pluginOutputs) {
106248
106389
  // note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
106249
106390
  // some sorting required: eg. a class constructor using constant from interface
106250
106391
  const list = [];
@@ -106257,6 +106398,9 @@ globalThis.abap = new runtime.ABAP();\n`;
106257
106398
  return `await import("./${filename}.mjs");`;
106258
106399
  }
106259
106400
  };
106401
+ for (const pluginOutput of pluginOutputs || []) {
106402
+ list.push(imp(pluginOutput.filename.replace(/\.mjs$/i, "")));
106403
+ }
106260
106404
  for (const obj of reg.getObjects()) {
106261
106405
  if (obj instanceof abaplint.Objects.Table
106262
106406
  || obj instanceof abaplint.Objects.DataElement
@@ -119236,6 +119380,74 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
119236
119380
  exports.Validation = exports.config = void 0;
119237
119381
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
119238
119382
  const types_1 = __webpack_require__(/*! ./types */ "./node_modules/@abaplint/transpiler/build/src/types.js");
119383
+ const defaultAllowedObjectTypes = [
119384
+ "APIS",
119385
+ "AUTH",
119386
+ "CLAS",
119387
+ "DEVC",
119388
+ "DOMA",
119389
+ "DTEL",
119390
+ "ENHO",
119391
+ "ENHS",
119392
+ "ENQU",
119393
+ "FUGR",
119394
+ "HTTP",
119395
+ "INTF",
119396
+ "IWMO",
119397
+ "IWOM",
119398
+ "IWPR",
119399
+ "IWSG",
119400
+ "IWSV",
119401
+ "MSAG",
119402
+ "NROB",
119403
+ "NSPC",
119404
+ "OA2P",
119405
+ "PARA",
119406
+ "PINF",
119407
+ "PROG",
119408
+ "WAPA",
119409
+ "SHLP",
119410
+ "SHMA",
119411
+ "SICF",
119412
+ "SMIM",
119413
+ "SPLO",
119414
+ "SRFC",
119415
+ "SUSC",
119416
+ "SUSH",
119417
+ "SUSO",
119418
+ "SXCI",
119419
+ "TABL",
119420
+ "TOBJ",
119421
+ "TRAN",
119422
+ "TTYP",
119423
+ "TYPE",
119424
+ "VCLS",
119425
+ "VIEW",
119426
+ "W3MI",
119427
+ "XSLT",
119428
+ "ZN01",
119429
+ "ZN02",
119430
+ "ZN03",
119431
+ "ZN04",
119432
+ "ZN05",
119433
+ "ZN06",
119434
+ "ZN07",
119435
+ "ZN08",
119436
+ "ZN09",
119437
+ "ZN10",
119438
+ "ZN11",
119439
+ "ZN12",
119440
+ "ZN13",
119441
+ "ZN14",
119442
+ "ZN15",
119443
+ "ZN16",
119444
+ "ZN17",
119445
+ "ZN18",
119446
+ "ZN19",
119447
+ "ZN20",
119448
+ "ZN21",
119449
+ "ZN22",
119450
+ ];
119239
119451
  exports.config = {
119240
119452
  "global": {
119241
119453
  "files": "/**/*.*",
@@ -119258,75 +119470,7 @@ exports.config = {
119258
119470
  },
119259
119471
  "parser_error": true,
119260
119472
  "allowed_object_types": {
119261
- "allowed": [
119262
- "APIS",
119263
- "AUTH",
119264
- "CLAS",
119265
- "DEVC",
119266
- "DOMA",
119267
- "DTEL",
119268
- "ENHO",
119269
- "ENHS",
119270
- "ENQU",
119271
- "FUGR",
119272
- "HTTP",
119273
- "INTF",
119274
- "IWMO",
119275
- "IWOM",
119276
- "IWPR",
119277
- "IWSG",
119278
- "IWSV",
119279
- "MSAG",
119280
- "NROB",
119281
- "NSPC",
119282
- "OA2P",
119283
- "PARA",
119284
- "PINF",
119285
- "PROG",
119286
- "WAPA",
119287
- "SHLP",
119288
- "SHMA",
119289
- "SICF",
119290
- "SMIM",
119291
- "SMIM",
119292
- "SPLO",
119293
- "SRFC",
119294
- "SUSC",
119295
- "SUSH",
119296
- "SUSO",
119297
- "SXCI",
119298
- "TABL",
119299
- "TOBJ",
119300
- "TRAN",
119301
- "TTYP",
119302
- "TYPE",
119303
- "VCLS",
119304
- "VIEW",
119305
- "W3MI",
119306
- "XSLT",
119307
- "ZN01",
119308
- "ZN02",
119309
- "ZN03",
119310
- "ZN04",
119311
- "ZN05",
119312
- "ZN06",
119313
- "ZN07",
119314
- "ZN08",
119315
- "ZN09",
119316
- "ZN10",
119317
- "ZN11",
119318
- "ZN12",
119319
- "ZN13",
119320
- "ZN14",
119321
- "ZN15",
119322
- "ZN16",
119323
- "ZN17",
119324
- "ZN18",
119325
- "ZN19",
119326
- "ZN20",
119327
- "ZN21",
119328
- "ZN22",
119329
- ],
119473
+ "allowed": defaultAllowedObjectTypes,
119330
119474
  },
119331
119475
  "unknown_types": true,
119332
119476
  "ambiguous_statement": true,
@@ -119343,8 +119487,10 @@ exports.config = {
119343
119487
  // hmm this ^ is okay? since lines will be prefixed with "abap.builtin"?
119344
119488
  class Validation {
119345
119489
  options;
119346
- constructor(options) {
119490
+ plugin;
119491
+ constructor(options, plugin) {
119347
119492
  this.options = options;
119493
+ this.plugin = plugin;
119348
119494
  }
119349
119495
  run(reg) {
119350
119496
  if (this.options?.ignoreSyntaxCheck === true) {
@@ -119354,6 +119500,13 @@ class Validation {
119354
119500
  exports.config.rules.check_syntax = true;
119355
119501
  }
119356
119502
  exports.config.rules.forbidden_identifier.check = ["^unique\\d+$"];
119503
+ const allowed = [...defaultAllowedObjectTypes];
119504
+ for (const type of this.plugin?.objectTypes() || []) {
119505
+ if (allowed.includes(type.toUpperCase()) === false) {
119506
+ allowed.push(type.toUpperCase());
119507
+ }
119508
+ }
119509
+ exports.config.rules.allowed_object_types.allowed = allowed;
119357
119510
  if (this.options?.unknownTypes === types_1.UnknownTypesEnum.runtimeError) {
119358
119511
  // this is not a constant, just a regex that happens to not match anything
119359
119512
  exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
@@ -126464,6 +126617,17 @@ module.exports = require("fs");
126464
126617
 
126465
126618
  /***/ },
126466
126619
 
126620
+ /***/ "module"
126621
+ /*!*************************!*\
126622
+ !*** external "module" ***!
126623
+ \*************************/
126624
+ (module) {
126625
+
126626
+ "use strict";
126627
+ module.exports = require("module");
126628
+
126629
+ /***/ },
126630
+
126467
126631
  /***/ "node:fs/promises"
126468
126632
  /*!***********************************!*\
126469
126633
  !*** external "node:fs/promises" ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.33",
3
+ "version": "2.13.35",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@abaplint/core": "^2.119.55",
31
- "@abaplint/transpiler": "^2.13.33",
30
+ "@abaplint/core": "^2.119.56",
31
+ "@abaplint/transpiler": "^2.13.35",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^24.12.2",
34
34
  "@types/progress": "^2.0.7",
package/schema.json ADDED
@@ -0,0 +1,235 @@
1
+ {
2
+ "$ref": "#/definitions/ITranspilerConfig",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "ITranspilerConfig": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "exclude_filter": {
9
+ "description": "list of regex, case insensitive",
10
+ "items": {
11
+ "type": "string"
12
+ },
13
+ "type": "array",
14
+ "uniqueItems": true
15
+ },
16
+ "input_filter": {
17
+ "description": "list of regex, case insensitive, empty gives all files, positive list",
18
+ "items": {
19
+ "type": "string"
20
+ },
21
+ "type": "array",
22
+ "uniqueItems": true
23
+ },
24
+ "input_folder": {
25
+ "anyOf": [
26
+ {
27
+ "type": "string"
28
+ },
29
+ {
30
+ "items": {
31
+ "type": "string"
32
+ },
33
+ "type": "array"
34
+ }
35
+ ]
36
+ },
37
+ "libs": {
38
+ "items": {
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "exclude_filter": {
42
+ "description": "list of regex, case insensitive",
43
+ "items": {
44
+ "type": "string"
45
+ },
46
+ "type": "array",
47
+ "uniqueItems": true
48
+ },
49
+ "files": {
50
+ "anyOf": [
51
+ {
52
+ "type": "string"
53
+ },
54
+ {
55
+ "items": {
56
+ "type": "string"
57
+ },
58
+ "type": "array"
59
+ }
60
+ ]
61
+ },
62
+ "folder": {
63
+ "type": "string"
64
+ },
65
+ "url": {
66
+ "type": "string"
67
+ }
68
+ },
69
+ "type": "object"
70
+ },
71
+ "type": "array"
72
+ },
73
+ "options": {
74
+ "$ref": "#/definitions/ITranspilerOptions"
75
+ },
76
+ "output_folder": {
77
+ "type": "string"
78
+ },
79
+ "plugins": {
80
+ "description": "list of npm module names or paths, resolved from the current working directory, each module exports \"plugins\", an array of ITranspilerPlugin instances",
81
+ "items": {
82
+ "type": "string"
83
+ },
84
+ "type": "array",
85
+ "uniqueItems": true
86
+ },
87
+ "write_source_map": {
88
+ "type": "boolean"
89
+ },
90
+ "write_unit_tests": {
91
+ "type": "boolean"
92
+ }
93
+ },
94
+ "required": [
95
+ "input_folder",
96
+ "output_folder",
97
+ "options"
98
+ ],
99
+ "type": "object"
100
+ },
101
+ "ITranspilerOptions": {
102
+ "additionalProperties": false,
103
+ "properties": {
104
+ "addCommonJS": {
105
+ "description": "adds common js modules",
106
+ "type": "boolean"
107
+ },
108
+ "addFilenames": {
109
+ "description": "adds filenames as comments in the output js",
110
+ "type": "boolean"
111
+ },
112
+ "ignoreSourceMap": {
113
+ "description": "ignore source map",
114
+ "type": "boolean"
115
+ },
116
+ "ignoreSyntaxCheck": {
117
+ "description": "ignore syntax check, used for internal testing",
118
+ "type": "boolean"
119
+ },
120
+ "importProg": {
121
+ "description": "import programs",
122
+ "type": "boolean"
123
+ },
124
+ "keywords": {
125
+ "description": "list of keywords to rename, if not supplied default will be used",
126
+ "items": {
127
+ "type": "string"
128
+ },
129
+ "type": "array"
130
+ },
131
+ "populateTables": {
132
+ "additionalProperties": false,
133
+ "description": "populate tables, all tables are populated if undefined and they exist",
134
+ "properties": {
135
+ "reposrc": {
136
+ "description": "insert into REPOSRC, skips if equals false",
137
+ "type": "boolean"
138
+ },
139
+ "seosubco": {
140
+ "description": "insert into SEOSUBCO, skips if equals false",
141
+ "type": "boolean"
142
+ },
143
+ "seosubcodf": {
144
+ "description": "insert into SEOSUBCODF, skips if equals false",
145
+ "type": "boolean"
146
+ },
147
+ "seosubcotx": {
148
+ "description": "insert into SEOSUBCOTX, skips if equals false",
149
+ "type": "boolean"
150
+ },
151
+ "tadir": {
152
+ "description": "insert into TADIR, skips if equals false",
153
+ "type": "boolean"
154
+ },
155
+ "wwwparams": {
156
+ "description": "insert into WWWPARAMS, skips if equals false",
157
+ "type": "boolean"
158
+ }
159
+ },
160
+ "type": "object"
161
+ },
162
+ "setup": {
163
+ "additionalProperties": false,
164
+ "description": "extra setup script to be executed during initialization",
165
+ "properties": {
166
+ "filename": {
167
+ "type": "string"
168
+ },
169
+ "postFunction": {
170
+ "type": "string"
171
+ },
172
+ "preFunction": {
173
+ "type": "string"
174
+ }
175
+ },
176
+ "required": [
177
+ "filename"
178
+ ],
179
+ "type": "object"
180
+ },
181
+ "skip": {
182
+ "$ref": "#/definitions/TestMethodList",
183
+ "description": "list of unit tests to skip"
184
+ },
185
+ "skipVersionCheck": {
186
+ "description": "skips version check, not recommended",
187
+ "type": "boolean"
188
+ },
189
+ "unknownTypes": {
190
+ "$ref": "#/definitions/UnknownTypesEnum",
191
+ "description": "sets behavior for unknown types, either fail at compile- or run-time"
192
+ }
193
+ },
194
+ "type": "object"
195
+ },
196
+ "TestMethodList": {
197
+ "items": {
198
+ "additionalProperties": false,
199
+ "properties": {
200
+ "class": {
201
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
202
+ "type": "string"
203
+ },
204
+ "method": {
205
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
206
+ "type": "string"
207
+ },
208
+ "note": {
209
+ "type": "string"
210
+ },
211
+ "object": {
212
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
213
+ "type": "string"
214
+ }
215
+ },
216
+ "required": [
217
+ "object",
218
+ "class",
219
+ "method"
220
+ ],
221
+ "type": "object"
222
+ },
223
+ "type": "array",
224
+ "uniqueItems": true
225
+ },
226
+ "UnknownTypesEnum": {
227
+ "enum": [
228
+ "compileError",
229
+ "runtimeError"
230
+ ],
231
+ "type": "string"
232
+ }
233
+ }
234
+ }
235
+