@nsshunt/stsutils 1.5.15 → 1.6.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/.github/workflows/npm-publish.yml +3 -3
- package/index.js +2 -1
- package/package.json +6 -5
- package/stsoptionsbase.js +10 -1
- package/validate.js +30 -0
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
- uses: actions/checkout@v2
|
|
17
17
|
- uses: actions/setup-node@v2
|
|
18
18
|
with:
|
|
19
|
-
node-version:
|
|
19
|
+
node-version: 17
|
|
20
20
|
- run: npm ci
|
|
21
21
|
- run: npm run lint
|
|
22
22
|
- run: npm test
|
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
- uses: actions/checkout@v2
|
|
29
29
|
- uses: actions/setup-node@v2
|
|
30
30
|
with:
|
|
31
|
-
node-version:
|
|
31
|
+
node-version: 17
|
|
32
32
|
registry-url: https://registry.npmjs.org/
|
|
33
33
|
- run: npm ci
|
|
34
34
|
- run: npm publish --access public
|
|
@@ -45,7 +45,7 @@ jobs:
|
|
|
45
45
|
# - uses: actions/checkout@v2
|
|
46
46
|
# - uses: actions/setup-node@v2
|
|
47
47
|
# with:
|
|
48
|
-
# node-version:
|
|
48
|
+
# node-version: 17
|
|
49
49
|
# registry-url: https://npm.pkg.github.com/
|
|
50
50
|
# - run: npm ci
|
|
51
51
|
# - run: npm publish
|
package/index.js
CHANGED
|
@@ -2,5 +2,6 @@ let sleep = require('./sleep.js');
|
|
|
2
2
|
let status = require('./status.js');
|
|
3
3
|
const AuthUtilsBrowser = require('./authutilsbrowser.js');
|
|
4
4
|
const STSOptionsBase = require('./stsoptionsbase.js');
|
|
5
|
+
const { AddSchema, Validate } = require('./validate.js');
|
|
5
6
|
|
|
6
|
-
module.exports = { sleep, status, STSOptionsBase, AuthUtilsBrowser };
|
|
7
|
+
module.exports = { sleep, status, STSOptionsBase, AuthUtilsBrowser, AddSchema, Validate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsutils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"parser": "@babel/eslint-parser"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/core": "^7.
|
|
26
|
-
"@babel/eslint-parser": "^7.
|
|
25
|
+
"@babel/core": "^7.17.0",
|
|
26
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
27
27
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
28
|
-
"@babel/plugin-proposal-private-methods": "^7.16.
|
|
29
|
-
"eslint": "^8.
|
|
28
|
+
"@babel/plugin-proposal-private-methods": "^7.16.11",
|
|
29
|
+
"eslint": "^8.8.0",
|
|
30
30
|
"jest": "^27.4.7"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"ajv": "^8.9.0",
|
|
33
34
|
"axios": "^0.25.0",
|
|
34
35
|
"colors": "^1.4.0",
|
|
35
36
|
"debug": "^4.3.3"
|
package/stsoptionsbase.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
const { Validate } = require('./validate.js');
|
|
2
|
+
|
|
1
3
|
class STSOptionsBase
|
|
2
4
|
{
|
|
3
5
|
#options = null;
|
|
4
6
|
|
|
5
|
-
constructor(options = null)
|
|
7
|
+
constructor(options = null, validator = null)
|
|
6
8
|
{
|
|
7
9
|
this.#options = options;
|
|
10
|
+
|
|
11
|
+
if (validator === null) {
|
|
12
|
+
console.log(JSON.stringify(options));
|
|
13
|
+
console.trace("Options Here ------------------------------------------------------------------------------------------")
|
|
14
|
+
} else {
|
|
15
|
+
Validate(validator, options);
|
|
16
|
+
}
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
/**
|
package/validate.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const Ajv = require('ajv/dist/jtd');
|
|
2
|
+
|
|
3
|
+
const ajv = new Ajv();
|
|
4
|
+
|
|
5
|
+
const _Validate = (validator, payload) => {
|
|
6
|
+
const valid = validator(payload);
|
|
7
|
+
if (!valid) {
|
|
8
|
+
console.error(validator.errors);
|
|
9
|
+
console.trace('Invalid Schema');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const AddSchema = (name, schema) => {
|
|
15
|
+
ajv.addSchema(schema, name);
|
|
16
|
+
return (payload) => {
|
|
17
|
+
const validator = ajv.getSchema(name)
|
|
18
|
+
_Validate(validator, payload)
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Validate = (name, payload) => {
|
|
23
|
+
const validator = ajv.getSchema(name)
|
|
24
|
+
_Validate(validator, payload);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
AddSchema,
|
|
29
|
+
Validate
|
|
30
|
+
};
|