@speclynx/apidom-parser-adapter-json-schema-json-2020-12 1.12.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 +82 -0
- package/LICENSE +202 -0
- package/LICENSES/AFL-3.0.txt +182 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/BSD-3-Clause.txt +26 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +65 -0
- package/README.md +90 -0
- package/dist/167.apidom-parser-adapter-json-schema-json-2020-12.browser.js +10 -0
- package/dist/167.apidom-parser-adapter-json-schema-json-2020-12.browser.min.js +1 -0
- package/dist/451.apidom-parser-adapter-json-schema-json-2020-12.browser.js +10 -0
- package/dist/451.apidom-parser-adapter-json-schema-json-2020-12.browser.min.js +1 -0
- package/dist/9786785aaddf11f37840fad896531940.wasm +0 -0
- package/dist/apidom-parser-adapter-json-schema-json-2020-12.browser.js +25179 -0
- package/dist/apidom-parser-adapter-json-schema-json-2020-12.browser.min.js +1 -0
- package/package.json +60 -0
- package/src/adapter.cjs +47 -0
- package/src/adapter.mjs +38 -0
- package/src/media-types.cjs +10 -0
- package/src/media-types.mjs +7 -0
- package/types/apidom-parser-adapter-json-schema-json-2020-12.d.ts +30 -0
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@speclynx/apidom-parser-adapter-json-schema-json-2020-12",
|
|
3
|
+
"version": "1.12.1",
|
|
4
|
+
"description": "Parser adapter for parsing JSON documents into JSON Schema 2020-12 namespace.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org",
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"unpkg": "./dist/apidom-parser-apdater-json-schema-json-2020-12.browser.min.js",
|
|
13
|
+
"main": "./src/adapter.cjs",
|
|
14
|
+
"exports": {
|
|
15
|
+
"types": "./types/apidom-parser-adapter-json-schema-json-2020-12.d.ts",
|
|
16
|
+
"import": "./src/adapter.mjs",
|
|
17
|
+
"require": "./src/adapter.cjs"
|
|
18
|
+
},
|
|
19
|
+
"types": "./types/apidom-parser-adapter-json-schema-json-2020-12.d.ts",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
|
|
22
|
+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
|
|
23
|
+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
|
|
24
|
+
"build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
|
|
25
|
+
"lint": "eslint ./",
|
|
26
|
+
"lint:fix": "eslint ./ --fix",
|
|
27
|
+
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
|
|
28
|
+
"typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit",
|
|
29
|
+
"typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
|
|
30
|
+
"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",
|
|
31
|
+
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
|
|
32
|
+
"postpack": "rimraf NOTICE LICENSES"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/speclynx/apidom.git"
|
|
37
|
+
},
|
|
38
|
+
"author": "Vladimir Gorej",
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@babel/runtime-corejs3": "^7.28.4",
|
|
42
|
+
"@speclynx/apidom-core": "^1.12.1",
|
|
43
|
+
"@speclynx/apidom-ns-json-schema-2020-12": "^1.12.1",
|
|
44
|
+
"@speclynx/apidom-parser-adapter-json": "^1.12.1",
|
|
45
|
+
"@types/ramda": "~0.30.0",
|
|
46
|
+
"ramda": "~0.32.0",
|
|
47
|
+
"ramda-adjunct": "^6.0.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"src/**/*.mjs",
|
|
51
|
+
"src/**/*.cjs",
|
|
52
|
+
"dist/",
|
|
53
|
+
"types/apidom-parser-adapter-json-schema-json-2020-12.d.ts",
|
|
54
|
+
"LICENSES",
|
|
55
|
+
"NOTICE",
|
|
56
|
+
"README.md",
|
|
57
|
+
"CHANGELOG.md"
|
|
58
|
+
],
|
|
59
|
+
"gitHead": "49be88493f922c4ace2e4ebc0f23387ccb62c4fc"
|
|
60
|
+
}
|
package/src/adapter.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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 _apidomCore = require("@speclynx/apidom-core");
|
|
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 => detectionRegExp.test(source) && (await (0, _apidomParserAdapterJson.detect)(source));
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
exports.detect = detect;
|
|
28
|
+
const parse = async (source, options = {}) => {
|
|
29
|
+
const refractorOpts = (0, _ramda.propOr)({}, 'refractorOpts', options);
|
|
30
|
+
const parserOpts = (0, _ramda.omit)(['refractorOpts'], options);
|
|
31
|
+
const parseResultElement = await (0, _apidomParserAdapterJson.parse)(source, parserOpts);
|
|
32
|
+
const {
|
|
33
|
+
result
|
|
34
|
+
} = parseResultElement;
|
|
35
|
+
if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
|
|
36
|
+
const jsonSchemaElement = _apidomNsJsonSchema.JSONSchemaElement.refract(result, refractorOpts);
|
|
37
|
+
jsonSchemaElement.classes.push('result');
|
|
38
|
+
parseResultElement.replaceResult(jsonSchemaElement);
|
|
39
|
+
}
|
|
40
|
+
return parseResultElement;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
exports.parse = parse;
|
|
47
|
+
const namespace = exports.namespace = (0, _apidomCore.createNamespace)(_apidomNsJsonSchema.default);
|
package/src/adapter.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { propOr, omit } from 'ramda';
|
|
2
|
+
import { isNotUndefined } from 'ramda-adjunct';
|
|
3
|
+
import { createNamespace } from '@speclynx/apidom-core';
|
|
4
|
+
import { parse as parseJSON, detect as detectJSON } from '@speclynx/apidom-parser-adapter-json';
|
|
5
|
+
import jsonSchemaNamespace, { JSONSchemaElement } 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 => detectionRegExp.test(source) && (await detectJSON(source));
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export const parse = async (source, options = {}) => {
|
|
21
|
+
const refractorOpts = propOr({}, 'refractorOpts', options);
|
|
22
|
+
const parserOpts = omit(['refractorOpts'], options);
|
|
23
|
+
const parseResultElement = await parseJSON(source, parserOpts);
|
|
24
|
+
const {
|
|
25
|
+
result
|
|
26
|
+
} = parseResultElement;
|
|
27
|
+
if (isNotUndefined(result)) {
|
|
28
|
+
const jsonSchemaElement = JSONSchemaElement.refract(result, refractorOpts);
|
|
29
|
+
jsonSchemaElement.classes.push('result');
|
|
30
|
+
parseResultElement.replaceResult(jsonSchemaElement);
|
|
31
|
+
}
|
|
32
|
+
return parseResultElement;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export const namespace = createNamespace(jsonSchemaNamespace);
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { JSONSchema202012MediaTypes } from '@speclynx/apidom-ns-json-schema-2020-12';
|
|
2
|
+
import { Namespace } from '@speclynx/apidom-core';
|
|
3
|
+
import { ParseResultElement } from '@speclynx/apidom-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const detect: (source: string) => Promise<boolean>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const detectionRegExp: RegExp;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const mediaTypes: JSONSchema202012MediaTypes;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const namespace: Namespace;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare const parse: (source: string, options?: Record<string, unknown>) => Promise<ParseResultElement>;
|
|
29
|
+
|
|
30
|
+
export { }
|