@kravc/dos 1.8.4 → 1.8.6
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/eslint.config.mjs +55 -0
- package/examples/CreateProfile.js +8 -0
- package/examples/UpdateProfile.js +7 -0
- package/package.json +11 -20
- package/src/Document.js +1 -3
- package/src/Operation.js +1 -2
- package/src/Service.js +1 -3
- package/src/helpers/asSafeClass.js +0 -1
- package/src/helpers/createContext.js +1 -2
- package/src/helpers/createSchemasMap.js +3 -3
- package/src/helpers/createSpec.js +14 -3
- package/src/helpers/defaultId.js +1 -1
- package/src/helpers/defaultSummary.js +1 -2
- package/src/helpers/defaultTags.js +1 -1
- package/src/helpers/getComponentTitle.js +2 -3
- package/src/helpers/logError.js +1 -1
- package/src/helpers/maskSecrets.js +1 -2
- package/src/operations/Index.js +1 -1
- package/src/security/JwtAuthorization.js +1 -2
- package/src/security/SystemAuthorization.js +1 -1
- package/.eslintrc.yaml +0 -41
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import js from "@eslint/js";
|
|
5
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [...compat.extends("eslint:recommended"), {
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: {
|
|
18
|
+
...globals.node,
|
|
19
|
+
...globals.mocha,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
ecmaVersion: 2018,
|
|
23
|
+
sourceType: "commonjs",
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
rules: {
|
|
27
|
+
"comma-style": "error",
|
|
28
|
+
"consistent-this": ["error", "_this"],
|
|
29
|
+
|
|
30
|
+
indent: ["error", 2, {
|
|
31
|
+
SwitchCase: 1,
|
|
32
|
+
VariableDeclarator: 2,
|
|
33
|
+
}],
|
|
34
|
+
|
|
35
|
+
"keyword-spacing": "error",
|
|
36
|
+
"no-multi-spaces": "off",
|
|
37
|
+
"no-spaced-func": "error",
|
|
38
|
+
"no-trailing-spaces": "error",
|
|
39
|
+
quotes: ["error", "single"],
|
|
40
|
+
semi: ["error", "never"],
|
|
41
|
+
curly: ["error"],
|
|
42
|
+
"prefer-arrow-callback": "error",
|
|
43
|
+
"space-before-blocks": "error",
|
|
44
|
+
|
|
45
|
+
"space-before-function-paren": [1, {
|
|
46
|
+
anonymous: "always",
|
|
47
|
+
named: "never",
|
|
48
|
+
}],
|
|
49
|
+
|
|
50
|
+
"space-infix-ops": "error",
|
|
51
|
+
"space-unary-ops": "error",
|
|
52
|
+
"no-return-await": "error",
|
|
53
|
+
eqeqeq: "error",
|
|
54
|
+
},
|
|
55
|
+
}];
|
|
@@ -7,6 +7,14 @@ const { publicKey } = require('../src/test/keys')
|
|
|
7
7
|
const JwtAuthorization = require('../src/security/JwtAuthorization')
|
|
8
8
|
|
|
9
9
|
class CreateProfile extends Create(Profile) {
|
|
10
|
+
static get tags() {
|
|
11
|
+
return [
|
|
12
|
+
'Profiles',
|
|
13
|
+
'profiles-write',
|
|
14
|
+
'System'
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
static get security() {
|
|
11
19
|
const algorithm = 'RS256'
|
|
12
20
|
|
|
@@ -7,6 +7,13 @@ const JwtAuthorization = require('../src/security/JwtAuthorization')
|
|
|
7
7
|
const SystemAuthorization = require('../src/security/SystemAuthorization')
|
|
8
8
|
|
|
9
9
|
class UpdateProfile extends Update(Profile) {
|
|
10
|
+
static get tags() {
|
|
11
|
+
return [
|
|
12
|
+
'profiles-write',
|
|
13
|
+
'Profiles',
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
static get security() {
|
|
11
18
|
return [
|
|
12
19
|
SystemAuthorization.createRequirement(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kravc/dos",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"description": "Convention-based, easy-to-use library for building API-driven serverless services.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Service",
|
|
@@ -25,33 +25,24 @@
|
|
|
25
25
|
"author": "Alexander Kravets <a@kra.vc>",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@kravc/schema": "^2.7.
|
|
29
|
-
"cookie": "^0.
|
|
28
|
+
"@kravc/schema": "^2.7.1",
|
|
29
|
+
"cookie": "^1.0.1",
|
|
30
30
|
"js-yaml": "^4.1.0",
|
|
31
31
|
"jsonwebtoken": "^9.0.2",
|
|
32
|
-
"lodash
|
|
33
|
-
"lodash.clonedeep": "^4.5.0",
|
|
34
|
-
"lodash.compact": "^3.0.1",
|
|
35
|
-
"lodash.get": "^4.4.2",
|
|
36
|
-
"lodash.isempty": "^4.4.0",
|
|
37
|
-
"lodash.isobject": "^3.0.2",
|
|
38
|
-
"lodash.isstring": "^4.0.1",
|
|
39
|
-
"lodash.isundefined": "^3.0.1",
|
|
40
|
-
"lodash.keyby": "^4.6.0",
|
|
41
|
-
"lodash.omit": "^4.5.0",
|
|
42
|
-
"lodash.pick": "^4.4.0",
|
|
43
|
-
"lodash.startcase": "^4.4.0",
|
|
44
|
-
"lodash.uniq": "^4.5.0",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
45
33
|
"pluralize": "^8.0.0",
|
|
46
34
|
"ulid": "^2.3.0",
|
|
47
35
|
"uuid": "^9.0.1",
|
|
48
36
|
"z-schema": "^6.0.1"
|
|
49
37
|
},
|
|
50
38
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
"eslint": "^
|
|
53
|
-
"
|
|
54
|
-
"
|
|
39
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
40
|
+
"@eslint/js": "^9.15.0",
|
|
41
|
+
"chai": "^5.1.2",
|
|
42
|
+
"eslint": "^9.15.0",
|
|
43
|
+
"globals": "^15.12.0",
|
|
44
|
+
"mocha": "^10.8.2",
|
|
45
|
+
"nyc": "^17.1.0"
|
|
55
46
|
},
|
|
56
47
|
"nyc": {
|
|
57
48
|
"include": "src",
|
package/src/Document.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const get
|
|
4
|
-
const omit = require('lodash.omit')
|
|
3
|
+
const { get, omit, capitalize } = require('lodash')
|
|
5
4
|
const { ulid } = require('ulid')
|
|
6
5
|
const Component = require('./Component')
|
|
7
|
-
const capitalize = require('lodash.capitalize')
|
|
8
6
|
const getIdPrefix = require('./helpers/getIdPrefix')
|
|
9
7
|
const getComponentTitle = require('./helpers/getComponentTitle')
|
|
10
8
|
const DocumentExistsError = require('./errors/DocumentExistsError')
|
package/src/Operation.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const isEmpty = require('lodash.isempty')
|
|
4
|
-
const cloneDeep = require('lodash.clonedeep')
|
|
5
3
|
const { Schema } = require('@kravc/schema')
|
|
4
|
+
const { isEmpty, cloneDeep } = require('lodash')
|
|
6
5
|
|
|
7
6
|
const defaultId = require('./helpers/defaultId')
|
|
8
7
|
const defaultTags = require('./helpers/defaultTags')
|
package/src/Service.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const get
|
|
4
|
-
const uniq = require('lodash.uniq')
|
|
3
|
+
const { get, uniq, compact } = require('lodash')
|
|
5
4
|
const handler = require('./helpers/handler')
|
|
6
|
-
const compact = require('lodash.compact')
|
|
7
5
|
const authorize = require('./helpers/authorize')
|
|
8
6
|
const createSpec = require('./helpers/createSpec')
|
|
9
7
|
const { Validator } = require('@kravc/schema')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const path
|
|
4
|
-
const keyBy
|
|
5
|
-
const loadSync
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const { keyBy } = require('lodash')
|
|
5
|
+
const loadSync = require('./loadSync')
|
|
6
6
|
const { readdirSync, statSync } = require('fs')
|
|
7
7
|
|
|
8
8
|
const ROOT_PATH = process.cwd()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const omit
|
|
4
|
-
const uniq = require('lodash.uniq')
|
|
3
|
+
const { omit, uniq } = require('lodash')
|
|
5
4
|
const ZSchema = require('z-schema')
|
|
6
5
|
const { parse } = require('url')
|
|
7
6
|
const jsonSchema = require('../../assets/schemas/oas2.json')
|
|
@@ -159,7 +158,19 @@ const createSpec = (operations, schemasMap, url) => {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
serviceTags = uniq(serviceTags)
|
|
162
|
-
|
|
161
|
+
|
|
162
|
+
console.log(serviceTags)
|
|
163
|
+
|
|
164
|
+
serviceTags.sort((a, b) => {
|
|
165
|
+
const aStartsWithUpper = /^[A-Z]/.test(a)
|
|
166
|
+
const bStartsWithUpper = /^[A-Z]/.test(b)
|
|
167
|
+
|
|
168
|
+
if (aStartsWithUpper && !bStartsWithUpper) { return -1 }
|
|
169
|
+
|
|
170
|
+
if (!aStartsWithUpper && bStartsWithUpper) { return 1 }
|
|
171
|
+
|
|
172
|
+
return a.localeCompare(b)
|
|
173
|
+
})
|
|
163
174
|
spec.tags = serviceTags.map(name => ({ name }))
|
|
164
175
|
|
|
165
176
|
const json = JSON
|
package/src/helpers/defaultId.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const startCase
|
|
4
|
-
const pluralize
|
|
5
|
-
const capitalize = require('lodash.capitalize')
|
|
3
|
+
const { startCase, capitalize } = require('lodash')
|
|
4
|
+
const pluralize = require('pluralize')
|
|
6
5
|
|
|
7
6
|
const getComponentTitle = (Component, isCapitalized = true, isPlural = false) => {
|
|
8
7
|
const { name } = Component
|
package/src/helpers/logError.js
CHANGED
package/src/operations/Index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { capitalize } = require('lodash')
|
|
3
4
|
const Operation = require('../Operation')
|
|
4
|
-
const capitalize = require('lodash.capitalize')
|
|
5
5
|
const getComponentTitle = require('../helpers/getComponentTitle')
|
|
6
6
|
|
|
7
7
|
const Index = (Component, componentAction = 'index') => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const get
|
|
3
|
+
const { get, capitalize } = require('lodash')
|
|
4
4
|
const cookie = require('cookie')
|
|
5
5
|
const { decode } = require('jsonwebtoken')
|
|
6
|
-
const capitalize = require('lodash.capitalize')
|
|
7
6
|
const verifyToken = require('./verifyToken')
|
|
8
7
|
const AccessDeniedError = require('../errors/AccessDeniedError')
|
|
9
8
|
const UnauthorizedError = require('../errors/UnauthorizedError')
|
package/.eslintrc.yaml
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
extends: 'eslint:recommended'
|
|
2
|
-
|
|
3
|
-
parserOptions:
|
|
4
|
-
ecmaVersion: 2018
|
|
5
|
-
|
|
6
|
-
env:
|
|
7
|
-
node: true
|
|
8
|
-
mocha: true
|
|
9
|
-
|
|
10
|
-
rules:
|
|
11
|
-
comma-style: error
|
|
12
|
-
consistent-this:
|
|
13
|
-
- error
|
|
14
|
-
- _this
|
|
15
|
-
indent:
|
|
16
|
-
- error
|
|
17
|
-
- 2
|
|
18
|
-
- SwitchCase: 1
|
|
19
|
-
VariableDeclarator: 2
|
|
20
|
-
keyword-spacing: error
|
|
21
|
-
no-multi-spaces: off
|
|
22
|
-
no-spaced-func: error
|
|
23
|
-
no-trailing-spaces: error
|
|
24
|
-
quotes:
|
|
25
|
-
- error
|
|
26
|
-
- single
|
|
27
|
-
semi:
|
|
28
|
-
- error
|
|
29
|
-
- never
|
|
30
|
-
curly:
|
|
31
|
-
- error
|
|
32
|
-
prefer-arrow-callback: error
|
|
33
|
-
space-before-blocks: error
|
|
34
|
-
space-before-function-paren:
|
|
35
|
-
- 1
|
|
36
|
-
- anonymous: always
|
|
37
|
-
named: never
|
|
38
|
-
space-infix-ops: error
|
|
39
|
-
space-unary-ops: error
|
|
40
|
-
no-return-await: error
|
|
41
|
-
eqeqeq: error
|