trm-client 11.1.2 → 11.2.0

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/changelog.txt CHANGED
@@ -8,6 +8,17 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2026-09-23 v11.2.0
12
+ -------------------
13
+ ! trm-core ^9.10.6
14
+ ! trm-commons ^5.1.0
15
+ + --connection-type option (env TRM_CONNECTION_TYPE) for non interactive connection
16
+ + --connection-args option (env TRM_CONNECTION_ARGS), JSON or JSON file path passed to connection
17
+ + cli option names mapped to connection argument keys
18
+ + warning for connection arguments not supported by connection type
19
+ + possible values in invalid connection type error
20
+ ! forward rfc destination no longer defaults to NONE (NONE only for non interactive connection)
21
+
11
22
  2026-09-02 v11.1.2
12
23
  -------------------
13
24
  ! trm-core ^9.10.5
@@ -46,6 +46,8 @@ export declare abstract class AbstractCommand {
46
46
  private checkTrmDependencies;
47
47
  parseTextArg(name: string): string;
48
48
  parseJsonArg(name: string): any;
49
+ private getConnectArgs;
50
+ private parseConnectionArgs;
49
51
  parseArrayArg(name: string): string[];
50
52
  parseNumberArg(name: string): number;
51
53
  run(args?: any, options?: AbstractCommandRunOptions): Promise<void>;
@@ -46,6 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.AbstractCommand = void 0;
49
+ const commander_1 = require("commander");
49
50
  const utils_1 = require("../utils");
50
51
  const LoggerType_1 = require("./LoggerType");
51
52
  const InquirerType_1 = require("./InquirerType");
@@ -206,7 +207,9 @@ class AbstractCommand {
206
207
  .option(`-r, --sap-router <sap router>`, `RFC SAP Router.`)
207
208
  .option(`-n, --sys-nr <sysnr>`, `Instance number.`)
208
209
  .option(`-e, --endpoint <endpoint>`, `REST endpoint.`)
209
- .option(`-x, --forward-rfc-dest [destination]`, `REST forward destination.`, `NONE`);
210
+ .option(`-x, --forward-rfc-dest [destination]`, `REST forward RFC destination.`)
211
+ .addOption(new commander_1.Option(`--connection-type <type>`, `Connection type (e.g. RFC, REST or a plugin connection type), skips the connection prompt.`).env(`TRM_CONNECTION_TYPE`))
212
+ .addOption(new commander_1.Option(`--connection-args <arguments>`, `Connection arguments, passed to the connection type (JSON or path to JSON file).`).env(`TRM_CONNECTION_ARGS`));
210
213
  if (!this.registerOpts.noSystemAlias) {
211
214
  this.command
212
215
  .option(`-a, --alias <alias>`, `System Alias.`);
@@ -384,6 +387,52 @@ class AbstractCommand {
384
387
  catch (_a) { }
385
388
  }
386
389
  }
390
+ getConnectArgs() {
391
+ const connectArgs = Object.assign({}, this.args);
392
+ const mapping = [
393
+ ['client', 'mandt'],
394
+ ['passwd', 'password'],
395
+ ['ashost', 'applicationServer'],
396
+ ['sysnr', 'sysNr'],
397
+ ['saprouter', 'sapRouter']
398
+ ];
399
+ mapping.forEach(([key, cliKey]) => {
400
+ if (connectArgs[key] === undefined && connectArgs[cliKey] !== undefined) {
401
+ connectArgs[key] = connectArgs[cliKey];
402
+ }
403
+ });
404
+ if (this.args.connectionType) {
405
+ connectArgs.type = this.args.connectionType;
406
+ if (typeof connectArgs.forwardRfcDest !== 'string') {
407
+ connectArgs.forwardRfcDest = 'NONE';
408
+ }
409
+ }
410
+ connectArgs.connectionArgs = this.parseConnectionArgs();
411
+ return connectArgs;
412
+ }
413
+ parseConnectionArgs() {
414
+ if (!this.args.connectionArgs) {
415
+ return undefined;
416
+ }
417
+ var sValue;
418
+ try {
419
+ sValue = (0, fs_1.readFileSync)(this.args.connectionArgs).toString();
420
+ }
421
+ catch (_a) {
422
+ sValue = this.args.connectionArgs;
423
+ }
424
+ var value;
425
+ try {
426
+ value = JSON.parse(sValue);
427
+ }
428
+ catch (_b) {
429
+ throw new Error(`Invalid connection arguments: expected a JSON object or the path to a JSON file.`);
430
+ }
431
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
432
+ throw new Error(`Invalid connection arguments: expected a JSON object.`);
433
+ }
434
+ return value;
435
+ }
387
436
  parseArrayArg(name) {
388
437
  if (this.args[name]) {
389
438
  try {
@@ -497,7 +546,8 @@ class AbstractCommand {
497
546
  system = systemAlias_1.SystemAlias.get(this.args.alias).getConnection();
498
547
  }
499
548
  else {
500
- system = (yield (0, prompts_1.connect)(this.args, true, this.registerOpts.addNoConnection)).connect.getSystemConnector();
549
+ const connectArgs = this.getConnectArgs();
550
+ system = (yield (0, prompts_1.connect)(connectArgs, !this.args.connectionType, this.registerOpts.addNoConnection)).connect.getSystemConnector();
501
551
  }
502
552
  yield system.connect(false);
503
553
  Core.SystemConnector.systemConnector = system;
@@ -13,8 +13,9 @@ export type ConnectArguments = {
13
13
  noSystemAlias?: boolean;
14
14
  force?: boolean;
15
15
  endpoint?: string;
16
- forwardRfcDest?: string;
16
+ forwardRfcDest?: string | boolean;
17
17
  connection?: ISystemConnector;
18
+ connectionArgs?: Record<string, any>;
18
19
  };
19
20
  export declare function connect(commandArgs: ConnectArguments, createAliasIfNotExist?: boolean, addNoConnection?: boolean): Promise<{
20
21
  connect: IConnect;
@@ -14,6 +14,20 @@ const systemAlias_1 = require("../../systemAlias");
14
14
  const utils_1 = require("../../utils");
15
15
  const trm_commons_1 = require("trm-commons");
16
16
  const lodash_1 = require("lodash");
17
+ function applyConnectionArgs(connection, commandArgs) {
18
+ const connectionArgs = commandArgs.connectionArgs;
19
+ if (!connectionArgs) {
20
+ return commandArgs;
21
+ }
22
+ const declared = connection.connectionArgs;
23
+ if (Array.isArray(declared)) {
24
+ const unknown = Object.keys(connectionArgs).filter(k => !declared.find(o => o.name === k));
25
+ if (unknown.length > 0) {
26
+ trm_commons_1.Logger.warning(`Connection "${connection.name}" doesn't support argument(s) ${unknown.join(', ')}. Supported arguments: ${declared.map(o => o.name).join(', ') || 'none'}.`);
27
+ }
28
+ }
29
+ return Object.assign(Object.assign({}, commandArgs), connectionArgs);
30
+ }
17
31
  const languageList = [
18
32
  { value: 'AR', name: 'AR (Arabic)' },
19
33
  { value: 'BG', name: 'BG (Bulgarian)' },
@@ -128,7 +142,7 @@ function connect(commandArgs_1) {
128
142
  }
129
143
  connection.setData(inq2.data);
130
144
  if (connection.onAfterLoginData) {
131
- yield connection.onAfterLoginData(force, commandArgs);
145
+ yield connection.onAfterLoginData(force, applyConnectionArgs(connection, commandArgs));
132
146
  }
133
147
  if (!(0, lodash_1.isEqual)(inq2.data, connection.getData())) {
134
148
  systemAlias_1.SystemAlias.delete(inq2.alias);
@@ -170,8 +184,9 @@ function connect(commandArgs_1) {
170
184
  }
171
185
  const connectionType = utils_1.GlobalContext.getInstance().getConnections().find(o => o.name === type);
172
186
  if (!connectionType) {
173
- throw new Error(`Invalid connection type "${type}"`);
187
+ throw new Error(`Invalid connection type "${type}". Possible values are ${utils_1.GlobalContext.getInstance().getConnections().map(o => o.name).join(', ')}.`);
174
188
  }
189
+ commandArgs = applyConnectionArgs(connectionType, commandArgs);
175
190
  if (connectionType.onConnectionData) {
176
191
  yield connectionType.onConnectionData(force, commandArgs);
177
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-client",
3
- "version": "11.1.2",
3
+ "version": "11.2.0",
4
4
  "description": "TRM (Transport Request Manager) Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,13 +46,13 @@
46
46
  "lodash": "^4.17.21",
47
47
  "sanitize-filename": "^1.6.3",
48
48
  "semver": "^7.7.4",
49
- "trm-commons": "^5.0.1",
50
- "trm-core": "^9.10.5",
49
+ "trm-commons": "^5.1.0",
50
+ "trm-core": "^9.10.6",
51
51
  "trm-registry-types": "^2.4.0",
52
52
  "xml2js": "^0.6.2"
53
53
  },
54
54
  "peerDependencies": {
55
- "trm-commons": "^5.0.1"
55
+ "trm-commons": "^5.1.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/ini": "^1.3.31",