@speclynx/apidom-ns-json-schema-draft-7 1.12.2 → 2.1.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,6 +3,31 @@
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
+ # [2.1.0](https://github.com/speclynx/apidom/compare/v2.0.1...v2.1.0) (2026-01-17)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-7
9
+
10
+ ## [2.0.1](https://github.com/speclynx/apidom/compare/v2.0.0...v2.0.1) (2026-01-14)
11
+
12
+ **Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-7
13
+
14
+ # [2.0.0](https://github.com/speclynx/apidom/compare/v1.12.2...v2.0.0) (2026-01-14)
15
+
16
+ ### Bug Fixes
17
+
18
+ - limit source maps memory consuption ([#20](https://github.com/speclynx/apidom/issues/20)) ([4a0574f](https://github.com/speclynx/apidom/commit/4a0574fd6d466be7c33c8a5871baacd384918d22))
19
+
20
+ ### Features
21
+
22
+ - apply innovations learned during last 3 years ([#11](https://github.com/speclynx/apidom/issues/11)) ([cfdbbfc](https://github.com/speclynx/apidom/commit/cfdbbfc2721b0dadc77eeba31dd4e8768c078d22))
23
+ - **traverse:** move traverse operations to apidom-traverse package ([#18](https://github.com/speclynx/apidom/issues/18)) ([36c9d49](https://github.com/speclynx/apidom/commit/36c9d490ceac2ea961e2b23fbbc72df7fb54bbf3))
24
+
25
+ ### BREAKING CHANGES
26
+
27
+ - source maps have been completely rewritten
28
+ - **traverse:** move traverse operations from core to traverse package
29
+ - breaking changes introduced to every package public API
30
+
6
31
  ## [1.12.2](https://github.com/speclynx/apidom/compare/v1.12.1...v1.12.2) (2025-12-23)
7
32
 
8
33
  **Note:** Version bump only for package @speclynx/apidom-ns-json-schema-draft-7
package/NOTICE CHANGED
@@ -5,11 +5,6 @@ This distribution includes modifications by SpecLynx.
5
5
  All such modifications are licensed under the Apache License, Version 2.0.
6
6
  A copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt`.
7
7
 
8
- ApiDOM
9
- Copyright 2020 SmartBear Software Inc.
10
- ApiDOM is licensed under Apache 2.0 license.
11
- Copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt` file.
12
-
13
8
  json-schema-ref-parser
14
9
  Copyright (c) 2015 James Messinger
15
10
  File packages/apidom-reference/src/util/url.ts (the file) was originally created under MIT license in https://github.com/APIDevTools/json-schema-ref-parser repository.
@@ -18,8 +13,8 @@ Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
18
13
 
19
14
  graphql-js
20
15
  Copyright (c) GraphQL Contributors
21
- File packages/apidom-ast/src/traversal/visitor.ts (the file) was originally created under MIT license in https://github.com/graphql/graphql-js repository.
22
- The file has been copied into this project and modified. All modifications are licensed under Apache 2.0 License.
16
+ File packages/apidom-traverse/src/traversal.ts (the file) was originally inspired by https://github.com/graphql/graphql-js repository.
17
+ All modifications are licensed under Apache 2.0 License.
23
18
  Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
24
19
 
25
20
  babel-plugin-add-import-extension
@@ -54,6 +49,20 @@ Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
54
49
  Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
55
50
  All modifications are licensed under Apache 2.0 License.
56
51
 
52
+ ApiDOM
53
+ Copyright 2020 SmartBear Software Inc.
54
+ ApiDOM is licensed under Apache 2.0 license.
55
+ Copy of the Apache 2.0 license can be found in `LICENSES/Apache-2.0.txt` file.
56
+
57
+ minim
58
+ Copyright (c) 2014 Stephen Mizell
59
+ The apidom-datamodel package contains code originally created under the MIT
60
+ License as part of the Minim project (https://github.com/refractproject/minim).
61
+ This code has been copied into this project and modified.
62
+ The original portions remain licensed under the MIT License. Our modifications
63
+ to that code are licensed under the Apache License 2.0.
64
+ Copy of the MIT license can be found in `LICENSES/MIT.txt` file.
65
+
57
66
  ---
58
67
 
59
68
  If the SPDX-FileCopyrightText and SPDX-License-Identifier tags are not present in the file,
package/README.md CHANGED
@@ -13,13 +13,14 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin
13
13
  ## JSON Schema Draft 7 namespace
14
14
 
15
15
  JSON Schema Draft 7 namespace consists of [number of elements](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-json-schema-draft-7/src/elements) implemented on top
16
- of [primitive ones](https://github.com/refractproject/minim/tree/master/lib/primitives).
16
+ of [primitive ones](https://github.com/speclynx/apidom/tree/main/packages/apidom-datamodel/src/primitives).
17
17
 
18
18
  ```js
19
- import { createNamespace } from '@speclynx/apidom-core';
19
+ import { Namespace } from '@speclynx/apidom-datamodel';
20
20
  import jsonShemaDraft7Namespace from '@speclynx/apidom-ns-json-schema-draft-7';
21
21
 
22
- const namespace = createNamespace(jsonShemaDraft7Namespace);
22
+ const namespace = new Namespace();
23
+ namespace.use(jsonShemaDraft7Namespace);
23
24
 
24
25
  const objectElement = new namespace.elements.Object();
25
26
  const jsonSchemaElement = new namespace.elements.JSONSchemaDraft7();
@@ -53,23 +54,22 @@ isJSONSchemaElement(jsonSchemaElement); // => true
53
54
 
54
55
  ## Traversal
55
56
 
56
- Traversing ApiDOM in this namespace is possible by using `visit` function from `apidom` package.
57
- This package comes with its own [keyMap](https://github.com/speclynx/apidom/blob/main/packages/apidom-ns-json-schema-draft-7/src/traversal/visitor.ts#L11) and [nodeTypeGetter](https://github.com/speclynx/apidom/blob/main/packages/apidom-ns-json-schema-draft-7/src/traversal/visitor.ts#L4).
58
- To learn more about these `visit` configuration options please refer to [@speclynx/apidom-ast documentation](https://github.com/speclynx/apidom/blob/main/packages/apidom-ast/README.md#visit).
57
+ Traversing ApiDOM in this namespace is possible by using `traverse` function from `@speclynx/apidom-traverse` package.
58
+ To learn more about the `traverse` function, please refer to [@speclynx/apidom-traverse documentation](https://github.com/speclynx/apidom/blob/main/packages/apidom-traverse/README.md).
59
59
 
60
60
  ```js
61
- import { visit } from '@speclynx/apidom-core';
62
- import { JSONSchemaElement, keyMap, getNodeType } from '@speclynx/apidom-ns-json-schema-draft-7';
61
+ import { traverse } from '@speclynx/apidom-traverse';
62
+ import { JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-7';
63
63
 
64
64
  const element = new JSONSchemaElement();
65
65
 
66
66
  const visitor = {
67
- JSONSchemaDraft7Element(jsonSchemaElement) {
68
- console.dir(jsonSchemaElement);
67
+ JSONSchemaDraft7Element(path) {
68
+ console.dir(path.node);
69
69
  },
70
70
  };
71
71
 
72
- visit(element, visitor, { keyMap, nodeTypeGetter: getNodeType });
72
+ traverse(element, visitor);
73
73
  ```
74
74
 
75
75
  ## Refractors
@@ -80,37 +80,37 @@ or generic ApiDOM structures into structures built from elements of this namespa
80
80
  **Refracting JavaScript structures**:
81
81
 
82
82
  ```js
83
- import { LinkDescriptionElement } from '@speclynx/apidom-ns-json-schema-draft-7';
83
+ import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-draft-7';
84
84
 
85
85
  const object = {
86
86
  anchor: 'nodes/{thisNodeId}',
87
87
  anchorPointer: '#/relative/json/pointer',
88
88
  };
89
89
 
90
- LinkDescriptionElement.refract(object); // => LinkDescriptionElement({ anchor, anchorPointer })
90
+ refractLinkDescription(object); // => LinkDescriptionElement({ anchor, anchorPointer })
91
91
  ```
92
92
 
93
93
  **Refracting generic ApiDOM structures**:
94
94
 
95
95
  ```js
96
- import { ObjectElement } from '@speclynx/apidom-core';
97
- import { LinkDescriptionElement } from '@speclynx/apidom-ns-json-schema-draft-7';
96
+ import { ObjectElement } from '@speclynx/apidom-datamodel';
97
+ import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-draft-7';
98
98
 
99
99
  const objectElement = new ObjectElement({
100
100
  anchor: 'nodes/{thisNodeId}',
101
101
  anchorPointer: '#/relative/json/pointer',
102
102
  });
103
103
 
104
- LinkDescriptionElement.refract(objectElement); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer' })
104
+ refractLinkDescription(objectElement); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer' })
105
105
  ```
106
106
 
107
107
  ### Refractor plugins
108
108
 
109
- Refractors can accept plugins as a second argument of refract static method.
109
+ Refractors can accept plugins as a second argument of refract function.
110
110
 
111
111
  ```js
112
- import { ObjectElement } from '@speclynx/apidom-core';
113
- import { LinkDescriptionElement } from '@speclynx/apidom-ns-json-schema-draft-7';
112
+ import { ObjectElement } from '@speclynx/apidom-datamodel';
113
+ import { refractLinkDescription } from '@speclynx/apidom-ns-json-schema-draft-7';
114
114
 
115
115
  const objectElement = new ObjectElement({
116
116
  anchor: 'nodes/{thisNodeId}',
@@ -123,8 +123,8 @@ const plugin = ({ predicates, namespace }) => ({
123
123
  console.dir('runs before traversal');
124
124
  },
125
125
  visitor: {
126
- LinkDescriptionElement(linkDescriptionElement) {
127
- linkDescriptionElement.anchorPointer = '#/relative/json/pointer/x';
126
+ LinkDescriptionElement(path) {
127
+ path.node.anchorPointer = '#/relative/json/pointer/x';
128
128
  },
129
129
  },
130
130
  post() {
@@ -132,7 +132,7 @@ const plugin = ({ predicates, namespace }) => ({
132
132
  },
133
133
  });
134
134
 
135
- LinkDescriptionElement.refract(objectElement, { plugins: [plugin] }); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer/x' })
135
+ refractLinkDescription(objectElement, { plugins: [plugin] }); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer/x' })
136
136
  ```
137
137
 
138
138
  You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
@@ -146,14 +146,14 @@ this missing value with the most appropriate semantic element type.
146
146
 
147
147
  ```js
148
148
  import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
149
- import { refractorPluginReplaceEmptyElement, JSONSchemaElement } from '@speclynx/apidom-ns-json-schema-draft-7';
149
+ import { refractorPluginReplaceEmptyElement, refractJSONSchema } from '@speclynx/apidom-ns-json-schema-draft-7';
150
150
 
151
151
  const yamlDefinition = `
152
152
  $schema: 'https://json-schema.org/draft-07/schema#'
153
153
  if:
154
154
  `;
155
155
  const apiDOM = await parse(yamlDefinition);
156
- const jsonSchemaElement = JSONSchemaElement.refract(apiDOM.result, {
156
+ const jsonSchemaElement = refractJSONSchema(apiDOM.result, {
157
157
  plugins: [refractorPluginReplaceEmptyElement()],
158
158
  });
159
159