@mimik/local 1.6.1 → 4.4.3
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/.eslintrc +15 -3
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +4 -0
- package/Gulpfile.js +6 -7
- package/README.md +163 -17
- package/configuration/config.js +4 -4
- package/index.js +364 -94
- package/lib/common.js +53 -3
- package/lib/commonExt.js +29 -21
- package/lib/helpers.js +81 -40
- package/lib/rp-axios-wrapper.js +36 -0
- package/lib/tasks.js +220 -106
- package/manual-test/getAPI.js +1 -1
- package/manual-test/retrieve.js +5 -3
- package/manual-test/start-example.json +46 -0
- package/manual-test/startTest-example.json +8 -0
- package/manual-test/test.json +46 -0
- package/manual-test/testMerge.js +66 -0
- package/manual-test/testString.js +7 -0
- package/package.json +29 -21
- package/package.json.bak +0 -57
package/.eslintrc
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
// Use this file as a starting point for your project's .eslintrc.
|
|
2
|
-
// Copy this file, and add rule overrides as needed.
|
|
3
1
|
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
"@mimik/document-env",
|
|
4
|
+
"@mimik/dependencies"
|
|
5
|
+
],
|
|
4
6
|
"env": {
|
|
5
7
|
"node": true
|
|
6
8
|
},
|
|
9
|
+
"parserOptions": {
|
|
10
|
+
"ecmaVersion": 2020
|
|
11
|
+
},
|
|
7
12
|
"extends": "airbnb",
|
|
8
13
|
"rules": {
|
|
14
|
+
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
|
|
9
15
|
"brace-style": [1, "stroustrup", {"allowSingleLine": true}],
|
|
10
16
|
"no-confusing-arrow": [0], // arrow isnt confusing
|
|
11
17
|
"max-len": [1, 180, { "ignoreComments": true }],
|
|
12
18
|
"linebreak-style": 0,
|
|
13
19
|
"quotes": [1, "single"],
|
|
14
|
-
"semi": [1, "always"]
|
|
20
|
+
"semi": [1, "always"],
|
|
21
|
+
"no-process-env": ["error"],
|
|
22
|
+
"@mimik/document-env/validate-document-env": 2,
|
|
23
|
+
"@mimik/dependencies/case-sensitive": 2,
|
|
24
|
+
"@mimik/dependencies/no-cycles": 2,
|
|
25
|
+
"@mimik/dependencies/no-unresolved": 2,
|
|
26
|
+
"@mimik/dependencies/require-json-ext": 2
|
|
15
27
|
},
|
|
16
28
|
"settings":{
|
|
17
29
|
"react": {
|
package/.husky/pre-push
ADDED
package/Gulpfile.js
CHANGED
|
@@ -9,22 +9,21 @@ const jsdoc2md = require('jsdoc-to-markdown');
|
|
|
9
9
|
const files = [
|
|
10
10
|
'index.js',
|
|
11
11
|
'Gulpfile.js',
|
|
12
|
-
'
|
|
13
|
-
'test
|
|
14
|
-
'lib
|
|
12
|
+
'configuration/**/*.js',
|
|
13
|
+
'test/**/*.js',
|
|
14
|
+
'lib/**/*.js',
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
const createDocs = (done) => {
|
|
18
18
|
jsdoc2md.render({ files: 'index.js' })
|
|
19
19
|
.then((output) => fs.writeFileSync('README.md', output))
|
|
20
|
-
.catch((err) => log.error('docs creation failed:', err.message))
|
|
21
|
-
|
|
20
|
+
.catch((err) => log.error('docs creation failed:', err.message))
|
|
21
|
+
.finally(() => done());
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const lint = () => gulp.src(files)
|
|
25
25
|
.pipe(eslint({}))
|
|
26
|
-
.pipe(eslint.format())
|
|
27
|
-
.pipe(eslint.failOnError());
|
|
26
|
+
.pipe(eslint.format());
|
|
28
27
|
|
|
29
28
|
const add = () => gulp.src('README.md')
|
|
30
29
|
.pipe(git.add({ quiet: true }));
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Set of function for local deployment.
|
|
5
5
|
|
|
6
6
|
The following files are expected to exist:
|
|
7
|
-
In the directory above the server root directory:
|
|
7
|
+
In the directory above the server root directory: `mSTConfig.json`, `mIDConfig.json`, `mITConfig.json`,`sumoLog.json`, `kinesisLog.json`, ``s3Log.json`, `customerConfig.json`, 'key.json`, `locationConfig.json` are being set. If they don't exist at the launch of the script, default will be setup.
|
|
8
8
|
- for `mSTConfig.json`:
|
|
9
9
|
``` javascript
|
|
10
10
|
{
|
|
@@ -45,7 +45,7 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
Similar properties than for mSTConfig on `domainName` and `port` apply.
|
|
48
|
-
- for `
|
|
48
|
+
- for `sumoLog.json`:
|
|
49
49
|
``` javascript
|
|
50
50
|
{
|
|
51
51
|
"<serverType>": {
|
|
@@ -57,10 +57,50 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
|
|
|
57
57
|
"code": "code for sumologic, everything after the last / in the sumologic URL"
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
|
-
|
|
60
|
+
- for `kinesisLog.json`:
|
|
61
|
+
``` javascript
|
|
62
|
+
{
|
|
63
|
+
"region": "region of the Kinesis implementation",
|
|
64
|
+
"accessKeyId": "access key id of Kinesis",
|
|
65
|
+
"secretAccessKey": "secret access key for Kinesis",
|
|
66
|
+
"streamNameInfo": "name of the kiniesis stream for info",
|
|
67
|
+
"streamNameError": "name of the kiniesis stream for error",
|
|
68
|
+
"streamNameOther": "name of the kiniesis stream for all the other levels"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
- for `s3Log.json`:
|
|
72
|
+
``` javascript
|
|
73
|
+
{
|
|
74
|
+
"region": "region of the S3 implementation",
|
|
75
|
+
"accessKeyId": "Access key id for S3",
|
|
76
|
+
"secretAccessKey": "secret access key for S3",
|
|
77
|
+
"bucketname": "name of the S3 bucket used to store the information",
|
|
78
|
+
"maxEvents": "number of events buffered before sending to S3 (integer)",
|
|
79
|
+
"timeout": "number of seconds before timeout to send to S3 (integer)",
|
|
80
|
+
"maxSize": "max size in Bytes before sending to S3 (integer)"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
- for `key.json`:
|
|
84
|
+
``` javascript
|
|
85
|
+
{
|
|
86
|
+
"apiKey": "key to access API definition on the API provider"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
- for `locationConfig.json`:
|
|
90
|
+
``` javascript
|
|
91
|
+
{
|
|
92
|
+
"url": "url of the location provider"
|
|
93
|
+
"key": "key to make request to the location provider"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
A property may be defined for each `serverType` involved. If the serverType does not exist the default will be picked.
|
|
61
97
|
- for `customerConfig.json`:
|
|
62
98
|
See `mST` `README.md` file for an example of a customer configuration. This may have to be updated to reflect the new servers.
|
|
63
|
-
- in the `local` directory of the server root directory: two files `start.json` and `testStart.json` may exit
|
|
99
|
+
- in the `local` directory of the server root directory: two files `start.json` and `testStart.json` may exit. `start.json` is used when `npm start` is executed, `testStart.json` is used when `npm test` is executed.
|
|
100
|
+
If the files don't exist `exampe-start.json` is used to create `start.json` and `testStart.json`.
|
|
101
|
+
Additionally `example-testStart.json` is used when to create `testStart.json`. The values in `example-testStart.json` take precedence over the values in `example-start.json`.
|
|
102
|
+
The configuration of these files depends on the configuration parameters of the server. If the files
|
|
103
|
+
The following is an example of start.json file for `mIT`:
|
|
64
104
|
``` javascript
|
|
65
105
|
{
|
|
66
106
|
"NODE_ENV": "local",
|
|
@@ -78,6 +118,7 @@ While all the files use the `.json` extension it is still possible to add commen
|
|
|
78
118
|
There are reserved environement variable used by the library for configuration:
|
|
79
119
|
- `oauthImplicitNeeded`: if the service handles user token the implicit configuration is needed
|
|
80
120
|
- `mIDNeeded`: if the service has mID as a target
|
|
121
|
+
- `locationNeeded`: if location translation is needed
|
|
81
122
|
- `standAlone`: if the service need to be operated without other service. If the service has targets most likely 500 errors will be generated
|
|
82
123
|
|
|
83
124
|
If SERVER_ID is not set in the start.json or testStart.json file, SERVER_ID will be assigned with a uuid.v4.
|
|
@@ -112,6 +153,8 @@ const local = require('@mimik/local');
|
|
|
112
153
|
* [~mSTSetup()](#module_local..mSTSetup) ⇒
|
|
113
154
|
* [~testSetup()](#module_local..testSetup) ⇒
|
|
114
155
|
* [~setup()](#module_local..setup) ⇒
|
|
156
|
+
* [~testSetup()](#module_local..testSetup) ⇒
|
|
157
|
+
* [~setup()](#module_local..setup) ⇒
|
|
115
158
|
|
|
116
159
|
<a name="module_local..test"></a>
|
|
117
160
|
|
|
@@ -153,11 +196,11 @@ The following files are needed to perform these actions:
|
|
|
153
196
|
|
|
154
197
|
| Filename | Description |
|
|
155
198
|
| -------- | ----------- |
|
|
156
|
-
| `../
|
|
199
|
+
| `../sumoLog.json` | The sumologic endpoints and code
|
|
200
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
201
|
+
| `../s3Log.json` | The S3 information
|
|
157
202
|
| `../mSTConfig.json` | The config for mST
|
|
158
203
|
| `../mITConfig.json` | The config for mIT
|
|
159
|
-
| `../mIDConfig.json` | The config for mID
|
|
160
|
-
| `../customerConfig.json` | The mST customer config
|
|
161
204
|
| `./local/testStart.json` | The local configuration. If it does not exist start.json and if sart.json does not exist start-example.json will be used to create start.json
|
|
162
205
|
**Category**: sync
|
|
163
206
|
<a name="module_local..mSTSetup"></a>
|
|
@@ -179,17 +222,103 @@ The following files are needed to perform these actions:
|
|
|
179
222
|
|
|
180
223
|
| Filename | Description |
|
|
181
224
|
| -------- | ----------- |
|
|
182
|
-
| `../
|
|
225
|
+
| `../sumoLog.json` | The sumologic endpoints and code
|
|
226
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
227
|
+
| `../s3Log.json` | The S3 information
|
|
183
228
|
| `../mSTConfig.json` | The config for mST
|
|
184
229
|
| `../mITConfig.json` | The config for mIT
|
|
185
|
-
| `../mIDConfig.json` | The config for mID
|
|
186
|
-
| `../customerConfig.json` | The mST customer config
|
|
187
230
|
| `./local/start.json` | The local configuration. If it does not exist start-example.json will be used to create start.json
|
|
188
231
|
**Category**: sync
|
|
189
232
|
<a name="module_local..testSetup"></a>
|
|
190
233
|
|
|
191
234
|
### local~testSetup() ⇒
|
|
192
|
-
Setup
|
|
235
|
+
Setup mIT for test.
|
|
236
|
+
|
|
237
|
+
**Kind**: inner method of [<code>local</code>](#module_local)
|
|
238
|
+
**Returns**: `null`.
|
|
239
|
+
|
|
240
|
+
Will exit 1 if there is an error.
|
|
241
|
+
|
|
242
|
+
Two modes are available:
|
|
243
|
+
1. stand alone
|
|
244
|
+
2. with mST
|
|
245
|
+
|
|
246
|
+
The environment variable STAND_ALONE will select the mode.
|
|
247
|
+
When in stand alone, the following actions are being performed:
|
|
248
|
+
|
|
249
|
+
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
250
|
+
2. get an admin token for that service
|
|
251
|
+
3. generate a json object store in a file under .
|
|
252
|
+
|
|
253
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
254
|
+
|
|
255
|
+
When mST and other servers are present, the following actions are being performed:
|
|
256
|
+
|
|
257
|
+
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
258
|
+
2. get an admin token for mST
|
|
259
|
+
3. register the service in mST
|
|
260
|
+
4. register an admin client for that service in mST
|
|
261
|
+
5. get an admin token for that service
|
|
262
|
+
6. get an admin token for mID if needed
|
|
263
|
+
7. generate a json object store in a file under .
|
|
264
|
+
|
|
265
|
+
The following files are needed to perform these actions:
|
|
266
|
+
|
|
267
|
+
| Filename | Description |
|
|
268
|
+
| -------- | ----------- |
|
|
269
|
+
| `../sumoLog.json` | The sumologic endpoints and code
|
|
270
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
271
|
+
| `../s3Log.json` | The S3 information
|
|
272
|
+
| `../mSTConfig.json` | The config for mST
|
|
273
|
+
| `../mITConfig.json` | The config for mIT
|
|
274
|
+
| `./local/testStart.json` | The local configuration. If it does not exist start.json and if sart.json does not exist start-example.json will be used to create start.json
|
|
275
|
+
**Category**: sync
|
|
276
|
+
<a name="module_local..setup"></a>
|
|
277
|
+
|
|
278
|
+
### local~setup() ⇒
|
|
279
|
+
Setup mIT.
|
|
280
|
+
|
|
281
|
+
**Kind**: inner method of [<code>local</code>](#module_local)
|
|
282
|
+
**Returns**: `null`.
|
|
283
|
+
|
|
284
|
+
Will exit 1 if there is an error.
|
|
285
|
+
|
|
286
|
+
Two modes are available:
|
|
287
|
+
1. stand alone
|
|
288
|
+
2. with mST
|
|
289
|
+
|
|
290
|
+
The environment variable STAND_ALONE will select the mode.
|
|
291
|
+
When in stand alone, the following actions are being performed:
|
|
292
|
+
|
|
293
|
+
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
294
|
+
2. get an admin token for that service
|
|
295
|
+
3. generate a shell script to start the server
|
|
296
|
+
|
|
297
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
298
|
+
|
|
299
|
+
When mST is present, the following actions are being performed:
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
303
|
+
2. get an Admin token for mST
|
|
304
|
+
3. register the service in mST
|
|
305
|
+
4. generate a shell script to start the server
|
|
306
|
+
|
|
307
|
+
The following files are needed to perform these actions:
|
|
308
|
+
|
|
309
|
+
| Filename | Description |
|
|
310
|
+
| -------- | ----------- |
|
|
311
|
+
| `../sumoLog.json` | The sumologic endpoints and code
|
|
312
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
313
|
+
| `../s3Log.json` | The S3 information
|
|
314
|
+
| `../mSTConfig.json` | The config for mST
|
|
315
|
+
| `../mITConfig.json` | The config for mIT
|
|
316
|
+
| `./local/start.json` | The local configuration. If it does not exist start-example.json will be used to create start.json
|
|
317
|
+
**Category**: sync
|
|
318
|
+
<a name="module_local..testSetup"></a>
|
|
319
|
+
|
|
320
|
+
### local~testSetup() ⇒
|
|
321
|
+
Setup a service (not mST, mIT) for test.
|
|
193
322
|
|
|
194
323
|
**Kind**: inner method of [<code>local</code>](#module_local)
|
|
195
324
|
**Returns**: `null`.
|
|
@@ -200,14 +329,14 @@ Two modes are available:
|
|
|
200
329
|
1. stand alone
|
|
201
330
|
2. with mST, mID are other dependent servers
|
|
202
331
|
|
|
203
|
-
The environment variable STAND_ALONE will select the
|
|
332
|
+
The environment variable STAND_ALONE will select the mode.
|
|
204
333
|
When in stand alone, the following actions are being performed:
|
|
205
334
|
|
|
206
335
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
207
336
|
2. get an admin token for that service
|
|
208
337
|
3. generate a json object store in a file under .
|
|
209
338
|
|
|
210
|
-
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most
|
|
339
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
211
340
|
|
|
212
341
|
When mST and other servers are present, the following actions are being performed:
|
|
213
342
|
|
|
@@ -224,7 +353,9 @@ The following files are needed to perform these actions:
|
|
|
224
353
|
|
|
225
354
|
| Filename | Description |
|
|
226
355
|
| -------- | ----------- |
|
|
227
|
-
| `../
|
|
356
|
+
| `../sumoLog.json` | The sumologic endpoints and code
|
|
357
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
358
|
+
| `../s3Log.json` | The S3 information
|
|
228
359
|
| `../mSTConfig.json` | The config for mST
|
|
229
360
|
| `../mITConfig.json` | The config for mIT
|
|
230
361
|
| `../mIDConfig.json` | The config for mID
|
|
@@ -234,14 +365,28 @@ The following files are needed to perform these actions:
|
|
|
234
365
|
<a name="module_local..setup"></a>
|
|
235
366
|
|
|
236
367
|
### local~setup() ⇒
|
|
237
|
-
Setup a service (not mST).
|
|
368
|
+
Setup a service (not mST, mIT).
|
|
238
369
|
|
|
239
370
|
**Kind**: inner method of [<code>local</code>](#module_local)
|
|
240
371
|
**Returns**: `null`.
|
|
241
372
|
|
|
242
373
|
Will exit 1 if there is an error.
|
|
243
374
|
|
|
244
|
-
|
|
375
|
+
Two modes are available:
|
|
376
|
+
1. stand alone
|
|
377
|
+
2. with mST, mID are other dependent servers
|
|
378
|
+
|
|
379
|
+
The environment variable STAND_ALONE will select the mode.
|
|
380
|
+
When in stand alone, the following actions are being performed:
|
|
381
|
+
|
|
382
|
+
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
383
|
+
2. get an admin token for that service
|
|
384
|
+
3. generate a shell script to start the server
|
|
385
|
+
|
|
386
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
387
|
+
|
|
388
|
+
When mST and other servers are present, the following actions are being performed:
|
|
389
|
+
|
|
245
390
|
|
|
246
391
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
247
392
|
2. get an Admin token for mST
|
|
@@ -254,10 +399,11 @@ The following files are needed to perform these actions:
|
|
|
254
399
|
| Filename | Description |
|
|
255
400
|
| -------- | ----------- |
|
|
256
401
|
| `../sumo.json` | The sumologic endpoints and code
|
|
402
|
+
| `../kinesisLog.json` | The Kinesis information
|
|
403
|
+
| `../s3Log.json` | The S3 information
|
|
257
404
|
| `../mSTConfig.json` | The config for mST
|
|
258
405
|
| `../mITConfig.json` | The config for mIT
|
|
259
406
|
| `../mIDConfig.json` | The config for mID
|
|
260
407
|
| `../customerConfig.json` | The mST customer config
|
|
261
|
-
| `./config.json` | The config of the service
|
|
262
408
|
| `./local/start.json` | The local configuration. If it does not exist start-example.json will be used to create start.json
|
|
263
409
|
**Category**: sync
|
package/configuration/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const adminExternalIdBase = '
|
|
1
|
+
const adminExternalIdBase = 'admin_default_local';
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
adminExternalIdBase,
|
|
@@ -9,7 +9,7 @@ module.exports = {
|
|
|
9
9
|
customerConfigFile: '../customerConfig.json',
|
|
10
10
|
APIProvider: 'https://api.swaggerhub.com/apis',
|
|
11
11
|
swaggerExt: 'swagger.json',
|
|
12
|
-
defaultDirectory:'./api',
|
|
12
|
+
defaultDirectory: './api',
|
|
13
13
|
testJsonFile: './server-test.json',
|
|
14
14
|
shellFile: './server-start.sh',
|
|
15
15
|
startFile: './local/start.json',
|
|
@@ -41,10 +41,10 @@ module.exports = {
|
|
|
41
41
|
audience: 'https://mimik',
|
|
42
42
|
},
|
|
43
43
|
admin: {
|
|
44
|
-
externalId: `${adminExternalIdBase}
|
|
44
|
+
externalId: `${adminExternalIdBase}_mID`,
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
-
DEFAULT_SUMO:{
|
|
47
|
+
DEFAULT_SUMO: {
|
|
48
48
|
default: {
|
|
49
49
|
url: 'https://default-sumo-endPoint',
|
|
50
50
|
code: '--- default code ---',
|