@speclynx/apidom-parser-adapter-json-schema-json-2020-12 3.2.1 → 4.0.1

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,6 +3,14 @@
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
+ ## [4.0.1](https://github.com/speclynx/apidom/compare/v4.0.0...v4.0.1) (2026-03-11)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-json-schema-json-2020-12
9
+
10
+ # [4.0.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
11
+
12
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-json-schema-json-2020-12
13
+
6
14
  ## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-json-schema-json-2020-12
@@ -28449,7 +28449,9 @@ class Path {
28449
28449
  *
28450
28450
  * @example
28451
28451
  * // For a path to $.paths['/pets'].get in an OpenAPI document:
28452
+ * ```
28452
28453
  * path.getPathKeys(); // => ['paths', '/pets', 'get']
28454
+ * ```
28453
28455
  */
28454
28456
  getPathKeys() {
28455
28457
  const keys = [];
@@ -28484,18 +28486,22 @@ class Path {
28484
28486
  * or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
28485
28487
  *
28486
28488
  * @example
28489
+ * ```
28487
28490
  * // JSON Pointer examples:
28488
28491
  * path.formatPath(); // "" (root)
28489
28492
  * path.formatPath(); // "/info"
28490
28493
  * path.formatPath(); // "/paths/~1pets/get"
28491
28494
  * path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
28495
+ * ```
28492
28496
  *
28493
28497
  * @example
28498
+ * ```
28494
28499
  * // JSONPath examples:
28495
28500
  * path.formatPath('jsonpath'); // "$" (root)
28496
28501
  * path.formatPath('jsonpath'); // "$['info']"
28497
28502
  * path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
28498
28503
  * path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
28504
+ * ```
28499
28505
  */
28500
28506
  formatPath(pathFormat = 'jsonpointer') {
28501
28507
  const parts = this.getPathKeys();
@@ -28705,15 +28711,15 @@ __webpack_require__.r(__webpack_exports__);
28705
28711
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
28706
28712
 
28707
28713
  /**
28708
- * Finds all elements matching the predicate.
28714
+ * Finds all paths whose elements match the predicate.
28709
28715
  * @public
28710
28716
  */
28711
28717
  const filter = (element, predicate) => {
28712
28718
  const result = [];
28713
28719
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
28714
28720
  enter(path) {
28715
- if (predicate(path.node)) {
28716
- result.push(path.node);
28721
+ if (predicate(path)) {
28722
+ result.push(path);
28717
28723
  }
28718
28724
  }
28719
28725
  });
@@ -28739,7 +28745,7 @@ __webpack_require__.r(__webpack_exports__);
28739
28745
  * @public
28740
28746
  */
28741
28747
  /**
28742
- * Finds the most inner node at the given offset.
28748
+ * Finds the path of the most inner node at the given offset.
28743
28749
  * If includeRightBound is set, also finds nodes that end at the given offset.
28744
28750
  * @public
28745
28751
  */
@@ -28764,7 +28770,7 @@ const findAtOffset = (element, options) => {
28764
28770
  const endOffset = node.endOffset;
28765
28771
  const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
28766
28772
  if (isWithinOffsetRange) {
28767
- result.push(node);
28773
+ result.push(path);
28768
28774
  return; // push to stack and dive in
28769
28775
  }
28770
28776
  path.skip(); // skip entire sub-tree
@@ -28787,15 +28793,15 @@ __webpack_require__.r(__webpack_exports__);
28787
28793
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
28788
28794
 
28789
28795
  /**
28790
- * Find first element that satisfies the provided predicate.
28796
+ * Finds first path whose element satisfies the provided predicate.
28791
28797
  * @public
28792
28798
  */
28793
28799
  const find = (element, predicate) => {
28794
28800
  let result;
28795
28801
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
28796
28802
  enter(path) {
28797
- if (predicate(path.node)) {
28798
- result = path.node;
28803
+ if (predicate(path)) {
28804
+ result = path;
28799
28805
  path.stop();
28800
28806
  }
28801
28807
  }
@@ -28814,9 +28820,7 @@ __webpack_require__.r(__webpack_exports__);
28814
28820
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
28815
28821
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
28816
28822
  /* harmony export */ });
28817
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5162);
28818
- /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2078);
28819
-
28823
+ /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2078);
28820
28824
 
28821
28825
  /**
28822
28826
  * @public
@@ -28825,7 +28829,7 @@ __webpack_require__.r(__webpack_exports__);
28825
28829
  * @public
28826
28830
  */
28827
28831
  /**
28828
- * Executes the callback on this element and all descendants.
28832
+ * Executes the callback on this element's path and all descendant paths.
28829
28833
  * @public
28830
28834
  */
28831
28835
  const forEach = (element, options) => {
@@ -28833,15 +28837,15 @@ const forEach = (element, options) => {
28833
28837
  let predicate;
28834
28838
  if (typeof options === 'function') {
28835
28839
  callback = options;
28836
- predicate = _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
28840
+ predicate = () => true;
28837
28841
  } else {
28838
28842
  callback = options.callback ?? (() => {});
28839
- predicate = options.predicate ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
28843
+ predicate = options.predicate ?? (() => true);
28840
28844
  }
28841
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_1__.traverse)(element, {
28845
+ (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
28842
28846
  enter(path) {
28843
- if (predicate(path.node)) {
28844
- callback(path.node);
28847
+ if (predicate(path)) {
28848
+ callback(path);
28845
28849
  }
28846
28850
  }
28847
28851
  });
@@ -28890,11 +28894,11 @@ __webpack_require__.r(__webpack_exports__);
28890
28894
  /* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5247);
28891
28895
 
28892
28896
  /**
28893
- * Complement of filter. Finds all elements NOT matching the predicate.
28897
+ * Complement of filter. Finds all paths whose elements do NOT match the predicate.
28894
28898
  * @public
28895
28899
  */
28896
28900
  const reject = (element, predicate) => {
28897
- return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, el => !predicate(el));
28901
+ return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
28898
28902
  };
28899
28903
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
28900
28904
 
@@ -28911,7 +28915,7 @@ __webpack_require__.r(__webpack_exports__);
28911
28915
  /* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4860);
28912
28916
 
28913
28917
  /**
28914
- * Tests whether at least one element passes the predicate.
28918
+ * Tests whether at least one path's element passes the predicate.
28915
28919
  * @public
28916
28920
  */
28917
28921
  const some = (element, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser-adapter-json-schema-json-2020-12",
3
- "version": "3.2.1",
3
+ "version": "4.0.1",
4
4
  "description": "Parser adapter for parsing JSON documents into JSON Schema 2020-12 namespace.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -54,10 +54,10 @@
54
54
  "license": "Apache-2.0",
55
55
  "dependencies": {
56
56
  "@babel/runtime-corejs3": "^7.28.4",
57
- "@speclynx/apidom-core": "3.2.1",
58
- "@speclynx/apidom-datamodel": "3.2.1",
59
- "@speclynx/apidom-ns-json-schema-2020-12": "3.2.1",
60
- "@speclynx/apidom-parser-adapter-json": "3.2.1",
57
+ "@speclynx/apidom-core": "4.0.1",
58
+ "@speclynx/apidom-datamodel": "4.0.1",
59
+ "@speclynx/apidom-ns-json-schema-2020-12": "4.0.1",
60
+ "@speclynx/apidom-parser-adapter-json": "4.0.1",
61
61
  "ramda": "~0.32.0",
62
62
  "ramda-adjunct": "^6.0.0"
63
63
  },
@@ -71,5 +71,5 @@
71
71
  "README.md",
72
72
  "CHANGELOG.md"
73
73
  ],
74
- "gitHead": "83a1e97089ef29134e41ff7cacd351973114ea5b"
74
+ "gitHead": "223132a9b00081ca04842efc2736a491f7876f44"
75
75
  }
package/src/adapter.cjs DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
- exports.__esModule = true;
6
- exports.parse = exports.namespace = exports.mediaTypes = exports.detectionRegExp = exports.detect = void 0;
7
- var _ramda = require("ramda");
8
- var _ramdaAdjunct = require("ramda-adjunct");
9
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
- var _apidomParserAdapterJson = require("@speclynx/apidom-parser-adapter-json");
11
- var _apidomNsJsonSchema = _interopRequireWildcard(require("@speclynx/apidom-ns-json-schema-2020-12"));
12
- var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
13
- exports.mediaTypes = _mediaTypes.default;
14
- /**
15
- * @public
16
- */
17
- const detectionRegExp = exports.detectionRegExp = /"\$schema"\s*:\s*"https:\/\/json-schema\.org\/draft\/(?<version_json>2020-12)\/schema"/;
18
-
19
- /**
20
- * @public
21
- */
22
- const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterJson.detect)(source, options));
23
-
24
- /**
25
- * @public
26
- */
27
- exports.detect = detect;
28
- /**
29
- * @public
30
- */
31
- const parse = async (source, options = {}) => {
32
- const refractorOpts = (0, _ramda.propOr)({}, 'refractorOpts', options);
33
- const parserOpts = (0, _ramda.omit)(['refractorOpts'], options);
34
- const parseResultElement = await (0, _apidomParserAdapterJson.parse)(source, parserOpts);
35
- const {
36
- result
37
- } = parseResultElement;
38
- if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
39
- const jsonSchemaElement = (0, _apidomNsJsonSchema.refractJSONSchema)(result, {
40
- consume: true,
41
- ...refractorOpts
42
- });
43
- jsonSchemaElement.classes.push('result');
44
- parseResultElement.replaceResult(jsonSchemaElement);
45
- }
46
- return parseResultElement;
47
- };
48
-
49
- /**
50
- * @public
51
- */
52
- exports.parse = parse;
53
- const namespace = exports.namespace = new _apidomDatamodel.Namespace().use(_apidomNsJsonSchema.default);
package/src/adapter.mjs DELETED
@@ -1,45 +0,0 @@
1
- import { propOr, omit } from 'ramda';
2
- import { isNotUndefined } from 'ramda-adjunct';
3
- import { Namespace } from '@speclynx/apidom-datamodel';
4
- import { parse as parseJSON, detect as detectJSON } from '@speclynx/apidom-parser-adapter-json';
5
- import jsonSchemaNamespace, { refractJSONSchema } from '@speclynx/apidom-ns-json-schema-2020-12';
6
- export { default as mediaTypes } from "./media-types.mjs";
7
- /**
8
- * @public
9
- */
10
- export const detectionRegExp = /"\$schema"\s*:\s*"https:\/\/json-schema\.org\/draft\/(?<version_json>2020-12)\/schema"/;
11
-
12
- /**
13
- * @public
14
- */
15
- export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectJSON(source, options));
16
-
17
- /**
18
- * @public
19
- */
20
-
21
- /**
22
- * @public
23
- */
24
- export const parse = async (source, options = {}) => {
25
- const refractorOpts = propOr({}, 'refractorOpts', options);
26
- const parserOpts = omit(['refractorOpts'], options);
27
- const parseResultElement = await parseJSON(source, parserOpts);
28
- const {
29
- result
30
- } = parseResultElement;
31
- if (isNotUndefined(result)) {
32
- const jsonSchemaElement = refractJSONSchema(result, {
33
- consume: true,
34
- ...refractorOpts
35
- });
36
- jsonSchemaElement.classes.push('result');
37
- parseResultElement.replaceResult(jsonSchemaElement);
38
- }
39
- return parseResultElement;
40
- };
41
-
42
- /**
43
- * @public
44
- */
45
- export const namespace = new Namespace().use(jsonSchemaNamespace);
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomNsJsonSchema = require("@speclynx/apidom-ns-json-schema-2020-12");
6
- /**
7
- * @public
8
- */
9
- const jsonMediaTypes = new _apidomNsJsonSchema.JSONSchema202012MediaTypes(..._apidomNsJsonSchema.mediaTypes.filterByFormat('generic'), ..._apidomNsJsonSchema.mediaTypes.filterByFormat('json'));
10
- var _default = exports.default = jsonMediaTypes;
@@ -1,7 +0,0 @@
1
- import { mediaTypes, JSONSchema202012MediaTypes } from '@speclynx/apidom-ns-json-schema-2020-12';
2
-
3
- /**
4
- * @public
5
- */
6
- const jsonMediaTypes = new JSONSchema202012MediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('json'));
7
- export default jsonMediaTypes;