@speclynx/apidom-ns-json-schema-draft-6 2.13.0 → 3.0.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 +19 -0
- package/dist/apidom-ns-json-schema-draft-6.browser.js +246 -100
- package/dist/apidom-ns-json-schema-draft-6.browser.min.js +1 -1
- package/package.json +7 -7
- package/src/refractor/index.cjs +4 -2
- package/src/refractor/index.mjs +4 -2
- package/src/refractor/plugins/replace-empty-element.cjs +4 -3
- package/src/refractor/plugins/replace-empty-element.mjs +4 -3
- package/types/apidom-ns-json-schema-draft-6.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-ns-json-schema-draft-6",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "JSON Schema Draft 6 namespace for ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
47
|
-
"@speclynx/apidom-core": "
|
|
48
|
-
"@speclynx/apidom-datamodel": "
|
|
49
|
-
"@speclynx/apidom-error": "
|
|
50
|
-
"@speclynx/apidom-ns-json-schema-draft-4": "
|
|
51
|
-
"@speclynx/apidom-traverse": "
|
|
47
|
+
"@speclynx/apidom-core": "3.0.0",
|
|
48
|
+
"@speclynx/apidom-datamodel": "3.0.0",
|
|
49
|
+
"@speclynx/apidom-error": "3.0.0",
|
|
50
|
+
"@speclynx/apidom-ns-json-schema-draft-4": "3.0.0",
|
|
51
|
+
"@speclynx/apidom-traverse": "3.0.0",
|
|
52
52
|
"ramda": "~0.32.0",
|
|
53
53
|
"ramda-adjunct": "^6.0.0",
|
|
54
54
|
"ts-mixer": "^6.0.4"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"README.md",
|
|
64
64
|
"CHANGELOG.md"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "cb94ec84ea789d121801065876e7a91799a363d0"
|
|
67
67
|
}
|
package/src/refractor/index.cjs
CHANGED
|
@@ -23,7 +23,8 @@ var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
|
|
|
23
23
|
const refract = (value, {
|
|
24
24
|
element = 'jSONSchemaDraft6',
|
|
25
25
|
plugins = [],
|
|
26
|
-
specificationObj = _specification.default
|
|
26
|
+
specificationObj = _specification.default,
|
|
27
|
+
consume = false
|
|
27
28
|
} = {}) => {
|
|
28
29
|
const genericElement = (0, _apidomDatamodel.refract)(value);
|
|
29
30
|
const resolvedSpec = (0, _apidomCore.resolveSpecification)(specificationObj);
|
|
@@ -40,7 +41,8 @@ const refract = (value, {
|
|
|
40
41
|
*/
|
|
41
42
|
const RootVisitorClass = (0, _ramda.path)(specPath, resolvedSpec);
|
|
42
43
|
const rootVisitor = new RootVisitorClass({
|
|
43
|
-
specObj: resolvedSpec
|
|
44
|
+
specObj: resolvedSpec,
|
|
45
|
+
consume
|
|
44
46
|
});
|
|
45
47
|
(0, _apidomTraverse.traverse)(genericElement, rootVisitor);
|
|
46
48
|
|
package/src/refractor/index.mjs
CHANGED
|
@@ -16,7 +16,8 @@ import createToolbox from "./toolbox.mjs";
|
|
|
16
16
|
const refract = (value, {
|
|
17
17
|
element = 'jSONSchemaDraft6',
|
|
18
18
|
plugins = [],
|
|
19
|
-
specificationObj = specification
|
|
19
|
+
specificationObj = specification,
|
|
20
|
+
consume = false
|
|
20
21
|
} = {}) => {
|
|
21
22
|
const genericElement = baseRefract(value);
|
|
22
23
|
const resolvedSpec = resolveSpecification(specificationObj);
|
|
@@ -33,7 +34,8 @@ const refract = (value, {
|
|
|
33
34
|
*/
|
|
34
35
|
const RootVisitorClass = path(specPath, resolvedSpec);
|
|
35
36
|
const rootVisitor = new RootVisitorClass({
|
|
36
|
-
specObj: resolvedSpec
|
|
37
|
+
specObj: resolvedSpec,
|
|
38
|
+
consume
|
|
37
39
|
});
|
|
38
40
|
traverse(genericElement, rootVisitor);
|
|
39
41
|
|
|
@@ -176,8 +176,9 @@ const schema = {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
const findElementFactory = (ancestor, keyName) => {
|
|
179
|
-
const elementType = (0, _apidomTraverse.getNodeType)(ancestor);
|
|
180
|
-
const
|
|
179
|
+
const elementType = (0, _apidomTraverse.getNodeType)(ancestor);
|
|
180
|
+
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0); // @ts-ignore
|
|
181
|
+
const keyMapping = schema[elementType] || schema[classType];
|
|
181
182
|
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
182
183
|
};
|
|
183
184
|
|
|
@@ -207,7 +208,7 @@ const plugin = () => () => ({
|
|
|
207
208
|
if (typeof elementFactory !== 'function') return;
|
|
208
209
|
const replacement = elementFactory.call({
|
|
209
210
|
context
|
|
210
|
-
}, undefined,
|
|
211
|
+
}, undefined, element.isMetaEmpty ? undefined : element.meta.cloneDeep(), element.isAttributesEmpty ? undefined : (0, _apidomDatamodel.cloneDeep)(element.attributes));
|
|
211
212
|
_apidomDatamodel.SourceMapElement.transfer(element, replacement);
|
|
212
213
|
_apidomDatamodel.StyleElement.transfer(element, replacement);
|
|
213
214
|
path.replaceWith(replacement);
|
|
@@ -170,8 +170,9 @@ const schema = {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
const findElementFactory = (ancestor, keyName) => {
|
|
173
|
-
const elementType = getNodeType(ancestor);
|
|
174
|
-
const
|
|
173
|
+
const elementType = getNodeType(ancestor);
|
|
174
|
+
const classType = ancestor.isMetaEmpty ? undefined : ancestor.classes.at(0); // @ts-ignore
|
|
175
|
+
const keyMapping = schema[elementType] || schema[classType];
|
|
175
176
|
return typeof keyMapping === 'undefined' ? undefined : Object.hasOwn(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
176
177
|
};
|
|
177
178
|
|
|
@@ -201,7 +202,7 @@ const plugin = () => () => ({
|
|
|
201
202
|
if (typeof elementFactory !== 'function') return;
|
|
202
203
|
const replacement = elementFactory.call({
|
|
203
204
|
context
|
|
204
|
-
}, undefined,
|
|
205
|
+
}, undefined, element.isMetaEmpty ? undefined : element.meta.cloneDeep(), element.isAttributesEmpty ? undefined : cloneDeep(element.attributes));
|
|
205
206
|
SourceMapElement.transfer(element, replacement);
|
|
206
207
|
StyleElement.transfer(element, replacement);
|
|
207
208
|
path.replaceWith(replacement);
|
|
@@ -299,7 +299,7 @@ export { PropertiesVisitorOptions }
|
|
|
299
299
|
/**
|
|
300
300
|
* @public
|
|
301
301
|
*/
|
|
302
|
-
export declare const refract: <T extends Element_2>(value: unknown, { element, plugins, specificationObj, }?: RefractorOptions) => T;
|
|
302
|
+
export declare const refract: <T extends Element_2>(value: unknown, { element, plugins, specificationObj, consume, }?: RefractorOptions) => T;
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
* Refracts a value into a JSONSchemaElement.
|
|
@@ -320,6 +320,7 @@ export declare interface RefractorOptions {
|
|
|
320
320
|
readonly element?: string;
|
|
321
321
|
readonly plugins?: RefractorPlugin[];
|
|
322
322
|
readonly specificationObj?: typeof specificationObj;
|
|
323
|
+
readonly consume?: boolean;
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
/**
|