@kravc/schema 2.7.0 → 2.7.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.
@@ -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
+ }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/schema",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Advanced JSON schema manipulation and validation library.",
5
5
  "keywords": [
6
6
  "JSON",
@@ -13,6 +13,7 @@
13
13
  "Verifiable Credential"
14
14
  ],
15
15
  "main": "src/index.js",
16
+ "types": "src/index.d.ts",
16
17
  "repository": {
17
18
  "type": "git",
18
19
  "url": "http://github.com/alexkravets/schema.git"
@@ -27,25 +28,21 @@
27
28
  "license": "ISC",
28
29
  "dependencies": {
29
30
  "credentials-context": "^2.0.0",
30
- "lodash.clonedeep": "^4.5.0",
31
- "lodash.groupby": "^4.6.0",
32
- "lodash.isobject": "^3.0.2",
33
- "lodash.isundefined": "^3.0.1",
34
- "lodash.keyby": "^4.6.0",
35
- "lodash.pick": "^4.4.0",
36
- "lodash.set": "^4.3.2",
37
- "lodash.uniq": "^4.5.0",
31
+ "lodash": "^4.17.21",
38
32
  "security-context": "^4.0.0",
39
33
  "validator": "^13.9.0",
40
34
  "z-schema": "^6.0.1"
41
35
  },
42
36
  "devDependencies": {
43
- "chai": "^4.3.7",
44
- "eslint": "^8.35.0",
37
+ "@eslint/eslintrc": "^3.2.0",
38
+ "@eslint/js": "^9.15.0",
39
+ "chai": "^5.1.2",
40
+ "eslint": "^9.15.0",
41
+ "globals": "^15.12.0",
45
42
  "js-yaml": "^4.1.0",
46
- "jsonld": "^5.2.0",
47
- "mocha": "^10.2.0",
48
- "nyc": "^15.1.0"
43
+ "jsonld": "^8.3.2",
44
+ "mocha": "^10.8.2",
45
+ "nyc": "^17.1.0"
49
46
  },
50
47
  "nyc": {
51
48
  "include": "src",
package/src/Schema.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const pick = require('lodash.pick')
4
- const cloneDeep = require('lodash.clonedeep')
3
+ const { pick, cloneDeep } = require('lodash')
5
4
  const validateId = require('./helpers/validateId')
6
5
  const normalizeRequired = require('./helpers/normalizeRequired')
7
6
  const normalizeProperties = require('./helpers/normalizeProperties')
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const pick = require('lodash.pick')
3
+ const { pick } = require('lodash')
4
4
 
5
5
  class ValidationError extends Error {
6
6
  constructor(schemaId, invalidObject, validationErrors) {
package/src/Validator.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const keyBy = require('lodash.keyby')
4
- const groupBy = require('lodash.groupby')
3
+ const { keyBy, groupBy } = require('lodash')
5
4
  const ZSchema = require('z-schema')
6
5
  const cleanupNulls = require('./helpers/cleanupNulls')
7
6
  const getReferenceIds = require('./helpers/getReferenceIds')
@@ -73,6 +72,7 @@ class Validator {
73
72
  // or numbers are '1', '2'... strings.
74
73
  normalizeAttributes(result, jsonSchema, this._jsonSchemasMap)
75
74
 
75
+ // eslint-disable-next-line no-unused-vars
76
76
  } catch (error) {
77
77
  // NOTE: Skip errors in cleanup and normalize attributes methods,
78
78
  // validation fails for objects with invalid value types.
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const isUndefined = require('lodash.isundefined')
3
+ const { isUndefined } = require('lodash')
4
4
 
5
5
  const cleanupAttributes = (object, jsonSchema, schemasMap) => {
6
6
  const { id, enum: isEnum } = jsonSchema
@@ -1,8 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const isObject = require('lodash.isobject')
4
- const cloneDeep = require('lodash.clonedeep')
5
3
  const { isArray } = Array
4
+ const { isObject, cloneDeep } = require('lodash')
6
5
 
7
6
  const cleanupNulls = object => {
8
7
  if (!isObject(object)) {
@@ -1,8 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const uniq = require('lodash.uniq')
4
- const Schema = require('../Schema')
5
- const isUndefined = require('lodash.isundefined')
3
+ const { isUndefined, uniq } = require('lodash')
4
+ const Schema = require('../Schema')
6
5
 
7
6
  const getReferenceIds = (schema, schemasMap) => {
8
7
  const getSchema = id => schemasMap[id]
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const isUndefined = require('lodash.isundefined')
3
+ const { isUndefined } = require('lodash')
4
4
 
5
5
  const mapObject = (object, jsonSchema, schemasMap, callback) => {
6
6
  const { id, enum: isEnum } = jsonSchema
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const mapObject = require('./mapObject')
4
- const isUndefined = require('lodash.isundefined')
5
4
  const normalizeType = require('./normalizeType')
5
+ const { isUndefined } = require('lodash')
6
6
 
7
7
  const normalizeAttributes = (object, jsonSchema, jsonSchemasMap) => {
8
8
  const callback = (propertyName, propertySchema, object) => {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const isUndefined = require('lodash.isundefined')
3
+ const { isUndefined } = require('lodash')
4
4
 
5
5
  const normalizeProperties = properties => {
6
6
  const { enum: isEnum } = properties
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const get = require('lodash.get')
4
- const set = require('lodash.set')
3
+ const { get, set } = require('lodash')
5
4
  const { schemaSymbol, jsonSymbol } = require('z-schema')
6
5
 
7
6
  const FORMAT_ERROR_CODES = [
package/src/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ declare type SchemaAttribute = object;
2
+
3
+ export declare class Schema {
4
+ constructor(
5
+ source: Record<string, SchemaAttribute>,
6
+ id: string,
7
+ url?: string
8
+ )
9
+ }
10
+
11
+ export declare class Validator {
12
+ constructor(
13
+ schemas: Schema[]
14
+ )
15
+ }
package/.eslintrc.yml DELETED
@@ -1,42 +0,0 @@
1
- extends: 'eslint:recommended'
2
-
3
- parserOptions:
4
- ecmaVersion: 2018
5
-
6
- env:
7
- es6: true
8
- node: true
9
- mocha: true
10
-
11
- rules:
12
- comma-style: error
13
- consistent-this:
14
- - error
15
- - _this
16
- indent:
17
- - error
18
- - 2
19
- - SwitchCase: 1
20
- VariableDeclarator: 2
21
- keyword-spacing: error
22
- no-multi-spaces: off
23
- no-spaced-func: error
24
- no-trailing-spaces: error
25
- quotes:
26
- - error
27
- - single
28
- semi:
29
- - error
30
- - never
31
- curly:
32
- - error
33
- prefer-arrow-callback: error
34
- space-before-blocks: error
35
- space-before-function-paren:
36
- - 1
37
- - anonymous: always
38
- named: never
39
- space-infix-ops: error
40
- space-unary-ops: error
41
- no-return-await: error
42
- eqeqeq: error