@speclynx/apidom-parser-adapter-openapi-yaml-2 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/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@speclynx/apidom-parser-adapter-openapi-yaml-2",
3
+ "version": "1.12.1",
4
+ "description": "Parser adapter for parsing YAML documents into OpenAPI 2.0 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-openapi-yaml-2.browser.min.js",
13
+ "main": "./src/adapter.cjs",
14
+ "exports": {
15
+ "types": "./types/apidom-parser-adapter-openapi-yaml-2.d.ts",
16
+ "import": "./src/adapter.mjs",
17
+ "require": "./src/adapter.cjs"
18
+ },
19
+ "types": "./types/apidom-parser-adapter-openapi-yaml-2.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-openapi-2": "^1.12.1",
44
+ "@speclynx/apidom-parser-adapter-yaml-1-2": "^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-openapi-yaml-2.d.ts",
54
+ "LICENSES",
55
+ "NOTICE",
56
+ "README.md",
57
+ "CHANGELOG.md"
58
+ ],
59
+ "gitHead": "49be88493f922c4ace2e4ebc0f23387ccb62c4fc"
60
+ }
@@ -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 _apidomParserAdapterYaml = require("@speclynx/apidom-parser-adapter-yaml-1-2");
11
+ var _apidomNsOpenapi = _interopRequireWildcard(require("@speclynx/apidom-ns-openapi-2"));
12
+ var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
13
+ exports.mediaTypes = _mediaTypes.default;
14
+ /**
15
+ * @public
16
+ */
17
+ const detectionRegExp = exports.detectionRegExp = /(?<YAML>^(["']?)swagger\2\s*:\s*(["'])(?<version_yaml>2\.0)\3(?:\s+|$))|(?<JSON>"swagger"\s*:\s*"(?<version_json>2\.0)")/m;
18
+
19
+ /**
20
+ * @public
21
+ */
22
+ const detect = async source => detectionRegExp.test(source) && (await (0, _apidomParserAdapterYaml.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, _apidomParserAdapterYaml.parse)(source, parserOpts);
32
+ const {
33
+ result
34
+ } = parseResultElement;
35
+ if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
36
+ const swaggerElement = _apidomNsOpenapi.SwaggerElement.refract(result, refractorOpts);
37
+ swaggerElement.classes.push('result');
38
+ parseResultElement.replaceResult(swaggerElement);
39
+ }
40
+ return parseResultElement;
41
+ };
42
+
43
+ /**
44
+ * @public
45
+ */
46
+ exports.parse = parse;
47
+ const namespace = exports.namespace = (0, _apidomCore.createNamespace)(_apidomNsOpenapi.default);
@@ -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 parseYAML, detect as detectYAML } from '@speclynx/apidom-parser-adapter-yaml-1-2';
5
+ import openApiNamespace, { SwaggerElement } from '@speclynx/apidom-ns-openapi-2';
6
+ export { default as mediaTypes } from "./media-types.mjs";
7
+ /**
8
+ * @public
9
+ */
10
+ export const detectionRegExp = /(?<YAML>^(["']?)swagger\2\s*:\s*(["'])(?<version_yaml>2\.0)\3(?:\s+|$))|(?<JSON>"swagger"\s*:\s*"(?<version_json>2\.0)")/m;
11
+
12
+ /**
13
+ * @public
14
+ */
15
+ export const detect = async source => detectionRegExp.test(source) && (await detectYAML(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 parseYAML(source, parserOpts);
24
+ const {
25
+ result
26
+ } = parseResultElement;
27
+ if (isNotUndefined(result)) {
28
+ const swaggerElement = SwaggerElement.refract(result, refractorOpts);
29
+ swaggerElement.classes.push('result');
30
+ parseResultElement.replaceResult(swaggerElement);
31
+ }
32
+ return parseResultElement;
33
+ };
34
+
35
+ /**
36
+ * @public
37
+ */
38
+ export const namespace = createNamespace(openApiNamespace);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-2");
6
+ /**
7
+ * @public
8
+ */
9
+ const yamlMediaTypes = new _apidomNsOpenapi.OpenAPIMediaTypes(..._apidomNsOpenapi.mediaTypes.filterByFormat('generic'), ..._apidomNsOpenapi.mediaTypes.filterByFormat('yaml'));
10
+ var _default = exports.default = yamlMediaTypes;
@@ -0,0 +1,7 @@
1
+ import { mediaTypes, OpenAPIMediaTypes } from '@speclynx/apidom-ns-openapi-2';
2
+
3
+ /**
4
+ * @public
5
+ */
6
+ const yamlMediaTypes = new OpenAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('yaml'));
7
+ export default yamlMediaTypes;
@@ -0,0 +1,30 @@
1
+ import { Namespace } from '@speclynx/apidom-core';
2
+ import { OpenAPIMediaTypes } from '@speclynx/apidom-ns-openapi-2';
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: OpenAPIMediaTypes;
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 { }