@mimik/local 6.0.12 → 7.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 +23 -23
- package/configuration/config.js +32 -28
- package/dotFiles/eslint.config.js +63 -0
- package/eslint.config.js +65 -0
- package/index.js +97 -93
- package/lib/common.js +3 -1
- package/lib/commonExt.js +12 -9
- package/lib/helpers.js +49 -30
- package/lib/rp-axios-wrapper.js +4 -5
- package/lib/tasks.js +113 -100
- package/manual-test/getAPI.js +1 -1
- package/manual-test/retrieve.js +1 -1
- package/manual-test/testMerge.js +27 -13
- package/manual-test/testString.js +4 -3
- package/package.json +34 -27
- package/scripts.json +3 -4
- package/.eslintrc +0 -43
- package/dotFiles/eslintrc.json +0 -102
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<a name="module_local"></a>
|
|
2
2
|
|
|
3
3
|
## local
|
|
4
|
-
Set of
|
|
4
|
+
Set of functions for local deployment.
|
|
5
5
|
|
|
6
6
|
The following files are expected to exist:
|
|
7
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.
|
|
@@ -63,9 +63,9 @@ Similar properties than for mSTConfig on `domainName` and `port` apply.
|
|
|
63
63
|
"region": "region of the Kinesis implementation",
|
|
64
64
|
"accessKeyId": "access key id of Kinesis",
|
|
65
65
|
"secretAccessKey": "secret access key for Kinesis",
|
|
66
|
-
"streamNameInfo": "name of the
|
|
67
|
-
"streamNameError": "name of the
|
|
68
|
-
"streamNameOther": "name of the
|
|
66
|
+
"streamNameInfo": "name of the Kinesis stream for info",
|
|
67
|
+
"streamNameError": "name of the Kinesis stream for error",
|
|
68
|
+
"streamNameOther": "name of the Kinesis stream for all the other levels"
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
- for `s3Log.json`:
|
|
@@ -103,7 +103,7 @@ See `mST` `README.md` file for an example of a customer configuration. This may
|
|
|
103
103
|
- 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.
|
|
104
104
|
If the files don't exist `exampe-start.json` is used to create `start.json` and `testStart.json`.
|
|
105
105
|
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`.
|
|
106
|
-
The configuration of these files depends on the configuration parameters of the server.
|
|
106
|
+
The configuration of these files depends on the configuration parameters of the server.
|
|
107
107
|
The following is an example of start.json file for `mIT`:
|
|
108
108
|
``` javascript
|
|
109
109
|
{
|
|
@@ -119,11 +119,11 @@ The following is an example of start.json file for `mIT`:
|
|
|
119
119
|
}
|
|
120
120
|
```
|
|
121
121
|
While all the files use the `.json` extension it is still possible to add comments `//` in the file to make the file more explicit or to remove some parameters.
|
|
122
|
-
There are reserved environement
|
|
122
|
+
There are reserved environement variables used by the library for configuration:
|
|
123
123
|
- `oauthImplicitNeeded`: if the service handles user token the implicit configuration is needed
|
|
124
124
|
- `mIDNeeded`: if the service has mID as a target
|
|
125
125
|
- `locationNeeded`: if location translation is needed
|
|
126
|
-
- `standAlone`: if the service
|
|
126
|
+
- `standAlone`: if the service needs to be operated without other service. If the service has targets most likely 500 errors will be generated
|
|
127
127
|
|
|
128
128
|
If SERVER_ID is not set in the start.json or testStart.json file, SERVER_ID will be assigned with a uuid.v4.
|
|
129
129
|
|
|
@@ -131,7 +131,7 @@ For test in json file (`server-test.json`) is created in `.`.
|
|
|
131
131
|
This file contains informations needed to start the test:
|
|
132
132
|
``` javascript
|
|
133
133
|
{
|
|
134
|
-
"start": "information needed to setup the environement
|
|
134
|
+
"start": "information needed to setup the environement variables for the test",
|
|
135
135
|
"CUSTOMER_NAME": "name of the customer to setup customer config",
|
|
136
136
|
"CUSTOMER_CODE": "code of the customer to setup coustomer config, `not available for MST`",
|
|
137
137
|
"BASE_PATH": "base path of the API",
|
|
@@ -144,7 +144,9 @@ In standAlone mode the test can easily get the token using `oauth-helper-temp`.
|
|
|
144
144
|
|
|
145
145
|
**Example**
|
|
146
146
|
```js
|
|
147
|
-
|
|
147
|
+
import local from '@mimik/local';
|
|
148
|
+
or
|
|
149
|
+
import { mSTTestSetup, mSTSetup, mITTestSetup, mITSetup, testSetup, setup, dotFiles, scripts, unScripts, commitCheckMsg, start2process, testJsonFile} from '@mimik/local';
|
|
148
150
|
```
|
|
149
151
|
|
|
150
152
|
* [local](#module_local)
|
|
@@ -179,7 +181,7 @@ The following files are needed to perform these actions:
|
|
|
179
181
|
| `../s3Log.json` | The S3 information
|
|
180
182
|
| `../mSTConfig.json` | The config for mST
|
|
181
183
|
| `../mITConfig.json` | The config for mIT
|
|
182
|
-
| `./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
|
|
184
|
+
| `./local/testStart.json` | The local configuration. If it does not exist start.json will be used and if sart.json does not exist start-example.json will be used to create start.json
|
|
183
185
|
**Category**: sync
|
|
184
186
|
<a name="module_local..mSTSetup"></a>
|
|
185
187
|
|
|
@@ -226,9 +228,9 @@ When in stand alone, the following actions are being performed:
|
|
|
226
228
|
|
|
227
229
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
228
230
|
2. get an admin token for that service
|
|
229
|
-
3. generate a
|
|
231
|
+
3. generate a JSON object store in a file under .
|
|
230
232
|
|
|
231
|
-
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
233
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error.
|
|
232
234
|
|
|
233
235
|
When mST and other servers are present, the following actions are being performed:
|
|
234
236
|
|
|
@@ -238,7 +240,7 @@ When mST and other servers are present, the following actions are being performe
|
|
|
238
240
|
4. register an admin client for that service in mST
|
|
239
241
|
5. get an admin token for that service
|
|
240
242
|
6. get an admin token for mID if needed
|
|
241
|
-
7. generate a
|
|
243
|
+
7. generate a JSON object store in a file under .
|
|
242
244
|
|
|
243
245
|
The following files are needed to perform these actions:
|
|
244
246
|
|
|
@@ -249,7 +251,7 @@ The following files are needed to perform these actions:
|
|
|
249
251
|
| `../s3Log.json` | The S3 information
|
|
250
252
|
| `../mSTConfig.json` | The config for mST
|
|
251
253
|
| `../mITConfig.json` | The config for mIT
|
|
252
|
-
| `./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
|
|
254
|
+
| `./local/testStart.json` | The local configuration. If it does not exist start.json will be used and if sart.json does not exist start-example.json will be used to create start.json
|
|
253
255
|
**Category**: sync
|
|
254
256
|
<a name="module_local..setup"></a>
|
|
255
257
|
|
|
@@ -272,13 +274,12 @@ When in stand alone, the following actions are being performed:
|
|
|
272
274
|
2. get an admin token for that service
|
|
273
275
|
3. generate a shell script to start the server
|
|
274
276
|
|
|
275
|
-
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
277
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error.
|
|
276
278
|
|
|
277
279
|
When mST is present, the following actions are being performed:
|
|
278
280
|
|
|
279
|
-
|
|
280
281
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
281
|
-
2. get an
|
|
282
|
+
2. get an admin token for mST
|
|
282
283
|
3. register the service in mST
|
|
283
284
|
4. generate a shell script to start the server
|
|
284
285
|
|
|
@@ -312,9 +313,9 @@ When in stand alone, the following actions are being performed:
|
|
|
312
313
|
|
|
313
314
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
314
315
|
2. get an admin token for that service
|
|
315
|
-
3. generate a
|
|
316
|
+
3. generate a JSON object store in a file under .
|
|
316
317
|
|
|
317
|
-
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
318
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error.
|
|
318
319
|
|
|
319
320
|
When mST and other servers are present, the following actions are being performed:
|
|
320
321
|
|
|
@@ -338,7 +339,7 @@ The following files are needed to perform these actions:
|
|
|
338
339
|
| `../mITConfig.json` | The config for mIT
|
|
339
340
|
| `../mIDConfig.json` | The config for mID
|
|
340
341
|
| `../customerConfig.json` | The mST customer config
|
|
341
|
-
| `./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
|
|
342
|
+
| `./local/testStart.json` | The local configuration. If it does not exist start.json will be used and if sart.json does not exist start-example.json will be used to create start.json
|
|
342
343
|
**Category**: sync
|
|
343
344
|
<a name="module_local..setup"></a>
|
|
344
345
|
|
|
@@ -361,13 +362,12 @@ When in stand alone, the following actions are being performed:
|
|
|
361
362
|
2. get an admin token for that service
|
|
362
363
|
3. generate a shell script to start the server
|
|
363
364
|
|
|
364
|
-
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
|
|
365
|
+
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error.
|
|
365
366
|
|
|
366
367
|
When mST and other servers are present, the following actions are being performed:
|
|
367
368
|
|
|
368
|
-
|
|
369
369
|
1. retrieve the API from [swaggerhub](https://app.swaggerhub.com/search?type=API&owner=mimik)
|
|
370
|
-
2. get an
|
|
370
|
+
2. get an admin token for mST
|
|
371
371
|
3. setup the customer in mST
|
|
372
372
|
4. register the service in mST
|
|
373
373
|
5. generate a shell script to start the server
|
package/configuration/config.js
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
|
+
const DEFAULT_MIT_PORT = 8050;
|
|
2
|
+
const DEFAULT_MID_PORT = 8015;
|
|
3
|
+
const DEFAULT_MST_PORT = 8025;
|
|
4
|
+
|
|
1
5
|
const adminExternalIdBase = 'admin_default_local';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
adminExternalIdBase,
|
|
5
|
-
mSTConfigFile: '../mSTConfig.json',
|
|
6
|
-
mITConfigFile: '../mITConfig.json',
|
|
7
|
-
mIDConfigFile: '../mIDConfig.json',
|
|
8
|
-
sumoFile: '../sumo.json',
|
|
9
|
-
customerConfigFile: '../customerConfig.json',
|
|
7
|
+
export const config = {
|
|
10
8
|
APIProvider: 'https://api.swaggerhub.com/apis',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
testJsonFile: './server-test.json',
|
|
14
|
-
shellFile: './server-start.sh',
|
|
15
|
-
startFile: './local/start.json',
|
|
16
|
-
testStartFile: './local/testStart.json',
|
|
17
|
-
exampleStartFile: './local/start-example.json',
|
|
18
|
-
DEFAULT_MST: {
|
|
19
|
-
basePath: '/mST/v1',
|
|
9
|
+
DEFAULT_MID: {
|
|
10
|
+
basePath: '/mID/v1',
|
|
20
11
|
protocol: 'http:',
|
|
21
12
|
domainName: 'localhost',
|
|
22
|
-
port:
|
|
13
|
+
port: DEFAULT_MID_PORT,
|
|
14
|
+
implicit: {
|
|
15
|
+
key: 'a-secret-key',
|
|
16
|
+
audience: 'https://mimik',
|
|
17
|
+
},
|
|
23
18
|
admin: {
|
|
24
|
-
|
|
25
|
-
clientSecret: 'timeForSecret',
|
|
19
|
+
externalId: `${adminExternalIdBase}_mID`,
|
|
26
20
|
},
|
|
27
21
|
},
|
|
28
22
|
DEFAULT_MIT: {
|
|
29
23
|
basePath: '/mIT/v1',
|
|
30
24
|
protocol: 'http:',
|
|
31
25
|
domainName: 'localhost',
|
|
32
|
-
port:
|
|
26
|
+
port: DEFAULT_MIT_PORT,
|
|
33
27
|
},
|
|
34
|
-
|
|
35
|
-
basePath: '/
|
|
28
|
+
DEFAULT_MST: {
|
|
29
|
+
basePath: '/mST/v1',
|
|
36
30
|
protocol: 'http:',
|
|
37
31
|
domainName: 'localhost',
|
|
38
|
-
port:
|
|
39
|
-
implicit: {
|
|
40
|
-
key: 'a-secret-key',
|
|
41
|
-
audience: 'https://mimik',
|
|
42
|
-
},
|
|
32
|
+
port: DEFAULT_MST_PORT,
|
|
43
33
|
admin: {
|
|
44
|
-
|
|
34
|
+
clientId: '12345',
|
|
35
|
+
clientSecret: 'timeForSecret',
|
|
45
36
|
},
|
|
46
37
|
},
|
|
47
38
|
DEFAULT_SUMO: {
|
|
@@ -50,4 +41,17 @@ module.exports = {
|
|
|
50
41
|
code: '--- default code ---',
|
|
51
42
|
},
|
|
52
43
|
},
|
|
44
|
+
adminExternalIdBase,
|
|
45
|
+
customerConfigFile: '../customerConfig.json',
|
|
46
|
+
defaultDirectory: './api',
|
|
47
|
+
exampleStartFile: './local/start-example.json',
|
|
48
|
+
mIDConfigFile: '../mIDConfig.json',
|
|
49
|
+
mITConfigFile: '../mITConfig.json',
|
|
50
|
+
mSTConfigFile: '../mSTConfig.json',
|
|
51
|
+
shellFile: './server-start.sh',
|
|
52
|
+
startFile: './local/start.json',
|
|
53
|
+
sumoFile: '../sumo.json',
|
|
54
|
+
swaggerExt: 'swagger.json',
|
|
55
|
+
testJsonFile: './server-test.json',
|
|
56
|
+
testStartFile: './local/testStart.json',
|
|
53
57
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import importPlugin from 'eslint-plugin-import';
|
|
2
|
+
import js from '@eslint/js';
|
|
3
|
+
import processDoc from '@mimik/eslint-plugin-document-env';
|
|
4
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
+
|
|
6
|
+
const MAX_LENGTH_LINE = 180;
|
|
7
|
+
const MAX_FUNCTION_PARAMETERS = 6;
|
|
8
|
+
const MAX_LINES_IN_FILES = 600;
|
|
9
|
+
const MAX_LINES_IN_FUNCTION = 150;
|
|
10
|
+
const MAX_STATEMENTS_IN_FUNCTION = 45;
|
|
11
|
+
const MIN_KEYS_IN_OBJECT = 10;
|
|
12
|
+
const MAX_COMPLEXITY = 30;
|
|
13
|
+
|
|
14
|
+
export default [
|
|
15
|
+
{
|
|
16
|
+
ignores: ['mochawesome-report/**', 'node_modules/**', 'dist/**'],
|
|
17
|
+
},
|
|
18
|
+
importPlugin.flatConfigs.recommended,
|
|
19
|
+
stylistic.configs.recommended,
|
|
20
|
+
js.configs.all,
|
|
21
|
+
{
|
|
22
|
+
plugins: {
|
|
23
|
+
processDoc,
|
|
24
|
+
},
|
|
25
|
+
languageOptions: {
|
|
26
|
+
ecmaVersion: 2022,
|
|
27
|
+
globals: {
|
|
28
|
+
console: 'readonly',
|
|
29
|
+
describe: 'readonly',
|
|
30
|
+
it: 'readonly',
|
|
31
|
+
require: 'readonly',
|
|
32
|
+
},
|
|
33
|
+
sourceType: 'module',
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
'@stylistic/brace-style': ['warn', 'stroustrup', { allowSingleLine: true }],
|
|
37
|
+
'@stylistic/line-comment-position': ['off'],
|
|
38
|
+
'@stylistic/semi': ['error', 'always'],
|
|
39
|
+
'capitalized-comments': ['off'],
|
|
40
|
+
'complexity': ['error', MAX_COMPLEXITY],
|
|
41
|
+
'curly': ['off'],
|
|
42
|
+
'id-length': ['error', { exceptions: ['x', 'y', 'z', 'i', 'j', 'k'] }],
|
|
43
|
+
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
44
|
+
'import/no-unresolved': ['error', { amd: true, caseSensitiveStrict: true, commonjs: true }],
|
|
45
|
+
'init-declarations': ['off'],
|
|
46
|
+
'linebreak-style': ['off'],
|
|
47
|
+
'max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true }],
|
|
48
|
+
'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true }],
|
|
49
|
+
'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true }],
|
|
50
|
+
'max-params': ['error', MAX_FUNCTION_PARAMETERS],
|
|
51
|
+
'max-statements': ['warn', MAX_STATEMENTS_IN_FUNCTION],
|
|
52
|
+
'no-confusing-arrow': ['off'], // arrow isnt confusing
|
|
53
|
+
'no-inline-comments': ['off'],
|
|
54
|
+
'no-process-env': ['error'],
|
|
55
|
+
'no-ternary': ['off'],
|
|
56
|
+
'no-undefined': ['off'],
|
|
57
|
+
'one-var': ['error', 'never'],
|
|
58
|
+
'processDoc/validate-document-env': ['error'],
|
|
59
|
+
'quotes': ['warn', 'single'],
|
|
60
|
+
'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: MIN_KEYS_IN_OBJECT, natural: false }],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import importPlugin from 'eslint-plugin-import';
|
|
2
|
+
import js from '@eslint/js';
|
|
3
|
+
import processDoc from '@mimik/eslint-plugin-document-env';
|
|
4
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
+
|
|
6
|
+
const MAX_LENGTH_LINE = 180;
|
|
7
|
+
const MAX_FUNCTION_PARAMETERS = 6;
|
|
8
|
+
const MAX_LINES_IN_FILES = 600;
|
|
9
|
+
const MAX_LINES_IN_FUNCTION = 150;
|
|
10
|
+
const MAX_STATEMENTS_IN_FUNCTION = 80;
|
|
11
|
+
const MIN_KEYS_IN_OBJECT = 10;
|
|
12
|
+
const MAX_COMPLEXITY = 80;
|
|
13
|
+
const MAX_DEPTH = 6;
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
{
|
|
17
|
+
ignores: ['mochawesome-report/**', 'node_modules/**', 'dist/**'],
|
|
18
|
+
},
|
|
19
|
+
importPlugin.flatConfigs.recommended,
|
|
20
|
+
stylistic.configs.recommended,
|
|
21
|
+
js.configs.all,
|
|
22
|
+
{
|
|
23
|
+
plugins: {
|
|
24
|
+
processDoc,
|
|
25
|
+
},
|
|
26
|
+
languageOptions: {
|
|
27
|
+
ecmaVersion: 2022,
|
|
28
|
+
globals: {
|
|
29
|
+
console: 'readonly',
|
|
30
|
+
describe: 'readonly',
|
|
31
|
+
it: 'readonly',
|
|
32
|
+
require: 'readonly',
|
|
33
|
+
},
|
|
34
|
+
sourceType: 'module',
|
|
35
|
+
},
|
|
36
|
+
rules: {
|
|
37
|
+
'@stylistic/brace-style': ['warn', 'stroustrup', { allowSingleLine: true }],
|
|
38
|
+
'@stylistic/line-comment-position': ['off'],
|
|
39
|
+
'@stylistic/semi': ['error', 'always'],
|
|
40
|
+
'capitalized-comments': ['off'],
|
|
41
|
+
'complexity': ['error', MAX_COMPLEXITY],
|
|
42
|
+
'curly': ['off'],
|
|
43
|
+
'id-length': ['error', { exceptions: ['x', 'y', 'z', 'i', 'j', 'k'] }],
|
|
44
|
+
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
45
|
+
'import/no-unresolved': ['error', { amd: true, caseSensitiveStrict: true, commonjs: true }],
|
|
46
|
+
'init-declarations': ['off'],
|
|
47
|
+
'linebreak-style': ['off'],
|
|
48
|
+
'max-depth': ['error', MAX_DEPTH],
|
|
49
|
+
'max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true }],
|
|
50
|
+
'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true }],
|
|
51
|
+
'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true }],
|
|
52
|
+
'max-params': ['error', MAX_FUNCTION_PARAMETERS],
|
|
53
|
+
'max-statements': ['warn', MAX_STATEMENTS_IN_FUNCTION],
|
|
54
|
+
'no-confusing-arrow': ['off'], // arrow isnt confusing
|
|
55
|
+
'no-inline-comments': ['off'],
|
|
56
|
+
'no-process-env': ['error'],
|
|
57
|
+
'no-ternary': ['off'],
|
|
58
|
+
'no-undefined': ['off'],
|
|
59
|
+
'one-var': ['error', 'never'],
|
|
60
|
+
'processDoc/validate-document-env': ['error'],
|
|
61
|
+
'quotes': ['warn', 'single'],
|
|
62
|
+
'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: MIN_KEYS_IN_OBJECT, natural: false }],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|