@swagger-api/apidom-json-path 1.0.0-alpha.8 → 1.0.0-beta.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 +12 -0
- package/dist/apidom-json-path.browser.js +2098 -743
- package/dist/apidom-json-path.browser.min.js +1 -1
- package/package.json +19 -19
- package/{cjs → src}/errors/EvaluationJsonPathError.cjs +7 -0
- package/{es → src}/errors/EvaluationJsonPathError.mjs +6 -0
- package/{cjs → src}/errors/JsonPathError.cjs +3 -0
- package/{es → src}/errors/JsonPathError.mjs +4 -0
- package/{cjs → src}/errors/MultiEvaluationJsonPathError.cjs +7 -0
- package/{es → src}/errors/MultiEvaluationJsonPathError.mjs +6 -0
- package/{cjs → src}/evaluate-multi.cjs +9 -0
- package/{es → src}/evaluate-multi.mjs +7 -0
- package/{cjs → src}/evaluate.cjs +5 -0
- package/{es → src}/evaluate.mjs +4 -0
- package/{cjs → src}/index.cjs +1 -0
- package/{es → src}/index.mjs +1 -0
- package/src/polyfills.cjs +25 -0
- package/src/polyfills.mjs +21 -0
- package/types/apidom-json-path.d.ts +78 -0
- package/types/dist.d.ts +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-json-path",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"description": "Evaluate JSONPath expressions against ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"unpkg": "./dist/apidom-json-path.browser.min.js",
|
|
12
|
-
"main": "./
|
|
12
|
+
"main": "./src/index.cjs",
|
|
13
13
|
"exports": {
|
|
14
|
-
"types": "./types/
|
|
15
|
-
"import": "./
|
|
16
|
-
"require": "./
|
|
14
|
+
"types": "./types/apidom-json-path.d.ts",
|
|
15
|
+
"import": "./src/index.mjs",
|
|
16
|
+
"require": "./src/index.cjs"
|
|
17
17
|
},
|
|
18
|
-
"types": "./types/
|
|
18
|
+
"types": "./types/apidom-json-path.d.ts",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
|
|
21
|
-
"build:es": "cross-env BABEL_ENV=es babel src --out-dir
|
|
22
|
-
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir
|
|
21
|
+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
|
|
22
|
+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
|
|
23
23
|
"build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
|
|
24
24
|
"lint": "eslint ./",
|
|
25
25
|
"lint:fix": "eslint ./ --fix",
|
|
26
|
-
"clean": "rimraf
|
|
26
|
+
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
|
|
27
27
|
"typescript:check-types": "tsc --noEmit",
|
|
28
|
-
"typescript:declaration": "tsc -p declaration.
|
|
29
|
-
"test": "cross-env
|
|
28
|
+
"typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
|
|
29
|
+
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
|
|
30
30
|
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
|
|
31
31
|
"postpack": "rimraf NOTICE LICENSES"
|
|
32
32
|
},
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/runtime-corejs3": "^7.20.7",
|
|
41
|
-
"@swagger-api/apidom-core": "^1.0.0-
|
|
42
|
-
"@swagger-api/apidom-error": "^1.0.0-
|
|
43
|
-
"@swagger-api/apidom-json-pointer": "^1.0.0-
|
|
44
|
-
"jsonpath-plus": "^
|
|
41
|
+
"@swagger-api/apidom-core": "^1.0.0-beta.0",
|
|
42
|
+
"@swagger-api/apidom-error": "^1.0.0-beta.0",
|
|
43
|
+
"@swagger-api/apidom-json-pointer": "^1.0.0-beta.0",
|
|
44
|
+
"jsonpath-plus": "^10.0.6"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
|
-
"
|
|
47
|
+
"src/**/*.mjs",
|
|
48
|
+
"src/**/*.cjs",
|
|
48
49
|
"dist/",
|
|
49
|
-
"
|
|
50
|
-
"types/dist.d.ts",
|
|
50
|
+
"types/apidom-json-path.d.ts",
|
|
51
51
|
"LICENSES",
|
|
52
52
|
"NOTICE",
|
|
53
53
|
"README.md",
|
|
54
54
|
"CHANGELOG.md"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "ed1426743ba9d9d581146e617ec1762df670320c"
|
|
57
57
|
}
|
|
@@ -4,6 +4,13 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = void 0;
|
|
6
6
|
var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
7
14
|
class EvaluationJsonPathError extends _JsonPathError.default {
|
|
8
15
|
path;
|
|
9
16
|
element;
|
|
@@ -4,6 +4,13 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.default = void 0;
|
|
6
6
|
var _JsonPathError = _interopRequireDefault(require("./JsonPathError.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
7
14
|
class MultiEvaluationJsonPathError extends _JsonPathError.default {
|
|
8
15
|
paths;
|
|
9
16
|
element;
|
|
@@ -7,8 +7,17 @@ var _jsonpathPlus = require("jsonpath-plus");
|
|
|
7
7
|
var _apidomCore = require("@swagger-api/apidom-core");
|
|
8
8
|
var _apidomJsonPointer = require("@swagger-api/apidom-json-pointer");
|
|
9
9
|
var _MultiEvaluationJsonPathError = _interopRequireDefault(require("./errors/MultiEvaluationJsonPathError.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
10
18
|
/**
|
|
11
19
|
* Evaluates multiple JSONPaths on ApiDOM element.
|
|
20
|
+
* @public
|
|
12
21
|
*/
|
|
13
22
|
const evaluateMulti = (paths, element) => {
|
|
14
23
|
try {
|
|
@@ -2,8 +2,15 @@ import { JSONPath } from 'jsonpath-plus';
|
|
|
2
2
|
import { toValue, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
3
|
import { evaluate as jsonPointerEvaluate } from '@swagger-api/apidom-json-pointer';
|
|
4
4
|
import MultiEvaluationJsonPathError from "./errors/MultiEvaluationJsonPathError.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
5
11
|
/**
|
|
6
12
|
* Evaluates multiple JSONPaths on ApiDOM element.
|
|
13
|
+
* @public
|
|
7
14
|
*/
|
|
8
15
|
const evaluateMulti = (paths, element) => {
|
|
9
16
|
try {
|
package/{cjs → src}/evaluate.cjs
RENAMED
|
@@ -7,8 +7,13 @@ var _jsonpathPlus = require("jsonpath-plus");
|
|
|
7
7
|
var _apidomCore = require("@swagger-api/apidom-core");
|
|
8
8
|
var _apidomJsonPointer = require("@swagger-api/apidom-json-pointer");
|
|
9
9
|
var _EvaluationJsonPathError = _interopRequireDefault(require("./errors/EvaluationJsonPathError.cjs"));
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Evaluates single JSONPath on ApiDOM element.
|
|
16
|
+
* @public
|
|
12
17
|
*/
|
|
13
18
|
const evaluate = (path, element) => {
|
|
14
19
|
try {
|
package/{es → src}/evaluate.mjs
RENAMED
|
@@ -2,8 +2,12 @@ import { JSONPath } from 'jsonpath-plus';
|
|
|
2
2
|
import { toValue, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
3
|
import { evaluate as jsonPointerEvaluate } from '@swagger-api/apidom-json-pointer';
|
|
4
4
|
import EvaluationJsonPathError from "./errors/EvaluationJsonPathError.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
5
8
|
/**
|
|
6
9
|
* Evaluates single JSONPath on ApiDOM element.
|
|
10
|
+
* @public
|
|
7
11
|
*/
|
|
8
12
|
const evaluate = (path, element) => {
|
|
9
13
|
try {
|
package/{cjs → src}/index.cjs
RENAMED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.evaluateMulti = exports.evaluate = exports.MultiEvaluationJsonPathError = exports.EvaluationJsonPathError = void 0;
|
|
6
|
+
require("./polyfills.cjs");
|
|
6
7
|
var _EvaluationJsonPathError = _interopRequireDefault(require("./errors/EvaluationJsonPathError.cjs"));
|
|
7
8
|
exports.EvaluationJsonPathError = _EvaluationJsonPathError.default;
|
|
8
9
|
var _MultiEvaluationJsonPathError = _interopRequireDefault(require("./errors/MultiEvaluationJsonPathError.cjs"));
|
package/{es → src}/index.mjs
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./polyfills.mjs";
|
|
1
2
|
export { default as EvaluationJsonPathError } from "./errors/EvaluationJsonPathError.mjs";
|
|
2
3
|
export { default as MultiEvaluationJsonPathError } from "./errors/MultiEvaluationJsonPathError.mjs";
|
|
3
4
|
export { default as evaluate } from "./evaluate.mjs";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
var _replaceAll = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/replace-all"));
|
|
5
|
+
var _hasOwn = _interopRequireDefault(require("core-js-pure/actual/object/has-own.js"));
|
|
6
|
+
var _replaceAll2 = _interopRequireDefault(require("core-js-pure/actual/string/replace-all.js"));
|
|
7
|
+
/* eslint-disable import/extensions */
|
|
8
|
+
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* These polyfills do maintain compatibility with Node.js >= 12.20.0
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
if (!Object.hasOwn) {
|
|
18
|
+
Object.hasOwn = _hasOwn.default;
|
|
19
|
+
}
|
|
20
|
+
if (!(0, _replaceAll.default)(String.prototype)) {
|
|
21
|
+
// eslint-disable-next-line no-extend-native
|
|
22
|
+
String.prototype.replaceAll = function replaceAll(search, replacement) {
|
|
23
|
+
return (0, _replaceAll2.default)(this, search, replacement);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _replaceAllInstanceProperty from "@babel/runtime-corejs3/core-js/instance/replace-all";
|
|
2
|
+
/* eslint-disable import/extensions */
|
|
3
|
+
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import hasOwnPonyfill from 'core-js-pure/actual/object/has-own.js';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import replaceAllPonyfill from 'core-js-pure/actual/string/replace-all.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* These polyfills do maintain compatibility with Node.js >= 12.20.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
if (!Object.hasOwn) {
|
|
14
|
+
Object.hasOwn = hasOwnPonyfill;
|
|
15
|
+
}
|
|
16
|
+
if (!_replaceAllInstanceProperty(String.prototype)) {
|
|
17
|
+
// eslint-disable-next-line no-extend-native
|
|
18
|
+
String.prototype.replaceAll = function replaceAll(search, replacement) {
|
|
19
|
+
return replaceAllPonyfill(this, search, replacement);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ApiDOMErrorOptions } from '@swagger-api/apidom-error';
|
|
2
|
+
import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
|
|
3
|
+
import { Element as Element_2 } from '@swagger-api/apidom-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare type Evaluate = {
|
|
9
|
+
<T extends Element_2>(path: string, element: T): Element_2[];
|
|
10
|
+
<T extends Element_2>(path: string[], element: T): Element_2[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Evaluates single JSONPath on ApiDOM element.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare const evaluate: Evaluate;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare type EvaluateMulti = {
|
|
23
|
+
<T extends Element_2>(paths: string[], element: T): JSONPathEvalTuple[];
|
|
24
|
+
<T extends Element_2>(paths: string[][], element: T): JSONPathEvalTuple[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Evaluates multiple JSONPaths on ApiDOM element.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const evaluateMulti: EvaluateMulti;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare class EvaluationJsonPathError<T extends Element_2> extends JsonPathError {
|
|
37
|
+
readonly path: string | string[];
|
|
38
|
+
readonly element: T;
|
|
39
|
+
constructor(message?: string, structuredOptions?: EvaluationJsonPathErrorOptions<T>);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare interface EvaluationJsonPathErrorOptions<T extends Element_2> extends ApiDOMErrorOptions {
|
|
46
|
+
path: string | string[];
|
|
47
|
+
element: T;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare class JsonPathError extends ApiDOMStructuredError {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare type JSONPathEvalTuple = [string, Element_2[]];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export declare class MultiEvaluationJsonPathError<T extends Element_2> extends JsonPathError {
|
|
65
|
+
readonly paths: string[] | string[][];
|
|
66
|
+
readonly element: T;
|
|
67
|
+
constructor(message?: string, structuredOptions?: MultiEvaluationJsonPathErrorOptions<T>);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare interface MultiEvaluationJsonPathErrorOptions<T extends Element_2> extends ApiDOMErrorOptions {
|
|
74
|
+
paths: string[] | string[][];
|
|
75
|
+
element: T;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { }
|
package/types/dist.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Element } from '@swagger-api/apidom-core';
|
|
2
|
-
import { ApiDOMStructuredError, ApiDOMErrorOptions } from '@swagger-api/apidom-error';
|
|
3
|
-
|
|
4
|
-
declare class JsonPathError extends ApiDOMStructuredError {
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface EvaluationJsonPathErrorOptions<T extends Element> extends ApiDOMErrorOptions {
|
|
8
|
-
path: string | string[];
|
|
9
|
-
element: T;
|
|
10
|
-
}
|
|
11
|
-
declare class EvaluationJsonPathError<T extends Element> extends JsonPathError {
|
|
12
|
-
readonly path: string | string[];
|
|
13
|
-
readonly element: T;
|
|
14
|
-
constructor(message?: string, structuredOptions?: EvaluationJsonPathErrorOptions<T>);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface MultiEvaluationJsonPathErrorOptions<T extends Element> extends ApiDOMErrorOptions {
|
|
18
|
-
paths: string[] | string[][];
|
|
19
|
-
element: T;
|
|
20
|
-
}
|
|
21
|
-
declare class MultiEvaluationJsonPathError<T extends Element> extends JsonPathError {
|
|
22
|
-
readonly paths: string[] | string[][];
|
|
23
|
-
readonly element: T;
|
|
24
|
-
constructor(message?: string, structuredOptions?: MultiEvaluationJsonPathErrorOptions<T>);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type Evaluate = {
|
|
28
|
-
<T extends Element>(path: string, element: T): Element[];
|
|
29
|
-
<T extends Element>(path: string[], element: T): Element[];
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Evaluates single JSONPath on ApiDOM element.
|
|
33
|
-
*/
|
|
34
|
-
declare const evaluate: Evaluate;
|
|
35
|
-
|
|
36
|
-
type JSONPathEvalTuple = [string, Element[]];
|
|
37
|
-
type EvaluateMulti = {
|
|
38
|
-
<T extends Element>(paths: string[], element: T): JSONPathEvalTuple[];
|
|
39
|
-
<T extends Element>(paths: string[][], element: T): JSONPathEvalTuple[];
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Evaluates multiple JSONPaths on ApiDOM element.
|
|
43
|
-
*/
|
|
44
|
-
declare const evaluateMulti: EvaluateMulti;
|
|
45
|
-
|
|
46
|
-
export { EvaluationJsonPathError, type EvaluationJsonPathErrorOptions, MultiEvaluationJsonPathError, type MultiEvaluationJsonPathErrorOptions, evaluate, evaluateMulti };
|