@takeshape/json-schema 10.2.0 → 10.2.4

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.
@@ -52,10 +52,7 @@ function isInvalidPropertyRequired(topLevelSchema, error) {
52
52
  }
53
53
  function isRequired(topLevelSchema, schema, name) {
54
54
  const schemas = schema.allOf || schema.anyOf || schema.oneOf || [schema];
55
- return schemas.some(childSchema => {
56
- var _followRef, _followRef$required;
57
- return (_followRef = followRef(topLevelSchema, childSchema)) === null || _followRef === void 0 ? void 0 : (_followRef$required = _followRef.required) === null || _followRef$required === void 0 ? void 0 : _followRef$required.includes(name);
58
- });
55
+ return schemas.some(childSchema => followRef(topLevelSchema, childSchema)?.required?.includes(name));
59
56
  }
60
57
  function getName(path) {
61
58
  const parts = parseDataPath(path);
@@ -80,7 +77,6 @@ function followRef(topLevelSchema, schema) {
80
77
  */
81
78
  function followSchemaPath(topLevelSchema, instancePath) {
82
79
  const followPath = (schema, path) => {
83
- var _schema, _schema$properties;
84
80
  schema = followRef(topLevelSchema, schema);
85
81
  if (path.length === 0) {
86
82
  return schema;
@@ -98,7 +94,7 @@ function followSchemaPath(topLevelSchema, instancePath) {
98
94
  if (schema.items && /^\d+$/.exec(first)) {
99
95
  return followPath(schema.items, rest);
100
96
  }
101
- const prop = (_schema = schema) === null || _schema === void 0 ? void 0 : (_schema$properties = _schema.properties) === null || _schema$properties === void 0 ? void 0 : _schema$properties[first];
97
+ const prop = schema?.properties?.[first];
102
98
  if (prop) {
103
99
  return rest.length ? followPath(prop, rest) : prop;
104
100
  }
@@ -109,10 +105,8 @@ function isSchemaObject(schema) {
109
105
  return typeof schema === 'object';
110
106
  }
111
107
  function getSchemaWithDefinitions(ajv, id) {
112
- var _ajv$getSchema2;
113
108
  if (id.startsWith('#')) {
114
- var _ajv$getSchema;
115
- const rootSchema = (_ajv$getSchema = ajv.getSchema('#')) === null || _ajv$getSchema === void 0 ? void 0 : _ajv$getSchema.schema;
109
+ const rootSchema = ajv.getSchema('#')?.schema;
116
110
  if (isSchemaObject(rootSchema)) {
117
111
  const path = refToPath(id);
118
112
  const {
@@ -124,7 +118,7 @@ function getSchemaWithDefinitions(ajv, id) {
124
118
  };
125
119
  }
126
120
  }
127
- return (_ajv$getSchema2 = ajv.getSchema(id)) === null || _ajv$getSchema2 === void 0 ? void 0 : _ajv$getSchema2.schema;
121
+ return ajv.getSchema(id)?.schema;
128
122
  }
129
123
  function validate(ajv, id, data, options) {
130
124
  const params = {
@@ -32,10 +32,7 @@ export function isInvalidPropertyRequired(topLevelSchema, error) {
32
32
  }
33
33
  function isRequired(topLevelSchema, schema, name) {
34
34
  const schemas = schema.allOf || schema.anyOf || schema.oneOf || [schema];
35
- return schemas.some(childSchema => {
36
- var _followRef, _followRef$required;
37
- return (_followRef = followRef(topLevelSchema, childSchema)) === null || _followRef === void 0 ? void 0 : (_followRef$required = _followRef.required) === null || _followRef$required === void 0 ? void 0 : _followRef$required.includes(name);
38
- });
35
+ return schemas.some(childSchema => followRef(topLevelSchema, childSchema)?.required?.includes(name));
39
36
  }
40
37
  function getName(path) {
41
38
  const parts = parseDataPath(path);
@@ -60,7 +57,6 @@ function followRef(topLevelSchema, schema) {
60
57
  */
61
58
  export function followSchemaPath(topLevelSchema, instancePath) {
62
59
  const followPath = (schema, path) => {
63
- var _schema, _schema$properties;
64
60
  schema = followRef(topLevelSchema, schema);
65
61
  if (path.length === 0) {
66
62
  return schema;
@@ -78,7 +74,7 @@ export function followSchemaPath(topLevelSchema, instancePath) {
78
74
  if (schema.items && /^\d+$/.exec(first)) {
79
75
  return followPath(schema.items, rest);
80
76
  }
81
- const prop = (_schema = schema) === null || _schema === void 0 ? void 0 : (_schema$properties = _schema.properties) === null || _schema$properties === void 0 ? void 0 : _schema$properties[first];
77
+ const prop = schema?.properties?.[first];
82
78
  if (prop) {
83
79
  return rest.length ? followPath(prop, rest) : prop;
84
80
  }
@@ -89,10 +85,8 @@ function isSchemaObject(schema) {
89
85
  return typeof schema === 'object';
90
86
  }
91
87
  function getSchemaWithDefinitions(ajv, id) {
92
- var _ajv$getSchema2;
93
88
  if (id.startsWith('#')) {
94
- var _ajv$getSchema;
95
- const rootSchema = (_ajv$getSchema = ajv.getSchema('#')) === null || _ajv$getSchema === void 0 ? void 0 : _ajv$getSchema.schema;
89
+ const rootSchema = ajv.getSchema('#')?.schema;
96
90
  if (isSchemaObject(rootSchema)) {
97
91
  const path = refToPath(id);
98
92
  const {
@@ -104,7 +98,7 @@ function getSchemaWithDefinitions(ajv, id) {
104
98
  };
105
99
  }
106
100
  }
107
- return (_ajv$getSchema2 = ajv.getSchema(id)) === null || _ajv$getSchema2 === void 0 ? void 0 : _ajv$getSchema2.schema;
101
+ return ajv.getSchema(id)?.schema;
108
102
  }
109
103
  export function validate(ajv, id, data, options) {
110
104
  const params = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/json-schema",
3
- "version": "10.2.0",
3
+ "version": "10.2.4",
4
4
  "description": "JSON Schema validator",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -20,14 +20,14 @@
20
20
  "ajv": "^8.11.0",
21
21
  "ajv-formats": "^2.1.1",
22
22
  "lodash": "^4.17.21",
23
- "@takeshape/util": "10.2.0"
23
+ "@takeshape/util": "10.2.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/lodash": "^4.14.165",
27
- "@takeshape/typescript-jest-junit-reporter": "10.2.0"
27
+ "@takeshape/typescript-jest-junit-reporter": "10.2.4"
28
28
  },
29
29
  "engines": {
30
- "node": ">=16"
30
+ "node": ">=18"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "pnpm build:js && pnpm build:es && pnpm build:types && pnpm build:copy",