@mimik/local 1.6.0 → 4.4.2

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 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": {
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run commit-ready
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run test
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
- 'coniguration/**.js',
13
- 'test/**.js',
14
- 'lib/**.js',
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
- return done();
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: five files `mSTConfig.json`, `mIDConfig.json`, `mITConfig.json`,`sumo.json`, `customerConfig.json` are being set. If the don't exist at the launch of the script, default will be setup.
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
  {
@@ -12,6 +12,7 @@ In the directory above the server root directory: five files `mSTConfig.json`, `
12
12
  "protocol": "protocol for the mST server, for example: `http:`, by default `http:`",
13
13
  "domainName": "domain name of the mST server",
14
14
  "port": "port for the mST server, for example: `8025`",
15
+ "passphrase": "passphrase to be used to generate public private key pair, if not present mST will user regular key",
15
16
  "update": "switch to indicate if mST needs to be updated, default is `false`. If the address is localhost, mST will be updated"
16
17
  "admin": {
17
18
  "clientId": "id or the client in order to get an admin token for mST, for example: `12345`",
@@ -44,7 +45,7 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
44
45
  }
45
46
  ```
46
47
  Similar properties than for mSTConfig on `domainName` and `port` apply.
47
- - for `sumo.json`:
48
+ - for `sumoLog.json`:
48
49
  ``` javascript
49
50
  {
50
51
  "<serverType>": {
@@ -56,10 +57,50 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
56
57
  "code": "code for sumologic, everything after the last / in the sumologic URL"
57
58
  }
58
59
  ```
59
- A property may be define for each `serverType` involved. If the serverType does not exist the default will be picked.
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.
60
97
  - for `customerConfig.json`:
61
98
  See `mST` `README.md` file for an example of a customer configuration. This may have to be updated to reflect the new servers.
62
- - in the `local` directory of the server root directory: two files `start.json` and `testStart.json` may exit, if `testStart.json` is missing, `start.json` will be used as testStart.json. The configuration of these files depends on the configuration parameters of the server. The following is an example of start.json file for `mIT`:
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`:
63
104
  ``` javascript
64
105
  {
65
106
  "NODE_ENV": "local",
@@ -77,6 +118,7 @@ While all the files use the `.json` extension it is still possible to add commen
77
118
  There are reserved environement variable used by the library for configuration:
78
119
  - `oauthImplicitNeeded`: if the service handles user token the implicit configuration is needed
79
120
  - `mIDNeeded`: if the service has mID as a target
121
+ - `locationNeeded`: if location translation is needed
80
122
  - `standAlone`: if the service need to be operated without other service. If the service has targets most likely 500 errors will be generated
81
123
 
82
124
  If SERVER_ID is not set in the start.json or testStart.json file, SERVER_ID will be assigned with a uuid.v4.
@@ -111,6 +153,8 @@ const local = require('@mimik/local');
111
153
  * [~mSTSetup()](#module_local..mSTSetup) ⇒
112
154
  * [~testSetup()](#module_local..testSetup) ⇒
113
155
  * [~setup()](#module_local..setup) ⇒
156
+ * [~testSetup()](#module_local..testSetup) ⇒
157
+ * [~setup()](#module_local..setup) ⇒
114
158
 
115
159
  <a name="module_local..test"></a>
116
160
 
@@ -152,11 +196,11 @@ The following files are needed to perform these actions:
152
196
 
153
197
  | Filename | Description |
154
198
  | -------- | ----------- |
155
- | `../sumo.json` | The sumologic endpoints and code
199
+ | `../sumoLog.json` | The sumologic endpoints and code
200
+ | `../kinesisLog.json` | The Kinesis information
201
+ | `../s3Log.json` | The S3 information
156
202
  | `../mSTConfig.json` | The config for mST
157
203
  | `../mITConfig.json` | The config for mIT
158
- | `../mIDConfig.json` | The config for mID
159
- | `../customerConfig.json` | The mST customer config
160
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
161
205
  **Category**: sync
162
206
  <a name="module_local..mSTSetup"></a>
@@ -178,17 +222,103 @@ The following files are needed to perform these actions:
178
222
 
179
223
  | Filename | Description |
180
224
  | -------- | ----------- |
181
- | `../sumo.json` | The sumologic endpoints and code
225
+ | `../sumoLog.json` | The sumologic endpoints and code
226
+ | `../kinesisLog.json` | The Kinesis information
227
+ | `../s3Log.json` | The S3 information
182
228
  | `../mSTConfig.json` | The config for mST
183
229
  | `../mITConfig.json` | The config for mIT
184
- | `../mIDConfig.json` | The config for mID
185
- | `../customerConfig.json` | The mST customer config
186
230
  | `./local/start.json` | The local configuration. If it does not exist start-example.json will be used to create start.json
187
231
  **Category**: sync
188
232
  <a name="module_local..testSetup"></a>
189
233
 
190
234
  ### local~testSetup() ⇒
191
- Setup a service (not mST) for test.
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.
192
322
 
193
323
  **Kind**: inner method of [<code>local</code>](#module_local)
194
324
  **Returns**: `null`.
@@ -199,14 +329,14 @@ Two modes are available:
199
329
  1. stand alone
200
330
  2. with mST, mID are other dependent servers
201
331
 
202
- The environment variable STAND_ALONE will select the the mode.
332
+ The environment variable STAND_ALONE will select the mode.
203
333
  When in stand alone, the following actions are being performed:
204
334
 
205
335
  1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
206
336
  2. get an admin token for that service
207
337
  3. generate a json object store in a file under .
208
338
 
209
- In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most like generate a 500 error
339
+ In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
210
340
 
211
341
  When mST and other servers are present, the following actions are being performed:
212
342
 
@@ -223,7 +353,9 @@ The following files are needed to perform these actions:
223
353
 
224
354
  | Filename | Description |
225
355
  | -------- | ----------- |
226
- | `../sumo.json` | The sumologic endpoints and code
356
+ | `../sumoLog.json` | The sumologic endpoints and code
357
+ | `../kinesisLog.json` | The Kinesis information
358
+ | `../s3Log.json` | The S3 information
227
359
  | `../mSTConfig.json` | The config for mST
228
360
  | `../mITConfig.json` | The config for mIT
229
361
  | `../mIDConfig.json` | The config for mID
@@ -233,14 +365,28 @@ The following files are needed to perform these actions:
233
365
  <a name="module_local..setup"></a>
234
366
 
235
367
  ### local~setup() ⇒
236
- Setup a service (not mST).
368
+ Setup a service (not mST, mIT).
237
369
 
238
370
  **Kind**: inner method of [<code>local</code>](#module_local)
239
371
  **Returns**: `null`.
240
372
 
241
373
  Will exit 1 if there is an error.
242
374
 
243
- The following actions are being performed:
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
+
244
390
 
245
391
  1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
246
392
  2. get an Admin token for mST
@@ -253,10 +399,11 @@ The following files are needed to perform these actions:
253
399
  | Filename | Description |
254
400
  | -------- | ----------- |
255
401
  | `../sumo.json` | The sumologic endpoints and code
402
+ | `../kinesisLog.json` | The Kinesis information
403
+ | `../s3Log.json` | The S3 information
256
404
  | `../mSTConfig.json` | The config for mST
257
405
  | `../mITConfig.json` | The config for mIT
258
406
  | `../mIDConfig.json` | The config for mID
259
407
  | `../customerConfig.json` | The mST customer config
260
- | `./config.json` | The config of the service
261
408
  | `./local/start.json` | The local configuration. If it does not exist start-example.json will be used to create start.json
262
409
  **Category**: sync
@@ -1,4 +1,4 @@
1
- const adminExternalIdBase = 'test-local';
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}-mID`,
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 ---',