trm-client 4.10.0 → 5.0.1

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,16 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2025-09-03 v5.0.0
12
+ -------------------
13
+
14
+ ! trm-core ^7.5.1
15
+ ! trm-commons ^3.2.0
16
+ ! moved settings to context
17
+ + plugin calls
18
+ + gracefully close connection
19
+ ! moved connection prompts to commons
20
+
11
21
  2025-08-13 v4.10.0
12
22
  -------------------
13
23
 
@@ -11,10 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.alias = alias;
13
13
  const systemAlias_1 = require("../systemAlias");
14
+ const utils_1 = require("../utils");
14
15
  const createAlias_1 = require("./createAlias");
15
16
  const deleteAlias_1 = require("./deleteAlias");
16
17
  const prompts_1 = require("./prompts");
17
- const utils_1 = require("../utils");
18
18
  const trm_commons_1 = require("trm-commons");
19
19
  const _create = () => __awaiter(void 0, void 0, void 0, function* () {
20
20
  const inq1 = yield trm_commons_1.Inquirer.prompt({
@@ -27,88 +27,23 @@ const _create = () => __awaiter(void 0, void 0, void 0, function* () {
27
27
  });
28
28
  });
29
29
  const _view = (alias) => {
30
- const client = alias.login.client;
31
- const lang = alias.login.lang;
32
- const user = alias.login.user;
33
- const hasPassword = alias.login.passwd ? true : false;
34
- if (alias.type === utils_1.SystemConnectorType.RFC) {
35
- const dest = alias.connection.dest;
36
- const ashost = alias.connection.ashost;
37
- const sysnr = alias.connection.sysnr;
38
- const saprouter = alias.connection.saprouter;
39
- const client = alias.login.client;
40
- if (dest) {
41
- trm_commons_1.Logger.info(`System ID: ${dest}`);
42
- }
43
- else {
44
- trm_commons_1.Logger.warning(`System ID: Unknown`);
45
- }
46
- if (ashost) {
47
- trm_commons_1.Logger.info(`Application server: ${ashost}`);
48
- }
49
- else {
50
- trm_commons_1.Logger.warning(`Application server: Unknown`);
51
- }
52
- if (sysnr) {
53
- trm_commons_1.Logger.info(`Instance number: ${sysnr}`);
54
- }
55
- else {
56
- trm_commons_1.Logger.warning(`Instance number: Unknown`);
57
- }
58
- if (saprouter) {
59
- trm_commons_1.Logger.info(`SAProuter: ${saprouter}`);
60
- }
61
- if (client) {
62
- trm_commons_1.Logger.info(`Logon client: ${client}`);
63
- }
64
- else {
65
- trm_commons_1.Logger.warning(`Logon client: Unknown`);
66
- }
67
- }
68
- else if (alias.type === utils_1.SystemConnectorType.REST) {
69
- const endpoint = alias.connection.endpoint;
70
- const rfcdest = alias.connection.rfcdest;
71
- if (endpoint) {
72
- trm_commons_1.Logger.info(`System endpoint: ${endpoint}`);
73
- }
74
- else {
75
- trm_commons_1.Logger.warning(`System endpoint: Unknown`);
76
- }
77
- if (rfcdest) {
78
- trm_commons_1.Logger.info(`RFC Forward: ${rfcdest}`);
79
- }
30
+ const connection = utils_1.Context.getInstance().connections.find(o => o.name === alias.type);
31
+ if (!connection) {
32
+ throw new Error(`Unknown connection type "${alias.type}".`);
80
33
  }
81
- if (lang) {
82
- trm_commons_1.Logger.info(`Logon language: ${lang}`);
34
+ if (connection.logData) {
35
+ connection.logData();
83
36
  }
84
37
  else {
85
- trm_commons_1.Logger.warning(`Logon language: Unknown`);
86
- }
87
- if (client) {
88
- trm_commons_1.Logger.info(`Logon client: ${client}`);
89
- }
90
- else {
91
- trm_commons_1.Logger.warning(`Logon client: Unknown`);
92
- }
93
- if (user) {
94
- trm_commons_1.Logger.info(`Logon user: ${user}`);
95
- }
96
- else {
97
- trm_commons_1.Logger.warning(`Logon user: Unknown`);
98
- }
99
- if (hasPassword) {
100
- trm_commons_1.Logger.info(`Logon password: SAVED IN PLAIN TEXT`);
101
- }
102
- else {
103
- trm_commons_1.Logger.warning(`Logon password: Unknown`);
38
+ trm_commons_1.Logger.info(`No data to show.`);
104
39
  }
105
40
  };
106
41
  const _check = (alias) => __awaiter(void 0, void 0, void 0, function* () {
107
42
  trm_commons_1.Logger.loading(`Checking connection with alias "${alias.alias}"...`);
108
- const oSystemAlias = new systemAlias_1.SystemAlias(alias.type, alias.connection, alias.login);
43
+ const oSystemAlias = new systemAlias_1.SystemAlias(alias.type, alias.data);
109
44
  try {
110
45
  yield oSystemAlias.getConnection().connect();
111
- trm_commons_1.Logger.success(`Connection OK.`);
46
+ trm_commons_1.Logger.success(`Connection to alias "${alias.alias}" OK.`);
112
47
  }
113
48
  catch (e) {
114
49
  trm_commons_1.Logger.error(`Connection failed!`);
@@ -117,39 +52,14 @@ const _check = (alias) => __awaiter(void 0, void 0, void 0, function* () {
117
52
  });
118
53
  const _edit = (alias) => __awaiter(void 0, void 0, void 0, function* () {
119
54
  var connectionSuccess = true;
120
- const connectionArgs = yield (0, prompts_1.connect)(Object.assign(Object.assign(Object.assign({}, alias.connection), alias.login), {
55
+ const connectionArgs = yield (0, prompts_1.connect)(Object.assign(Object.assign({}, alias.data), {
121
56
  type: alias.type,
122
57
  noSystemAlias: true,
123
58
  force: true
124
59
  }), false);
125
60
  try {
126
61
  systemAlias_1.SystemAlias.delete(alias.alias);
127
- var updatedAlias;
128
- if (connectionArgs.type === utils_1.SystemConnectorType.RFC) {
129
- updatedAlias = systemAlias_1.SystemAlias.create(alias.alias, connectionArgs.type, {
130
- ashost: connectionArgs.ashost,
131
- dest: connectionArgs.dest,
132
- sysnr: connectionArgs.sysnr,
133
- saprouter: connectionArgs.saprouter
134
- }, {
135
- client: connectionArgs.client,
136
- lang: connectionArgs.lang,
137
- passwd: connectionArgs.passwd,
138
- user: connectionArgs.user
139
- });
140
- }
141
- else if (connectionArgs.type === utils_1.SystemConnectorType.REST) {
142
- updatedAlias = systemAlias_1.SystemAlias.create(alias.alias, connectionArgs.type, {
143
- endpoint: connectionArgs.endpoint,
144
- rfcdest: connectionArgs.forwardRfcDest
145
- }, {
146
- lang: connectionArgs.lang,
147
- passwd: connectionArgs.passwd,
148
- user: connectionArgs.user,
149
- client: connectionArgs.client
150
- });
151
- }
152
- yield updatedAlias.getConnection().connect();
62
+ yield systemAlias_1.SystemAlias.create(alias.alias, connectionArgs.name, connectionArgs.getData()).getConnection().connect();
153
63
  }
154
64
  catch (e) {
155
65
  connectionSuccess = false;
@@ -162,30 +72,7 @@ const _edit = (alias) => __awaiter(void 0, void 0, void 0, function* () {
162
72
  else {
163
73
  trm_commons_1.Logger.error(`Alias "${alias.alias}" couldn't be updated.`);
164
74
  systemAlias_1.SystemAlias.delete(alias.alias);
165
- if (alias.type === utils_1.SystemConnectorType.RFC) {
166
- systemAlias_1.SystemAlias.create(alias.alias, alias.type, {
167
- ashost: alias.connection.ashost,
168
- dest: alias.connection.dest,
169
- sysnr: alias.connection.sysnr,
170
- saprouter: alias.connection.saprouter
171
- }, {
172
- client: alias.login.client,
173
- lang: alias.login.lang,
174
- passwd: alias.login.passwd,
175
- user: alias.login.user
176
- });
177
- }
178
- else if (alias.type === utils_1.SystemConnectorType.REST) {
179
- systemAlias_1.SystemAlias.create(alias.alias, alias.type, {
180
- endpoint: alias.connection.endpoint,
181
- rfcdest: alias.connection.rfcdest
182
- }, {
183
- lang: alias.login.lang,
184
- passwd: alias.login.passwd,
185
- user: alias.login.user,
186
- client: alias.login.client
187
- });
188
- }
75
+ systemAlias_1.SystemAlias.create(alias.alias, alias.type, alias.data);
189
76
  }
190
77
  }
191
78
  });
@@ -1,7 +1,6 @@
1
1
  import { ISystemConnector } from "trm-core";
2
- import { SystemConnectorType } from "../../utils";
3
2
  export type ConnectArguments = {
4
- type?: SystemConnectorType;
3
+ type?: string;
5
4
  dest?: string;
6
5
  ashost?: string;
7
6
  sysnr?: string;
@@ -48,11 +48,7 @@ const systemAlias_1 = require("../systemAlias");
48
48
  const prompts_1 = require("./prompts");
49
49
  const commons_1 = require("./commons");
50
50
  const trm_core_1 = require("trm-core");
51
- const utils_1 = require("../utils");
52
51
  const trm_commons_1 = require("trm-commons");
53
- const _compareConnectionData = (a, b) => {
54
- return false;
55
- };
56
52
  const _promptConnections = (aConnections) => __awaiter(void 0, void 0, void 0, function* () {
57
53
  if (aConnections.length > 0) {
58
54
  trm_commons_1.Logger.info(`Compare systems: ${aConnections.map(o => o.getDest()).join(', ')}`);
@@ -67,44 +63,10 @@ const _promptConnections = (aConnections) => __awaiter(void 0, void 0, void 0, f
67
63
  }]);
68
64
  askConnection = inq1.continue !== undefined ? inq1.continue : askConnection;
69
65
  if (askConnection) {
70
- const connectArgs = yield (0, prompts_1.connect)({}, false);
71
- var oConnection;
72
- if (connectArgs.type === utils_1.SystemConnectorType.RFC) {
73
- oConnection = (0, utils_1.getSystemConnector)(connectArgs.type, {
74
- connection: {
75
- ashost: connectArgs.ashost,
76
- dest: connectArgs.dest,
77
- sysnr: connectArgs.sysnr,
78
- saprouter: connectArgs.saprouter
79
- },
80
- login: {
81
- user: connectArgs.user,
82
- passwd: connectArgs.passwd,
83
- lang: connectArgs.lang,
84
- client: connectArgs.client
85
- }
86
- });
87
- }
88
- else if (connectArgs.type === utils_1.SystemConnectorType.REST) {
89
- oConnection = (0, utils_1.getSystemConnector)(connectArgs.type, {
90
- connection: {
91
- endpoint: connectArgs.endpoint,
92
- rfcdest: connectArgs.forwardRfcDest
93
- },
94
- login: {
95
- user: connectArgs.user,
96
- passwd: connectArgs.passwd,
97
- lang: connectArgs.lang,
98
- client: connectArgs.client
99
- }
100
- });
101
- }
102
- if (oConnection) {
103
- if (!aConnections.find(o => _compareConnectionData(o.getConnectionData(), oConnection.getConnectionData()))) {
104
- yield oConnection.connect();
105
- aConnections.push(oConnection);
106
- }
107
- }
66
+ const connectArgs = yield (0, prompts_1.connect)({}, false, false);
67
+ const systemConnector = connectArgs.getSystemConnector();
68
+ yield systemConnector.connect();
69
+ aConnections.push(systemConnector);
108
70
  }
109
71
  return {
110
72
  continue: askConnection,
@@ -136,10 +98,7 @@ function compare(commandArgs) {
136
98
  for (const sAlias of aInputConnections) {
137
99
  const oAlias = systemAlias_1.SystemAlias.get(sAlias);
138
100
  const oConnection = oAlias.getConnection();
139
- if (!aConnections.find(o => _compareConnectionData(o.getConnectionData(), oConnection.getConnectionData()))) {
140
- yield oConnection.connect();
141
- aConnections.push(oConnection);
142
- }
101
+ aConnections.push(oConnection);
143
102
  }
144
103
  }
145
104
  if (aConnections.length === 0) {
@@ -18,7 +18,6 @@ const commons_1 = require("./commons");
18
18
  const utils_1 = require("../utils");
19
19
  const chalk_1 = __importDefault(require("chalk"));
20
20
  const trm_commons_1 = require("trm-commons");
21
- const settings_1 = require("../settings");
22
21
  function content(commandArgs) {
23
22
  return __awaiter(this, void 0, void 0, function* () {
24
23
  trm_commons_1.Logger.loading(`Searching package "${commandArgs.package}"...`);
@@ -31,9 +30,9 @@ function content(commandArgs) {
31
30
  const packageContent = yield remotePackage.fetchRemoteContent(commandArgs.version, {
32
31
  tempDirPath: (0, utils_1.getTempFolder)(),
33
32
  r3transDirPath: commandArgs.r3transPath,
34
- useDocker: settings_1.Settings.getInstance().data.r3transDocker,
33
+ useDocker: utils_1.Context.getInstance().settings.r3transDocker,
35
34
  dockerOptions: {
36
- name: settings_1.Settings.getInstance().data.r3transDockerName
35
+ name: utils_1.Context.getInstance().settings.r3transDockerName
37
36
  }
38
37
  });
39
38
  if (!commandArgs.all) {
@@ -12,60 +12,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createAlias = createAlias;
13
13
  const systemAlias_1 = require("../systemAlias");
14
14
  const prompts_1 = require("./prompts");
15
- const utils_1 = require("../utils");
16
15
  const trm_commons_1 = require("trm-commons");
17
16
  function createAlias(commandArgs) {
18
17
  return __awaiter(this, void 0, void 0, function* () {
19
- const connectionArgs = yield (0, prompts_1.connect)({
18
+ const connection = yield (0, prompts_1.connect)({
20
19
  noSystemAlias: true,
21
20
  force: true
22
- }, false);
21
+ }, false, false);
22
+ systemAlias_1.SystemAlias.create(commandArgs.alias, connection.name, connection.getData());
23
23
  trm_commons_1.Logger.loading(`Connecting to "${commandArgs.alias}"...`);
24
- var alias;
25
- if (connectionArgs.type === utils_1.SystemConnectorType.RFC) {
26
- alias = systemAlias_1.SystemAlias.create(commandArgs.alias, connectionArgs.type, {
27
- ashost: connectionArgs.ashost,
28
- dest: connectionArgs.dest,
29
- sysnr: connectionArgs.sysnr,
30
- saprouter: connectionArgs.saprouter
31
- }, {
32
- client: connectionArgs.client,
33
- lang: connectionArgs.lang,
34
- passwd: connectionArgs.passwd,
35
- user: connectionArgs.user
36
- });
24
+ var connectionSuccess = true;
25
+ try {
26
+ yield connection.getSystemConnector().connect();
37
27
  }
38
- else if (connectionArgs.type === utils_1.SystemConnectorType.REST) {
39
- alias = systemAlias_1.SystemAlias.create(commandArgs.alias, connectionArgs.type, {
40
- endpoint: connectionArgs.endpoint,
41
- rfcdest: connectionArgs.forwardRfcDest
42
- }, {
43
- lang: connectionArgs.lang,
44
- passwd: connectionArgs.passwd,
45
- user: connectionArgs.user,
46
- client: connectionArgs.client
47
- });
28
+ catch (e) {
29
+ connectionSuccess = false;
30
+ throw e;
48
31
  }
49
- if (alias) {
50
- var connectionSuccess = true;
51
- try {
52
- yield alias.getConnection().connect();
32
+ finally {
33
+ if (connectionSuccess) {
34
+ trm_commons_1.Logger.success(`Alias "${commandArgs.alias}" created.`);
53
35
  }
54
- catch (e) {
55
- connectionSuccess = false;
56
- throw e;
36
+ else {
37
+ systemAlias_1.SystemAlias.delete(commandArgs.alias);
57
38
  }
58
- finally {
59
- if (connectionSuccess) {
60
- trm_commons_1.Logger.success(`Alias "${commandArgs.alias}" created.`);
61
- }
62
- else {
63
- systemAlias_1.SystemAlias.delete(commandArgs.alias);
64
- }
65
- }
66
- }
67
- else {
68
- throw new Error(`Alias "${commandArgs.alias}" couldn't be created.`);
69
39
  }
70
40
  });
71
41
  }
@@ -14,7 +14,6 @@ const trm_core_1 = require("trm-core");
14
14
  const utils_1 = require("../utils");
15
15
  const commons_1 = require("./commons");
16
16
  const trm_commons_1 = require("trm-commons");
17
- const settings_1 = require("../settings");
18
17
  const _parsePackageReplacementsArgument = (arg) => {
19
18
  if (arg) {
20
19
  try {
@@ -40,9 +39,9 @@ function _import(commandArgs) {
40
39
  r3transOptions: {
41
40
  tempDirPath: (0, utils_1.getTempFolder)(),
42
41
  r3transDirPath: commandArgs.r3transPath,
43
- useDocker: settings_1.Settings.getInstance().data.r3transDocker,
42
+ useDocker: utils_1.Context.getInstance().settings.r3transDocker,
44
43
  dockerOptions: {
45
- name: settings_1.Settings.getInstance().data.r3transDockerName
44
+ name: utils_1.Context.getInstance().settings.r3transDockerName
46
45
  }
47
46
  },
48
47
  noInquirer: commandArgs.noPrompts,
@@ -14,7 +14,6 @@ const trm_core_1 = require("trm-core");
14
14
  const utils_1 = require("../utils");
15
15
  const commons_1 = require("./commons");
16
16
  const trm_commons_1 = require("trm-commons");
17
- const settings_1 = require("../settings");
18
17
  const _parsePackageReplacementsArgument = (arg) => {
19
18
  if (arg) {
20
19
  try {
@@ -39,9 +38,9 @@ function install(commandArgs) {
39
38
  r3transOptions: {
40
39
  tempDirPath: (0, utils_1.getTempFolder)(),
41
40
  r3transDirPath: commandArgs.r3transPath,
42
- useDocker: settings_1.Settings.getInstance().data.r3transDocker,
41
+ useDocker: utils_1.Context.getInstance().settings.r3transDocker,
43
42
  dockerOptions: {
44
- name: settings_1.Settings.getInstance().data.r3transDockerName
43
+ name: utils_1.Context.getInstance().settings.r3transDockerName
45
44
  }
46
45
  },
47
46
  noInquirer: commandArgs.noPrompts,
@@ -1,2 +1,3 @@
1
1
  import { ConnectArguments } from "../arguments";
2
- export declare function connect(commandArgs: ConnectArguments, createAliasIfNotExist?: boolean, addNoConnection?: boolean): Promise<ConnectArguments>;
2
+ import { IConnect } from "trm-commons";
3
+ export declare function connect(commandArgs: ConnectArguments, createAliasIfNotExist?: boolean, addNoConnection?: boolean): Promise<IConnect>;