@swagger-api/apidom-json-path 0.74.1 → 0.76.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/CHANGELOG.md CHANGED
@@ -3,46 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [0.74.1](https://github.com/swagger-api/apidom/compare/v0.74.0...v0.74.1) (2023-07-28)
7
-
8
- **Note:** Version bump only for package @swagger-api/apidom-json-path
9
-
10
-
6
+ # [0.76.0](https://github.com/swagger-api/apidom/compare/v0.75.0...v0.76.0) (2023-09-01)
11
7
 
8
+ ### Features
12
9
 
10
+ - **json-path:** use error hierarchy and metadata when throwing errors ([#3107](https://github.com/swagger-api/apidom/issues/3107)) ([d55a846](https://github.com/swagger-api/apidom/commit/d55a8466de9814f19aedbacb48c55761f2f3fe38)), closes [#3039](https://github.com/swagger-api/apidom/issues/3039)
13
11
 
14
- # [0.74.0](https://github.com/swagger-api/apidom/compare/v0.73.0...v0.74.0) (2023-07-24)
12
+ # [0.75.0](https://github.com/swagger-api/apidom/compare/v0.74.1...v0.75.0) (2023-08-22)
15
13
 
16
14
  **Note:** Version bump only for package @swagger-api/apidom-json-path
17
15
 
16
+ ## [0.74.1](https://github.com/swagger-api/apidom/compare/v0.74.0...v0.74.1) (2023-07-28)
18
17
 
18
+ **Note:** Version bump only for package @swagger-api/apidom-json-path
19
19
 
20
+ # [0.74.0](https://github.com/swagger-api/apidom/compare/v0.73.0...v0.74.0) (2023-07-24)
20
21
 
22
+ **Note:** Version bump only for package @swagger-api/apidom-json-path
21
23
 
22
24
  # [0.73.0](https://github.com/swagger-api/apidom/compare/v0.72.0...v0.73.0) (2023-07-18)
23
25
 
24
26
  **Note:** Version bump only for package @swagger-api/apidom-json-path
25
27
 
26
-
27
-
28
-
29
-
30
28
  # [0.72.0](https://github.com/swagger-api/apidom/compare/v0.71.1...v0.72.0) (2023-07-17)
31
29
 
32
30
  **Note:** Version bump only for package @swagger-api/apidom-json-path
33
31
 
34
-
35
-
36
-
37
-
38
32
  # [0.71.0](https://github.com/swagger-api/apidom/compare/v0.70.4...v0.71.0) (2023-07-13)
39
33
 
40
34
  **Note:** Version bump only for package @swagger-api/apidom-json-path
41
35
 
42
-
43
-
44
-
45
-
46
36
  ## [0.70.1](https://github.com/swagger-api/apidom/compare/v0.70.0...v0.70.1) (2023-06-15)
47
37
 
48
38
  **Note:** Version bump only for package @swagger-api/apidom-json-path
package/NOTICE CHANGED
@@ -38,7 +38,7 @@ Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
38
38
  - File packages/apidom-core/src/deepmerge.ts contains algorithms that we originally created
39
39
  in https://github.com/TehShrike/deepmerge/blob/master/index.js to handle deep merging of JavaScript Objects and Arrays.
40
40
  These algorithms have been reverse engineered and adapted to support deep merging of ApiDOM structures.
41
- - File packages/apidom-core/test/deepmerge.ts contains tests and fixtures that we originally created
41
+ - File packages/apidom-core/test/deepmerge.ts contains tests and fixtures that were originally created
42
42
  in https://github.com/TehShrike/deepmerge/blob/master/test/merge.js to test deep merging of JavaScript Objects and Arrays.
43
43
  These tests have been adapted to support testing deep merging of ApiDOM structures.
44
44
  - File packages/apidom-core/README.md contains text fragments that were originally created
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _apidomCore = require("@swagger-api/apidom-core");
7
+ var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
8
+ class EvaluationJsonPathError extends _JsonPathError.default {
9
+ constructor(message, structuredOptions) {
10
+ super(message, structuredOptions);
11
+ if (typeof structuredOptions !== 'undefined') {
12
+ this.path = structuredOptions.path;
13
+ this.element = structuredOptions.element.element;
14
+ if ((0, _apidomCore.hasElementSourceMap)(structuredOptions.element)) {
15
+ this.elementSourceMap = (0, _apidomCore.toValue)(structuredOptions.element.getMetaProperty('sourceMap'));
16
+ }
17
+ }
18
+ }
19
+ }
20
+ var _default = EvaluationJsonPathError;
21
+ exports.default = _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _apidomError = require("@swagger-api/apidom-error");
6
+ class JsonPathError extends _apidomError.ApiDOMStructuredError {}
7
+ var _default = JsonPathError;
8
+ exports.default = _default;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _apidomCore = require("@swagger-api/apidom-core");
7
+ var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
8
+ class MultiEvaluationJsonPathError extends _JsonPathError.default {
9
+ constructor(message, structuredOptions) {
10
+ super(message, structuredOptions);
11
+ if (typeof structuredOptions !== 'undefined') {
12
+ this.paths = structuredOptions.paths;
13
+ this.element = structuredOptions.element.element;
14
+ if ((0, _apidomCore.hasElementSourceMap)(structuredOptions.element)) {
15
+ this.elementSourceMap = (0, _apidomCore.toValue)(structuredOptions.element.getMetaProperty('sourceMap'));
16
+ }
17
+ }
18
+ }
19
+ }
20
+ var _default = MultiEvaluationJsonPathError;
21
+ exports.default = _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _jsonpathPlus = require("jsonpath-plus");
7
+ var _apidomCore = require("@swagger-api/apidom-core");
8
+ var _apidomJsonPointer = require("@swagger-api/apidom-json-pointer");
9
+ var _MultiEvaluationJsonPathError = _interopRequireDefault(require("./errors/MultiEvaluationJsonPathError.cjs"));
10
+ /**
11
+ * Evaluates multiple JSONPaths on ApiDOM element.
12
+ */
13
+ const evaluateMulti = (paths, element) => {
14
+ try {
15
+ const json = (0, _apidomCore.toValue)(element);
16
+ const results = [];
17
+ for (const path of paths) {
18
+ const pointers = (0, _jsonpathPlus.JSONPath)({
19
+ path,
20
+ json,
21
+ resultType: 'pointer'
22
+ });
23
+ const endPointValues = [];
24
+ for (const pointer of pointers) {
25
+ const endPointValue = (0, _apidomJsonPointer.evaluate)(pointer, element);
26
+ endPointValues.push(endPointValue);
27
+ }
28
+ if (Array.isArray(path)) {
29
+ results.push([_jsonpathPlus.JSONPath.toPathString(path), endPointValues]);
30
+ } else {
31
+ results.push([path, endPointValues]);
32
+ }
33
+ }
34
+ return results;
35
+ } catch (error) {
36
+ throw new _MultiEvaluationJsonPathError.default(`JSON Path evaluation failed while multi-evaluating "${String(paths)}".`, {
37
+ paths,
38
+ element,
39
+ cause: error
40
+ });
41
+ }
42
+ };
43
+ var _default = evaluateMulti;
44
+ exports.default = _default;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _jsonpathPlus = require("jsonpath-plus");
7
+ var _apidomCore = require("@swagger-api/apidom-core");
8
+ var _apidomJsonPointer = require("@swagger-api/apidom-json-pointer");
9
+ var _EvaluationJsonPathError = _interopRequireDefault(require("./errors/EvaluationJsonPathError.cjs"));
10
+ /**
11
+ * Evaluates single JSONPath on ApiDOM element.
12
+ */
13
+ const evaluate = (path, element) => {
14
+ try {
15
+ const json = (0, _apidomCore.toValue)(element);
16
+ const pointers = (0, _jsonpathPlus.JSONPath)({
17
+ path,
18
+ json,
19
+ resultType: 'pointer'
20
+ });
21
+ return pointers.map(pointer => (0, _apidomJsonPointer.evaluate)(pointer, element));
22
+ } catch (error) {
23
+ throw new _EvaluationJsonPathError.default(`JSON Path evaluation failed while evaluating "${String(path)}".`, {
24
+ path,
25
+ element,
26
+ cause: error
27
+ });
28
+ }
29
+ };
30
+ var _default = evaluate;
31
+ exports.default = _default;
package/cjs/index.cjs CHANGED
@@ -1,47 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
3
4
  exports.__esModule = true;
4
- exports.evaluateMulti = exports.evaluate = void 0;
5
- var _jsonpathPlus = require("jsonpath-plus");
6
- var _apidomCore = require("@swagger-api/apidom-core");
7
- var _apidomJsonPointer = require("@swagger-api/apidom-json-pointer");
8
- /**
9
- * Evaluates single JSONPath on ApiDOM element.
10
- */
11
- const evaluate = (path, element) => {
12
- const json = (0, _apidomCore.toValue)(element);
13
- const pointers = (0, _jsonpathPlus.JSONPath)({
14
- path,
15
- json,
16
- resultType: 'pointer'
17
- });
18
- return pointers.map(pointer => (0, _apidomJsonPointer.evaluate)(pointer, element));
19
- };
20
-
21
- /**
22
- * Evaluates multiple JSONPaths on ApiDOM element.
23
- */
24
- exports.evaluate = evaluate;
25
- const evaluateMulti = (paths, element) => {
26
- const json = (0, _apidomCore.toValue)(element);
27
- const results = [];
28
- for (const path of paths) {
29
- const pointers = (0, _jsonpathPlus.JSONPath)({
30
- path,
31
- json,
32
- resultType: 'pointer'
33
- });
34
- const endPointValues = [];
35
- for (const pointer of pointers) {
36
- const endPointValue = (0, _apidomJsonPointer.evaluate)(pointer, element);
37
- endPointValues.push(endPointValue);
38
- }
39
- if (Array.isArray(path)) {
40
- results.push([_jsonpathPlus.JSONPath.toPathString(path), endPointValues]);
41
- } else {
42
- results.push([path, endPointValues]);
43
- }
44
- }
45
- return results;
46
- };
47
- exports.evaluateMulti = evaluateMulti;
5
+ exports.evaluateMulti = exports.evaluate = exports.MultiEvaluationJsonPathError = exports.EvaluationJsonPathError = void 0;
6
+ var _EvaluationJsonPathError = _interopRequireDefault(require("./errors/EvaluationJsonPathError.cjs"));
7
+ exports.EvaluationJsonPathError = _EvaluationJsonPathError.default;
8
+ var _MultiEvaluationJsonPathError = _interopRequireDefault(require("./errors/MultiEvaluationJsonPathError.cjs"));
9
+ exports.MultiEvaluationJsonPathError = _MultiEvaluationJsonPathError.default;
10
+ var _evaluate = _interopRequireDefault(require("./evaluate.cjs"));
11
+ exports.evaluate = _evaluate.default;
12
+ var _evaluateMulti = _interopRequireDefault(require("./evaluate-multi.cjs"));
13
+ exports.evaluateMulti = _evaluateMulti.default;