@speclynx/apidom-parser-adapter-overlay-yaml-1 4.3.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 +11 -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 +74 -0
- package/README.md +87 -0
- package/dist/apidom-parser-adapter-overlay-yaml-1.browser.js +38872 -0
- package/dist/apidom-parser-adapter-overlay-yaml-1.browser.min.js +1 -0
- package/package.json +74 -0
- package/src/adapter.cjs +53 -0
- package/src/adapter.mjs +45 -0
- package/src/media-types.cjs +10 -0
- package/src/media-types.mjs +7 -0
- package/types/apidom-parser-adapter-overlay-yaml-1.d.ts +39 -0
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@speclynx/apidom-parser-adapter-overlay-yaml-1",
|
|
3
|
+
"version": "4.3.0",
|
|
4
|
+
"description": "Parser adapter for parsing YAML documents into Overlay 1.x.y namespace.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"apidom",
|
|
7
|
+
"api",
|
|
8
|
+
"overlay",
|
|
9
|
+
"openapi",
|
|
10
|
+
"yaml",
|
|
11
|
+
"parser",
|
|
12
|
+
"parse",
|
|
13
|
+
"tree-sitter",
|
|
14
|
+
"ast",
|
|
15
|
+
"spec",
|
|
16
|
+
"specification",
|
|
17
|
+
"typescript",
|
|
18
|
+
"javascript"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org",
|
|
23
|
+
"provenance": false
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"unpkg": "./dist/apidom-parser-adapter-overlay-yaml-1.browser.min.js",
|
|
28
|
+
"main": "./src/adapter.cjs",
|
|
29
|
+
"exports": {
|
|
30
|
+
"types": "./types/apidom-parser-adapter-overlay-yaml-1.d.ts",
|
|
31
|
+
"import": "./src/adapter.mjs",
|
|
32
|
+
"require": "./src/adapter.cjs"
|
|
33
|
+
},
|
|
34
|
+
"types": "./types/apidom-parser-adapter-overlay-yaml-1.d.ts",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
|
|
37
|
+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
|
|
38
|
+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
|
|
39
|
+
"build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
|
|
40
|
+
"lint": "eslint ./",
|
|
41
|
+
"lint:fix": "eslint ./ --fix",
|
|
42
|
+
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
|
|
43
|
+
"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",
|
|
44
|
+
"typescript:check-types": "tsc --noEmit",
|
|
45
|
+
"typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
|
|
46
|
+
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
|
|
47
|
+
"postpack": "rimraf NOTICE LICENSES"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/speclynx/apidom.git"
|
|
52
|
+
},
|
|
53
|
+
"author": "Vladimir Gorej",
|
|
54
|
+
"license": "Apache-2.0",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@babel/runtime-corejs3": "^7.28.4",
|
|
57
|
+
"@speclynx/apidom-core": "4.3.0",
|
|
58
|
+
"@speclynx/apidom-datamodel": "4.3.0",
|
|
59
|
+
"@speclynx/apidom-ns-overlay-1": "4.3.0",
|
|
60
|
+
"@speclynx/apidom-parser-adapter-yaml-1-2": "4.3.0",
|
|
61
|
+
"ramda": "~0.32.0",
|
|
62
|
+
"ramda-adjunct": "^6.0.0"
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"src/**/*.mjs",
|
|
66
|
+
"src/**/*.cjs",
|
|
67
|
+
"dist/",
|
|
68
|
+
"types/apidom-parser-adapter-overlay-yaml-1.d.ts",
|
|
69
|
+
"LICENSES",
|
|
70
|
+
"NOTICE",
|
|
71
|
+
"README.md",
|
|
72
|
+
"CHANGELOG.md"
|
|
73
|
+
]
|
|
74
|
+
}
|
package/src/adapter.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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 _apidomParserAdapterYaml = require("@speclynx/apidom-parser-adapter-yaml-1-2");
|
|
11
|
+
var _apidomNsOverlay = _interopRequireWildcard(require("@speclynx/apidom-ns-overlay-1"));
|
|
12
|
+
var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
|
|
13
|
+
exports.mediaTypes = _mediaTypes.default;
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
const detectionRegExp = exports.detectionRegExp = /(?<YAML>^(["']?)overlay\2\s*:\s*(["']?)(?<version_yaml>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?<JSON>"overlay"\s*:\s*"(?<version_json>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/m;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterYaml.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, _apidomParserAdapterYaml.parse)(source, parserOpts);
|
|
35
|
+
const {
|
|
36
|
+
result
|
|
37
|
+
} = parseResultElement;
|
|
38
|
+
if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
|
|
39
|
+
const overlay1Element = (0, _apidomNsOverlay.refractOverlay1)(result, {
|
|
40
|
+
consume: true,
|
|
41
|
+
...refractorOpts
|
|
42
|
+
});
|
|
43
|
+
overlay1Element.classes.push('result');
|
|
44
|
+
parseResultElement.replaceResult(overlay1Element);
|
|
45
|
+
}
|
|
46
|
+
return parseResultElement;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
exports.parse = parse;
|
|
53
|
+
const namespace = exports.namespace = new _apidomDatamodel.Namespace().use(_apidomNsOverlay.default);
|
package/src/adapter.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { propOr, omit } from 'ramda';
|
|
2
|
+
import { isNotUndefined } from 'ramda-adjunct';
|
|
3
|
+
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { parse as parseYAML, detect as detectYAML } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
5
|
+
import overlayNamespacePlugin, { refractOverlay1 } from '@speclynx/apidom-ns-overlay-1';
|
|
6
|
+
export { default as mediaTypes } from "./media-types.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const detectionRegExp = /(?<YAML>^(["']?)overlay\2\s*:\s*(["']?)(?<version_yaml>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?<JSON>"overlay"\s*:\s*"(?<version_json>1\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/m;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectYAML(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 parseYAML(source, parserOpts);
|
|
28
|
+
const {
|
|
29
|
+
result
|
|
30
|
+
} = parseResultElement;
|
|
31
|
+
if (isNotUndefined(result)) {
|
|
32
|
+
const overlay1Element = refractOverlay1(result, {
|
|
33
|
+
consume: true,
|
|
34
|
+
...refractorOpts
|
|
35
|
+
});
|
|
36
|
+
overlay1Element.classes.push('result');
|
|
37
|
+
parseResultElement.replaceResult(overlay1Element);
|
|
38
|
+
}
|
|
39
|
+
return parseResultElement;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export const namespace = new Namespace().use(overlayNamespacePlugin);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsOverlay = require("@speclynx/apidom-ns-overlay-1");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
const yamlMediaTypes = new _apidomNsOverlay.OverlayMediaTypes(..._apidomNsOverlay.mediaTypes.filterByFormat('generic'), ..._apidomNsOverlay.mediaTypes.filterByFormat('yaml'));
|
|
10
|
+
var _default = exports.default = yamlMediaTypes;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { detect as detect_2 } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
2
|
+
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { OverlayMediaTypes } from '@speclynx/apidom-ns-overlay-1';
|
|
4
|
+
import { parse as parse_2 } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
5
|
+
import { ParseOptions as ParseOptions_2 } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const detect: typeof detect_2;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const detectionRegExp: RegExp;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const mediaTypes: OverlayMediaTypes;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare const namespace: Namespace;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare const parse: typeof parse_2;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare interface ParseOptions extends ParseOptions_2 {
|
|
36
|
+
refractorOpts?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { }
|