@mimik/local 5.2.2 → 6.0.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/README.md +5 -2
- package/index.js +18 -13
- package/lib/common.js +20 -6
- package/lib/rp-axios-wrapper.js +42 -26
- package/lib/tasks.js +97 -61
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -83,8 +83,11 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
|
|
|
83
83
|
- for `key.json`:
|
|
84
84
|
``` javascript
|
|
85
85
|
{
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
"gitbub": {
|
|
87
|
+
"username": "username to access the bitbucket account",
|
|
88
|
+
"password": "password to access the bitbucket account"
|
|
89
|
+
},
|
|
90
|
+
"swaggerhub": "key to access private API on swaggerhub"
|
|
88
91
|
}
|
|
89
92
|
```
|
|
90
93
|
- for `locationConfig.json`:
|
package/index.js
CHANGED
|
@@ -48,6 +48,8 @@ colors.setTheme({
|
|
|
48
48
|
|
|
49
49
|
const INSTALL = 'install';
|
|
50
50
|
|
|
51
|
+
const getBasePath = (apiDef) => apiDef.basePath || apiDef.servers[0].url;
|
|
52
|
+
|
|
51
53
|
/**
|
|
52
54
|
* @module local
|
|
53
55
|
* @example
|
|
@@ -135,8 +137,11 @@ const INSTALL = 'install';
|
|
|
135
137
|
* - for `key.json`:
|
|
136
138
|
* ``` javascript
|
|
137
139
|
* {
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
+
* "gitbub": {
|
|
141
|
+
* "username": "username to access the bitbucket account",
|
|
142
|
+
* "password": "password to access the bitbucket account"
|
|
143
|
+
* },
|
|
144
|
+
* "swaggerhub": "key to access private API on swaggerhub"
|
|
140
145
|
* }
|
|
141
146
|
* ```
|
|
142
147
|
* - for `locationConfig.json`:
|
|
@@ -198,14 +203,14 @@ const mSTInit = (confType) => {
|
|
|
198
203
|
const config = init(regType, false, true);
|
|
199
204
|
const start = startSetup(config, startConfig);
|
|
200
205
|
|
|
201
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile
|
|
202
|
-
.then((
|
|
206
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
207
|
+
.then((apiDefinition) => {
|
|
203
208
|
console.log('- mST base url: ' + config.mSTBaseUrl.info);
|
|
204
209
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
205
210
|
console.log('- mST config: ' + JSON.stringify(config.mST, null, 2).info);
|
|
206
211
|
if (confType === TEST) {
|
|
207
212
|
start.CUSTOMER_NAME = SYSTEM_NAME;
|
|
208
|
-
start.BASE_PATH =
|
|
213
|
+
start.BASE_PATH = getBasePath(apiDefinition);
|
|
209
214
|
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, 2), type: 'JSON file' };
|
|
210
215
|
}
|
|
211
216
|
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
@@ -225,8 +230,8 @@ const mITInit = (confType) => {
|
|
|
225
230
|
let start = startSetup(config, startConfig);
|
|
226
231
|
let authorization;
|
|
227
232
|
|
|
228
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile
|
|
229
|
-
.then((
|
|
233
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
234
|
+
.then((apiDefinition) => {
|
|
230
235
|
console.log('- mST base url: ' + `${mSTBaseUrl}`.info);
|
|
231
236
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
232
237
|
if (startConfig.standAlone === 'yes') {
|
|
@@ -235,7 +240,7 @@ const mITInit = (confType) => {
|
|
|
235
240
|
if (confType === TEST) {
|
|
236
241
|
start.CUSTOMER_NAME = SYSTEM_NAME;
|
|
237
242
|
start.CUSTOMER_CODE = DUMMY_CUSTOMER_CODE;
|
|
238
|
-
start.BASE_PATH =
|
|
243
|
+
start.BASE_PATH = getBasePath(apiDefinition);
|
|
239
244
|
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, 2), type: 'JSON file' };
|
|
240
245
|
}
|
|
241
246
|
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
@@ -262,7 +267,7 @@ const mITInit = (confType) => {
|
|
|
262
267
|
if (confType === TEST) {
|
|
263
268
|
start.CUSTOMER_NAME = customer.name;
|
|
264
269
|
start.CUSTOMER_CODE = customer.code;
|
|
265
|
-
start.BASE_PATH =
|
|
270
|
+
start.BASE_PATH = getBasePath(apiDefinition);
|
|
266
271
|
start.MST_TOKEN = authorization;
|
|
267
272
|
start.ADMIN_TOKEN = adminToken;
|
|
268
273
|
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, 2), type: 'JSON file' };
|
|
@@ -292,8 +297,8 @@ const serverInit = (confType) => {
|
|
|
292
297
|
let start = startSetup(config, startConfig);
|
|
293
298
|
let authorization;
|
|
294
299
|
|
|
295
|
-
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile
|
|
296
|
-
.then((
|
|
300
|
+
getAPI(start.SWAGGER_FILE_DIRECTORY || DEFAULT_DIRECTORY, config.pack.swaggerFile, config.key)
|
|
301
|
+
.then((apiDefinition) => {
|
|
297
302
|
console.log('- mST base url: ' + `${mSTBaseUrl}`.info);
|
|
298
303
|
console.log('- mIT base url: ' + config.MITBaseUrl.info);
|
|
299
304
|
if (standAlone || !isMSTSet) {
|
|
@@ -302,7 +307,7 @@ const serverInit = (confType) => {
|
|
|
302
307
|
if (confType === TEST) {
|
|
303
308
|
start.CUSTOMER_NAME = customer.name;
|
|
304
309
|
start.CUSTOMER_CODE = DUMMY_CUSTOMER_CODE;
|
|
305
|
-
start.BASE_PATH =
|
|
310
|
+
start.BASE_PATH = getBasePath(apiDefinition);
|
|
306
311
|
return { file: testJsonFile, content: JSON.stringify(start2env(start), null, 2), type: 'JSON file' };
|
|
307
312
|
}
|
|
308
313
|
return { file: shellFile, content: start2shell(start), type: 'shell script' };
|
|
@@ -333,7 +338,7 @@ const serverInit = (confType) => {
|
|
|
333
338
|
if (confType === TEST) {
|
|
334
339
|
start.CUSTOMER_NAME = customer.name;
|
|
335
340
|
start.CUSTOMER_CODE = customer.code;
|
|
336
|
-
start.BASE_PATH =
|
|
341
|
+
start.BASE_PATH = getBasePath(apiDefinition);
|
|
337
342
|
start.MST_TOKEN = authorization;
|
|
338
343
|
start.ADMIN_TOKEN = adminToken;
|
|
339
344
|
const testResponse = { file: testJsonFile, content: JSON.stringify(start2env(start), null, 2), type: 'JSON file' };
|
package/lib/common.js
CHANGED
|
@@ -9,12 +9,17 @@ const locationFile = '../locationConfig.json';
|
|
|
9
9
|
const keyFile = '../key.json';
|
|
10
10
|
const customerConfigFile = '../customerConfig.json';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const API_PROVIDER_BITBUCKET = 'https://api.bitbucket.org/2.0/repositories';
|
|
13
|
+
const API_PROVIDER_SWAGGERHUB = 'https://api.swaggerhub.com/apis';
|
|
13
14
|
const API_SOURCE = '/src';
|
|
14
15
|
const SWAGGER = 'swagger';
|
|
15
|
-
const
|
|
16
|
-
const
|
|
16
|
+
const EXTENSION_YML = '.yml';
|
|
17
|
+
const EXTENSION_JSON = '.json';
|
|
18
|
+
const POSTFIX = `${SWAGGER}${EXTENSION_JSON}`;
|
|
17
19
|
const DEFAULT_DIRECTORY = './api';
|
|
20
|
+
const SWAGGERHUB = 'swaggerhub';
|
|
21
|
+
const BITBUCKET = 'bitbucket';
|
|
22
|
+
const RESOLVED = 'resolved=true';
|
|
18
23
|
|
|
19
24
|
const AWS_S3 = 'awsS3';
|
|
20
25
|
const AWS_KINESIS = 'awsKinesis';
|
|
@@ -45,6 +50,10 @@ const LITERAL = true;
|
|
|
45
50
|
const IGNORE = '!';
|
|
46
51
|
|
|
47
52
|
const correlationId = `test-local@0/${new Date().toISOString()}`;
|
|
53
|
+
const languageDescription = `${process.release.name} ${process.version}`;
|
|
54
|
+
const platformDescription = `${process.platform}; ${process.arch}`;
|
|
55
|
+
const inBracket = `(${platformDescription}; ${languageDescription})`;
|
|
56
|
+
const userAgent = `test-local ${inBracket}`;
|
|
48
57
|
|
|
49
58
|
const DEFAULT_MST = {
|
|
50
59
|
basePath: '/mST/v1',
|
|
@@ -145,11 +154,15 @@ module.exports = {
|
|
|
145
154
|
locationFile,
|
|
146
155
|
keyFile,
|
|
147
156
|
customerConfigFile,
|
|
148
|
-
|
|
157
|
+
API_PROVIDER_BITBUCKET,
|
|
158
|
+
API_PROVIDER_SWAGGERHUB,
|
|
159
|
+
BITBUCKET,
|
|
160
|
+
SWAGGERHUB,
|
|
149
161
|
API_SOURCE,
|
|
150
162
|
SWAGGER,
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
EXTENSION_YML,
|
|
164
|
+
POSTFIX,
|
|
165
|
+
RESOLVED,
|
|
153
166
|
DEFAULT_DIRECTORY,
|
|
154
167
|
testJsonFile,
|
|
155
168
|
shellFile,
|
|
@@ -158,6 +171,7 @@ module.exports = {
|
|
|
158
171
|
exampleStartFile,
|
|
159
172
|
exampleTestStartFile,
|
|
160
173
|
correlationId,
|
|
174
|
+
userAgent,
|
|
161
175
|
LITERAL,
|
|
162
176
|
IGNORE,
|
|
163
177
|
TEST,
|
package/lib/rp-axios-wrapper.js
CHANGED
|
@@ -1,35 +1,51 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
const http = require('http');
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
.then((res) => {
|
|
6
|
-
if (options.resolveWithFullResponse) return res;
|
|
7
|
-
return res.data;
|
|
8
|
-
})
|
|
9
|
-
.catch((err) => {
|
|
10
|
-
const { response } = err;
|
|
4
|
+
const { correlationId, userAgent } = require('./common');
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const rp = (origOptions) => {
|
|
7
|
+
const options = origOptions;
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
if (options.headers) {
|
|
10
|
+
options.headers['user-agent'] = userAgent;
|
|
11
|
+
if (!options.headers['x-correlation-id']) options.headers['x-correlationId'] = correlationId;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
options.headers = {
|
|
15
|
+
'user-agent': userAgent,
|
|
16
|
+
'x-correlationId': correlationId,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return axios(options)
|
|
20
|
+
.then((res) => {
|
|
21
|
+
if (options.resolveWithFullResponse) return res;
|
|
22
|
+
return res.data;
|
|
23
|
+
})
|
|
24
|
+
.catch((err) => {
|
|
25
|
+
const { response } = err;
|
|
26
|
+
|
|
27
|
+
if (!response) {
|
|
28
|
+
const error = new Error('system Error');
|
|
29
|
+
|
|
30
|
+
error.statusCode = 500;
|
|
31
|
+
error.title = http.STATUS_CODES[error.statusCode];
|
|
32
|
+
error.info = {
|
|
33
|
+
code: err.code,
|
|
34
|
+
address: err.address,
|
|
35
|
+
port: err.port,
|
|
36
|
+
syscall: err.syscall,
|
|
37
|
+
};
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
const { data } = response;
|
|
41
|
+
const error = new Error(data ? data.message || response.statusText : response.statusText);
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
error.statusCode = response.status;
|
|
44
|
+
error.title = response.statusText;
|
|
45
|
+
if (data && data.info) error.info = data.info;
|
|
46
|
+
throw error;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
33
49
|
|
|
34
50
|
module.exports = {
|
|
35
51
|
rp,
|
package/lib/tasks.js
CHANGED
|
@@ -28,12 +28,15 @@ const {
|
|
|
28
28
|
mIDConfigFile,
|
|
29
29
|
ERR_CHECK,
|
|
30
30
|
SUCCESS_CHECK,
|
|
31
|
-
|
|
31
|
+
POSTFIX,
|
|
32
32
|
API_SOURCE,
|
|
33
33
|
SWAGGER,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
API_PROVIDER_SWAGGERHUB,
|
|
35
|
+
API_PROVIDER_BITBUCKET,
|
|
36
|
+
SWAGGERHUB,
|
|
37
|
+
BITBUCKET,
|
|
38
|
+
RESOLVED,
|
|
39
|
+
EXTENSION_YML,
|
|
37
40
|
LITERAL,
|
|
38
41
|
DEFAULT_SUMOLOG,
|
|
39
42
|
DEFAULT_S3LOG,
|
|
@@ -253,10 +256,8 @@ const startSetup = (config, origStart) => {
|
|
|
253
256
|
* @function getAPI
|
|
254
257
|
* @category async
|
|
255
258
|
* @param {PATH<string>} directory - Directory to store the API file.
|
|
256
|
-
* @param {
|
|
257
|
-
* @param {string}
|
|
258
|
-
* @param {SEMVER<string>} version - Version fo the API to retrieve.
|
|
259
|
-
* @param {string} basicAuth - username password to access the bitbucket account
|
|
259
|
+
* @param {object} swaggerFile - Information from package.swaggeFile.
|
|
260
|
+
* @param {string} key - `bitbucket` with username password to access the bitbucket account or string to access `swaggerhub`.
|
|
260
261
|
* .
|
|
261
262
|
* @return {Promise}.
|
|
262
263
|
* @fulfil {object} The API file itself.
|
|
@@ -264,88 +265,124 @@ const startSetup = (config, origStart) => {
|
|
|
264
265
|
*
|
|
265
266
|
* The directory will be created if it does not exist.
|
|
266
267
|
*/
|
|
267
|
-
const getAPI = (directory,
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
const getAPI = (directory, swaggerFile, key) => {
|
|
269
|
+
const {
|
|
270
|
+
account,
|
|
271
|
+
name,
|
|
272
|
+
version,
|
|
273
|
+
provider,
|
|
274
|
+
} = swaggerFile;
|
|
275
|
+
const swaggerOptions = (spec) => ({
|
|
276
|
+
spec,
|
|
277
|
+
allowMetaPatches: false,
|
|
278
|
+
skipNormalization: true,
|
|
279
|
+
mode: 'strict',
|
|
280
|
+
});
|
|
273
281
|
|
|
274
282
|
process.stdout.write('- getting API definition in (' + directory.info + ')');
|
|
275
|
-
|
|
283
|
+
const apiFilename = path.join(directory, `${account}${SWAGGER_SEP}${name}${SWAGGER_SEP}${version}${SWAGGER_SEP}${POSTFIX}`);
|
|
284
|
+
let apiDefinition;
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
if (fs.existsSync(apiFilename)) {
|
|
288
|
+
console.log(': ' + apiFilename.info + ' ' + 'already setup'.warn);
|
|
289
|
+
apiDefinition = fs.readFileSync(apiFilename, 'utf8');
|
|
290
|
+
}
|
|
291
|
+
}
|
|
276
292
|
catch (err) {
|
|
277
|
-
|
|
278
|
-
|
|
293
|
+
console.log(': ' + ERR_CHECK.error);
|
|
294
|
+
return Promise.reject(err);
|
|
295
|
+
}
|
|
296
|
+
if (apiDefinition) {
|
|
297
|
+
try { apiDefinition = json.parse(apiDefinition); }
|
|
298
|
+
catch (err) {
|
|
299
|
+
console.log(ERR_CHECK.error);
|
|
279
300
|
return Promise.reject(err);
|
|
280
301
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
let apiDefinition;
|
|
287
|
-
|
|
288
|
-
try { apiDefinition = json.parse(fs.readFileSync(apiFilename).toString()); }
|
|
289
|
-
catch (errRead) { return Promise.reject(errRead); }
|
|
290
|
-
return SwaggerClient.resolve({
|
|
291
|
-
spec: apiDefinition,
|
|
292
|
-
allowMetaPatches: false,
|
|
293
|
-
skipNormalization: true,
|
|
294
|
-
mode: 'strict',
|
|
295
|
-
})
|
|
302
|
+
return SwaggerClient.resolve(swaggerOptions(apiDefinition))
|
|
303
|
+
.catch((err) => {
|
|
304
|
+
console.log(' ' + ERR_CHECK.error);
|
|
305
|
+
throw err;
|
|
306
|
+
})
|
|
296
307
|
.then((apiDefinitionResult) => {
|
|
297
308
|
if (apiDefinitionResult.errors.length !== 0) {
|
|
298
309
|
throw new Error('Errors while resolving definition');
|
|
299
310
|
}
|
|
300
311
|
fs.writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, 2));
|
|
301
|
-
console.log(SUCCESS_CHECK.success);
|
|
312
|
+
console.log(' ' + SUCCESS_CHECK.success);
|
|
302
313
|
return apiDefinitionResult.spec;
|
|
303
314
|
})
|
|
304
315
|
.catch((err) => {
|
|
305
|
-
console.log(ERR_CHECK.error);
|
|
306
316
|
const error = err;
|
|
307
317
|
|
|
308
318
|
error.message = `${error.message} - { "apiFilename": "${apiFilename}" }`;
|
|
319
|
+
console.log(' ' + ERR_CHECK.error);
|
|
309
320
|
throw error;
|
|
310
321
|
});
|
|
311
322
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
try {
|
|
324
|
+
if (!fs.existsSync(directory)) {
|
|
325
|
+
fs.mkdirSync(directory);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch (err) {
|
|
329
|
+
console.log(': ' + ERR_CHECK.error);
|
|
330
|
+
return Promise.reject(err);
|
|
331
|
+
}
|
|
332
|
+
const prov = provider || BITBUCKET;
|
|
333
|
+
const opts = {
|
|
316
334
|
method: 'GET',
|
|
317
|
-
|
|
335
|
+
headers: {},
|
|
318
336
|
};
|
|
319
337
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
338
|
+
try {
|
|
339
|
+
switch (prov) {
|
|
340
|
+
case SWAGGERHUB: {
|
|
341
|
+
opts.url = `${API_PROVIDER_SWAGGERHUB}/${account}/${name}/${version}?${RESOLVED}`;
|
|
342
|
+
if (key[SWAGGERHUB]) opts.headers.Authorization = key[SWAGGERHUB];
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
case BITBUCKET: {
|
|
346
|
+
if (!key[BITBUCKET] || !key[BITBUCKET].username || !key[BITBUCKET].password) {
|
|
347
|
+
throw new Error('missing username/password for accessing Bitbucket');
|
|
348
|
+
}
|
|
349
|
+
if (key[BITBUCKET].username === DEFAULT_BITBUCKET_USERNAME || key[BITBUCKET].password === DEFAULT_BITBUCKET_PASSWORD) {
|
|
350
|
+
throw new Error('missing username/password for accessing Bitbucket');
|
|
351
|
+
}
|
|
352
|
+
opts.headers.Authorization = `Basic ${Base64.encode(`${key[BITBUCKET].username}:${key[BITBUCKET].password}`)}`;
|
|
353
|
+
opts.url = `${API_PROVIDER_BITBUCKET}/${account}/${name}${API_SOURCE}/${version}/${SWAGGER}${EXTENSION_YML}`;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
default: {
|
|
357
|
+
throw new Error('invalid API provider');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
323
360
|
}
|
|
324
|
-
try { options.headers = { authorization: `Basic ${Base64.encode(`${basicAuth.username}:${basicAuth.password}`)}` }; }
|
|
325
361
|
catch (err) {
|
|
326
|
-
console.log(ERR_CHECK.error);
|
|
362
|
+
console.log(': ' + ERR_CHECK.error);
|
|
327
363
|
return Promise.reject(err);
|
|
328
364
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
365
|
+
process.stdout.write(' at (' + `${opts.url}`.info + '): ');
|
|
366
|
+
return rp(opts)
|
|
367
|
+
.then((result) => {
|
|
368
|
+
let resultJSON = result;
|
|
369
|
+
|
|
370
|
+
if (typeof result !== 'object') resultJSON = yaml.load(result);
|
|
371
|
+
return SwaggerClient.resolve(swaggerOptions(resultJSON));
|
|
372
|
+
})
|
|
336
373
|
.then((apiDefinitionResult) => {
|
|
337
374
|
if (apiDefinitionResult.errors.length !== 0) {
|
|
338
|
-
throw new Error('
|
|
375
|
+
throw new Error('errors while resolving definition');
|
|
339
376
|
}
|
|
340
377
|
fs.writeFileSync(apiFilename, JSON.stringify(apiDefinitionResult.spec, null, 2));
|
|
341
378
|
console.log(SUCCESS_CHECK.success);
|
|
342
379
|
return apiDefinitionResult.spec;
|
|
343
380
|
})
|
|
344
381
|
.catch((err) => {
|
|
345
|
-
console.log(ERR_CHECK.error);
|
|
346
382
|
const error = err;
|
|
347
383
|
|
|
348
384
|
error.message = `${error.message} - { "apiFilename": "${apiFilename}" }`;
|
|
385
|
+
console.log(ERR_CHECK.error);
|
|
349
386
|
throw error;
|
|
350
387
|
});
|
|
351
388
|
};
|
|
@@ -354,7 +391,7 @@ const gettingSystemCustomer = (authorization, mSTbaseUrl) => {
|
|
|
354
391
|
process.stdout.write('- getting customer (' + SYSTEM_NAME.info + '): ');
|
|
355
392
|
return rp({
|
|
356
393
|
method: 'GET',
|
|
357
|
-
headers: { authorization
|
|
394
|
+
headers: { authorization },
|
|
358
395
|
url: `${mSTbaseUrl}/customers/${SYSTEM_NAME}`,
|
|
359
396
|
})
|
|
360
397
|
.then((responseGET) => {
|
|
@@ -374,7 +411,7 @@ const settingUpCustomer = (customer, authorization, mSTbaseUrl, update) => {
|
|
|
374
411
|
|
|
375
412
|
return rp({
|
|
376
413
|
method: 'GET',
|
|
377
|
-
headers: { authorization
|
|
414
|
+
headers: { authorization },
|
|
378
415
|
url: `${mSTbaseUrl}/customers/${customer.name}`,
|
|
379
416
|
})
|
|
380
417
|
.catch((err) => {
|
|
@@ -387,7 +424,7 @@ const settingUpCustomer = (customer, authorization, mSTbaseUrl, update) => {
|
|
|
387
424
|
console.log('creating new customer'.info);
|
|
388
425
|
return rp({
|
|
389
426
|
method: 'POST',
|
|
390
|
-
headers: { authorization
|
|
427
|
+
headers: { authorization },
|
|
391
428
|
url: `${mSTbaseUrl}/customers`,
|
|
392
429
|
data: customer,
|
|
393
430
|
})
|
|
@@ -407,7 +444,7 @@ const settingUpCustomer = (customer, authorization, mSTbaseUrl, update) => {
|
|
|
407
444
|
console.log('already setup and update is true in mSTConfig.json, updating'.info);
|
|
408
445
|
return rp({
|
|
409
446
|
method: 'PUT',
|
|
410
|
-
headers: { authorization
|
|
447
|
+
headers: { authorization },
|
|
411
448
|
url: `${mSTbaseUrl}/customers/${customer.name}`,
|
|
412
449
|
data: customer,
|
|
413
450
|
})
|
|
@@ -427,7 +464,7 @@ const settingUpServer = (serverType, serverId, customer, authorization, mSTbaseU
|
|
|
427
464
|
return rp({
|
|
428
465
|
method: 'POST',
|
|
429
466
|
url: `${mSTbaseUrl}/clients`,
|
|
430
|
-
headers: { authorization
|
|
467
|
+
headers: { authorization },
|
|
431
468
|
data: {
|
|
432
469
|
externalId: serverId,
|
|
433
470
|
type: serverType,
|
|
@@ -486,7 +523,7 @@ const settingUpAdminClient = (serverType, adminExternalId, customer, authorizati
|
|
|
486
523
|
return rp({
|
|
487
524
|
method: 'POST',
|
|
488
525
|
url: `${mSTbaseUrl}/clients`,
|
|
489
|
-
headers: { authorization
|
|
526
|
+
headers: { authorization },
|
|
490
527
|
data: {
|
|
491
528
|
externalId: adminExternalId,
|
|
492
529
|
type: 'admin',
|
|
@@ -503,7 +540,7 @@ const settingUpAdminClient = (serverType, adminExternalId, customer, authorizati
|
|
|
503
540
|
return rp({
|
|
504
541
|
method: 'GET',
|
|
505
542
|
url: `${mSTbaseUrl}/clients/${adminExternalId}`,
|
|
506
|
-
headers: { authorization
|
|
543
|
+
headers: { authorization },
|
|
507
544
|
}).catch((errGET) => {
|
|
508
545
|
console.log(ERR_CHECK.error);
|
|
509
546
|
throw errGET;
|
|
@@ -526,7 +563,6 @@ const getAdminToken = (audienceType, admin, mSTbaseUrl) => {
|
|
|
526
563
|
}
|
|
527
564
|
return rp({
|
|
528
565
|
method: 'POST',
|
|
529
|
-
headers: { 'x-correlation-id': correlationId },
|
|
530
566
|
url: `${mSTbaseUrl}/oauth/token`,
|
|
531
567
|
data: {
|
|
532
568
|
client_id: admin.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/local",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Local setup configuration for normal and test opreration",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"@mimik/eslint-plugin-dependencies": "^2.4.5",
|
|
33
33
|
"@mimik/eslint-plugin-document-env": "^1.0.5",
|
|
34
34
|
"@mimik/git-hooks": "^1.5.7",
|
|
35
|
-
"axios": "1.3.
|
|
35
|
+
"axios": "1.3.6",
|
|
36
36
|
"bluebird": "3.7.2",
|
|
37
37
|
"chai": "4.3.7",
|
|
38
38
|
"colors": "1.4.0",
|
|
39
39
|
"comment-json": "4.2.3",
|
|
40
40
|
"debug": "4.3.4",
|
|
41
|
-
"eslint": "8.
|
|
41
|
+
"eslint": "8.39.0",
|
|
42
42
|
"eslint-config-airbnb": "19.0.4",
|
|
43
43
|
"eslint-plugin-import": "2.27.5",
|
|
44
44
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"mochawesome": "7.1.3",
|
|
55
55
|
"nyc": "15.1.0",
|
|
56
56
|
"rewire": "6.0.0",
|
|
57
|
-
"sinon": "15.0.
|
|
57
|
+
"sinon": "15.0.4",
|
|
58
58
|
"supertest": "6.3.3",
|
|
59
59
|
"swagger-client": "3.19.6",
|
|
60
60
|
"uuid": "9.0.0"
|