@ama-sdk/core 13.4.0-prerelease.24 → 13.4.0-prerelease.27

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/cjs/fwk/index.js CHANGED
@@ -13,6 +13,7 @@ _export_star(require("./logger"), exports);
13
13
  _export_star(require("./mocks/index"), exports);
14
14
  _export_star(require("./param-serialization"), exports);
15
15
  _export_star(require("./reviver"), exports);
16
+ _export_star(require("./server"), exports);
16
17
  function _export_star(from, to) {
17
18
  Object.keys(from).forEach(function(k) {
18
19
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "selectServerBasePath", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return selectServerBasePath;
9
+ }
10
+ });
11
+ function _array_like_to_array(arr, len) {
12
+ if (len == null || len > arr.length) len = arr.length;
13
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
14
+ return arr2;
15
+ }
16
+ function _array_with_holes(arr) {
17
+ if (Array.isArray(arr)) return arr;
18
+ }
19
+ function _iterable_to_array_limit(arr, i) {
20
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21
+ if (_i == null) return;
22
+ var _arr = [];
23
+ var _n = true;
24
+ var _d = false;
25
+ var _s, _e;
26
+ try {
27
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
28
+ _arr.push(_s.value);
29
+ if (i && _arr.length === i) break;
30
+ }
31
+ } catch (err) {
32
+ _d = true;
33
+ _e = err;
34
+ } finally{
35
+ try {
36
+ if (!_n && _i["return"] != null) _i["return"]();
37
+ } finally{
38
+ if (_d) throw _e;
39
+ }
40
+ }
41
+ return _arr;
42
+ }
43
+ function _non_iterable_rest() {
44
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
+ }
46
+ function _sliced_to_array(arr, i) {
47
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
48
+ }
49
+ function _unsupported_iterable_to_array(o, minLen) {
50
+ if (!o) return;
51
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
52
+ var n = Object.prototype.toString.call(o).slice(8, -1);
53
+ if (n === "Object" && o.constructor) n = o.constructor.name;
54
+ if (n === "Map" || n === "Set") return Array.from(n);
55
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
56
+ }
57
+ var selectServerBasePath = function(clientServerConfigurations, servers, logger) {
58
+ var basePath = clientServerConfigurations.basePath, server = clientServerConfigurations.server, defaultBasePath = clientServerConfigurations.defaultBasePath;
59
+ if (basePath) {
60
+ var _logger_debug;
61
+ logger === null || logger === void 0 ? void 0 : (_logger_debug = logger.debug) === null || _logger_debug === void 0 ? void 0 : _logger_debug.call(logger, 'Using basePath from client configuration');
62
+ return basePath;
63
+ }
64
+ if (!servers || servers.length === 0) {
65
+ var _logger_debug1;
66
+ logger === null || logger === void 0 ? void 0 : (_logger_debug1 = logger.debug) === null || _logger_debug1 === void 0 ? void 0 : _logger_debug1.call(logger, 'No server configuration provided and no server defined in the API, using default basePath "'.concat(defaultBasePath || '', '"'));
67
+ return defaultBasePath || '';
68
+ }
69
+ var matchingServer = servers === null || servers === void 0 ? void 0 : servers[(server === null || server === void 0 ? void 0 : server.index) || 0];
70
+ if (!matchingServer) {
71
+ var _logger_warn;
72
+ logger === null || logger === void 0 ? void 0 : (_logger_warn = logger.warn) === null || _logger_warn === void 0 ? void 0 : _logger_warn.call(logger, 'No server matching at index "'.concat((server === null || server === void 0 ? void 0 : server.index) || 0, '" has been found in the API, using the first server'));
73
+ matchingServer = servers[0];
74
+ }
75
+ return Object.entries(matchingServer.variables || {}).reduce(function(acc, param) {
76
+ var _param = _sliced_to_array(param, 2), variableName = _param[0], variable = _param[1];
77
+ var _server_variables;
78
+ var _server_variables_variableName;
79
+ var variableValue = (_server_variables_variableName = server === null || server === void 0 ? void 0 : (_server_variables = server.variables) === null || _server_variables === void 0 ? void 0 : _server_variables[variableName]) !== null && _server_variables_variableName !== void 0 ? _server_variables_variableName : variable.defaultValue;
80
+ if (variableValue === undefined) {
81
+ logger === null || logger === void 0 ? void 0 : logger.warn('No value provided for server variable "'.concat(variableName, '", using empty string as default'));
82
+ variableValue = '';
83
+ }
84
+ if (variable.enumValues && variable.enumValues.length > 0 && variableValue && !variable.enumValues.includes(variableValue)) {
85
+ logger === null || logger === void 0 ? void 0 : logger.warn('Value "'.concat(variableValue, '" provided for server variable "').concat(variableName, '" is not in the allowed enum [').concat(variable.enumValues.join(', '), "]") + ', using value "'.concat(variable.defaultValue || variable.enumValues[0], '" instead'));
86
+ variableValue = variable.defaultValue || variable.enumValues[0];
87
+ }
88
+ return acc.replaceAll("{".concat(variableName, "}"), variableValue);
89
+ }, matchingServer.url);
90
+ };
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ var _server = require("./server");
6
+ describe('selectServerBasePath', function() {
7
+ var mockLogger;
8
+ beforeEach(function() {
9
+ mockLogger = {
10
+ log: jest.fn(),
11
+ debug: jest.fn(),
12
+ info: jest.fn(),
13
+ warn: jest.fn(),
14
+ error: jest.fn()
15
+ };
16
+ });
17
+ describe('when clientServerConfigurations has basePath', function() {
18
+ it('should return the basePath from client configurations', function() {
19
+ var clientConfig = {
20
+ basePath: 'https://api.example.com/v1'
21
+ };
22
+ var result = (0, _server.selectServerBasePath)(clientConfig);
23
+ expect(result).toBe('https://api.example.com/v1');
24
+ });
25
+ it('should return the basePath from client configurations even when servers are provided', function() {
26
+ var clientConfig = {
27
+ basePath: 'https://api.example.com/v1'
28
+ };
29
+ var servers = [
30
+ {
31
+ url: 'https://other.example.com'
32
+ }
33
+ ];
34
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
35
+ expect(result).toBe('https://api.example.com/v1');
36
+ });
37
+ });
38
+ describe('when clientServerConfigurations has no basePath', function() {
39
+ it('should return the first server URL when servers are provided', function() {
40
+ var clientConfig = {};
41
+ var servers = [
42
+ {
43
+ url: 'https://server1.example.com'
44
+ },
45
+ {
46
+ url: 'https://server2.example.com'
47
+ }
48
+ ];
49
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
50
+ expect(result).toBe('https://server1.example.com');
51
+ });
52
+ it('should handle server with variables', function() {
53
+ var clientConfig = {};
54
+ var servers = [
55
+ {
56
+ url: 'https://{environment}.example.com/{version}',
57
+ variables: {
58
+ environment: {
59
+ defaultValue: 'api',
60
+ enumValues: [
61
+ 'api',
62
+ 'staging',
63
+ 'dev'
64
+ ]
65
+ },
66
+ version: {
67
+ defaultValue: 'v1'
68
+ }
69
+ }
70
+ }
71
+ ];
72
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
73
+ expect(result).toBe('https://api.example.com/v1');
74
+ });
75
+ it('should handle server with custom variable values', function() {
76
+ var clientConfig = {};
77
+ var servers = [
78
+ {
79
+ url: 'https://{environment}.example.com/{version}',
80
+ variables: {
81
+ environment: {
82
+ defaultValue: 'api',
83
+ enumValues: [
84
+ 'api',
85
+ 'staging',
86
+ 'dev'
87
+ ]
88
+ },
89
+ version: {
90
+ defaultValue: 'v1'
91
+ }
92
+ }
93
+ }
94
+ ];
95
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
96
+ expect(result).toBe('https://api.example.com/v1');
97
+ });
98
+ it('should return empty string when no servers are provided', function() {
99
+ var clientConfig = {};
100
+ var result = (0, _server.selectServerBasePath)(clientConfig);
101
+ expect(result).toBe('');
102
+ });
103
+ it('should return empty string when servers array is empty', function() {
104
+ var clientConfig = {};
105
+ var servers = [];
106
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
107
+ expect(result).toBe('');
108
+ });
109
+ it('should default the basePath when no server available in the specification', function() {
110
+ var clientConfig = {
111
+ server: {
112
+ index: 1
113
+ },
114
+ defaultBasePath: 'https://api.example.com/v1'
115
+ };
116
+ var servers = [];
117
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
118
+ expect(result).toBe('https://api.example.com/v1');
119
+ });
120
+ });
121
+ describe('error handling', function() {
122
+ it('should log warnings when server variables are missing defaults', function() {
123
+ var clientConfig = {};
124
+ var servers = [
125
+ {
126
+ url: 'https://{environment}.example.com',
127
+ variables: {
128
+ environment: {
129
+ enumValues: [
130
+ 'api',
131
+ 'staging'
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ ];
137
+ (0, _server.selectServerBasePath)(clientConfig, servers, mockLogger);
138
+ expect(mockLogger.warn).toHaveBeenCalledWith('No value provided for server variable "environment", using empty string as default');
139
+ });
140
+ it('should log warnings when server variable value is not in enum', function() {
141
+ var clientConfig = {
142
+ server: {
143
+ variables: {
144
+ environment: 'prod'
145
+ }
146
+ }
147
+ };
148
+ var servers = [
149
+ {
150
+ url: 'https://{environment}.example.com',
151
+ variables: {
152
+ environment: {
153
+ defaultValue: 'production',
154
+ enumValues: [
155
+ 'development',
156
+ 'staging',
157
+ 'production'
158
+ ]
159
+ }
160
+ }
161
+ }
162
+ ];
163
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers, mockLogger);
164
+ expect(mockLogger.warn).toHaveBeenCalledWith('Value "prod" provided for server variable "environment" is not in the allowed enum [development, staging, production], using value "production" instead');
165
+ expect(result).toBe('https://production.example.com');
166
+ });
167
+ it('should log warning when no matching server index is found', function() {
168
+ var clientConfig = {
169
+ server: {
170
+ index: 5
171
+ }
172
+ };
173
+ var servers = [
174
+ {
175
+ url: 'https://server1.example.com'
176
+ },
177
+ {
178
+ url: 'https://server2.example.com'
179
+ }
180
+ ];
181
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers, mockLogger);
182
+ expect(mockLogger.warn).toHaveBeenCalledWith('No server matching at index "5" has been found in the API, using the first server');
183
+ expect(result).toBe('https://server1.example.com');
184
+ });
185
+ });
186
+ describe('with logger', function() {
187
+ it('should log debug information about server selection', function() {
188
+ var clientConfig = {
189
+ basePath: 'https://api.example.com/v1'
190
+ };
191
+ (0, _server.selectServerBasePath)(clientConfig, undefined, mockLogger);
192
+ expect(mockLogger.debug).toHaveBeenCalledWith('Using basePath from client configuration');
193
+ });
194
+ it('should log when using fallback to default base url', function() {
195
+ var clientConfig = {
196
+ defaultBasePath: 'https://fallback.example.com'
197
+ };
198
+ var servers = [];
199
+ (0, _server.selectServerBasePath)(clientConfig, servers, mockLogger);
200
+ expect(mockLogger.debug).toHaveBeenCalledWith('No server configuration provided and no server defined in the API, using default basePath "https://fallback.example.com"');
201
+ });
202
+ });
203
+ describe('edge cases', function() {
204
+ it('should handle servers with empty URL', function() {
205
+ var clientConfig = {};
206
+ var servers = [
207
+ {
208
+ url: ''
209
+ },
210
+ {
211
+ url: 'https://valid.example.com'
212
+ }
213
+ ];
214
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
215
+ expect(result).toBe('');
216
+ });
217
+ it('should handle basePath with trailing slash normalization', function() {
218
+ var clientConfig = {
219
+ basePath: 'https://api.example.com/v1/'
220
+ };
221
+ var result = (0, _server.selectServerBasePath)(clientConfig);
222
+ // Depends on implementation - might normalize trailing slash
223
+ expect(result).toMatch(/^https:\/\/api\.example\.com\/v1\/?$/);
224
+ });
225
+ it('should handle complex server variable substitution', function() {
226
+ var clientConfig = {};
227
+ var servers = [
228
+ {
229
+ url: '{protocol}://{host}:{port}/{basePath}',
230
+ variables: {
231
+ protocol: {
232
+ defaultValue: 'https'
233
+ },
234
+ host: {
235
+ defaultValue: 'api.example.com'
236
+ },
237
+ port: {
238
+ defaultValue: '443'
239
+ },
240
+ basePath: {
241
+ defaultValue: 'v1'
242
+ }
243
+ }
244
+ }
245
+ ];
246
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
247
+ expect(result).toBe('https://api.example.com:443/v1');
248
+ });
249
+ it('should handle server variables with enum validation', function() {
250
+ var clientConfig = {};
251
+ var servers = [
252
+ {
253
+ url: 'https://{environment}.example.com',
254
+ variables: {
255
+ environment: {
256
+ defaultValue: 'production',
257
+ enumValues: [
258
+ 'development',
259
+ 'staging',
260
+ 'production'
261
+ ]
262
+ }
263
+ }
264
+ }
265
+ ];
266
+ var result = (0, _server.selectServerBasePath)(clientConfig, servers);
267
+ expect(result).toBe('https://production.example.com');
268
+ });
269
+ });
270
+ });
@@ -9,3 +9,4 @@ export * from './logger';
9
9
  export * from './mocks/index';
10
10
  export * from './param-serialization';
11
11
  export * from './reviver';
12
+ export * from './server';
@@ -0,0 +1,86 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _iterable_to_array_limit(arr, i) {
10
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11
+ if (_i == null) return;
12
+ var _arr = [];
13
+ var _n = true;
14
+ var _d = false;
15
+ var _s, _e;
16
+ try {
17
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
18
+ _arr.push(_s.value);
19
+ if (i && _arr.length === i) break;
20
+ }
21
+ } catch (err) {
22
+ _d = true;
23
+ _e = err;
24
+ } finally{
25
+ try {
26
+ if (!_n && _i["return"] != null) _i["return"]();
27
+ } finally{
28
+ if (_d) throw _e;
29
+ }
30
+ }
31
+ return _arr;
32
+ }
33
+ function _non_iterable_rest() {
34
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _sliced_to_array(arr, i) {
37
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
38
+ }
39
+ function _unsupported_iterable_to_array(o, minLen) {
40
+ if (!o) return;
41
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor) n = o.constructor.name;
44
+ if (n === "Map" || n === "Set") return Array.from(n);
45
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
+ }
47
+ /**
48
+ * Select the server URL to use based on the provided basePathServer configuration
49
+ * @param clientServerConfigurations basePath and server configuration to use for the request
50
+ * @param servers List of servers defined in the specification
51
+ * @param logger Logger to use to report messages
52
+ * @returns The selected server URL
53
+ */ export var selectServerBasePath = function(clientServerConfigurations, servers, logger) {
54
+ var basePath = clientServerConfigurations.basePath, server = clientServerConfigurations.server, defaultBasePath = clientServerConfigurations.defaultBasePath;
55
+ if (basePath) {
56
+ var _logger_debug;
57
+ logger === null || logger === void 0 ? void 0 : (_logger_debug = logger.debug) === null || _logger_debug === void 0 ? void 0 : _logger_debug.call(logger, 'Using basePath from client configuration');
58
+ return basePath;
59
+ }
60
+ if (!servers || servers.length === 0) {
61
+ var _logger_debug1;
62
+ logger === null || logger === void 0 ? void 0 : (_logger_debug1 = logger.debug) === null || _logger_debug1 === void 0 ? void 0 : _logger_debug1.call(logger, 'No server configuration provided and no server defined in the API, using default basePath "'.concat(defaultBasePath || '', '"'));
63
+ return defaultBasePath || '';
64
+ }
65
+ var matchingServer = servers === null || servers === void 0 ? void 0 : servers[(server === null || server === void 0 ? void 0 : server.index) || 0];
66
+ if (!matchingServer) {
67
+ var _logger_warn;
68
+ logger === null || logger === void 0 ? void 0 : (_logger_warn = logger.warn) === null || _logger_warn === void 0 ? void 0 : _logger_warn.call(logger, 'No server matching at index "'.concat((server === null || server === void 0 ? void 0 : server.index) || 0, '" has been found in the API, using the first server'));
69
+ matchingServer = servers[0];
70
+ }
71
+ return Object.entries(matchingServer.variables || {}).reduce(function(acc, param) {
72
+ var _param = _sliced_to_array(param, 2), variableName = _param[0], variable = _param[1];
73
+ var _server_variables;
74
+ var _server_variables_variableName;
75
+ var variableValue = (_server_variables_variableName = server === null || server === void 0 ? void 0 : (_server_variables = server.variables) === null || _server_variables === void 0 ? void 0 : _server_variables[variableName]) !== null && _server_variables_variableName !== void 0 ? _server_variables_variableName : variable.defaultValue;
76
+ if (variableValue === undefined) {
77
+ logger === null || logger === void 0 ? void 0 : logger.warn('No value provided for server variable "'.concat(variableName, '", using empty string as default'));
78
+ variableValue = '';
79
+ }
80
+ if (variable.enumValues && variable.enumValues.length > 0 && variableValue && !variable.enumValues.includes(variableValue)) {
81
+ logger === null || logger === void 0 ? void 0 : logger.warn('Value "'.concat(variableValue, '" provided for server variable "').concat(variableName, '" is not in the allowed enum [').concat(variable.enumValues.join(', '), "]") + ', using value "'.concat(variable.defaultValue || variable.enumValues[0], '" instead'));
82
+ variableValue = variable.defaultValue || variable.enumValues[0];
83
+ }
84
+ return acc.replaceAll("{".concat(variableName, "}"), variableValue);
85
+ }, matchingServer.url);
86
+ };
@@ -0,0 +1,266 @@
1
+ import { selectServerBasePath } from './server';
2
+ describe('selectServerBasePath', function() {
3
+ var mockLogger;
4
+ beforeEach(function() {
5
+ mockLogger = {
6
+ log: jest.fn(),
7
+ debug: jest.fn(),
8
+ info: jest.fn(),
9
+ warn: jest.fn(),
10
+ error: jest.fn()
11
+ };
12
+ });
13
+ describe('when clientServerConfigurations has basePath', function() {
14
+ it('should return the basePath from client configurations', function() {
15
+ var clientConfig = {
16
+ basePath: 'https://api.example.com/v1'
17
+ };
18
+ var result = selectServerBasePath(clientConfig);
19
+ expect(result).toBe('https://api.example.com/v1');
20
+ });
21
+ it('should return the basePath from client configurations even when servers are provided', function() {
22
+ var clientConfig = {
23
+ basePath: 'https://api.example.com/v1'
24
+ };
25
+ var servers = [
26
+ {
27
+ url: 'https://other.example.com'
28
+ }
29
+ ];
30
+ var result = selectServerBasePath(clientConfig, servers);
31
+ expect(result).toBe('https://api.example.com/v1');
32
+ });
33
+ });
34
+ describe('when clientServerConfigurations has no basePath', function() {
35
+ it('should return the first server URL when servers are provided', function() {
36
+ var clientConfig = {};
37
+ var servers = [
38
+ {
39
+ url: 'https://server1.example.com'
40
+ },
41
+ {
42
+ url: 'https://server2.example.com'
43
+ }
44
+ ];
45
+ var result = selectServerBasePath(clientConfig, servers);
46
+ expect(result).toBe('https://server1.example.com');
47
+ });
48
+ it('should handle server with variables', function() {
49
+ var clientConfig = {};
50
+ var servers = [
51
+ {
52
+ url: 'https://{environment}.example.com/{version}',
53
+ variables: {
54
+ environment: {
55
+ defaultValue: 'api',
56
+ enumValues: [
57
+ 'api',
58
+ 'staging',
59
+ 'dev'
60
+ ]
61
+ },
62
+ version: {
63
+ defaultValue: 'v1'
64
+ }
65
+ }
66
+ }
67
+ ];
68
+ var result = selectServerBasePath(clientConfig, servers);
69
+ expect(result).toBe('https://api.example.com/v1');
70
+ });
71
+ it('should handle server with custom variable values', function() {
72
+ var clientConfig = {};
73
+ var servers = [
74
+ {
75
+ url: 'https://{environment}.example.com/{version}',
76
+ variables: {
77
+ environment: {
78
+ defaultValue: 'api',
79
+ enumValues: [
80
+ 'api',
81
+ 'staging',
82
+ 'dev'
83
+ ]
84
+ },
85
+ version: {
86
+ defaultValue: 'v1'
87
+ }
88
+ }
89
+ }
90
+ ];
91
+ var result = selectServerBasePath(clientConfig, servers);
92
+ expect(result).toBe('https://api.example.com/v1');
93
+ });
94
+ it('should return empty string when no servers are provided', function() {
95
+ var clientConfig = {};
96
+ var result = selectServerBasePath(clientConfig);
97
+ expect(result).toBe('');
98
+ });
99
+ it('should return empty string when servers array is empty', function() {
100
+ var clientConfig = {};
101
+ var servers = [];
102
+ var result = selectServerBasePath(clientConfig, servers);
103
+ expect(result).toBe('');
104
+ });
105
+ it('should default the basePath when no server available in the specification', function() {
106
+ var clientConfig = {
107
+ server: {
108
+ index: 1
109
+ },
110
+ defaultBasePath: 'https://api.example.com/v1'
111
+ };
112
+ var servers = [];
113
+ var result = selectServerBasePath(clientConfig, servers);
114
+ expect(result).toBe('https://api.example.com/v1');
115
+ });
116
+ });
117
+ describe('error handling', function() {
118
+ it('should log warnings when server variables are missing defaults', function() {
119
+ var clientConfig = {};
120
+ var servers = [
121
+ {
122
+ url: 'https://{environment}.example.com',
123
+ variables: {
124
+ environment: {
125
+ enumValues: [
126
+ 'api',
127
+ 'staging'
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ ];
133
+ selectServerBasePath(clientConfig, servers, mockLogger);
134
+ expect(mockLogger.warn).toHaveBeenCalledWith('No value provided for server variable "environment", using empty string as default');
135
+ });
136
+ it('should log warnings when server variable value is not in enum', function() {
137
+ var clientConfig = {
138
+ server: {
139
+ variables: {
140
+ environment: 'prod'
141
+ }
142
+ }
143
+ };
144
+ var servers = [
145
+ {
146
+ url: 'https://{environment}.example.com',
147
+ variables: {
148
+ environment: {
149
+ defaultValue: 'production',
150
+ enumValues: [
151
+ 'development',
152
+ 'staging',
153
+ 'production'
154
+ ]
155
+ }
156
+ }
157
+ }
158
+ ];
159
+ var result = selectServerBasePath(clientConfig, servers, mockLogger);
160
+ expect(mockLogger.warn).toHaveBeenCalledWith('Value "prod" provided for server variable "environment" is not in the allowed enum [development, staging, production], using value "production" instead');
161
+ expect(result).toBe('https://production.example.com');
162
+ });
163
+ it('should log warning when no matching server index is found', function() {
164
+ var clientConfig = {
165
+ server: {
166
+ index: 5
167
+ }
168
+ };
169
+ var servers = [
170
+ {
171
+ url: 'https://server1.example.com'
172
+ },
173
+ {
174
+ url: 'https://server2.example.com'
175
+ }
176
+ ];
177
+ var result = selectServerBasePath(clientConfig, servers, mockLogger);
178
+ expect(mockLogger.warn).toHaveBeenCalledWith('No server matching at index "5" has been found in the API, using the first server');
179
+ expect(result).toBe('https://server1.example.com');
180
+ });
181
+ });
182
+ describe('with logger', function() {
183
+ it('should log debug information about server selection', function() {
184
+ var clientConfig = {
185
+ basePath: 'https://api.example.com/v1'
186
+ };
187
+ selectServerBasePath(clientConfig, undefined, mockLogger);
188
+ expect(mockLogger.debug).toHaveBeenCalledWith('Using basePath from client configuration');
189
+ });
190
+ it('should log when using fallback to default base url', function() {
191
+ var clientConfig = {
192
+ defaultBasePath: 'https://fallback.example.com'
193
+ };
194
+ var servers = [];
195
+ selectServerBasePath(clientConfig, servers, mockLogger);
196
+ expect(mockLogger.debug).toHaveBeenCalledWith('No server configuration provided and no server defined in the API, using default basePath "https://fallback.example.com"');
197
+ });
198
+ });
199
+ describe('edge cases', function() {
200
+ it('should handle servers with empty URL', function() {
201
+ var clientConfig = {};
202
+ var servers = [
203
+ {
204
+ url: ''
205
+ },
206
+ {
207
+ url: 'https://valid.example.com'
208
+ }
209
+ ];
210
+ var result = selectServerBasePath(clientConfig, servers);
211
+ expect(result).toBe('');
212
+ });
213
+ it('should handle basePath with trailing slash normalization', function() {
214
+ var clientConfig = {
215
+ basePath: 'https://api.example.com/v1/'
216
+ };
217
+ var result = selectServerBasePath(clientConfig);
218
+ // Depends on implementation - might normalize trailing slash
219
+ expect(result).toMatch(/^https:\/\/api\.example\.com\/v1\/?$/);
220
+ });
221
+ it('should handle complex server variable substitution', function() {
222
+ var clientConfig = {};
223
+ var servers = [
224
+ {
225
+ url: '{protocol}://{host}:{port}/{basePath}',
226
+ variables: {
227
+ protocol: {
228
+ defaultValue: 'https'
229
+ },
230
+ host: {
231
+ defaultValue: 'api.example.com'
232
+ },
233
+ port: {
234
+ defaultValue: '443'
235
+ },
236
+ basePath: {
237
+ defaultValue: 'v1'
238
+ }
239
+ }
240
+ }
241
+ ];
242
+ var result = selectServerBasePath(clientConfig, servers);
243
+ expect(result).toBe('https://api.example.com:443/v1');
244
+ });
245
+ it('should handle server variables with enum validation', function() {
246
+ var clientConfig = {};
247
+ var servers = [
248
+ {
249
+ url: 'https://{environment}.example.com',
250
+ variables: {
251
+ environment: {
252
+ defaultValue: 'production',
253
+ enumValues: [
254
+ 'development',
255
+ 'staging',
256
+ 'production'
257
+ ]
258
+ }
259
+ }
260
+ }
261
+ ];
262
+ var result = selectServerBasePath(clientConfig, servers);
263
+ expect(result).toBe('https://production.example.com');
264
+ });
265
+ });
266
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/core",
3
- "version": "13.4.0-prerelease.24",
3
+ "version": "13.4.0-prerelease.27",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,7 +43,7 @@
43
43
  "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
44
44
  },
45
45
  "dependencies": {
46
- "@o3r/schematics": "~13.4.0-prerelease.24",
46
+ "@o3r/schematics": "~13.4.0-prerelease.27",
47
47
  "@swc/helpers": "~0.5.0",
48
48
  "ts-node": "~10.9.2",
49
49
  "tslib": "^2.6.2",
@@ -52,7 +52,7 @@
52
52
  "peerDependencies": {
53
53
  "@angular-devkit/schematics": "^20.0.0",
54
54
  "@angular/cli": "^20.0.0",
55
- "@o3r/schematics": "~13.4.0-prerelease.24",
55
+ "@o3r/schematics": "~13.4.0-prerelease.27",
56
56
  "@schematics/angular": "^20.0.0",
57
57
  "typescript": "^5.9.0"
58
58
  },
@@ -81,9 +81,9 @@
81
81
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
82
82
  "@nx/eslint-plugin": "~21.6.0",
83
83
  "@nx/jest": "~21.6.0",
84
- "@o3r/build-helpers": "~13.4.0-prerelease.24",
85
- "@o3r/eslint-plugin": "~13.4.0-prerelease.24",
86
- "@o3r/test-helpers": "~13.4.0-prerelease.24",
84
+ "@o3r/build-helpers": "~13.4.0-prerelease.27",
85
+ "@o3r/eslint-plugin": "~13.4.0-prerelease.27",
86
+ "@o3r/test-helpers": "~13.4.0-prerelease.27",
87
87
  "@schematics/angular": "~20.3.0",
88
88
  "@stylistic/eslint-plugin": "~5.5.0",
89
89
  "@swc/cli": "~0.7.7",
@@ -1,10 +1,31 @@
1
1
  import { ReplyPlugin, type RequestOptions, RequestPlugin } from '../../plugins';
2
2
  import type { Logger } from '../logger';
3
3
  import type { ParamSerialization, SupportedParamInterface } from '../param-serialization';
4
+ /** Server configuration to use for the request */
5
+ export interface ServerConfiguration {
6
+ /**
7
+ * Index of the server in the list
8
+ * The first server will be used if not specified
9
+ */
10
+ index?: number;
11
+ /** Variables used in the server URL defined in the specification */
12
+ variables?: Record<string, string>;
13
+ }
14
+ /** Base path and server configuration and selection to use for the request */
15
+ export interface BasePathServer {
16
+ /**
17
+ * URL of the call to process (without the query parameters)
18
+ * Note: If both {@link basePath} and {@link server} are provided, server will be ignored
19
+ * @example 'https://api.example.com/v1/resource'
20
+ */
21
+ basePath?: string;
22
+ /** Default basePath to use if no {@link basePath} is provided, no server are matching the API server list and no default server has been specified in the specification */
23
+ defaultBasePath?: string;
24
+ /** basePath server configuration to use for the request */
25
+ server?: ServerConfiguration;
26
+ }
4
27
  /** Interface of the constructor configuration object */
5
- export interface BaseApiClientOptions {
6
- /** API Gateway base path (when targeting a proxy or middleware) */
7
- basePath: string;
28
+ export interface BaseApiClientOptions extends BasePathServer {
8
29
  /** List of plugins to apply on the request before calling the API */
9
30
  requestPlugins: RequestPlugin[] | ((originalRequestOpts: RequestOptions) => RequestPlugin[] | Promise<RequestPlugin[]>);
10
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"base-api-constructor.d.ts","sourceRoot":"","sources":["../../../../src/fwk/core/base-api-constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,cAAc,EACnB,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,MAAM,EACP,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,wDAAwD;AACxD,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAA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AAmB,CAAC,CAAC,CAAC,SAAS,uBAAuB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,sBAAsB,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB;KAAE,GAAG;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;KAAE,CAAC;CACvK;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,oBAAoB,CAAC;CACxE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,CAE7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"base-api-constructor.js","sourceRoot":"","sources":["../../../../src/fwk/core/base-api-constructor.ts"],"names":[],"mappings":"AA6CA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAW;IAC7C,OAAO,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AACjF,CAAC"}
1
+ {"version":3,"file":"base-api-constructor.js","sourceRoot":"","sources":["../../../../src/fwk/core/base-api-constructor.ts"],"names":[],"mappings":"AAoEA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAW;IAC7C,OAAO,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AACjF,CAAC"}
@@ -9,4 +9,5 @@ export * from './logger';
9
9
  export * from './mocks/index';
10
10
  export * from './param-serialization';
11
11
  export * from './reviver';
12
+ export * from './server';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/src/fwk/index.js CHANGED
@@ -9,4 +9,5 @@ export * from './logger';
9
9
  export * from './mocks/index';
10
10
  export * from './param-serialization';
11
11
  export * from './reviver';
12
+ export * from './server';
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { BasePathServer } from './core';
2
+ import type { Logger } from './logger';
3
+ /** Variable used in server URL */
4
+ export interface ServerVariable {
5
+ /** Variable possible values */
6
+ enumValues?: string[];
7
+ /** Description of the variable */
8
+ description?: string;
9
+ /** Default value */
10
+ defaultValue?: string;
11
+ }
12
+ /** Server as described by the OpenAPI specification */
13
+ export interface Server {
14
+ /** URL of the server */
15
+ url: string;
16
+ /** Description of the server */
17
+ description?: string;
18
+ /** Variable which can be used in the URL */
19
+ variables?: Record<string, ServerVariable>;
20
+ }
21
+ /**
22
+ * Select the server URL to use based on the provided basePathServer configuration
23
+ * @param clientServerConfigurations basePath and server configuration to use for the request
24
+ * @param servers List of servers defined in the specification
25
+ * @param logger Logger to use to report messages
26
+ * @returns The selected server URL
27
+ */
28
+ export declare const selectServerBasePath: (clientServerConfigurations: BasePathServer, servers?: Server[], logger?: Logger) => string;
29
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/fwk/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EACV,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,uDAAuD;AACvD,MAAM,WAAW,MAAM;IACrB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,4BAA4B,cAAc,EAAE,UAAU,MAAM,EAAE,EAAE,SAAS,MAAM,KAAG,MAgCtH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Select the server URL to use based on the provided basePathServer configuration
3
+ * @param clientServerConfigurations basePath and server configuration to use for the request
4
+ * @param servers List of servers defined in the specification
5
+ * @param logger Logger to use to report messages
6
+ * @returns The selected server URL
7
+ */
8
+ export const selectServerBasePath = (clientServerConfigurations, servers, logger) => {
9
+ const { basePath, server, defaultBasePath } = clientServerConfigurations;
10
+ if (basePath) {
11
+ logger?.debug?.('Using basePath from client configuration');
12
+ return basePath;
13
+ }
14
+ if (!servers || servers.length === 0) {
15
+ logger?.debug?.(`No server configuration provided and no server defined in the API, using default basePath "${defaultBasePath || ''}"`);
16
+ return defaultBasePath || '';
17
+ }
18
+ let matchingServer = servers?.[server?.index || 0];
19
+ if (!matchingServer) {
20
+ logger?.warn?.(`No server matching at index "${server?.index || 0}" has been found in the API, using the first server`);
21
+ matchingServer = servers[0];
22
+ }
23
+ return Object.entries(matchingServer.variables || {})
24
+ .reduce((acc, [variableName, variable]) => {
25
+ let variableValue = server?.variables?.[variableName] ?? variable.defaultValue;
26
+ if (variableValue === undefined) {
27
+ logger?.warn(`No value provided for server variable "${variableName}", using empty string as default`);
28
+ variableValue = '';
29
+ }
30
+ if (variable.enumValues && variable.enumValues.length > 0 && variableValue && !variable.enumValues.includes(variableValue)) {
31
+ logger?.warn(`Value "${variableValue}" provided for server variable "${variableName}" is not in the allowed enum [${variable.enumValues.join(', ')}]`
32
+ + `, using value "${variable.defaultValue || variable.enumValues[0]}" instead`);
33
+ variableValue = variable.defaultValue || variable.enumValues[0];
34
+ }
35
+ return acc.replaceAll(`{${variableName}}`, variableValue);
36
+ }, matchingServer.url);
37
+ };
38
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/fwk/server.ts"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,0BAA0C,EAAE,OAAkB,EAAE,MAAe,EAAU,EAAE;IAC9H,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,0BAA0B,CAAC;IACzE,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,EAAE,KAAK,EAAE,CAAC,0CAA0C,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,KAAK,EAAE,CAAC,8FAA8F,eAAe,IAAI,EAAE,GAAG,CAAC,CAAC;QACxI,OAAO,eAAe,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,IAAI,cAAc,GAAG,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,EAAE,IAAI,EAAE,CAAC,gCAAgC,MAAM,EAAE,KAAK,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACxH,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,IAAI,EAAE,CAAC;SAClD,MAAM,C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