From f5b2c07d86fea023931284dabdc56311ef0b3656 Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Tue, 20 Sep 2022 17:39:03 -0700 Subject: [PATCH 1/6] chore: staring translating to TS Signed-off-by: Pawel Psztyc --- .eslintrc | 72 + .gitignore | 1 + commitlint.config.js => commitlint.config.cjs | 0 index.d.ts | 51 - index.js | 43 - package-lock.json | 6899 +++++++---------- package.json | 110 +- src/index.ts | 51 + .../{AmfInputParser.js => AmfInputParser.ts} | 128 +- src/lib/AmfParameterMixin.d.ts | 169 - ...ParameterMixin.js => AmfParameterMixin.ts} | 511 +- src/lib/ApiAuthDataHelper.js | 101 - src/lib/ApiAuthDataHelper.ts | 56 + src/lib/InputCache.d.ts | 57 - src/lib/InputCache.js | 107 - src/lib/InputCache.ts | 96 + ...lCustomData.js => Oauth2RamlCustomData.ts} | 130 +- src/lib/PayloadUtils.d.ts | 21 - src/lib/{PayloadUtils.js => PayloadUtils.ts} | 48 +- ...rocessor.js => QueryParameterProcessor.ts} | 96 +- src/lib/SecurityProcessor.d.ts | 63 - ...urityProcessor.js => SecurityProcessor.ts} | 99 +- src/lib/UrlUtils.d.ts | 46 - src/lib/{UrlUtils.js => UrlUtils.ts} | 76 +- src/lib/{Utils.js => Utils.ts} | 80 +- .../auth-ui/{ApiKeyAuth.js => ApiKeyAuth.ts} | 86 +- .../auth-ui/{ApiUiBase.js => ApiUiBase.ts} | 44 +- .../auth-ui/{CustomAuth.js => CustomAuth.ts} | 148 +- src/lib/auth-ui/OAuth1Auth.js | 81 - .../auth-ui/{OAuth2Auth.js => OAuth2Auth.ts} | 296 +- ...{PassThroughAuth.js => PassThroughAuth.ts} | 128 +- src/lib/navigation-layout/ApiSorting.d.ts | 8 - .../{ApiSorting.js => ApiSorting.ts} | 6 +- src/lib/navigation-layout/EndpointsTree.d.ts | 39 - .../{EndpointsTree.js => EndpointsTree.ts} | 60 +- src/{types.d.ts => types.ts} | 26 +- tsconfig.json | 31 +- web-dev-server.config.mjs | 42 +- web-test-runner.config.mjs | 56 +- 39 files changed, 4341 insertions(+), 5821 deletions(-) create mode 100644 .eslintrc rename commitlint.config.js => commitlint.config.cjs (100%) delete mode 100644 index.d.ts delete mode 100644 index.js create mode 100644 src/index.ts rename src/lib/{AmfInputParser.js => AmfInputParser.ts} (55%) delete mode 100644 src/lib/AmfParameterMixin.d.ts rename src/lib/{AmfParameterMixin.js => AmfParameterMixin.ts} (58%) delete mode 100644 src/lib/ApiAuthDataHelper.js create mode 100644 src/lib/ApiAuthDataHelper.ts delete mode 100644 src/lib/InputCache.d.ts delete mode 100644 src/lib/InputCache.js create mode 100644 src/lib/InputCache.ts rename src/lib/{Oauth2RamlCustomData.js => Oauth2RamlCustomData.ts} (59%) delete mode 100644 src/lib/PayloadUtils.d.ts rename src/lib/{PayloadUtils.js => PayloadUtils.ts} (62%) rename src/lib/{QueryParameterProcessor.js => QueryParameterProcessor.ts} (57%) delete mode 100644 src/lib/SecurityProcessor.d.ts rename src/lib/{SecurityProcessor.js => SecurityProcessor.ts} (61%) delete mode 100644 src/lib/UrlUtils.d.ts rename src/lib/{UrlUtils.js => UrlUtils.ts} (68%) rename src/lib/{Utils.js => Utils.ts} (72%) rename src/lib/auth-ui/{ApiKeyAuth.js => ApiKeyAuth.ts} (75%) rename src/lib/auth-ui/{ApiUiBase.js => ApiUiBase.ts} (63%) rename src/lib/auth-ui/{CustomAuth.js => CustomAuth.ts} (69%) delete mode 100644 src/lib/auth-ui/OAuth1Auth.js rename src/lib/auth-ui/{OAuth2Auth.js => OAuth2Auth.ts} (68%) rename src/lib/auth-ui/{PassThroughAuth.js => PassThroughAuth.ts} (70%) delete mode 100644 src/lib/navigation-layout/ApiSorting.d.ts rename src/lib/navigation-layout/{ApiSorting.js => ApiSorting.ts} (55%) delete mode 100644 src/lib/navigation-layout/EndpointsTree.d.ts rename src/lib/navigation-layout/{EndpointsTree.js => EndpointsTree.ts} (78%) rename src/{types.d.ts => types.ts} (96%) diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..4929ce8 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,72 @@ +{ + "env": { + "es2021": true + }, + "parser": "@typescript-eslint/parser", + "extends": [ + "@open-wc", + "prettier", + "plugin:@typescript-eslint/recommended" + ], + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "no-unused-vars": "off", + "no-continue": "off", + "no-plusplus": "off", + "no-shadow": "off", + "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/explicit-function-return-type": "error", + "@typescript-eslint/no-unused-vars": [ + "error" + ], + "import/no-unresolved": "off", + "import/extensions": [ + "error", + "always", + { + "ignorePackages": true + } + ] + }, + "overrides": [ + { + "files": [ + "src/pages/**/*.ts", + "src/bindings/**/*.ts" + ], + "rules": { + "class-methods-use-this": "off" + } + }, + { + "files": [ + "src/elements/**/*.ts" + ], + "rules": { + "class-methods-use-this": "off" + } + }, + { + "files": [ "src/**/*.ts" ], + "rules": { + "no-useless-constructor": "off", + "no-empty-function": "off", + "no-use-before-define": "off", + "no-dupe-class-members": "off" + } + } + ], + "globals": { + "EventListener": true, + "Prism": true, + "RequestInit": true, + "WorkerType": true, + "FormDataEntryValue": true, + "MutationObserverInit": true, + "ScrollToOptions": true, + "NodeListOf": true, + "GlobalEventHandlers": true + } +} diff --git a/.gitignore b/.gitignore index f19881a..cea01cc 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ demo/vendor.js demo/models/ .idea/ +tsconfig.tsbuildinfo diff --git a/commitlint.config.js b/commitlint.config.cjs similarity index 100% rename from commitlint.config.js rename to commitlint.config.cjs diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index bd710d1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -export { default as ApiOperationDocumentElement } from './src/elements/ApiOperationDocumentElement'; -export { default as ApiParameterDocumentElement } from './src/elements/ApiParameterDocumentElement'; -export { default as ApiPayloadDocumentElement } from './src/elements/ApiPayloadDocumentElement'; -export { default as ApiRequestDocumentElement } from './src/elements/ApiRequestDocumentElement'; -export { default as ApiResourceDocumentElement } from './src/elements/ApiResourceDocumentElement'; -export { default as ApiResponseDocumentElement } from './src/elements/ApiResponseDocumentElement'; -export { default as ApiSchemaDocumentElement } from './src/elements/ApiSchemaDocumentElement'; -export { default as ApiDocumentationDocumentElement } from './src/elements/ApiDocumentationDocumentElement'; -export { default as ApiChannelDocumentElement } from './src/elements/ApiChannelDocumentElement'; -export { default as ApiAnnotationDocumentElement } from './src/elements/ApiAnnotationDocumentElement'; -export { default as ApiSummaryElement } from './src/elements/ApiSummaryElement'; -export { default as XhrSimpleRequestElement } from './src/elements/XhrSimpleRequestElement'; -export { default as XhrSimpleRequestTransportElement } from './src/elements/XhrSimpleRequestTransportElement'; -export { default as ApiRequestElement } from './src/elements/ApiRequestElement'; -export { default as ApiRequestEditorElement } from './src/elements/ApiRequestEditorElement'; -export { default as ApiAuthorizationEditorElement } from './src/elements/ApiAuthorizationEditorElement'; -export { default as ApiAuthorizationMethodElement } from './src/elements/ApiAuthorizationMethodElement'; -export { default as ApiServerSelectorElement } from './src/elements/ApiServerSelectorElement'; -export { default as ApiNavigationElement } from './src/elements/ApiNavigationElement'; -export { default as ApiNavigationLegacyElement } from './src/elements/ApiNavigationLegacyElement.js'; -export { default as ApiSecurityDocumentElement } from './src/elements/ApiSecurityDocumentElement'; -export { default as ApiParametrizedSecuritySchemeElement } from './src/elements/ApiParametrizedSecuritySchemeElement'; -export { default as ApiSecurityRequirementDocumentElement } from './src/elements/ApiSecurityRequirementDocumentElement'; -export { default as ApiDocumentationElement } from './src/elements/ApiDocumentationElement'; -export * as InputCache from './src/lib/InputCache'; -export * as UrlLib from './src/lib/UrlUtils'; -export * as Utils from './src/lib/Utils'; -export { SecurityProcessor } from './src/lib/SecurityProcessor'; -export * from './src/types' -export { AmfHelperMixin } from './src/helpers/AmfHelperMixin'; -export { AmfSerializer } from './src/helpers/AmfSerializer'; -export { ns } from './src/helpers/Namespace'; -export * as Amf from './src/helpers/amf'; -export * as Api from './src/helpers/api'; -export { ApiExampleGenerator } from './src/schema/ApiExampleGenerator'; -export { ApiMonacoSchemaGenerator } from './src/schema/ApiMonacoSchemaGenerator'; -export { ApiSchemaValues } from './src/schema/ApiSchemaValues'; -export { ApiSchemaGenerator } from './src/schema/ApiSchemaGenerator'; -export { EventTypes as ApiEventTypes } from './src/events/EventTypes'; -export { Events as ApiEvents } from './src/events/Events'; -export { ApiNavigationEventDetail } from './src/events/NavigationEvents'; -export { ReportingErrorEventDetail } from './src/events/ReportingEvents'; -export { AbortRequestEvent, ApiRequestEvent, ApiResponseEvent } from './src/events/RequestEvents'; -export { ServerChangeEvent, ServerChangeEventDetail, ServerCountChangeEvent, ServerCountChangeEventDetail } from './src/events/ServerEvents'; -export { TelemetryCustomMetric, TelemetryCustomValue, TelemetryDetail, TelemetryEventDetail, TelemetryExceptionDetail, TelemetryScreenViewDetail, TelemetrySocialDetail, TelemetryTimingDetail } from './src/events/TelemetryEvents'; -export { DomEventsAmfStore } from './src/store/DomEventsAmfStore'; -export { AmfStore } from './src/store/AmfStore'; -export { AmfStoreDomEventsMixin } from './src/store/mixins/AmfStoreDomEventsMixin'; -export { InMemAmfGraphStore } from './src/store/InMemAmfGraphStore'; -export { NavigationContextMenu } from './src/plugins/NavigationContextMenu'; -export { default as NavigationContextMenuCommands } from './src/plugins/NavigationCommands'; diff --git a/index.js b/index.js deleted file mode 100644 index 3bbfe85..0000000 --- a/index.js +++ /dev/null @@ -1,43 +0,0 @@ -export { default as ApiOperationDocumentElement } from './src/elements/ApiOperationDocumentElement.js'; -export { default as ApiParameterDocumentElement } from './src/elements/ApiParameterDocumentElement.js'; -export { default as ApiPayloadDocumentElement } from './src/elements/ApiPayloadDocumentElement.js'; -export { default as ApiRequestDocumentElement } from './src/elements/ApiRequestDocumentElement.js'; -export { default as ApiResourceDocumentElement } from './src/elements/ApiResourceDocumentElement.js'; -export { default as ApiResponseDocumentElement } from './src/elements/ApiResponseDocumentElement.js'; -export { default as ApiSchemaDocumentElement } from './src/elements/ApiSchemaDocumentElement.js'; -export { default as ApiDocumentationDocumentElement } from './src/elements/ApiDocumentationDocumentElement.js'; -export { default as ApiChannelDocumentElement } from './src/elements/ApiChannelDocumentElement.js'; -export { default as ApiAnnotationDocumentElement } from './src/elements/ApiAnnotationDocumentElement.js'; -export { default as ApiSummaryElement } from './src/elements/ApiSummaryElement.js'; -export { default as XhrSimpleRequestElement } from './src/elements/XhrSimpleRequestElement.js'; -export { default as XhrSimpleRequestTransportElement } from './src/elements/XhrSimpleRequestTransportElement.js'; -export { default as ApiRequestElement } from './src/elements/ApiRequestElement.js'; -export { default as ApiRequestEditorElement } from './src/elements/ApiRequestEditorElement.js'; -export { default as ApiAuthorizationEditorElement } from './src/elements/ApiAuthorizationEditorElement.js'; -export { default as ApiAuthorizationMethodElement } from './src/elements/ApiAuthorizationMethodElement.js'; -export { default as ApiServerSelectorElement } from './src/elements/ApiServerSelectorElement.js'; -export { default as ApiNavigationElement } from './src/elements/ApiNavigationElement.js'; -export { default as ApiNavigationLegacyElement } from './src/elements/ApiNavigationLegacyElement.js'; -export { default as ApiSecurityDocumentElement } from './src/elements/ApiSecurityDocumentElement.js'; -export { default as ApiParametrizedSecuritySchemeElement } from './src/elements/ApiParametrizedSecuritySchemeElement.js'; -export { default as ApiSecurityRequirementDocumentElement } from './src/elements/ApiSecurityRequirementDocumentElement.js'; -export { default as ApiDocumentationElement } from './src/elements/ApiDocumentationElement.js'; -export { EventTypes as ApiEventTypes } from './src/events/EventTypes.js'; -export { Events as ApiEvents } from './src/events/Events.js'; -export * as InputCache from './src/lib/InputCache.js'; -export * as UrlLib from './src/lib/UrlUtils.js'; -export * as Utils from './src/lib/Utils.js'; -export { SecurityProcessor } from './src/lib/SecurityProcessor.js'; -export { AmfHelperMixin } from './src/helpers/AmfHelperMixin.js'; -export { AmfSerializer } from './src/helpers/AmfSerializer.js'; -export { ns } from './src/helpers/Namespace.js'; -export { ApiExampleGenerator } from './src/schema/ApiExampleGenerator.js'; -export { ApiMonacoSchemaGenerator } from './src/schema/ApiMonacoSchemaGenerator.js'; -export { ApiSchemaValues } from './src/schema/ApiSchemaValues.js'; -export { ApiSchemaGenerator } from './src/schema/ApiSchemaGenerator.js'; -export { DomEventsAmfStore } from './src/store/DomEventsAmfStore.js'; -export { AmfStore } from './src/store/AmfStore.js'; -export { AmfStoreDomEventsMixin } from './src/store/mixins/AmfStoreDomEventsMixin.js'; -export { InMemAmfGraphStore } from './src/store/InMemAmfGraphStore.js'; -export { NavigationContextMenu } from './src/plugins/NavigationContextMenu.js'; -export { default as NavigationContextMenuCommands } from './src/plugins/NavigationCommands.js'; diff --git a/package-lock.json b/package-lock.json index efb6185..65aa877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,65 +1,51 @@ { "name": "@api-components/amf-components", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/amf-components", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "license": "Apache-2.0", "dependencies": { - "@advanced-rest-client/base": "^0.1.0", - "@advanced-rest-client/events": "^0.2.22", - "@advanced-rest-client/highlight": "^2.0.1", - "@advanced-rest-client/http-code-snippets": "^4.0.0", + "@advanced-rest-client/base": "^0.1.10", + "@advanced-rest-client/events": "^18.0.2", + "@advanced-rest-client/highlight": "^2.0.2", + "@advanced-rest-client/http-code-snippets": "^4.0.1", "@advanced-rest-client/icons": "^4.0.0", - "@advanced-rest-client/oauth": "^0.1.0", + "@advanced-rest-client/oauth": "^0.2.1", "@advanced-rest-client/uuid": "^4.0.0", - "@anypoint-web-components/awc": "^1.0.5", - "@api-client/context-menu": "^0.2.0", - "@open-wc/dedupe-mixin": "^1.3.0", - "@pawel-up/data-mock": "^0.1.7", + "@anypoint-web-components/awc": "^3.0.12", + "@api-client/context-menu": "^0.4.1", + "@open-wc/dedupe-mixin": "^1.3.1", + "@pawel-up/data-mock": "^0.3.2", "amf-json-ld-lib": "0.0.14", - "dompurify": "^2.3.3", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "dompurify": "^2.4.0", + "lit": "^2.3.1" }, "devDependencies": { - "@advanced-rest-client/arc-demo-helper": "^5.0.1", - "@commitlint/cli": "^16.2.1", - "@commitlint/config-conventional": "^16.2.1", - "@open-wc/eslint-config": "^7.0.0", - "@open-wc/testing": "^3.0.1", - "@web/dev-server": "^0.1.25", - "@web/test-runner": "^0.13.20", - "@web/test-runner-playwright": "^0.8.8", - "amf-client-js": "^5.0.5", - "eslint": "^8.1.0", - "eslint-config-prettier": "^8.3.0", - "husky": "^7.0.4", - "lint-staged": "^12.3.5", - "sinon": "^13.0.1", - "typescript": "^4.4.4", + "@commitlint/cli": "^17.1.2", + "@commitlint/config-conventional": "^17.1.0", + "@open-wc/eslint-config": "^8.0.2", + "@open-wc/testing": "^3.1.6", + "@types/dompurify": "^2.3.4", + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@typescript-eslint/parser": "^5.22.0", + "@web/dev-server": "^0.1.34", + "@web/test-runner": "^0.14.0", + "@web/test-runner-playwright": "^0.8.10", + "amf-client-js": "^5.1.0", + "concurrently": "^7.4.0", + "eslint": "^8.23.1", + "eslint-config-prettier": "^8.5.0", + "husky": "^8.0.1", + "lint-staged": "^13.0.3", + "sinon": "^14.0.0", + "tslib": "^2.4.0", + "typescript": "^4.8.3", "typescript-lit-html-plugin": "^0.9.0", - "uuid": "^8.3.2" - } - }, - "node_modules/@advanced-rest-client/arc-demo-helper": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/arc-demo-helper/-/arc-demo-helper-5.0.4.tgz", - "integrity": "sha512-428Pr58NOnRNx6jKmtfLueoZkzW48RhAQnnn4NnJ3bmQPsbjDhT72Kz9k9tSfECzFY1zBhRndtHvyenfwteJMw==", - "dev": true, - "dependencies": { - "@anypoint-web-components/awc": "^1.0.5", - "@open-wc/dedupe-mixin": "^1.3.0", - "@polymer/font-roboto": "^3.0.2", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1", - "prismjs": "^1.25.0" - }, - "peerDependencies": { - "@advanced-rest-client/events": "^0.2.22" + "uuid": "^9.0.0" } }, "node_modules/@advanced-rest-client/base": { @@ -89,11 +75,47 @@ "jsrsasign": "^10.4.0" } }, - "node_modules/@advanced-rest-client/events": { + "node_modules/@advanced-rest-client/base/node_modules/@advanced-rest-client/events": { "version": "0.2.32", "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" }, + "node_modules/@advanced-rest-client/base/node_modules/@advanced-rest-client/oauth": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.1.0.tgz", + "integrity": "sha512-GQtQzrm2Mi5haq6Iv2Da7OwApK5+bHGvj8tc2aPCUzEeWnsQdI0kP8fOmGuNCLnk8h/FNG+B1ducjGuknChBuw==", + "dependencies": { + "@advanced-rest-client/events": "^0.2.28" + }, + "peerDependencies": { + "jsrsasign": "^10.4.0" + } + }, + "node_modules/@advanced-rest-client/base/node_modules/@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "dependencies": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + }, + "node_modules/@advanced-rest-client/base/node_modules/@api-client/context-menu": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.2.0.tgz", + "integrity": "sha512-OpOhXaXEihcQHm5WrgbjoHy/aSEzmc3g3s3gkUrqGxyPFGZYD/OF6iNdMV/HIMrjWK2LHw266s/Rxp5L60Kr0g==", + "dependencies": { + "@anypoint-web-components/awc": "^1.0.5", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + }, + "node_modules/@advanced-rest-client/events": { + "version": "18.0.2", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-18.0.2.tgz", + "integrity": "sha512-vlfQUji9dX7LNOmEK6rhAZQTgO2XBQ+Yx7Q+fR1ufe+wP1GoezCg944z9GSr0dIpCuSRxe+jj/n5Lr+G4jmHtQ==" + }, "node_modules/@advanced-rest-client/highlight": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@advanced-rest-client/highlight/-/highlight-2.0.2.tgz", @@ -110,6 +132,21 @@ "prismjs": "^1.25.0" } }, + "node_modules/@advanced-rest-client/highlight/node_modules/@advanced-rest-client/events": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", + "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + }, + "node_modules/@advanced-rest-client/highlight/node_modules/@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "dependencies": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + }, "node_modules/@advanced-rest-client/http-code-snippets": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@advanced-rest-client/http-code-snippets/-/http-code-snippets-4.0.1.tgz", @@ -121,6 +158,16 @@ "prismjs": "^1.25.0" } }, + "node_modules/@advanced-rest-client/http-code-snippets/node_modules/@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "dependencies": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + }, "node_modules/@advanced-rest-client/icons": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@advanced-rest-client/icons/-/icons-4.0.0.tgz", @@ -138,6 +185,11 @@ "@advanced-rest-client/events": "^0.2.29" } }, + "node_modules/@advanced-rest-client/libs/node_modules/@advanced-rest-client/events": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", + "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + }, "node_modules/@advanced-rest-client/monaco-support": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@advanced-rest-client/monaco-support/-/monaco-support-1.0.1.tgz", @@ -147,12 +199,9 @@ } }, "node_modules/@advanced-rest-client/oauth": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.1.0.tgz", - "integrity": "sha512-GQtQzrm2Mi5haq6Iv2Da7OwApK5+bHGvj8tc2aPCUzEeWnsQdI0kP8fOmGuNCLnk8h/FNG+B1ducjGuknChBuw==", - "dependencies": { - "@advanced-rest-client/events": "^0.2.28" - }, + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.2.1.tgz", + "integrity": "sha512-R1Ke8SNs29AcOgw2MDm2d/iI7qjUIAF1DVGvnahZlKyCOrEH6xbak7BxRmEuNMayjbFdSUXQHDquUNS+lvaoNQ==", "peerDependencies": { "jsrsasign": "^10.4.0" } @@ -162,630 +211,338 @@ "resolved": "https://registry.npmjs.org/@advanced-rest-client/uuid/-/uuid-4.0.0.tgz", "integrity": "sha512-ln7TGYaiGGRiXFHxo722EPcEDSccq+jclDRYTOTrRp3fTvUrm8P+tHCPFJTGa68Hi/rDhMZN3SkfF3+thtM7eQ==" }, - "node_modules/@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, - "peer": true, - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.0" - }, - "engines": { - "node": ">=6.0.0" - } + "node_modules/@aml-org/amf-antlr-parsers": { + "version": "0.5.17", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.5.17.tgz", + "integrity": "sha512-GHPMGjkcNeTjp+DxASQ/y5oijNiaYPSItHT1YNEkGGZnd+d5MLhrlujIx2cKn7aKcxLNTGY1skNFEIf1jZtWxQ==", + "dev": true }, "node_modules/@anypoint-web-components/awc": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", - "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-3.0.12.tgz", + "integrity": "sha512-jn54YDqYLxSN8byOuvvojwdEMMq3pXce6llZcYCLoEmecoWiqypbN40CA2haW21QmGNrNZZKaFBcWzm4dP5ZcA==", "dependencies": { - "@open-wc/dedupe-mixin": "^1.3.0", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "lit": "^2.2.1", + "tslib": "^2.3.1" } }, "node_modules/@api-client/context-menu": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.2.0.tgz", - "integrity": "sha512-OpOhXaXEihcQHm5WrgbjoHy/aSEzmc3g3s3gkUrqGxyPFGZYD/OF6iNdMV/HIMrjWK2LHw266s/Rxp5L60Kr0g==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.4.1.tgz", + "integrity": "sha512-PJ1LWUrreArXLYOfTGLy023xyOQFhcz/xFsqWSY7Ob+V/6TIZ6pEli+kRArhE2FuyZCZa3FPaA0rr7pTOTuaTw==", "dependencies": { - "@anypoint-web-components/awc": "^1.0.5", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "@anypoint-web-components/awc": "^3.0.1", + "lit": "^2.2.2" } }, "node_modules/@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", "dev": true, "dependencies": { - "@babel/highlight": "^7.16.7" + "@babel/highlight": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/compat-data": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.7.tgz", - "integrity": "sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true, - "peer": true, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/core": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.7.tgz", - "integrity": "sha512-djHlEfFHnSnTAcPb7dATbiM5HxGOP98+3JLBZtjRb5I7RXrw7kFRoG2dXM8cm3H+o11A8IFH/uprmJpwFynRNQ==", + "node_modules/@babel/highlight": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, - "peer": true, "dependencies": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.7", - "@babel/helper-compilation-targets": "^7.17.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helpers": "^7.17.7", - "@babel/parser": "^7.17.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.1.2", - "semver": "^6.3.0" + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" }, "engines": { "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", + "node_modules/@babel/runtime": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.0.tgz", + "integrity": "sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==", "dev": true, - "peer": true, "dependencies": { - "eslint-scope": "^5.1.1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.0" + "regenerator-runtime": "^0.13.4" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.11.0", - "eslint": "^7.5.0 || ^8.0.0" + "node": ">=6.9.0" } }, - "node_modules/@babel/eslint-plugin": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/eslint-plugin/-/eslint-plugin-7.17.7.tgz", - "integrity": "sha512-JATUoJJXSgwI0T8juxWYtK1JSgoLpIGUsCHIv+NMXcUDA2vIe6nvAHR9vnuJgs/P1hOFw7vPwibixzfqBBLIVw==", + "node_modules/@babel/runtime-corejs3": { + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.19.1.tgz", + "integrity": "sha512-j2vJGnkopRzH+ykJ8h68wrHnEUmtK//E723jjixiAl/PPf6FhqY/vYRcMVlNydRKQjQsTsYEjpx+DZMIvnGk/g==", "dev": true, - "peer": true, "dependencies": { - "eslint-rule-composer": "^0.3.0" + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.4" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/eslint-parser": ">=7.11.0", - "eslint": ">=7.5.0" + "node": ">=6.9.0" } }, - "node_modules/@babel/generator": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.7.tgz", - "integrity": "sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==", + "node_modules/@commitlint/cli": { + "version": "17.1.2", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.1.2.tgz", + "integrity": "sha512-h/4Hlka3bvCLbnxf0Er2ri5A44VMlbMSkdTRp8Adv2tRiklSTRIoPGs7OEXDv3EoDs2AAzILiPookgM4Gi7LOw==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "@commitlint/format": "^17.0.0", + "@commitlint/lint": "^17.1.0", + "@commitlint/load": "^17.1.2", + "@commitlint/read": "^17.1.0", + "@commitlint/types": "^17.0.0", + "execa": "^5.0.0", + "lodash": "^4.17.19", + "resolve-from": "5.0.0", + "resolve-global": "1.0.0", + "yargs": "^17.0.0" + }, + "bin": { + "commitlint": "cli.js" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz", - "integrity": "sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==", + "node_modules/@commitlint/config-conventional": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.1.0.tgz", + "integrity": "sha512-WU2p0c9/jLi8k2q2YrDV96Y8XVswQOceIQ/wyJvQxawJSCasLdRB3kUIYdNjOCJsxkpoUlV/b90ZPxp1MYZDiA==", "dev": true, - "peer": true, "dependencies": { - "@babel/compat-data": "^7.17.7", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", - "semver": "^6.3.0" + "conventional-changelog-conventionalcommits": "^5.0.0" }, "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", + "node_modules/@commitlint/config-validator": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.1.0.tgz", + "integrity": "sha512-Q1rRRSU09ngrTgeTXHq6ePJs2KrI+axPTgkNYDWSJIuS1Op4w3J30vUfSXjwn5YEJHklK3fSqWNHmBhmTR7Vdg==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.16.7" + "@commitlint/types": "^17.0.0", + "ajv": "^8.11.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", + "node_modules/@commitlint/config-validator/node_modules/ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", "dev": true, - "peer": true, "dependencies": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" }, - "engines": { - "node": ">=6.9.0" + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", + "node_modules/@commitlint/config-validator/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/@commitlint/ensure": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.0.0.tgz", + "integrity": "sha512-M2hkJnNXvEni59S0QPOnqCKIK52G1XyXBGw51mvh7OXDudCmZ9tZiIPpU882p475Mhx48Ien1MbWjCP1zlyC0A==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.16.7" + "@commitlint/types": "^17.0.0", + "lodash": "^4.17.19" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", + "node_modules/@commitlint/execute-rule": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-17.0.0.tgz", + "integrity": "sha512-nVjL/w/zuqjCqSJm8UfpNaw66V9WzuJtQvEnCrK4jDw6qKTmZB+1JQ8m6BQVZbNBcwfYdDNKnhIhqI0Rk7lgpQ==", "dev": true, - "peer": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", + "node_modules/@commitlint/format": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-17.0.0.tgz", + "integrity": "sha512-MZzJv7rBp/r6ZQJDEodoZvdRM0vXu1PfQvMTNWFb8jFraxnISMTnPBWMMjr2G/puoMashwaNM//fl7j8gGV5lA==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.16.7" + "@commitlint/types": "^17.0.0", + "chalk": "^4.1.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz", - "integrity": "sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw==", + "node_modules/@commitlint/format/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "peer": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" + "color-convert": "^2.0.1" }, "engines": { - "node": ">=6.9.0" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@babel/helper-simple-access": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz", - "integrity": "sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA==", + "node_modules/@commitlint/format/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.17.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", + "node_modules/@commitlint/format/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, - "peer": true, "dependencies": { - "@babel/types": "^7.16.7" + "color-name": "~1.1.4" }, "engines": { - "node": ">=6.9.0" + "node": ">=7.0.0" } }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } + "node_modules/@commitlint/format/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true }, - "node_modules/@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", + "node_modules/@commitlint/format/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, - "peer": true, "engines": { - "node": ">=6.9.0" + "node": ">=8" } }, - "node_modules/@babel/helpers": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.7.tgz", - "integrity": "sha512-TKsj9NkjJfTBxM7Phfy7kv6yYc4ZcOo+AaWGqQOKTPDOmcGkIFb5xNA746eKisQkm4yavUYh4InYM9S+VnO01w==", + "node_modules/@commitlint/format/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "peer": true, "dependencies": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" + "has-flag": "^4.0.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=8" } }, - "node_modules/@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", + "node_modules/@commitlint/is-ignored": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.1.0.tgz", + "integrity": "sha512-JITWKDMHhIh8IpdIbcbuH9rEQJty1ZWelgjleTFrVRAcEwN/sPzk1aVUXRIZNXMJWbZj8vtXRJnFihrml8uECQ==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "@commitlint/types": "^17.0.0", + "semver": "7.3.7" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/parser": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.7.tgz", - "integrity": "sha512-bm3AQf45vR4gKggRfvJdYJ0gFLoCbsPxiFLSH6hTVYABptNHY6l9NrhnucVjQ/X+SPtLANT9lc0fFhikj+VBRA==", + "node_modules/@commitlint/is-ignored/node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, - "peer": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { - "parser": "bin/babel-parser.js" + "semver": "bin/semver.js" }, "engines": { - "node": ">=6.0.0" + "node": ">=10" } }, - "node_modules/@babel/runtime": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.7.tgz", - "integrity": "sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==", + "node_modules/@commitlint/lint": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.1.0.tgz", + "integrity": "sha512-ltpqM2ogt/+SDhUaScFo0MdscncEF96lvQTPMM/VTTWlw7sTGLLWkOOppsee2MN/uLNNWjQ7kqkd4h6JqoM9AQ==", "dev": true, "dependencies": { - "regenerator-runtime": "^0.13.4" + "@commitlint/is-ignored": "^17.1.0", + "@commitlint/parse": "^17.0.0", + "@commitlint/rules": "^17.0.0", + "@commitlint/types": "^17.0.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=v14" } }, - "node_modules/@babel/runtime-corejs3": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.7.tgz", - "integrity": "sha512-TvliGJjhxis5m7xIMvlXH/xG8Oa/LK0SCUCyfKD6nLi42n5fB4WibDJ0g9trmmBB6hwpMNx+Lzbxy9/4gpMaVw==", + "node_modules/@commitlint/load": { + "version": "17.1.2", + "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.1.2.tgz", + "integrity": "sha512-sk2p/jFYAWLChIfOIp/MGSIn/WzZ0vkc3afw+l4X8hGEYkvDe4gQUUAVxjl/6xMRn0HgnSLMZ04xXh5pkTsmgg==", "dev": true, "dependencies": { - "core-js-pure": "^3.20.2", - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.3.tgz", - "integrity": "sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==", - "dev": true, - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.3", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "peer": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@commitlint/cli": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-16.2.1.tgz", - "integrity": "sha512-zfKf+B9osuiDbxGMJ7bWFv7XFCW8wlQYPtCffNp7Ukdb7mdrep5R9e03vPUZysnwp8NX6hg05kPEvnD/wRIGWw==", - "dev": true, - "dependencies": { - "@commitlint/format": "^16.2.1", - "@commitlint/lint": "^16.2.1", - "@commitlint/load": "^16.2.1", - "@commitlint/read": "^16.2.1", - "@commitlint/types": "^16.2.1", - "lodash": "^4.17.19", - "resolve-from": "5.0.0", - "resolve-global": "1.0.0", - "yargs": "^17.0.0" - }, - "bin": { - "commitlint": "cli.js" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/config-conventional": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-16.2.1.tgz", - "integrity": "sha512-cP9gArx7gnaj4IqmtCIcHdRjTYdRUi6lmGE+lOzGGjGe45qGOS8nyQQNvkNy2Ey2VqoSWuXXkD8zCUh6EHf1Ww==", - "dev": true, - "dependencies": { - "conventional-changelog-conventionalcommits": "^4.3.1" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/config-validator": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-16.2.1.tgz", - "integrity": "sha512-hogSe0WGg7CKmp4IfNbdNES3Rq3UEI4XRPB8JL4EPgo/ORq5nrGTVzxJh78omibNuB8Ho4501Czb1Er1MoDWpw==", - "dev": true, - "dependencies": { - "@commitlint/types": "^16.2.1", - "ajv": "^6.12.6" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/ensure": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-16.2.1.tgz", - "integrity": "sha512-/h+lBTgf1r5fhbDNHOViLuej38i3rZqTQnBTk+xEg+ehOwQDXUuissQ5GsYXXqI5uGy+261ew++sT4EA3uBJ+A==", - "dev": true, - "dependencies": { - "@commitlint/types": "^16.2.1", - "lodash": "^4.17.19" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/execute-rule": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-16.2.1.tgz", - "integrity": "sha512-oSls82fmUTLM6cl5V3epdVo4gHhbmBFvCvQGHBRdQ50H/690Uq1Dyd7hXMuKITCIdcnr9umyDkr8r5C6HZDF3g==", - "dev": true, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/format": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-16.2.1.tgz", - "integrity": "sha512-Yyio9bdHWmNDRlEJrxHKglamIk3d6hC0NkEUW6Ti6ipEh2g0BAhy8Od6t4vLhdZRa1I2n+gY13foy+tUgk0i1Q==", - "dev": true, - "dependencies": { - "@commitlint/types": "^16.2.1", - "chalk": "^4.0.0" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/format/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@commitlint/format/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@commitlint/format/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@commitlint/format/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/@commitlint/format/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@commitlint/format/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@commitlint/is-ignored": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-16.2.1.tgz", - "integrity": "sha512-exl8HRzTIfb1YvDJp2b2HU5z1BT+9tmgxR2XF0YEzkMiCIuEKh+XLeocPr1VcvAKXv3Cmv5X/OfNRp+i+/HIhQ==", - "dev": true, - "dependencies": { - "@commitlint/types": "^16.2.1", - "semver": "7.3.5" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/is-ignored/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@commitlint/lint": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-16.2.1.tgz", - "integrity": "sha512-fNINQ3X2ZqsCkNB3Z0Z8ElmhewqrS3gy2wgBTx97BkcjOWiyPAGwDJ752hwrsUnWAVBRztgw826n37xPzxsOgg==", - "dev": true, - "dependencies": { - "@commitlint/is-ignored": "^16.2.1", - "@commitlint/parse": "^16.2.1", - "@commitlint/rules": "^16.2.1", - "@commitlint/types": "^16.2.1" - }, - "engines": { - "node": ">=v12" - } - }, - "node_modules/@commitlint/load": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-16.2.1.tgz", - "integrity": "sha512-oSpz0jTyVI/A1AIImxJINTLDOMB8YF7lWGm+Jg5wVWM0r7ucpuhyViVvpSRTgvL0z09oIxlctyFGWUQQpI42uw==", - "dev": true, - "dependencies": { - "@commitlint/config-validator": "^16.2.1", - "@commitlint/execute-rule": "^16.2.1", - "@commitlint/resolve-extends": "^16.2.1", - "@commitlint/types": "^16.2.1", - "@types/node": ">=12", - "chalk": "^4.0.0", + "@commitlint/config-validator": "^17.1.0", + "@commitlint/execute-rule": "^17.0.0", + "@commitlint/resolve-extends": "^17.1.0", + "@commitlint/types": "^17.0.0", + "@types/node": "^14.0.0", + "chalk": "^4.1.0", "cosmiconfig": "^7.0.0", - "cosmiconfig-typescript-loader": "^1.0.0", + "cosmiconfig-typescript-loader": "^4.0.0", "lodash": "^4.17.19", "resolve-from": "^5.0.0", - "typescript": "^4.4.3" + "ts-node": "^10.8.1", + "typescript": "^4.6.4" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, + "node_modules/@commitlint/load/node_modules/@types/node": { + "version": "14.18.29", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.29.tgz", + "integrity": "sha512-LhF+9fbIX4iPzhsRLpK5H7iPdvW8L4IwGciXQIOEcuF62+9nw/VQVsOViAOOGxY3OlOKGLFv0sWwJXdwQeTn6A==", + "dev": true + }, "node_modules/@commitlint/load/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -857,107 +614,108 @@ } }, "node_modules/@commitlint/message": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-16.2.1.tgz", - "integrity": "sha512-2eWX/47rftViYg7a3axYDdrgwKv32mxbycBJT6OQY/MJM7SUfYNYYvbMFOQFaA4xIVZt7t2Alyqslbl6blVwWw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.0.0.tgz", + "integrity": "sha512-LpcwYtN+lBlfZijHUdVr8aNFTVpHjuHI52BnfoV01TF7iSLnia0jttzpLkrLmI8HNQz6Vhr9UrxDWtKZiMGsBw==", "dev": true, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/parse": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-16.2.1.tgz", - "integrity": "sha512-2NP2dDQNL378VZYioLrgGVZhWdnJO4nAxQl5LXwYb08nEcN+cgxHN1dJV8OLJ5uxlGJtDeR8UZZ1mnQ1gSAD/g==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.0.0.tgz", + "integrity": "sha512-cKcpfTIQYDG1ywTIr5AG0RAiLBr1gudqEsmAGCTtj8ffDChbBRxm6xXs2nv7GvmJN7msOt7vOKleLvcMmRa1+A==", "dev": true, "dependencies": { - "@commitlint/types": "^16.2.1", + "@commitlint/types": "^17.0.0", "conventional-changelog-angular": "^5.0.11", "conventional-commits-parser": "^3.2.2" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/read": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-16.2.1.tgz", - "integrity": "sha512-tViXGuaxLTrw2r7PiYMQOFA2fueZxnnt0lkOWqKyxT+n2XdEMGYcI9ID5ndJKXnfPGPppD0w/IItKsIXlZ+alw==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-17.1.0.tgz", + "integrity": "sha512-73BoFNBA/3Ozo2JQvGsE0J8SdrJAWGfZQRSHqvKaqgmY042Su4gXQLqvAzgr55S9DI1l9TiU/5WDuh8IE86d/g==", "dev": true, "dependencies": { - "@commitlint/top-level": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/top-level": "^17.0.0", + "@commitlint/types": "^17.0.0", "fs-extra": "^10.0.0", - "git-raw-commits": "^2.0.0" + "git-raw-commits": "^2.0.0", + "minimist": "^1.2.6" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/resolve-extends": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-16.2.1.tgz", - "integrity": "sha512-NbbCMPKTFf2J805kwfP9EO+vV+XvnaHRcBy6ud5dF35dxMsvdJqke54W3XazXF1ZAxC4a3LBy4i/GNVBAthsEg==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.1.0.tgz", + "integrity": "sha512-jqKm00LJ59T0O8O4bH4oMa4XyJVEOK4GzH8Qye9XKji+Q1FxhZznxMV/bDLyYkzbTodBt9sL0WLql8wMtRTbqQ==", "dev": true, "dependencies": { - "@commitlint/config-validator": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/config-validator": "^17.1.0", + "@commitlint/types": "^17.0.0", "import-fresh": "^3.0.0", "lodash": "^4.17.19", "resolve-from": "^5.0.0", "resolve-global": "^1.0.0" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/rules": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-16.2.1.tgz", - "integrity": "sha512-ZFezJXQaBBso+BOTre/+1dGCuCzlWVaeLiVRGypI53qVgPMzQqZhkCcrxBFeqB87qeyzr4A4EoG++IvITwwpIw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.0.0.tgz", + "integrity": "sha512-45nIy3dERKXWpnwX9HeBzK5SepHwlDxdGBfmedXhL30fmFCkJOdxHyOJsh0+B0RaVsLGT01NELpfzJUmtpDwdQ==", "dev": true, "dependencies": { - "@commitlint/ensure": "^16.2.1", - "@commitlint/message": "^16.2.1", - "@commitlint/to-lines": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/ensure": "^17.0.0", + "@commitlint/message": "^17.0.0", + "@commitlint/to-lines": "^17.0.0", + "@commitlint/types": "^17.0.0", "execa": "^5.0.0" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/to-lines": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-16.2.1.tgz", - "integrity": "sha512-9/VjpYj5j1QeY3eiog1zQWY6axsdWAc0AonUUfyZ7B0MVcRI0R56YsHAfzF6uK/g/WwPZaoe4Lb1QCyDVnpVaQ==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-17.0.0.tgz", + "integrity": "sha512-nEi4YEz04Rf2upFbpnEorG8iymyH7o9jYIVFBG1QdzebbIFET3ir+8kQvCZuBE5pKCtViE4XBUsRZz139uFrRQ==", "dev": true, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/top-level": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-16.2.1.tgz", - "integrity": "sha512-lS6GSieHW9y6ePL73ied71Z9bOKyK+Ib9hTkRsB8oZFAyQZcyRwq2w6nIa6Fngir1QW51oKzzaXfJL94qwImyw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-17.0.0.tgz", + "integrity": "sha512-dZrEP1PBJvodNWYPOYiLWf6XZergdksKQaT6i1KSROLdjf5Ai0brLOv5/P+CPxBeoj3vBxK4Ax8H1Pg9t7sHIQ==", "dev": true, "dependencies": { "find-up": "^5.0.0" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/types": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-16.2.1.tgz", - "integrity": "sha512-7/z7pA7BM0i8XvMSBynO7xsB3mVQPUZbVn6zMIlp/a091XJ3qAXRXc+HwLYhiIdzzS5fuxxNIHZMGHVD4HJxdA==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.0.0.tgz", + "integrity": "sha512-hBAw6U+SkAT5h47zDMeOu3HSiD0SODw4Aq7rRNh1ceUmL7GyLKYhPbUvlRWqZ65XjBLPHZhFyQlRaPNz8qvUyQ==", "dev": true, "dependencies": { - "chalk": "^4.0.0" + "chalk": "^4.1.0" }, "engines": { - "node": ">=v12" + "node": ">=v14" } }, "node_modules/@commitlint/types/node_modules/ansi-styles": { @@ -1030,22 +788,13 @@ "node": ">=8" } }, - "node_modules/@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true, - "engines": { - "node": ">= 12" - } - }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" }, "engines": { "node": ">=12" @@ -1058,29 +807,32 @@ "dev": true }, "node_modules/@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", + "integrity": "sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", + "espree": "^9.4.0", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1105,23 +857,23 @@ } }, "node_modules/@esm-bundle/chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/@esm-bundle/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-6Tx35wWiNw7X0nLY9RMx8v3EL8SacCFW+eEZOE9Hc+XxmU5HFE2AFEg+GehUZpiyDGwVvPH75ckGlqC7coIPnA==", + "version": "4.3.4-fix.0", + "resolved": "https://registry.npmjs.org/@esm-bundle/chai/-/chai-4.3.4-fix.0.tgz", + "integrity": "sha512-26SKdM4uvDWlY8/OOOxSB1AqQWeBosCX3wRYUZO7enTAj03CtVxIiCimYVG2WpULcyV51qapK4qTovwkUr5Mlw==", "dev": true, "dependencies": { "@types/chai": "^4.2.12" } }, "node_modules/@github/time-elements": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.2.tgz", - "integrity": "sha512-YVtZVLBikP6I7na22kfB9PKIseISwX41MFJ7lPuNz1VVH2IR5cpRRU6F1X6kcchPChljuvMUR4OiwMWHOJQ8kQ==" + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.4.tgz", + "integrity": "sha512-DTe/w0uKVeciKzGtYadNdfS8D86pXdGF+OrKg+vi8PKlotJ45zAc26zNpmmfCcMblBBg2+uoi3OxmUm7am/0sg==" }, "node_modules/@humanwhocodes/config-array": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz", - "integrity": "sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", + "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -1132,6 +884,29 @@ "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/gitignore-to-minimatch": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", + "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -1139,28 +914,25 @@ "dev": true }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", "dev": true, - "peer": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true, - "peer": true + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, - "peer": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -1372,511 +1144,174 @@ "dependencies": { "@material/feature-targeting": "14.0.0-canary.261f2db59.0", "@material/theme": "14.0.0-canary.261f2db59.0", - "tslib": "^2.1.0" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@open-wc/chai-dom-equals": { - "version": "0.12.36", - "resolved": "https://registry.npmjs.org/@open-wc/chai-dom-equals/-/chai-dom-equals-0.12.36.tgz", - "integrity": "sha512-Gt1fa37h4rtWPQGETSU4n1L678NmMi9KwHM1sH+JCGcz45rs8DBPx7MUVeGZ+HxRlbEI5t9LU2RGGv6xT2OlyA==", - "dev": true, - "dependencies": { - "@open-wc/semantic-dom-diff": "^0.13.16", - "@types/chai": "^4.1.7" - } - }, - "node_modules/@open-wc/chai-dom-equals/node_modules/@open-wc/semantic-dom-diff": { - "version": "0.13.21", - "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.13.21.tgz", - "integrity": "sha512-BONpjHcGX2zFa9mfnwBCLEmlDsOHzT+j6Qt1yfK3MzFXFtAykfzFjAgaxPetu0YbBlCfXuMlfxI4vlRGCGMvFg==", - "dev": true - }, - "node_modules/@open-wc/dedupe-mixin": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@open-wc/dedupe-mixin/-/dedupe-mixin-1.3.0.tgz", - "integrity": "sha512-UfdK1MPnR6T7f3svzzYBfu3qBkkZ/KsPhcpc3JYhsUY4hbpwNF9wEQtD4Z+/mRqMTJrKg++YSxIxE0FBhY3RIw==" - }, - "node_modules/@open-wc/eslint-config": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@open-wc/eslint-config/-/eslint-config-7.0.0.tgz", - "integrity": "sha512-iuWgs5XSPqb9zhdHIeKDSzepnjRyhoYSoS6RI+vyLMfVFRxZoqt0Yv4Q8xJ8yByXbJyakmvpukTyEKbcuIQ7Uw==", - "dev": true, - "dependencies": { - "eslint": "^7.6.0", - "eslint-config-airbnb-base": "^14.0.0", - "eslint-plugin-html": "^6.0.0", - "eslint-plugin-import": "^2.18.2", - "eslint-plugin-lit": "^1.2.0", - "eslint-plugin-lit-a11y": "^2.1.0", - "eslint-plugin-no-only-tests": "^2.4.0", - "eslint-plugin-wc": "^1.2.0" - }, - "peerDependencies": { - "@babel/eslint-plugin": "^7.6.0", - "eslint-plugin-html": "^6.0.0", - "eslint-plugin-import": "^2.18.2", - "eslint-plugin-lit": "^1.3.0", - "eslint-plugin-lit-a11y": "^2.1.0", - "eslint-plugin-no-only-tests": "^2.4.0", - "eslint-plugin-wc": "^1.2.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.10.4" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/@eslint/eslintrc": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", - "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", - "dev": true, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.1.1", - "espree": "^7.3.0", - "globals": "^13.9.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/@humanwhocodes/config-array": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", - "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", - "dev": true, - "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/@open-wc/eslint-config/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/eslint": { - "version": "7.32.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", - "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", - "dev": true, - "dependencies": { - "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.3", - "@humanwhocodes/config-array": "^0.5.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^2.0.0", - "espree": "^7.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.1.2", - "globals": "^13.6.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^6.0.9", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/eslint-config-airbnb-base": { - "version": "14.2.1", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz", - "integrity": "sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==", - "dev": true, - "dependencies": { - "confusing-browser-globals": "^1.0.10", - "object.assign": "^4.1.2", - "object.entries": "^1.1.2" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", - "eslint-plugin-import": "^2.22.1" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/espree": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", - "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", - "dev": true, - "dependencies": { - "acorn": "^7.4.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^1.3.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@open-wc/eslint-config/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" + "tslib": "^2.1.0" } }, - "node_modules/@open-wc/eslint-config/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, "engines": { - "node": ">= 4" + "node": ">= 8" } }, - "node_modules/@open-wc/eslint-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" + "engines": { + "node": ">= 8" } }, - "node_modules/@open-wc/eslint-config/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" }, "engines": { - "node": ">=10" + "node": ">= 8" } }, - "node_modules/@open-wc/eslint-config/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/@open-wc/chai-dom-equals": { + "version": "0.12.36", + "resolved": "https://registry.npmjs.org/@open-wc/chai-dom-equals/-/chai-dom-equals-0.12.36.tgz", + "integrity": "sha512-Gt1fa37h4rtWPQGETSU4n1L678NmMi9KwHM1sH+JCGcz45rs8DBPx7MUVeGZ+HxRlbEI5t9LU2RGGv6xT2OlyA==", "dev": true, "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" + "@open-wc/semantic-dom-diff": "^0.13.16", + "@types/chai": "^4.1.7" } }, - "node_modules/@open-wc/eslint-config/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "node_modules/@open-wc/chai-dom-equals/node_modules/@open-wc/semantic-dom-diff": { + "version": "0.13.21", + "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.13.21.tgz", + "integrity": "sha512-BONpjHcGX2zFa9mfnwBCLEmlDsOHzT+j6Qt1yfK3MzFXFtAykfzFjAgaxPetu0YbBlCfXuMlfxI4vlRGCGMvFg==", + "dev": true + }, + "node_modules/@open-wc/dedupe-mixin": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@open-wc/dedupe-mixin/-/dedupe-mixin-1.3.1.tgz", + "integrity": "sha512-ukowSvzpZQDUH0Y3znJTsY88HkiGk3Khc0WGpIPhap1xlerieYi27QBg6wx/nTurpWfU6XXXsx9ocxDYCdtw0Q==" + }, + "node_modules/@open-wc/eslint-config": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@open-wc/eslint-config/-/eslint-config-8.0.2.tgz", + "integrity": "sha512-ymOFXtsAXv1tkpW48touNZVGfV6X/ii/Ir+IZfFQi3KicJ/HF5wqK1x8Un4ZZzXravGqPqGfXCycKeyJf8s+pg==", "dev": true, - "engines": { - "node": ">=10" + "dependencies": { + "eslint-config-airbnb-base": "^15.0.0", + "eslint-plugin-html": "^6.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-lit": "^1.2.0", + "eslint-plugin-lit-a11y": "^2.2.2", + "eslint-plugin-no-only-tests": "^2.4.0", + "eslint-plugin-wc": "^1.2.0" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "peerDependencies": { + "eslint": ">=7.6.0", + "eslint-plugin-html": "^6.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-lit": "^1.3.0", + "eslint-plugin-lit-a11y": "^2.2.2", + "eslint-plugin-no-only-tests": "^2.4.0", + "eslint-plugin-wc": "^1.2.0" } }, "node_modules/@open-wc/scoped-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@open-wc/scoped-elements/-/scoped-elements-2.0.1.tgz", - "integrity": "sha512-JS6ozxUFwFX3+Er91v9yQzNIaFn7OnE0iESKTbFvkkKdNwvAPtp1fpckBKIvWk8Ae9ZcoI9DYZuT2DDbMPcadA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@open-wc/scoped-elements/-/scoped-elements-2.1.3.tgz", + "integrity": "sha512-WoQD5T8Me9obek+iyjgrAMw9wxZZg4ytIteIN1i9LXW2KohezUp0LTOlWgBajWJo0/bpjUKiODX73cMYL2i3hw==", "dev": true, "dependencies": { "@lit/reactive-element": "^1.0.0", - "@open-wc/dedupe-mixin": "^1.3.0", - "@webcomponents/scoped-custom-element-registry": "^0.0.3" + "@open-wc/dedupe-mixin": "^1.3.0" } }, "node_modules/@open-wc/scoped-elements/node_modules/@lit/reactive-element": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.3.1.tgz", - "integrity": "sha512-nOJARIr3pReqK3hfFCSW2Zg/kFcFsSAlIE7z4a0C9D2dPrgD/YSn3ZP2ET/rxKB65SXyG7jJbkynBRm+tGlacw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.4.1.tgz", + "integrity": "sha512-qDv4851VFSaBWzpS02cXHclo40jsbAjRXnebNXpm0uVg32kCneZPo9RYVQtrTNICtZ+1wAYHu1ZtxWSWMbKrBw==", "dev": true }, "node_modules/@open-wc/semantic-dom-diff": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.19.5.tgz", - "integrity": "sha512-Wi0Fuj3dzqlWClU0y+J4k/nqTcH0uwgOWxZXPyeyG3DdvuyyjgiT4L4I/s6iVShWQvvEsyXnj7yVvixAo3CZvg==", + "version": "0.19.7", + "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.19.7.tgz", + "integrity": "sha512-ahwHb7arQXXnkIGCrOsM895FJQrU47VWZryCsSSzl5nB3tJKcJ8yjzQ3D/yqZn6v8atqOz61vaY05aNsqoz3oA==", "dev": true, "dependencies": { - "@types/chai": "^4.2.11", - "@web/test-runner-commands": "^0.5.7" + "@types/chai": "^4.3.1", + "@web/test-runner-commands": "^0.6.1" } }, "node_modules/@open-wc/testing": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@open-wc/testing/-/testing-3.1.2.tgz", - "integrity": "sha512-2KjEszLItrIEZwCLFjWOSy4rnLzLOpgckrKfZjNA39PpFR3xD9bqYU30TTnLRHBk2B/0ZUbHglyca3iwcF964w==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/@open-wc/testing/-/testing-3.1.6.tgz", + "integrity": "sha512-MIf9cBtac4/UBE5a+R5cXiRhOGfzetsV+ZPFc188AfkPDPbmffHqjrRoCyk4B/qS6fLEulSBMLSaQ+6ze971gQ==", "dev": true, "dependencies": { - "@esm-bundle/chai": "^4.3.4", + "@esm-bundle/chai": "^4.3.4-fix.0", "@open-wc/chai-dom-equals": "^0.12.36", - "@open-wc/semantic-dom-diff": "^0.19.5", + "@open-wc/semantic-dom-diff": "^0.19.7", "@open-wc/testing-helpers": "^2.1.2", "@types/chai": "^4.2.11", - "@types/chai-dom": "^0.0.9", + "@types/chai-dom": "^0.0.12", "@types/sinon-chai": "^3.2.3", "chai-a11y-axe": "^1.3.2" } }, "node_modules/@open-wc/testing-helpers": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@open-wc/testing-helpers/-/testing-helpers-2.1.2.tgz", - "integrity": "sha512-NEdsV47DnOWaw3Wpp85p4qZ6bdubtGPdlTiblk8vSf2HJ2sR4b3ckyRWzsj/k+pcxrDGt8z0Awz71p+048Rrfg==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@open-wc/testing-helpers/-/testing-helpers-2.1.3.tgz", + "integrity": "sha512-hQujGaWncmWLx/974jq5yf2jydBNNTwnkISw2wLGiYgX34+3R6/ns301Oi9S3Il96Kzd8B7avdExp/gDgqcF5w==", "dev": true, "dependencies": { - "@open-wc/scoped-elements": "^2.0.1", + "@open-wc/scoped-elements": "^2.1.3", "lit": "^2.0.0", "lit-html": "^2.0.0" } }, "node_modules/@open-wc/testing-helpers/node_modules/lit-html": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.2.1.tgz", - "integrity": "sha512-AiJ/Rs0awjICs2FioTnHSh+Np5dhYSkyRczKy3wKjp8qjLhr1Ov+GiHrUQNdX8ou1LMuznpIME990AZsa/tR8g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.3.1.tgz", + "integrity": "sha512-FyKH6LTW6aBdkfNhNSHyZTnLgJSTe5hMk7HFtc/+DcN1w74C215q8B+Cfxc2OuIEpBNcEKxgF64qL8as30FDHA==", "dev": true, "dependencies": { "@types/trusted-types": "^2.0.2" } }, "node_modules/@pawel-up/data-mock": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@pawel-up/data-mock/-/data-mock-0.1.7.tgz", - "integrity": "sha512-1sCVyyiJvN3bAjr5ZPWs4iALchm6v1hZfmowenjabduMVxvx+dAEkeowSyL07F+wWtnFTLvRNvf7DiK6OuwzVA==" + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@pawel-up/data-mock/-/data-mock-0.3.2.tgz", + "integrity": "sha512-OtnZGTpINoY75crmQiJ4jlokxAGSPx+1fLK7vWMizSG/1Vbtau17x6vfOt6GtTjw7tJ4Bkbj11bmjYumLT0r6w==", + "dependencies": { + "@types/har-format": "^1.2.7" + } }, "node_modules/@pawel-up/html.md": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@pawel-up/html.md/-/html.md-0.1.0.tgz", "integrity": "sha512-xJjiWGJUOaTZd9W5KgFfrwnjQTDT46lHs3i4zFkBi+nCGk5M/WRDX1RGEfjRAIE5BKvGn/kXeKXbjefNnT6msQ==" }, - "node_modules/@polymer/font-roboto": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@polymer/font-roboto/-/font-roboto-3.0.2.tgz", - "integrity": "sha512-tx5TauYSmzsIvmSqepUPDYbs4/Ejz2XbZ1IkD7JEGqkdNUJlh+9KU85G56Tfdk/xjEZ8zorFfN09OSwiMrIQWA==", - "dev": true - }, "node_modules/@rollup/plugin-node-resolve": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", - "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz", + "integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==", "dev": true, "dependencies": { "@rollup/pluginutils": "^3.1.0", "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", "deepmerge": "^4.2.2", + "is-builtin-module": "^3.1.0", "is-module": "^1.0.0", "resolve": "^1.19.0" }, @@ -1884,7 +1319,7 @@ "node": ">= 10.0.0" }, "peerDependencies": { - "rollup": "^1.20.0||^2.0.0" + "rollup": "^2.42.0" } }, "node_modules/@rollup/pluginutils": { @@ -1914,9 +1349,9 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.1.tgz", - "integrity": "sha512-Wp5vwlZ0lOqpSYGKqr53INws9HLkt6JDc/pDZcPf7bchQnrXJMXPns8CXx0hFikMSGSWfvtvvpb2gtMVfkWagA==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz", + "integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==", "dev": true, "dependencies": { "@sinonjs/commons": "^1.7.0" @@ -1934,33 +1369,33 @@ } }, "node_modules/@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz", + "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, "node_modules/@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", "dev": true }, "node_modules/@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", "dev": true }, "node_modules/@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", "dev": true }, "node_modules/@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", "dev": true }, "node_modules/@types/accepts": { @@ -1989,15 +1424,15 @@ } }, "node_modules/@types/chai": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz", - "integrity": "sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", "dev": true }, "node_modules/@types/chai-dom": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@types/chai-dom/-/chai-dom-0.0.9.tgz", - "integrity": "sha512-jj4F2NJog2/GBYsyJ8+NvhnWUBbPY4MUAKLdPJE6+568rw12GGXvj0ycUuP5nndVrnJgozmJAoMTvxvjJATXWw==", + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@types/chai-dom/-/chai-dom-0.0.12.tgz", + "integrity": "sha512-4rE7sDw713cV61TYzQbMrPjC4DjNk3x4vk9nAVRNXcSD4p0/5lEEfm0OgoCz5eNuWUXNKA0YiKiH/JDTuKivkA==", "dev": true, "dependencies": { "@types/chai": "*" @@ -2029,9 +1464,9 @@ } }, "node_modules/@types/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-0mPF08jn9zYI0n0Q/Pnz7C4kThdSt+6LD4amsrYDDpgBfrVWa3TcCOxKX1zkGgYniGagRv8heN2cbh+CAn+uuQ==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.5.tgz", + "integrity": "sha512-v6LCdKfK6BwcqMo+wYW05rLS12S0ZO0Fl4w1h4aaZMD7bqT3gVUns6FvLJKGZHQmYn3SX55JWGpziwJRwVgutA==", "dev": true }, "node_modules/@types/convert-source-map": { @@ -2058,6 +1493,15 @@ "integrity": "sha512-epMsEE85fi4lfmJUH/89/iV/LI+F5CvNIvmgs5g5jYFPfhO2S/ae8WSsLOKWdwtoaZw9Q2IhJ4tQ5tFCcS/4HA==", "dev": true }, + "node_modules/@types/dompurify": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-2.3.4.tgz", + "integrity": "sha512-EXzDatIb5EspL2eb/xPGmaC8pePcTHrkDCONjeisusLFrVfl38Pjea/R0YJGu3k9ZQadSvMqW0WXPI2hEo2Ajg==", + "dev": true, + "dependencies": { + "@types/trusted-types": "*" + } + }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -2065,9 +1509,9 @@ "dev": true }, "node_modules/@types/express": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", - "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz", + "integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==", "dev": true, "dependencies": { "@types/body-parser": "*", @@ -2077,9 +1521,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.28", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz", - "integrity": "sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==", + "version": "4.17.31", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", + "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", "dev": true, "dependencies": { "@types/node": "*", @@ -2087,6 +1531,11 @@ "@types/range-parser": "*" } }, + "node_modules/@types/har-format": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.8.tgz", + "integrity": "sha512-OP6L9VuZNdskgNN3zFQQ54ceYD8OLq5IbqO4VK91ORLfOm7WdT/CiT/pHEBSQEqCInJ2y3O6iCm/zGtPElpgJQ==" + }, "node_modules/@types/http-assert": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.3.tgz", @@ -2123,10 +1572,16 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, "node_modules/@types/keygrip": { @@ -2136,9 +1591,9 @@ "dev": true }, "node_modules/@types/koa": { - "version": "2.13.4", - "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.13.4.tgz", - "integrity": "sha512-dfHYMfU+z/vKtQB7NUrthdAEiSvnLebvBjwHtfFmpZmB7em2N3WVQdHgnFq+xvyVgxW5jKDmjWfLD3lw4g4uTw==", + "version": "2.13.5", + "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.13.5.tgz", + "integrity": "sha512-HSUOdzKz3by4fnqagwthW/1w/yJspTgppyyalPVbgZf8jQWvdIXcVW5h2DGtw4zYntOaeRGx49r1hxoPWrD4aA==", "dev": true, "dependencies": { "@types/accepts": "*", @@ -2161,9 +1616,9 @@ } }, "node_modules/@types/mime": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", - "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", + "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==", "dev": true }, "node_modules/@types/minimist": { @@ -2179,9 +1634,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "version": "18.7.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.18.tgz", + "integrity": "sha512-m+6nTEOadJZuTPkKR/SYK3A2d7FZrgElol9UP1Kae90VVU4a6mxnPuLiIW1m4Cq4gZ/nWb9GrdVXJCoCazDAbg==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -2224,19 +1679,19 @@ } }, "node_modules/@types/serve-static": { - "version": "1.13.10", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", - "integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", "dev": true, "dependencies": { - "@types/mime": "^1", + "@types/mime": "*", "@types/node": "*" } }, "node_modules/@types/sinon": { - "version": "10.0.11", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", - "integrity": "sha512-dmZsHlBsKUtBpHriNjlK0ndlvEh8dcb9uV9Afsbt89QIyydpC7NcR+nWlAhASfy3GHnxTl4FX/aKE7XZUt/B4g==", + "version": "10.0.13", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.13.tgz", + "integrity": "sha512-UVjDqJblVNQYvVNUsj0PuYYw0ELRmgt1Nt5Vk0pT5f16ROGfcKJY8o1HVuMOJOpD727RrGB9EGvoaTQE5tgxZQ==", "dev": true, "dependencies": { "@types/sinonjs__fake-timers": "*" @@ -2252,34 +1707,257 @@ "@types/sinon": "*" } }, - "node_modules/@types/sinonjs__fake-timers": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.1.tgz", - "integrity": "sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==", - "dev": true - }, - "node_modules/@types/trusted-types": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz", - "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==" - }, - "node_modules/@types/ws": { - "version": "7.4.7", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", - "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "node_modules/@types/sinonjs__fake-timers": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz", + "integrity": "sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA==", + "dev": true + }, + "node_modules/@types/trusted-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz", + "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==", + "dev": true, + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.38.0.tgz", + "integrity": "sha512-GgHi/GNuUbTOeoJiEANi0oI6fF3gBQc3bGFYj40nnAPCbhrtEDf2rjBmefFadweBmO1Du1YovHeDP2h5JLhtTQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/type-utils": "5.38.0", + "@typescript-eslint/utils": "5.38.0", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.38.0.tgz", + "integrity": "sha512-/F63giJGLDr0ms1Cr8utDAxP2SPiglaD6V+pCOcG35P2jCqdfR7uuEhz1GIC3oy4hkUF8xA1XSXmd9hOh/a5EA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/typescript-estree": "5.38.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.38.0.tgz", + "integrity": "sha512-ByhHIuNyKD9giwkkLqzezZ9y5bALW8VNY6xXcP+VxoH4JBDKjU5WNnsiD4HJdglHECdV+lyaxhvQjTUbRboiTA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/visitor-keys": "5.38.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.38.0.tgz", + "integrity": "sha512-iZq5USgybUcj/lfnbuelJ0j3K9dbs1I3RICAJY9NZZpDgBYXmuUlYQGzftpQA9wC8cKgtS6DASTvF3HrXwwozA==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "5.38.0", + "@typescript-eslint/utils": "5.38.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.38.0.tgz", + "integrity": "sha512-HHu4yMjJ7i3Cb+8NUuRCdOGu2VMkfmKyIJsOr9PfkBVYLYrtMCK/Ap50Rpov+iKpxDTfnqvDbuPLgBE5FwUNfA==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.38.0.tgz", + "integrity": "sha512-6P0RuphkR+UuV7Avv7MU3hFoWaGcrgOdi8eTe1NwhMp2/GjUJoODBTRWzlHpZh6lFOaPmSvgxGlROa0Sg5Zbyg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/visitor-keys": "5.38.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.38.0.tgz", + "integrity": "sha512-6sdeYaBgk9Fh7N2unEXGz+D+som2QCQGPAf1SxrkEr+Z32gMreQ0rparXTNGRRfYUWk/JzbGdcM8NSSd6oqnTA==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/typescript-estree": "5.38.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.38.0.tgz", + "integrity": "sha512-MxnrdIyArnTi+XyFLR+kt/uNAcdOnmT+879os7qDRI+EYySR4crXJq9BXPfRzzLGq0wgxkwidrCJ9WCAoacm1w==", "dev": true, "dependencies": { - "@types/node": "*" + "@typescript-eslint/types": "5.38.0", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@types/yauzl": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz", - "integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==", + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, - "optional": true, - "dependencies": { - "@types/node": "*" + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@web/browser-logs": { @@ -2307,9 +1985,9 @@ } }, "node_modules/@web/config-loader/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2322,16 +2000,16 @@ } }, "node_modules/@web/dev-server": { - "version": "0.1.30", - "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.1.30.tgz", - "integrity": "sha512-nUKR+lq06gaCvH6vKmfhPe/Kka1Xp7yN1FN5NEx+Yk4+9CyxZ3UJt2eHXedrcz+XCafxExW114ElEDgCahJowg==", + "version": "0.1.34", + "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.1.34.tgz", + "integrity": "sha512-+te6iwxAQign1KyhHpkR/a3+5qw/Obg/XWCES2So6G5LcZ86zIKXbUpWAJuNOqiBV6eGwqEB1AozKr2Jj7gj/Q==", "dev": true, "dependencies": { "@babel/code-frame": "^7.12.11", "@types/command-line-args": "^5.0.0", "@web/config-loader": "^0.1.3", - "@web/dev-server-core": "^0.3.17", - "@web/dev-server-rollup": "^0.3.13", + "@web/dev-server-core": "^0.3.19", + "@web/dev-server-rollup": "^0.3.19", "camelcase": "^6.2.0", "command-line-args": "^5.1.1", "command-line-usage": "^6.1.1", @@ -2351,9 +2029,9 @@ } }, "node_modules/@web/dev-server-core": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.3.17.tgz", - "integrity": "sha512-vN1dwQ8yDHGiAvCeUo9xFfjo+pFl8TW+pON7k9kfhbegrrB8CKhJDUxmHbZsyQUmjf/iX57/LhuWj1xGhRL8AA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.3.19.tgz", + "integrity": "sha512-Q/Xt4RMVebLWvALofz1C0KvP8qHbzU1EmdIA2Y1WMPJwiFJFhPxdr75p9YxK32P2t0hGs6aqqS5zE0HW9wYzYA==", "dev": true, "dependencies": { "@types/koa": "^2.11.6", @@ -2361,7 +2039,7 @@ "@web/parse5-utils": "^1.2.0", "chokidar": "^3.4.3", "clone": "^2.1.2", - "es-module-lexer": "^0.9.0", + "es-module-lexer": "^1.0.0", "get-stream": "^6.0.0", "is-stream": "^2.0.0", "isbinaryfile": "^4.0.6", @@ -2380,16 +2058,16 @@ } }, "node_modules/@web/dev-server-rollup": { - "version": "0.3.15", - "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.3.15.tgz", - "integrity": "sha512-hhxvBmNIY19vXeocYB1IBOuhpVpy1L7jbwBarmvC0QJKZsgkxssNTzXJ8iga70c2+H0c/rBz1xUaKuAcov0uOA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.3.19.tgz", + "integrity": "sha512-IwiwI+fyX0YuvAOldStlYJ+Zm/JfSCk9OSGIs7+fWbOYysEHwkEVvBwoPowaclSZA44Tobvqt+6ej9udbbZ/WQ==", "dev": true, "dependencies": { - "@rollup/plugin-node-resolve": "^11.0.1", - "@web/dev-server-core": "^0.3.16", + "@rollup/plugin-node-resolve": "^13.0.4", + "@web/dev-server-core": "^0.3.19", "nanocolors": "^0.2.1", "parse5": "^6.0.1", - "rollup": "^2.66.1", + "rollup": "^2.67.0", "whatwg-url": "^11.0.0" }, "engines": { @@ -2410,17 +2088,17 @@ } }, "node_modules/@web/test-runner": { - "version": "0.13.27", - "resolved": "https://registry.npmjs.org/@web/test-runner/-/test-runner-0.13.27.tgz", - "integrity": "sha512-yVhXK9sPJE2VQs1/KPTIeQvUxh+02OZkn+tgcr0+W8ovvrFD4ucF2X26cpeOTuD+Y67ERUi/EopIze3aelw6sg==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@web/test-runner/-/test-runner-0.14.0.tgz", + "integrity": "sha512-9xVKnsviCqXL/xi48l0GpDDfvdczZsKHfEhmZglGMTL+I5viDMAj0GGe7fD9ygJ6UT2+056a3RzyIW5x9lZTDQ==", "dev": true, "dependencies": { "@web/browser-logs": "^0.2.2", "@web/config-loader": "^0.1.3", - "@web/dev-server": "^0.1.24", + "@web/dev-server": "^0.1.33", "@web/test-runner-chrome": "^0.10.7", - "@web/test-runner-commands": "^0.6.0", - "@web/test-runner-core": "^0.10.22", + "@web/test-runner-commands": "^0.6.3", + "@web/test-runner-core": "^0.10.27", "@web/test-runner-mocha": "^0.7.5", "camelcase": "^6.2.0", "command-line-args": "^5.1.1", @@ -2456,12 +2134,12 @@ } }, "node_modules/@web/test-runner-commands": { - "version": "0.5.13", - "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.5.13.tgz", - "integrity": "sha512-FXnpUU89ALbRlh9mgBd7CbSn5uzNtr8gvnQZPOvGLDAJ7twGvZdUJEAisPygYx2BLPSFl3/Mre8pH8zshJb8UQ==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.6.5.tgz", + "integrity": "sha512-W+wLg10jEAJY9N6tNWqG1daKmAzxGmTbO/H9fFfcgOgdxdn+hHiR4r2/x1iylKbFLujHUQlnjNQeu2d6eDPFqg==", "dev": true, "dependencies": { - "@web/test-runner-core": "^0.10.20", + "@web/test-runner-core": "^0.10.27", "mkdirp": "^1.0.4" }, "engines": { @@ -2469,9 +2147,9 @@ } }, "node_modules/@web/test-runner-core": { - "version": "0.10.25", - "resolved": "https://registry.npmjs.org/@web/test-runner-core/-/test-runner-core-0.10.25.tgz", - "integrity": "sha512-gH8VXyZbwf+sqPiH4cnXYf86SqwBLtou+0LFFCLaDQRbMlrfi5byAISt39fNX2ejd46bF1cZn6DK+mzb/Xjccw==", + "version": "0.10.27", + "resolved": "https://registry.npmjs.org/@web/test-runner-core/-/test-runner-core-0.10.27.tgz", + "integrity": "sha512-ClV/hSxs4wDm/ANFfQOdRRFb/c0sYywC1QfUXG/nS4vTp3nnt7x7mjydtMGGLmvK9f6Zkubkc1aa+7ryfmVwNA==", "dev": true, "dependencies": { "@babel/code-frame": "^7.12.11", @@ -2482,7 +2160,7 @@ "@types/istanbul-lib-coverage": "^2.0.3", "@types/istanbul-reports": "^3.0.0", "@web/browser-logs": "^0.2.1", - "@web/dev-server-core": "^0.3.16", + "@web/dev-server-core": "^0.3.18", "chokidar": "^3.4.3", "cli-cursor": "^3.1.0", "co-body": "^6.1.0", @@ -2505,19 +2183,10 @@ "node": ">=12.0.0" } }, - "node_modules/@web/test-runner-core/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, "node_modules/@web/test-runner-coverage-v8": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/@web/test-runner-coverage-v8/-/test-runner-coverage-v8-0.4.8.tgz", - "integrity": "sha512-Ib0AscR8Xf9E/V7rf3XOVQTe4vKIbwSTupxV1xGgzj3x4RKUuMUg9FLz9EigZ5iN0mOzZKDllyRS523hbdhDtA==", + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/@web/test-runner-coverage-v8/-/test-runner-coverage-v8-0.4.9.tgz", + "integrity": "sha512-y9LWL4uY25+fKQTljwr0XTYjeWIwU4h8eYidVuLoW3n1CdFkaddv+smrGzzF5j8XY+Mp6TmV9NdxjvMWqVkDdw==", "dev": true, "dependencies": { "@web/test-runner-core": "^0.10.20", @@ -2543,47 +2212,19 @@ } }, "node_modules/@web/test-runner-playwright": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/@web/test-runner-playwright/-/test-runner-playwright-0.8.8.tgz", - "integrity": "sha512-bhb0QVldfDoPJqOj5mm1hpE6FReyddc/iIuAkVf/kbJvgggTCT2bWGxUvXJlGzf+4epmDhU+hSTfEoLL9R2vGw==", + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@web/test-runner-playwright/-/test-runner-playwright-0.8.10.tgz", + "integrity": "sha512-DEnPihsxjJAPU/UPe3Wb6GVES4xICUrue0UVVxJL651m4zREuUHwSFm4S+cVq78qYcro3WuvCAnucdVB8bUCNw==", "dev": true, "dependencies": { "@web/test-runner-core": "^0.10.20", "@web/test-runner-coverage-v8": "^0.4.8", - "playwright": "^1.14.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@web/test-runner/node_modules/@web/test-runner-commands": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.6.1.tgz", - "integrity": "sha512-P4aQqp0duumeGdGxQ8TwLnplkrXzpLqb47eSEEqBRS//C1H7s6VskaqEng+k0dbk+cSpEa4RuZGY/G5k8aTjTw==", - "dev": true, - "dependencies": { - "@web/test-runner-core": "^0.10.20", - "mkdirp": "^1.0.4" + "playwright": "^1.22.2" }, "engines": { "node": ">=12.0.0" } }, - "node_modules/@web/test-runner/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@webcomponents/scoped-custom-element-registry": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@webcomponents/scoped-custom-element-registry/-/scoped-custom-element-registry-0.0.3.tgz", - "integrity": "sha512-lpSzgDCGbM99dytb3+J3Suo4+Bk1E13MPnWB42JK8GwxSAxFz+tC7TTv2hhDSIE2IirGNKNKCf3m08ecu6eAsQ==", - "dev": true - }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -2598,9 +2239,9 @@ } }, "node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -2669,11 +2310,12 @@ } }, "node_modules/amf-client-js": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/amf-client-js/-/amf-client-js-5.0.5.tgz", - "integrity": "sha512-WLCfA2DtN5RsdnDSxRyH5R2VaDagR+Foe6Na42P57FdLUN6UXJM4xjazcK/FCdHqI23RZmOXlceArIHFZt8HOA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/amf-client-js/-/amf-client-js-5.1.0.tgz", + "integrity": "sha512-3/6jyw3i4IlPlPZJX5pEXPzya/TFG2JklVo065hUCHKOQB2u9DTtBCbZyS6HufK30P2ofxyhKEBJbqSULn2TPw==", "dev": true, "dependencies": { + "@aml-org/amf-antlr-parsers": "0.5.17", "ajv": "6.12.6" }, "bin": { @@ -2690,10 +2332,12 @@ } }, "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=6" } @@ -2784,18 +2428,18 @@ "node_modules/array-ify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==", "dev": true }, "node_modules/array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", "get-intrinsic": "^1.1.1", "is-string": "^1.0.7" }, @@ -2816,14 +2460,15 @@ } }, "node_modules/array.prototype.flat": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz", - "integrity": "sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", "dev": true, "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.19.0" + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" }, "engines": { "node": ">= 0.4" @@ -2835,7 +2480,7 @@ "node_modules/arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -2851,18 +2496,18 @@ } }, "node_modules/async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "dependencies": { "lodash": "^4.17.14" } }, "node_modules/axe-core": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.1.tgz", - "integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.3.tgz", + "integrity": "sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w==", "dev": true, "engines": { "node": ">=4" @@ -2942,36 +2587,6 @@ "node": ">=8" } }, - "node_modules/browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "peer": true, - "dependencies": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -2999,16 +2614,16 @@ "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", "dev": true, "engines": { "node": "*" } }, "node_modules/builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true, "engines": { "node": ">=6" @@ -3099,17 +2714,6 @@ "node": ">=6" } }, - "node_modules/caniuse-lite": { - "version": "1.0.30001317", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz", - "integrity": "sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ==", - "dev": true, - "peer": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } - }, "node_modules/chai-a11y-axe": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/chai-a11y-axe/-/chai-a11y-axe-1.4.0.tgz", @@ -3167,9 +2771,9 @@ "dev": true }, "node_modules/chrome-launcher": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz", - "integrity": "sha512-ZQqX5kb9H0+jy1OqLnWampfocrtSZaGl7Ny3F9GRha85o4odbL8x55paUzh51UC7cEmZ5obp3H2Mm70uC2PpRA==", + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.1.tgz", + "integrity": "sha512-UugC8u59/w2AyX5sHLZUHoxBAiSiunUhZa3zZwMH6zPVis0C3dDKiRWyUGIo14tTbZHGVviWxv3PQWZ7taZ4fg==", "dev": true, "dependencies": { "@types/node": "*", @@ -3276,7 +2880,7 @@ "node_modules/clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", "dev": true, "engines": { "node": ">=0.8" @@ -3285,7 +2889,7 @@ "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true, "engines": { "iojs": ">= 1.0.0", @@ -3316,24 +2920,15 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, "node_modules/colorette": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", - "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, - "node_modules/colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true, - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/command-line-args": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.2.1.tgz", @@ -3350,14 +2945,14 @@ } }, "node_modules/command-line-usage": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.1.tgz", - "integrity": "sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.3.tgz", + "integrity": "sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==", "dev": true, "dependencies": { - "array-back": "^4.0.1", + "array-back": "^4.0.2", "chalk": "^2.4.2", - "table-layout": "^1.0.1", + "table-layout": "^1.0.2", "typical": "^5.2.0" }, "engines": { @@ -3383,12 +2978,12 @@ } }, "node_modules/commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz", + "integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==", "dev": true, "engines": { - "node": ">= 12" + "node": "^12.20.0 || >=14" } }, "node_modules/compare-func": { @@ -3404,9 +2999,121 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/concurrently": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-7.4.0.tgz", + "integrity": "sha512-M6AfrueDt/GEna/Vg9BqQ+93yuvzkSKmoTixnwEJkH0LlcGrRC2eCmjeG1tLLHIYfpYJABokqSGyMcXjm96AFA==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "date-fns": "^2.29.1", + "lodash": "^4.17.21", + "rxjs": "^7.0.0", + "shell-quote": "^1.7.3", + "spawn-command": "^0.0.2-1", + "supports-color": "^8.1.0", + "tree-kill": "^1.2.2", + "yargs": "^17.3.1" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/concurrently/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/concurrently/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/confusing-browser-globals": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", @@ -3468,9 +3175,9 @@ } }, "node_modules/conventional-changelog-conventionalcommits": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.3.tgz", - "integrity": "sha512-LTTQV4fwOM4oLPad317V/QNQ1FY4Hju5qeBIM1uTHbrnCE+Eg4CdRZ3gO2pUeR+tzWdp80M2j3qFFEDWVqOV4g==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", + "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", "dev": true, "dependencies": { "compare-func": "^2.0.0", @@ -3524,9 +3231,9 @@ } }, "node_modules/core-js-pure": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz", - "integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==", + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.25.2.tgz", + "integrity": "sha512-ItD7YpW1cUB4jaqFLZXe1AXkyqIxz6GqPnsDV4uF4hVcWh/WAGIqSqw5p0/WdsILM0Xht9s3Koyw05R3K6RtiA==", "dev": true, "hasInstallScript": true, "funding": { @@ -3551,14 +3258,10 @@ } }, "node_modules/cosmiconfig-typescript-loader": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-1.0.6.tgz", - "integrity": "sha512-2nEotziYJWtNtoTjKbchj9QrdTT6DBxCvqjNKoDKARw+e2yZmTQCa07uRrykLIZuvSgp69YXLH89UHc0WhdMfQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-4.1.0.tgz", + "integrity": "sha512-HbWIuR5O+XO5Oj9SZ5bzgrD4nN+rfhrm2PMb0FVx+t+XIvC45n8F0oTNnztXtspWGw0i2IzHaUWFD5LzV1JB4A==", "dev": true, - "dependencies": { - "cosmiconfig": "^7", - "ts-node": "^10.6.0" - }, "engines": { "node": ">=12", "npm": ">=6" @@ -3566,6 +3269,7 @@ "peerDependencies": { "@types/node": "*", "cosmiconfig": ">=7", + "ts-node": ">=10", "typescript": ">=3" } }, @@ -3607,6 +3311,19 @@ "node": ">=8" } }, + "node_modules/date-fns": { + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", + "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", + "dev": true, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/debounce": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", @@ -3614,9 +3331,9 @@ "dev": true }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -3633,7 +3350,7 @@ "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3642,7 +3359,7 @@ "node_modules/decamelize-keys": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "integrity": "sha512-ocLWuYzRPoS9bfiSdDd3cxvrzovVMZnRDVEzAs+hWIVXGDbHxWMECij2OBuyB/An0FFW/nLuq6Kv1i/YC5Qfzg==", "dev": true, "dependencies": { "decamelize": "^1.1.0", @@ -3655,7 +3372,7 @@ "node_modules/decamelize-keys/node_modules/map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3664,7 +3381,7 @@ "node_modules/deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", "dev": true }, "node_modules/deep-extend": { @@ -3701,21 +3418,25 @@ } }, "node_modules/define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, "dependencies": { - "object-keys": "^1.0.12" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", "dev": true }, "node_modules/depd": { @@ -3737,9 +3458,9 @@ } }, "node_modules/destroy": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.1.1.tgz", - "integrity": "sha512-jxwFW+yrVOLdwqIWvowFOM8UPdhZnvOF6mhXQQLXMxBDLtv2JVJlVJPEwkDv9prqscEtGtmnxuuI6pQKStK1vA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", "dev": true, "engines": { "node": ">= 0.8", @@ -3747,15 +3468,15 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.969999", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.969999.tgz", - "integrity": "sha512-6GfzuDWU0OFAuOvBokXpXPLxjOJ5DZ157Ue3sGQQM3LgAamb8m0R0ruSfN0DDu+XG5XJgT50i6zZ/0o8RglreQ==", + "version": "0.0.981744", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", + "integrity": "sha512-0cuGS8+jhR67Fy7qG3i3Pc7Aw494sb9yG9QgpG97SFVWwolgYjlhJg7n+UaHxOQT30d1TYu/EYe9k01ivLErIg==", "dev": true }, "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true, "engines": { "node": ">=0.3.1" @@ -3786,9 +3507,9 @@ } }, "node_modules/dom-serializer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", - "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", "dev": true, "dependencies": { "domelementtype": "^2.0.1", @@ -3822,7 +3543,7 @@ "node_modules/dom5/node_modules/@types/parse5": { "version": "2.2.34", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-2.2.34.tgz", - "integrity": "sha1-44cKEOgnNacg9i1x3NGDunjvOp0=", + "integrity": "sha512-p3qOvaRsRpFyEmaS36RtLzpdxZZnmxGuT1GMgzkTtTJVFuEw7KFjGK83MFODpJExgX1bEzy9r0NYjMC3IMfi7w==", "dev": true, "dependencies": { "@types/node": "*" @@ -3835,9 +3556,9 @@ "dev": true }, "node_modules/domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true, "funding": [ { @@ -3847,9 +3568,9 @@ ] }, "node_modules/domhandler": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.0.tgz", - "integrity": "sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", "dev": true, "dependencies": { "domelementtype": "^2.2.0" @@ -3862,9 +3583,9 @@ } }, "node_modules/dompurify": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.6.tgz", - "integrity": "sha512-OFP2u/3T1R5CEgWCEONuJ1a5+MFKnOYpkywpUSxv/dj1LeBT1erK+JwM7zK0ROy2BRhqVCf0LRw/kHqKuMkVGg==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.4.0.tgz", + "integrity": "sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA==" }, "node_modules/domutils": { "version": "2.8.0", @@ -3901,16 +3622,9 @@ "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "dev": true }, - "node_modules/electron-to-chromium": { - "version": "1.4.85", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz", - "integrity": "sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg==", - "dev": true, - "peer": true - }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -3920,7 +3634,7 @@ "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "dev": true, "engines": { "node": ">= 0.8" @@ -3940,6 +3654,8 @@ "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "ansi-colors": "^4.1.1" }, @@ -3975,31 +3691,34 @@ "dev": true }, "node_modules/es-abstract": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", - "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.2.tgz", + "integrity": "sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==", "dev": true, "dependencies": { "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.2", "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.2", + "has-property-descriptors": "^1.0.0", + "has-symbols": "^1.0.3", "internal-slot": "^1.0.3", "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.1", + "is-negative-zero": "^2.0.2", "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.1", + "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", - "is-weakref": "^1.0.1", - "object-inspect": "^1.11.0", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.2", "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -4009,11 +3728,20 @@ } }, "node_modules/es-module-lexer": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", - "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.0.3.tgz", + "integrity": "sha512-iC67eXHToclrlVhQfpRawDiF8D8sQxNxmbqw5oebegOaJkyx/w9C/k57/5e6yJR2zIByRt9OXdqX50DV2t6ZKw==", "dev": true }, + "node_modules/es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + } + }, "node_modules/es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -4043,26 +3771,28 @@ "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "dev": true }, "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, "engines": { "node": ">=0.8.0" } }, "node_modules/eslint": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", - "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.1.tgz", + "integrity": "sha512-w7C1IXCc6fNqjpuYd0yPlcTKKmHlHHktRkzmBPZ+7cvNBQuiNjx0xaMTjAJGCafJhQkrFJooREv0CtrVzmHwqg==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.2.1", - "@humanwhocodes/config-array": "^0.9.2", + "@eslint/eslintrc": "^1.3.2", + "@humanwhocodes/config-array": "^0.10.4", + "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@humanwhocodes/module-importer": "^1.0.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -4072,30 +3802,32 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.4.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", + "find-up": "^5.0.0", "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "globals": "^13.15.0", + "globby": "^11.1.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" @@ -4107,6 +3839,25 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-airbnb-base": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", + "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", + "dev": true, + "dependencies": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.5", + "semver": "^6.3.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "peerDependencies": { + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.2" + } + }, "node_modules/eslint-config-prettier": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", @@ -4126,32 +3877,10 @@ "dev": true, "dependencies": { "debug": "^3.2.7", - "resolve": "^1.20.0" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", - "dev": true, - "dependencies": { - "debug": "^3.2.7", - "find-up": "^2.1.0" - }, - "engines": { - "node": ">=4" + "resolve": "^1.20.0" } }, - "node_modules/eslint-module-utils/node_modules/debug": { + "node_modules/eslint-import-resolver-node/node_modules/debug": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", @@ -4160,62 +3889,30 @@ "ms": "^2.1.1" } }, - "node_modules/eslint-module-utils/node_modules/find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "dependencies": { - "locate-path": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "node_modules/eslint-module-utils": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", + "integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==", "dev": true, "dependencies": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "debug": "^3.2.7" }, "engines": { "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "dependencies": { - "p-try": "^1.0.0" }, - "engines": { - "node": ">=4" + "peerDependenciesMeta": { + "eslint": { + "optional": true + } } }, - "node_modules/eslint-module-utils/node_modules/p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "dependencies": { - "p-limit": "^1.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint-module-utils/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true, - "engines": { - "node": ">=4" + "ms": "^2.1.1" } }, "node_modules/eslint-plugin-html": { @@ -4228,9 +3925,9 @@ } }, "node_modules/eslint-plugin-import": { - "version": "2.25.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz", - "integrity": "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", "dev": true, "dependencies": { "array-includes": "^3.1.4", @@ -4238,14 +3935,14 @@ "debug": "^2.6.9", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.2", + "eslint-module-utils": "^2.7.3", "has": "^1.0.3", - "is-core-module": "^2.8.0", + "is-core-module": "^2.8.1", "is-glob": "^4.0.3", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "object.values": "^1.1.5", - "resolve": "^1.20.0", - "tsconfig-paths": "^3.12.0" + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" }, "engines": { "node": ">=4" @@ -4278,7 +3975,7 @@ "node_modules/eslint-plugin-import/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/eslint-plugin-lit": { @@ -4299,9 +3996,9 @@ } }, "node_modules/eslint-plugin-lit-a11y": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-lit-a11y/-/eslint-plugin-lit-a11y-2.2.0.tgz", - "integrity": "sha512-1Vy9mR7UGigPnOHj5qJMU3uEK+Qul7dQOg9I6YKEYrw3C3HUx1FS/FbICjZI+n/v+2qvvJhw+5Tghuld2QWUJw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-lit-a11y/-/eslint-plugin-lit-a11y-2.2.2.tgz", + "integrity": "sha512-9dJfnwPOOA6x7Ow/+GFoOt1hr4mSNrF6KBWQ2OFFAY/9aBYtyBX4fRbpxqS2y3ld66/bjWru2+LGWgNVr5GxzQ==", "dev": true, "dependencies": { "aria-query": "^4.2.2", @@ -4348,16 +4045,6 @@ "eslint": ">=5" } }, - "node_modules/eslint-rule-composer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", - "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", - "dev": true, - "peer": true, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/eslint-rule-extender": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/eslint-rule-extender/-/eslint-rule-extender-0.0.1.tgz", @@ -4516,9 +4203,9 @@ } }, "node_modules/eslint/node_modules/globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -4564,17 +4251,20 @@ } }, "node_modules/espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", + "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", "dev": true, "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/espree/node_modules/eslint-visitor-keys": { @@ -4586,19 +4276,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", @@ -4668,7 +4345,7 @@ "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "dev": true, "engines": { "node": ">= 0.6" @@ -4739,9 +4416,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -4763,7 +4440,7 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/fastq": { @@ -4778,7 +4455,7 @@ "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", "dev": true, "dependencies": { "pend": "~1.2.0" @@ -4850,15 +4527,15 @@ } }, "node_modules/flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "dev": true, "engines": { "node": ">= 0.6" @@ -4871,9 +4548,9 @@ "dev": true }, "node_modules/fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "dependencies": { "graceful-fs": "^4.2.0", @@ -4887,7 +4564,7 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { @@ -4910,20 +4587,31 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "node_modules/function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", "dev": true, - "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + }, "engines": { - "node": ">=6.9.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/get-caller-file": { @@ -4936,14 +4624,14 @@ } }, "node_modules/get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.3" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4997,15 +4685,15 @@ } }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -5031,7 +4719,7 @@ "node_modules/global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "integrity": "sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==", "dev": true, "dependencies": { "ini": "^1.3.4" @@ -5040,16 +4728,6 @@ "node": ">=4" } }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "peer": true, - "engines": { - "node": ">=4" - } - }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -5071,9 +4749,15 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, "node_modules/hard-rejection": { @@ -5098,9 +4782,9 @@ } }, "node_modules/has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -5109,12 +4793,24 @@ "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -5211,16 +4907,16 @@ "node_modules/http-errors/node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", "dev": true, "engines": { "node": ">= 0.6" } }, "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "dependencies": { "agent-base": "6", @@ -5240,15 +4936,15 @@ } }, "node_modules/husky": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", - "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true, "bin": { "husky": "lib/bin.js" }, "engines": { - "node": ">=12" + "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/typicode" @@ -5323,7 +5019,7 @@ "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "engines": { "node": ">=0.8.19" @@ -5341,7 +5037,7 @@ "node_modules/inflation": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.0.0.tgz", - "integrity": "sha1-i0F+R8KPklpFEz2RTKH9OJEH8w8=", + "integrity": "sha512-m3xv4hJYR2oXw4o4Y5l6P5P16WYmazYof+el6Al3f+YlggGj6qT9kImBAnzDelRALnP5d3h4jGBPKzYCizjZZw==", "dev": true, "engines": { "node": ">= 0.8.0" @@ -5350,7 +5046,7 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", @@ -5384,15 +5080,15 @@ } }, "node_modules/ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", "dev": true }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, "node_modules/is-bigint": { @@ -5435,10 +5131,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-builtin-module": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.6.tgz", + "integrity": "sha512-krO72EO2NptOGAX2KYyqbP9vYMlNAXdB53rq6f8LXY6RY7JdSR/3BD6wLUlPHSAesmY9vstNrjvqGaCiRK/91Q==", "dev": true, "engines": { "node": ">= 0.4" @@ -5448,9 +5159,9 @@ } }, "node_modules/is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -5492,7 +5203,7 @@ "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5540,7 +5251,7 @@ "node_modules/is-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", "dev": true }, "node_modules/is-negative-zero": { @@ -5565,9 +5276,9 @@ } }, "node_modules/is-number-object": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", - "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, "dependencies": { "has-tostringtag": "^1.0.0" @@ -5591,7 +5302,7 @@ "node_modules/is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5620,10 +5331,13 @@ } }, "node_modules/is-shared-array-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz", - "integrity": "sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5673,7 +5387,7 @@ "node_modules/is-text-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", + "integrity": "sha512-xFuJpne9oFz5qDaodwmmG08e3CawH/2ZV8Qqza1Ko7Sk8POWbkRdwIoAWVhqvq0XeUzANEhKo2n0IXUGBm7A/w==", "dev": true, "dependencies": { "text-extensions": "^1.0.0" @@ -5685,7 +5399,7 @@ "node_modules/is-valid-element-name": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-valid-element-name/-/is-valid-element-name-1.0.0.tgz", - "integrity": "sha1-Ju8/12zfHxItEFQG4y01sN4AWYE=", + "integrity": "sha512-GZITEJY2LkSjQfaIPBha7eyZv+ge0PhBR7KITeCCWvy7VBQrCUdFkvpI+HrAPQjVtVjy1LvlEkqQTHckoszruw==", "dev": true, "dependencies": { "is-potential-custom-element-name": "^1.0.0" @@ -5718,13 +5432,13 @@ "node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "node_modules/isbinaryfile": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.8.tgz", - "integrity": "sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", "dev": true, "engines": { "node": ">= 8.0.0" @@ -5736,7 +5450,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/istanbul-lib-coverage": { @@ -5784,9 +5498,9 @@ } }, "node_modules/istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", "dev": true, "dependencies": { "html-escaper": "^2.0.0", @@ -5796,18 +5510,18 @@ "node": ">=8" } }, - "node_modules/jpeg-js": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.3.tgz", - "integrity": "sha512-ru1HWKek8octvUHFHvE5ZzQ1yAsJmIvRdGWvSoKV52XKyuyYA437QWDttXT8eZXDSbuMpHlLzPDZUPd6idIz+Q==", - "dev": true - }, "node_modules/js-levenshtein-esm": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/js-levenshtein-esm/-/js-levenshtein-esm-1.2.0.tgz", "integrity": "sha512-fzreKVq1eD7eGcQr7MtRpQH94f8gIfhdrc7yeih38xh684TNMK9v5aAu2wxfIRMk/GpAJRrzcirMAPIaSDaByQ==", "dev": true }, + "node_modules/js-sdsl": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.4.tgz", + "integrity": "sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==", + "dev": true + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5826,19 +5540,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, - "peer": true, - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -5854,23 +5555,19 @@ "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, - "peer": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.0" }, "bin": { "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" } }, "node_modules/jsonc-parser": { @@ -5894,7 +5591,7 @@ "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", "dev": true, "engines": [ "node >= 0.2.0" @@ -5917,9 +5614,9 @@ } }, "node_modules/jsrsasign": { - "version": "10.5.12", - "resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-10.5.12.tgz", - "integrity": "sha512-YE03UOxqAkF7smFH/WKsDO8uPsvK3n+OUaT4qV77YwGJ+IiWwNyBh7XILQ+k1BSIdrsMWsEb2vyoBAw6aP5EBQ==", + "version": "10.5.27", + "resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-10.5.27.tgz", + "integrity": "sha512-1F4LmDeJZHYwoVvB44jEo2uZL3XuwYNzXCDOu53Ui6vqofGQ/gCYDmaxfVZtN0TGd92UKXr/BONcfrPonUIcQQ==", "peer": true, "funding": { "url": "https://github.com/kjur/jsrsasign#donations" @@ -6051,15 +5748,15 @@ } }, "node_modules/language-subtag-registry": { - "version": "0.3.21", - "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz", - "integrity": "sha512-L0IqwlIXjilBVVYKFT37X9Ih11Um5NEl9cbJIuU/SwP/zEEAbBPOnEeeuxVMf45ydWQRDQN3Nqc96OgbH1K+Pg==", + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", + "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==", "dev": true }, "node_modules/language-tags": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", - "integrity": "sha1-0yHbxNowuovzAk4ED6XBRmH5GTo=", + "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", "dev": true, "dependencies": { "language-subtag-registry": "~0.3.2" @@ -6100,13 +5797,13 @@ "node_modules/lighthouse-logger/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/lilconfig": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.4.tgz", - "integrity": "sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.5.tgz", + "integrity": "sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==", "dev": true, "engines": { "node": ">=10" @@ -6119,45 +5816,152 @@ "dev": true }, "node_modules/lint-staged": { - "version": "12.3.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.5.tgz", - "integrity": "sha512-oOH36RUs1It7b9U/C7Nl/a0sLfoIBcMB8ramiB3nuJ6brBqzsWiUAFSR5DQ3yyP/OR7XKMpijtgKl2DV1lQ3lA==", + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.0.3.tgz", + "integrity": "sha512-9hmrwSCFroTSYLjflGI8Uk+GWAwMB4OlpU4bMJEAT5d/llQwtYKoim4bLOyLCuWFAhWEupE0vkIFqtw/WIsPug==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", - "colorette": "^2.0.16", - "commander": "^8.3.0", - "debug": "^4.3.3", - "execa": "^5.1.1", - "lilconfig": "2.0.4", - "listr2": "^4.0.1", - "micromatch": "^4.0.4", + "colorette": "^2.0.17", + "commander": "^9.3.0", + "debug": "^4.3.4", + "execa": "^6.1.0", + "lilconfig": "2.0.5", + "listr2": "^4.0.5", + "micromatch": "^4.0.5", "normalize-path": "^3.0.0", - "object-inspect": "^1.12.0", + "object-inspect": "^1.12.2", + "pidtree": "^0.6.0", "string-argv": "^0.3.1", - "supports-color": "^9.2.1", - "yaml": "^1.10.2" + "yaml": "^2.1.1" }, "bin": { "lint-staged": "bin/lint-staged.js" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": "^14.13.1 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/lint-staged" } }, - "node_modules/lint-staged/node_modules/supports-color": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.2.1.tgz", - "integrity": "sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ==", + "node_modules/lint-staged/node_modules/execa": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz", + "integrity": "sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^3.0.1", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/lint-staged/node_modules/human-signals": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", + "integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==", + "dev": true, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/lint-staged/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", "dev": true, "engines": { "node": ">=12" }, "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/yaml": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", + "dev": true, + "engines": { + "node": ">= 14" } }, "node_modules/listr2": { @@ -6280,13 +6084,13 @@ } }, "node_modules/lit": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit/-/lit-2.2.1.tgz", - "integrity": "sha512-dSe++R50JqrvNGXmI9OE13de1z5U/Y3J2dTm/9GC86vedI8ILoR8ZGnxfThFpvQ9m0lR0qRnIR4IiKj/jDCfYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.3.1.tgz", + "integrity": "sha512-TejktDR4mqG3qB32Y8Lm5Lye3c8SUehqz7qRsxe1PqGYL6me2Ef+jeQAEqh20BnnGncv4Yxy2njEIT0kzK1WCw==", "dependencies": { - "@lit/reactive-element": "^1.3.0", + "@lit/reactive-element": "^1.4.0", "lit-element": "^3.2.0", - "lit-html": "^2.2.0" + "lit-html": "^2.3.0" } }, "node_modules/lit-element": { @@ -6303,23 +6107,23 @@ "integrity": "sha512-B9btcSgPYb1q4oSOb/PrOT6Z/H+r6xuNzfH4lFli/AWhYwdtrgQkQWBbIc6mdnf6E2IL3gDXdkkqNktpU0OZQA==" }, "node_modules/lit/node_modules/@lit/reactive-element": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.3.1.tgz", - "integrity": "sha512-nOJARIr3pReqK3hfFCSW2Zg/kFcFsSAlIE7z4a0C9D2dPrgD/YSn3ZP2ET/rxKB65SXyG7jJbkynBRm+tGlacw==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.4.1.tgz", + "integrity": "sha512-qDv4851VFSaBWzpS02cXHclo40jsbAjRXnebNXpm0uVg32kCneZPo9RYVQtrTNICtZ+1wAYHu1ZtxWSWMbKrBw==" }, "node_modules/lit/node_modules/lit-element": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.2.0.tgz", - "integrity": "sha512-HbE7yt2SnUtg5DCrWt028oaU4D5F4k/1cntAFHTkzY8ZIa8N0Wmu92PxSxucsQSOXlODFrICkQ5x/tEshKi13g==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.2.2.tgz", + "integrity": "sha512-6ZgxBR9KNroqKb6+htkyBwD90XGRiqKDHVrW/Eh0EZ+l+iC+u+v+w3/BA5NGi4nizAVHGYvQBHUDuSmLjPp7NQ==", "dependencies": { "@lit/reactive-element": "^1.3.0", "lit-html": "^2.2.0" } }, "node_modules/lit/node_modules/lit-html": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.2.1.tgz", - "integrity": "sha512-AiJ/Rs0awjICs2FioTnHSh+Np5dhYSkyRczKy3wKjp8qjLhr1Ov+GiHrUQNdX8ou1LMuznpIME990AZsa/tR8g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.3.1.tgz", + "integrity": "sha512-FyKH6LTW6aBdkfNhNSHyZTnLgJSTe5hMk7HFtc/+DcN1w74C215q8B+Cfxc2OuIEpBNcEKxgF64qL8as30FDHA==", "dependencies": { "@types/trusted-types": "^2.0.2" } @@ -6348,13 +6152,13 @@ "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", "dev": true }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, "node_modules/lodash.merge": { @@ -6363,12 +6167,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "node_modules/lodash.truncate": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", - "dev": true - }, "node_modules/log-update": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", @@ -6526,9 +6324,9 @@ } }, "node_modules/marked": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", - "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz", + "integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==", "bin": { "marked": "bin/marked.js" }, @@ -6537,15 +6335,15 @@ } }, "node_modules/marky": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.4.tgz", - "integrity": "sha512-zd2/GiSn6U3/jeFVZ0J9CA1LzQ8RfIVvXkb/U0swFHF/zT+dVohTAWjmo2DcIuofmIIIROlwTbd+shSeXmxr0w==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz", + "integrity": "sha512-q9JtQJKjpsVxCRVgQ+WapguSbKC3SQ5HEzFGPAJMStgh3QjCawp00UKv3MTTAArTmGmmPUvllHZoNbZ3gs0I+Q==", "dev": true }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", "dev": true, "engines": { "node": ">= 0.6" @@ -6603,29 +6401,17 @@ "node": ">= 8" } }, - "node_modules/micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, - "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/mime": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", - "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, - "bin": { - "mime": "cli.js" + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" }, "engines": { - "node": ">=10.0.0" + "node": ">=8.6" } }, "node_modules/mime-db": { @@ -6680,9 +6466,9 @@ } }, "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "node_modules/minimist-options": { @@ -6735,9 +6521,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -6749,7 +6535,7 @@ "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/negotiator": { @@ -6797,32 +6583,25 @@ "node_modules/node-fetch/node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, "node_modules/node-fetch/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, "node_modules/node-fetch/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, - "node_modules/node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", - "dev": true, - "peer": true - }, "node_modules/normalize-package-data": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", @@ -6839,9 +6618,9 @@ } }, "node_modules/normalize-package-data/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -6875,9 +6654,9 @@ } }, "node_modules/object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6893,14 +6672,14 @@ } }, "node_modules/object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", "dev": true, "dependencies": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", "object-keys": "^1.1.1" }, "engines": { @@ -6956,7 +6735,7 @@ "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" @@ -6980,7 +6759,7 @@ "node_modules/only": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", - "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=", + "integrity": "sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==", "dev": true }, "node_modules/open": { @@ -7063,12 +6842,12 @@ } }, "node_modules/p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/parent-module": { @@ -7137,7 +6916,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -7179,16 +6958,9 @@ "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, - "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true, - "peer": true - }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -7201,25 +6973,16 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pixelmatch": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.2.1.tgz", - "integrity": "sha512-WjcAdYSnKrrdDdqTcVEY7aB7UhhwjYQKYhHiBXdJef0MOaQeYpUdQ+iVyBLa5YBKS8MPVPPMX7rpOByISLpeEQ==", + "node_modules/pidtree": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", + "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", "dev": true, - "dependencies": { - "pngjs": "^4.0.1" - }, "bin": { - "pixelmatch": "bin/pixelmatch" - } - }, - "node_modules/pixelmatch/node_modules/pngjs": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-4.0.1.tgz", - "integrity": "sha512-rf5+2/ioHeQxR6IxuYNYGFytUyG3lma/WW1nsmjeHlWwtb2aByla6dkVc8pmJ9nplzkTA0q2xx7mMWrOTqT4Gg==", - "dev": true, + "pidtree": "bin/pidtree.js" + }, "engines": { - "node": ">=8.0.0" + "node": ">=0.10" } }, "node_modules/pkg-dir": { @@ -7286,102 +7049,43 @@ "node": ">=8" } }, - "node_modules/pkg-dir/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/playwright": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.20.0.tgz", - "integrity": "sha512-YcFXhXttk9yvpc8PMbfvts6KEopXjxdBh47BdOiA7xhjF/gkXeSM0Hs9CSdbL9mp2xtlB5xqE7+D+F2soQOjbA==", + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.26.0.tgz", + "integrity": "sha512-XxTVlvFEYHdatxUkh1KiPq9BclNtFKMi3BgQnl/aactmhN4G9AkZUXwt0ck6NDAOrDFlfibhbM7A1kZwQJKSBw==", "dev": true, "hasInstallScript": true, "dependencies": { - "playwright-core": "1.20.0" + "playwright-core": "1.26.0" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=12" + "node": ">=14" } }, "node_modules/playwright-core": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.20.0.tgz", - "integrity": "sha512-d25IRcdooS278Cijlp8J8A5fLQZ+/aY3dKRJvgX5yjXA69N0huIUdnh3xXSgn+LsQ9DCNmB7Ngof3eY630jgdA==", + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.26.0.tgz", + "integrity": "sha512-p8huU8eU4gD3VkJd3DA1nA7R3XA6rFvFL+1RYS96cSljCF2yJE9CWEHTPF4LqX8KN9MoWCrAfVKP5381X3CZqg==", "dev": true, - "dependencies": { - "colors": "1.4.0", - "commander": "8.3.0", - "debug": "4.3.3", - "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", - "jpeg-js": "0.4.3", - "mime": "3.0.0", - "pixelmatch": "5.2.1", - "pngjs": "6.0.0", - "progress": "2.0.3", - "proper-lockfile": "4.1.2", - "proxy-from-env": "1.1.0", - "rimraf": "3.0.2", - "socks-proxy-agent": "6.1.1", - "stack-utils": "2.0.5", - "ws": "8.4.2", - "yauzl": "2.10.0", - "yazl": "2.5.1" - }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=12" - } - }, - "node_modules/playwright-core/node_modules/ws": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz", - "integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==", - "dev": true, - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/pngjs": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz", - "integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==", - "dev": true, - "engines": { - "node": ">=12.13.0" + "node": ">=14" } }, "node_modules/portfinder": { - "version": "1.0.28", - "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz", - "integrity": "sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==", + "version": "1.0.32", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", + "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==", "dev": true, "dependencies": { - "async": "^2.6.2", - "debug": "^3.1.1", - "mkdirp": "^0.5.5" + "async": "^2.6.4", + "debug": "^3.2.7", + "mkdirp": "^0.5.6" }, "engines": { "node": ">= 0.12.0" @@ -7397,12 +7101,12 @@ } }, "node_modules/portfinder/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" @@ -7418,9 +7122,9 @@ } }, "node_modules/prismjs": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz", - "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==", + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", "engines": { "node": ">=6" } @@ -7434,17 +7138,6 @@ "node": ">=0.4.0" } }, - "node_modules/proper-lockfile": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", - "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.4", - "retry": "^0.12.0", - "signal-exit": "^3.0.2" - } - }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -7471,16 +7164,16 @@ } }, "node_modules/puppeteer-core": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.5.1.tgz", - "integrity": "sha512-dobVqWjV34ilyfQHR3BBnCYaekBYTi5MgegEYBRYd3s3uFy8jUpZEEWbaFjG9ETm+LGzR5Lmr0aF6LLuHtiuCg==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.7.0.tgz", + "integrity": "sha512-rXja4vcnAzFAP1OVLq/5dWNfwBGuzcOARJ6qGV7oAZhnLmVRU8G5MsdeQEAOy332ZhkIOnn9jp15R89LKHyp2Q==", "dev": true, "dependencies": { "cross-fetch": "3.1.5", - "debug": "4.3.3", - "devtools-protocol": "0.0.969999", + "debug": "4.3.4", + "devtools-protocol": "0.0.981744", "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", + "https-proxy-agent": "5.0.1", "pkg-dir": "4.2.0", "progress": "2.0.3", "proxy-from-env": "1.1.0", @@ -7517,7 +7210,7 @@ "node_modules/q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", "dev": true, "engines": { "node": ">=0.6.0", @@ -7525,9 +7218,9 @@ } }, "node_modules/qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dev": true, "dependencies": { "side-channel": "^1.0.4" @@ -7692,15 +7385,6 @@ "node": ">=8" } }, - "node_modules/read-pkg-up/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/read-pkg-up/node_modules/type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -7800,6 +7484,23 @@ "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", "dev": true }, + "node_modules/regexp.prototype.flags": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -7815,7 +7516,7 @@ "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -7840,12 +7541,12 @@ } }, "node_modules/resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "dependencies": { - "is-core-module": "^2.8.1", + "is-core-module": "^2.9.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -7880,7 +7581,7 @@ "node_modules/resolve-path": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", - "integrity": "sha1-xL2p9e+y/OZSR4c6s2u02DT+Fvc=", + "integrity": "sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==", "dev": true, "dependencies": { "http-errors": "~1.6.2", @@ -7893,7 +7594,7 @@ "node_modules/resolve-path/node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", "dev": true, "engines": { "node": ">= 0.6" @@ -7902,7 +7603,7 @@ "node_modules/resolve-path/node_modules/http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "dependencies": { "depd": "~1.1.2", @@ -7917,7 +7618,7 @@ "node_modules/resolve-path/node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "node_modules/resolve-path/node_modules/setprototypeof": { @@ -7939,15 +7640,6 @@ "node": ">=8" } }, - "node_modules/retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -7980,9 +7672,9 @@ } }, "node_modules/rollup": { - "version": "2.70.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.1.tgz", - "integrity": "sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==", + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz", + "integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -8018,9 +7710,9 @@ } }, "node_modules/rxjs": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", - "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.6.tgz", + "integrity": "sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw==", "dev": true, "dependencies": { "tslib": "^2.1.0" @@ -8074,6 +7766,12 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", + "dev": true + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -8095,13 +7793,13 @@ "dev": true }, "node_modules/sinon": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-13.0.1.tgz", - "integrity": "sha512-8yx2wIvkBjIq/MGY1D9h1LMraYW+z1X0mb648KZnKSdvLasvDu7maa0dFaNYdTDczFgbjNw2tOmWdTk9saVfwQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz", + "integrity": "sha512-ugA6BFmE+WrJdh0owRZHToLd32Uw3Lxq6E6LtNRU+xTVBefx632h03Q7apXWRsRdZAJ41LB8aUfn2+O4jsDNMw==", "dev": true, "dependencies": { "@sinonjs/commons": "^1.8.3", - "@sinonjs/fake-timers": "^9.0.0", + "@sinonjs/fake-timers": "^9.1.2", "@sinonjs/samsam": "^6.1.1", "diff": "^5.0.0", "nise": "^5.1.1", @@ -8159,9 +7857,9 @@ } }, "node_modules/slice-ansi/node_modules/ansi-styles": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz", - "integrity": "sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.1.tgz", + "integrity": "sha512-qDOv24WjnYuL+wbwHdlsYZFy+cgPtrYw0Tn7GLORicQp9BkQLzrgI3Pm4VyR9ERZ41YTn7KlMPuL1n05WdZvmg==", "dev": true, "engines": { "node": ">=12" @@ -8170,54 +7868,21 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", - "dev": true, - "engines": { - "node": ">= 6.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", - "dev": true, - "dependencies": { - "ip": "^1.1.5", - "smart-buffer": "^4.2.0" - }, - "engines": { - "node": ">= 10.13.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/socks-proxy-agent": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", - "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", - "dev": true, - "dependencies": { - "agent-base": "^6.0.2", - "debug": "^4.3.1", - "socks": "^2.6.1" - }, - "engines": { - "node": ">= 10" - } - }, "node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", "dev": true, - "peer": true, "engines": { - "node": ">=0.10.0" + "node": ">= 8" } }, + "node_modules/spawn-command": { + "version": "0.0.2-1", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", + "integrity": "sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==", + "dev": true + }, "node_modules/spdx-correct": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", @@ -8245,9 +7910,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz", + "integrity": "sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==", "dev": true }, "node_modules/split2": { @@ -8259,37 +7924,10 @@ "readable-stream": "^3.0.0" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/stack-utils": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz", - "integrity": "sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA==", - "dev": true, - "dependencies": { - "escape-string-regexp": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/stack-utils/node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", "dev": true, "engines": { "node": ">= 0.6" @@ -8378,26 +8016,28 @@ } }, "node_modules/string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -8418,7 +8058,7 @@ "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, "engines": { "node": ">=4" @@ -8481,22 +8121,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/table": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", - "integrity": "sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA==", - "dev": true, - "dependencies": { - "ajv": "^8.0.1", - "lodash.truncate": "^4.4.2", - "slice-ansi": "^4.0.0", - "string-width": "^4.2.3", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/table-layout": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.2.tgz", @@ -8523,110 +8147,9 @@ }, "node_modules/table-layout/node_modules/typical": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", - "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/table/node_modules/ajv": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/table/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/table/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/table/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/table/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/table/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/table/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, - "node_modules/table/node_modules/slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/slice-ansi?sponsor=1" - } - }, - "node_modules/table/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz", + "integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==", "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, "engines": { "node": ">=8" } @@ -8671,13 +8194,13 @@ "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "node_modules/through2": { @@ -8689,16 +8212,6 @@ "readable-stream": "3" } }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true, - "peer": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -8732,6 +8245,15 @@ "node": ">=12" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", @@ -8742,12 +8264,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -8758,7 +8280,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -8794,33 +8316,21 @@ } }, "node_modules/tsconfig-paths": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz", - "integrity": "sha512-cg/1jAZoL57R39+wiw4u/SCC6Ic9Q5NqjBOb+9xISedOYurfog9ZNmKJSxAnb2m/5Bq4lE9lhUcau33Ml8DM0g==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", "dev": true, "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.1", - "minimist": "^1.2.0", + "minimist": "^1.2.6", "strip-bom": "^3.0.0" } }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, "node_modules/tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, "node_modules/tsscmp": { "version": "1.0.6", @@ -8831,6 +8341,27 @@ "node": ">=0.6.x" } }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -8878,9 +8409,9 @@ } }, "node_modules/typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8915,9 +8446,9 @@ } }, "node_modules/typescript-template-language-service-decorator": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/typescript-template-language-service-decorator/-/typescript-template-language-service-decorator-2.2.0.tgz", - "integrity": "sha512-xiolqt1i7e22rpqMaprPgSFVgU64u3b9n6EJlAaUYE61jumipKAdI1+O5khPlWslpTUj80YzjUKjJ2jxT0D74w==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/typescript-template-language-service-decorator/-/typescript-template-language-service-decorator-2.3.1.tgz", + "integrity": "sha512-+Q5+cvBtPO4VKNyyI6O+XnIne+/hq/WfNhBaF4hJP8nB8TbikTg+2h9uBMsqduwX1+kVfwG9SBSwMTtvi2Ep7w==", "dev": true }, "node_modules/typical": { @@ -8930,14 +8461,14 @@ } }, "node_modules/unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "dependencies": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" }, "funding": { @@ -8966,7 +8497,7 @@ "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "dev": true, "engines": { "node": ">= 0.8" @@ -8984,28 +8515,22 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true, "bin": { "uuid": "dist/bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "node_modules/v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "node_modules/v8-to-istanbul": { @@ -9022,15 +8547,6 @@ "node": ">=10.12.0" } }, - "node_modules/v8-to-istanbul/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -9044,7 +8560,7 @@ "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", "dev": true, "engines": { "node": ">= 0.8" @@ -9084,9 +8600,9 @@ } }, "node_modules/vscode-languageserver-types": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz", - "integrity": "sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==", + "version": "3.17.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", + "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==", "dev": true }, "node_modules/vscode-nls": { @@ -9267,13 +8783,13 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "node_modules/ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "dev": true, "engines": { "node": ">=8.3.0" @@ -9316,9 +8832,9 @@ } }, "node_modules/yargs": { - "version": "17.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", - "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "version": "17.5.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", + "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", "dev": true, "dependencies": { "cliui": "^7.0.2", @@ -9372,9 +8888,9 @@ } }, "node_modules/yargs/node_modules/yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "engines": { "node": ">=12" @@ -9383,26 +8899,17 @@ "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "dev": true, "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, - "node_modules/yazl": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", - "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==", - "dev": true, - "dependencies": { - "buffer-crc32": "~0.2.3" - } - }, "node_modules/ylru": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.2.1.tgz", - "integrity": "sha512-faQrqNMzcPCHGVC2aaOINk13K+aaBDUPjGWl0teOXywElLjyVAB6Oe2jj62jHYtwsU49jXhScYbvPENK+6zAvQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.3.2.tgz", + "integrity": "sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==", "dev": true, "engines": { "node": ">= 4.0.0" @@ -9431,20 +8938,6 @@ } }, "dependencies": { - "@advanced-rest-client/arc-demo-helper": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/arc-demo-helper/-/arc-demo-helper-5.0.4.tgz", - "integrity": "sha512-428Pr58NOnRNx6jKmtfLueoZkzW48RhAQnnn4NnJ3bmQPsbjDhT72Kz9k9tSfECzFY1zBhRndtHvyenfwteJMw==", - "dev": true, - "requires": { - "@anypoint-web-components/awc": "^1.0.5", - "@open-wc/dedupe-mixin": "^1.3.0", - "@polymer/font-roboto": "^3.0.2", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1", - "prismjs": "^1.25.0" - } - }, "@advanced-rest-client/base": { "version": "0.1.10", "resolved": "https://registry.npmjs.org/@advanced-rest-client/base/-/base-0.1.10.tgz", @@ -9467,12 +8960,47 @@ "lit-html": "^1.4.1", "monaco-editor": "^0.29.1", "prismjs": "^1.25.0" + }, + "dependencies": { + "@advanced-rest-client/events": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", + "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + }, + "@advanced-rest-client/oauth": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.1.0.tgz", + "integrity": "sha512-GQtQzrm2Mi5haq6Iv2Da7OwApK5+bHGvj8tc2aPCUzEeWnsQdI0kP8fOmGuNCLnk8h/FNG+B1ducjGuknChBuw==", + "requires": { + "@advanced-rest-client/events": "^0.2.28" + } + }, + "@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "requires": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + }, + "@api-client/context-menu": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.2.0.tgz", + "integrity": "sha512-OpOhXaXEihcQHm5WrgbjoHy/aSEzmc3g3s3gkUrqGxyPFGZYD/OF6iNdMV/HIMrjWK2LHw266s/Rxp5L60Kr0g==", + "requires": { + "@anypoint-web-components/awc": "^1.0.5", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + } } }, "@advanced-rest-client/events": { - "version": "0.2.32", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", - "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + "version": "18.0.2", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-18.0.2.tgz", + "integrity": "sha512-vlfQUji9dX7LNOmEK6rhAZQTgO2XBQ+Yx7Q+fR1ufe+wP1GoezCg944z9GSr0dIpCuSRxe+jj/n5Lr+G4jmHtQ==" }, "@advanced-rest-client/highlight": { "version": "2.0.2", @@ -9488,6 +9016,23 @@ "lit-html": "^1.4.1", "marked": "^4.0.12", "prismjs": "^1.25.0" + }, + "dependencies": { + "@advanced-rest-client/events": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", + "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + }, + "@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "requires": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + } } }, "@advanced-rest-client/http-code-snippets": { @@ -9499,6 +9044,18 @@ "@anypoint-web-components/awc": "^1.0.8", "lit-element": "^2.5.1", "prismjs": "^1.25.0" + }, + "dependencies": { + "@anypoint-web-components/awc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", + "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "requires": { + "@open-wc/dedupe-mixin": "^1.3.0", + "lit-element": "^2.5.1", + "lit-html": "^1.4.1" + } + } } }, "@advanced-rest-client/icons": { @@ -9516,6 +9073,13 @@ "integrity": "sha512-NjUDtnPO6z8VZoKuzkQAHmjvFwjjRM8Q1UDZ6Qg6xfPMYPyqf2UTGlDo77y6Xx0u8gfU8P4QW9uGVxMaV3nozQ==", "requires": { "@advanced-rest-client/events": "^0.2.29" + }, + "dependencies": { + "@advanced-rest-client/events": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/events/-/events-0.2.32.tgz", + "integrity": "sha512-utzItgaFzNzHu6GMrSSrnG0OiqLka0N9k4AnD/RIe1sszRTlj3d4JblfjBtZeoC9DmHE3pPZYQ+cBkPkB+Ka8g==" + } } }, "@advanced-rest-client/monaco-support": { @@ -9527,339 +9091,97 @@ } }, "@advanced-rest-client/oauth": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.1.0.tgz", - "integrity": "sha512-GQtQzrm2Mi5haq6Iv2Da7OwApK5+bHGvj8tc2aPCUzEeWnsQdI0kP8fOmGuNCLnk8h/FNG+B1ducjGuknChBuw==", - "requires": { - "@advanced-rest-client/events": "^0.2.28" - } + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.2.1.tgz", + "integrity": "sha512-R1Ke8SNs29AcOgw2MDm2d/iI7qjUIAF1DVGvnahZlKyCOrEH6xbak7BxRmEuNMayjbFdSUXQHDquUNS+lvaoNQ==", + "requires": {} }, "@advanced-rest-client/uuid": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@advanced-rest-client/uuid/-/uuid-4.0.0.tgz", "integrity": "sha512-ln7TGYaiGGRiXFHxo722EPcEDSccq+jclDRYTOTrRp3fTvUrm8P+tHCPFJTGa68Hi/rDhMZN3SkfF3+thtM7eQ==" }, - "@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, - "peer": true, - "requires": { - "@jridgewell/trace-mapping": "^0.3.0" - } + "@aml-org/amf-antlr-parsers": { + "version": "0.5.17", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.5.17.tgz", + "integrity": "sha512-GHPMGjkcNeTjp+DxASQ/y5oijNiaYPSItHT1YNEkGGZnd+d5MLhrlujIx2cKn7aKcxLNTGY1skNFEIf1jZtWxQ==", + "dev": true }, "@anypoint-web-components/awc": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-1.0.9.tgz", - "integrity": "sha512-oY6fnXDOvE+4QZxEIR8/0gt6rYpEkvFCAx+qPUm4ieAEeGaPjPfm0DTEphTOgTpa0pmxHYrjdE9YZZdTGaAqxg==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/@anypoint-web-components/awc/-/awc-3.0.12.tgz", + "integrity": "sha512-jn54YDqYLxSN8byOuvvojwdEMMq3pXce6llZcYCLoEmecoWiqypbN40CA2haW21QmGNrNZZKaFBcWzm4dP5ZcA==", "requires": { - "@open-wc/dedupe-mixin": "^1.3.0", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "lit": "^2.2.1", + "tslib": "^2.3.1" } }, "@api-client/context-menu": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.2.0.tgz", - "integrity": "sha512-OpOhXaXEihcQHm5WrgbjoHy/aSEzmc3g3s3gkUrqGxyPFGZYD/OF6iNdMV/HIMrjWK2LHw266s/Rxp5L60Kr0g==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@api-client/context-menu/-/context-menu-0.4.1.tgz", + "integrity": "sha512-PJ1LWUrreArXLYOfTGLy023xyOQFhcz/xFsqWSY7Ob+V/6TIZ6pEli+kRArhE2FuyZCZa3FPaA0rr7pTOTuaTw==", "requires": { - "@anypoint-web-components/awc": "^1.0.5", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "@anypoint-web-components/awc": "^3.0.1", + "lit": "^2.2.2" } }, "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.16.7" - } - }, - "@babel/compat-data": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.7.tgz", - "integrity": "sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==", - "dev": true, - "peer": true - }, - "@babel/core": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.7.tgz", - "integrity": "sha512-djHlEfFHnSnTAcPb7dATbiM5HxGOP98+3JLBZtjRb5I7RXrw7kFRoG2dXM8cm3H+o11A8IFH/uprmJpwFynRNQ==", - "dev": true, - "peer": true, - "requires": { - "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.7", - "@babel/helper-compilation-targets": "^7.17.7", - "@babel/helper-module-transforms": "^7.17.7", - "@babel/helpers": "^7.17.7", - "@babel/parser": "^7.17.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.1.2", - "semver": "^6.3.0" - } - }, - "@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", - "dev": true, - "peer": true, - "requires": { - "eslint-scope": "^5.1.1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.0" - } - }, - "@babel/eslint-plugin": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/eslint-plugin/-/eslint-plugin-7.17.7.tgz", - "integrity": "sha512-JATUoJJXSgwI0T8juxWYtK1JSgoLpIGUsCHIv+NMXcUDA2vIe6nvAHR9vnuJgs/P1hOFw7vPwibixzfqBBLIVw==", - "dev": true, - "peer": true, - "requires": { - "eslint-rule-composer": "^0.3.0" - } - }, - "@babel/generator": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.7.tgz", - "integrity": "sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==", - "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - } - }, - "@babel/helper-compilation-targets": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz", - "integrity": "sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==", - "dev": true, - "peer": true, - "requires": { - "@babel/compat-data": "^7.17.7", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", - "semver": "^6.3.0" - } - }, - "@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", - "dev": true, - "peer": true, - "requires": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", - "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", - "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", - "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-module-transforms": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz", - "integrity": "sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw==", - "dev": true, - "peer": true, - "requires": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.17.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-simple-access": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz", - "integrity": "sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", "dev": true, - "peer": true, - "requires": { - "@babel/types": "^7.17.0" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", - "dev": true, - "peer": true, "requires": { - "@babel/types": "^7.16.7" + "@babel/highlight": "^7.18.6" } }, "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true }, - "@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", - "dev": true, - "peer": true - }, - "@babel/helpers": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.7.tgz", - "integrity": "sha512-TKsj9NkjJfTBxM7Phfy7kv6yYc4ZcOo+AaWGqQOKTPDOmcGkIFb5xNA746eKisQkm4yavUYh4InYM9S+VnO01w==", - "dev": true, - "peer": true, - "requires": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" - } - }, "@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.16.7", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, - "@babel/parser": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.7.tgz", - "integrity": "sha512-bm3AQf45vR4gKggRfvJdYJ0gFLoCbsPxiFLSH6hTVYABptNHY6l9NrhnucVjQ/X+SPtLANT9lc0fFhikj+VBRA==", - "dev": true, - "peer": true - }, "@babel/runtime": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.7.tgz", - "integrity": "sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==", + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.0.tgz", + "integrity": "sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==", "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } }, "@babel/runtime-corejs3": { - "version": "7.17.7", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.7.tgz", - "integrity": "sha512-TvliGJjhxis5m7xIMvlXH/xG8Oa/LK0SCUCyfKD6nLi42n5fB4WibDJ0g9trmmBB6hwpMNx+Lzbxy9/4gpMaVw==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.19.1.tgz", + "integrity": "sha512-j2vJGnkopRzH+ykJ8h68wrHnEUmtK//E723jjixiAl/PPf6FhqY/vYRcMVlNydRKQjQsTsYEjpx+DZMIvnGk/g==", "dev": true, "requires": { - "core-js-pure": "^3.20.2", + "core-js-pure": "^3.25.1", "regenerator-runtime": "^0.13.4" } }, - "@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, - "peer": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/traverse": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.3.tgz", - "integrity": "sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==", - "dev": true, - "peer": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.3", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", - "globals": "^11.1.0" - } - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "peer": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - }, "@commitlint/cli": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-16.2.1.tgz", - "integrity": "sha512-zfKf+B9osuiDbxGMJ7bWFv7XFCW8wlQYPtCffNp7Ukdb7mdrep5R9e03vPUZysnwp8NX6hg05kPEvnD/wRIGWw==", + "version": "17.1.2", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.1.2.tgz", + "integrity": "sha512-h/4Hlka3bvCLbnxf0Er2ri5A44VMlbMSkdTRp8Adv2tRiklSTRIoPGs7OEXDv3EoDs2AAzILiPookgM4Gi7LOw==", "dev": true, "requires": { - "@commitlint/format": "^16.2.1", - "@commitlint/lint": "^16.2.1", - "@commitlint/load": "^16.2.1", - "@commitlint/read": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/format": "^17.0.0", + "@commitlint/lint": "^17.1.0", + "@commitlint/load": "^17.1.2", + "@commitlint/read": "^17.1.0", + "@commitlint/types": "^17.0.0", + "execa": "^5.0.0", "lodash": "^4.17.19", "resolve-from": "5.0.0", "resolve-global": "1.0.0", @@ -9867,48 +9189,68 @@ } }, "@commitlint/config-conventional": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-16.2.1.tgz", - "integrity": "sha512-cP9gArx7gnaj4IqmtCIcHdRjTYdRUi6lmGE+lOzGGjGe45qGOS8nyQQNvkNy2Ey2VqoSWuXXkD8zCUh6EHf1Ww==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.1.0.tgz", + "integrity": "sha512-WU2p0c9/jLi8k2q2YrDV96Y8XVswQOceIQ/wyJvQxawJSCasLdRB3kUIYdNjOCJsxkpoUlV/b90ZPxp1MYZDiA==", "dev": true, "requires": { - "conventional-changelog-conventionalcommits": "^4.3.1" + "conventional-changelog-conventionalcommits": "^5.0.0" } }, "@commitlint/config-validator": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-16.2.1.tgz", - "integrity": "sha512-hogSe0WGg7CKmp4IfNbdNES3Rq3UEI4XRPB8JL4EPgo/ORq5nrGTVzxJh78omibNuB8Ho4501Czb1Er1MoDWpw==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.1.0.tgz", + "integrity": "sha512-Q1rRRSU09ngrTgeTXHq6ePJs2KrI+axPTgkNYDWSJIuS1Op4w3J30vUfSXjwn5YEJHklK3fSqWNHmBhmTR7Vdg==", "dev": true, "requires": { - "@commitlint/types": "^16.2.1", - "ajv": "^6.12.6" + "@commitlint/types": "^17.0.0", + "ajv": "^8.11.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + } } }, "@commitlint/ensure": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-16.2.1.tgz", - "integrity": "sha512-/h+lBTgf1r5fhbDNHOViLuej38i3rZqTQnBTk+xEg+ehOwQDXUuissQ5GsYXXqI5uGy+261ew++sT4EA3uBJ+A==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.0.0.tgz", + "integrity": "sha512-M2hkJnNXvEni59S0QPOnqCKIK52G1XyXBGw51mvh7OXDudCmZ9tZiIPpU882p475Mhx48Ien1MbWjCP1zlyC0A==", "dev": true, "requires": { - "@commitlint/types": "^16.2.1", + "@commitlint/types": "^17.0.0", "lodash": "^4.17.19" } }, "@commitlint/execute-rule": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-16.2.1.tgz", - "integrity": "sha512-oSls82fmUTLM6cl5V3epdVo4gHhbmBFvCvQGHBRdQ50H/690Uq1Dyd7hXMuKITCIdcnr9umyDkr8r5C6HZDF3g==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-17.0.0.tgz", + "integrity": "sha512-nVjL/w/zuqjCqSJm8UfpNaw66V9WzuJtQvEnCrK4jDw6qKTmZB+1JQ8m6BQVZbNBcwfYdDNKnhIhqI0Rk7lgpQ==", "dev": true }, "@commitlint/format": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-16.2.1.tgz", - "integrity": "sha512-Yyio9bdHWmNDRlEJrxHKglamIk3d6hC0NkEUW6Ti6ipEh2g0BAhy8Od6t4vLhdZRa1I2n+gY13foy+tUgk0i1Q==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-17.0.0.tgz", + "integrity": "sha512-MZzJv7rBp/r6ZQJDEodoZvdRM0vXu1PfQvMTNWFb8jFraxnISMTnPBWMMjr2G/puoMashwaNM//fl7j8gGV5lA==", "dev": true, "requires": { - "@commitlint/types": "^16.2.1", - "chalk": "^4.0.0" + "@commitlint/types": "^17.0.0", + "chalk": "^4.1.0" }, "dependencies": { "ansi-styles": { @@ -9963,19 +9305,19 @@ } }, "@commitlint/is-ignored": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-16.2.1.tgz", - "integrity": "sha512-exl8HRzTIfb1YvDJp2b2HU5z1BT+9tmgxR2XF0YEzkMiCIuEKh+XLeocPr1VcvAKXv3Cmv5X/OfNRp+i+/HIhQ==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.1.0.tgz", + "integrity": "sha512-JITWKDMHhIh8IpdIbcbuH9rEQJty1ZWelgjleTFrVRAcEwN/sPzk1aVUXRIZNXMJWbZj8vtXRJnFihrml8uECQ==", "dev": true, "requires": { - "@commitlint/types": "^16.2.1", - "semver": "7.3.5" + "@commitlint/types": "^17.0.0", + "semver": "7.3.7" }, "dependencies": { "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -9984,36 +9326,43 @@ } }, "@commitlint/lint": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-16.2.1.tgz", - "integrity": "sha512-fNINQ3X2ZqsCkNB3Z0Z8ElmhewqrS3gy2wgBTx97BkcjOWiyPAGwDJ752hwrsUnWAVBRztgw826n37xPzxsOgg==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.1.0.tgz", + "integrity": "sha512-ltpqM2ogt/+SDhUaScFo0MdscncEF96lvQTPMM/VTTWlw7sTGLLWkOOppsee2MN/uLNNWjQ7kqkd4h6JqoM9AQ==", "dev": true, "requires": { - "@commitlint/is-ignored": "^16.2.1", - "@commitlint/parse": "^16.2.1", - "@commitlint/rules": "^16.2.1", - "@commitlint/types": "^16.2.1" + "@commitlint/is-ignored": "^17.1.0", + "@commitlint/parse": "^17.0.0", + "@commitlint/rules": "^17.0.0", + "@commitlint/types": "^17.0.0" } }, "@commitlint/load": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-16.2.1.tgz", - "integrity": "sha512-oSpz0jTyVI/A1AIImxJINTLDOMB8YF7lWGm+Jg5wVWM0r7ucpuhyViVvpSRTgvL0z09oIxlctyFGWUQQpI42uw==", + "version": "17.1.2", + "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.1.2.tgz", + "integrity": "sha512-sk2p/jFYAWLChIfOIp/MGSIn/WzZ0vkc3afw+l4X8hGEYkvDe4gQUUAVxjl/6xMRn0HgnSLMZ04xXh5pkTsmgg==", "dev": true, "requires": { - "@commitlint/config-validator": "^16.2.1", - "@commitlint/execute-rule": "^16.2.1", - "@commitlint/resolve-extends": "^16.2.1", - "@commitlint/types": "^16.2.1", - "@types/node": ">=12", - "chalk": "^4.0.0", + "@commitlint/config-validator": "^17.1.0", + "@commitlint/execute-rule": "^17.0.0", + "@commitlint/resolve-extends": "^17.1.0", + "@commitlint/types": "^17.0.0", + "@types/node": "^14.0.0", + "chalk": "^4.1.0", "cosmiconfig": "^7.0.0", - "cosmiconfig-typescript-loader": "^1.0.0", + "cosmiconfig-typescript-loader": "^4.0.0", "lodash": "^4.17.19", "resolve-from": "^5.0.0", - "typescript": "^4.4.3" + "ts-node": "^10.8.1", + "typescript": "^4.6.4" }, "dependencies": { + "@types/node": { + "version": "14.18.29", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.29.tgz", + "integrity": "sha512-LhF+9fbIX4iPzhsRLpK5H7iPdvW8L4IwGciXQIOEcuF62+9nw/VQVsOViAOOGxY3OlOKGLFv0sWwJXdwQeTn6A==", + "dev": true + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -10066,42 +9415,43 @@ } }, "@commitlint/message": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-16.2.1.tgz", - "integrity": "sha512-2eWX/47rftViYg7a3axYDdrgwKv32mxbycBJT6OQY/MJM7SUfYNYYvbMFOQFaA4xIVZt7t2Alyqslbl6blVwWw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.0.0.tgz", + "integrity": "sha512-LpcwYtN+lBlfZijHUdVr8aNFTVpHjuHI52BnfoV01TF7iSLnia0jttzpLkrLmI8HNQz6Vhr9UrxDWtKZiMGsBw==", "dev": true }, "@commitlint/parse": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-16.2.1.tgz", - "integrity": "sha512-2NP2dDQNL378VZYioLrgGVZhWdnJO4nAxQl5LXwYb08nEcN+cgxHN1dJV8OLJ5uxlGJtDeR8UZZ1mnQ1gSAD/g==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.0.0.tgz", + "integrity": "sha512-cKcpfTIQYDG1ywTIr5AG0RAiLBr1gudqEsmAGCTtj8ffDChbBRxm6xXs2nv7GvmJN7msOt7vOKleLvcMmRa1+A==", "dev": true, "requires": { - "@commitlint/types": "^16.2.1", + "@commitlint/types": "^17.0.0", "conventional-changelog-angular": "^5.0.11", "conventional-commits-parser": "^3.2.2" } }, "@commitlint/read": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-16.2.1.tgz", - "integrity": "sha512-tViXGuaxLTrw2r7PiYMQOFA2fueZxnnt0lkOWqKyxT+n2XdEMGYcI9ID5ndJKXnfPGPppD0w/IItKsIXlZ+alw==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-17.1.0.tgz", + "integrity": "sha512-73BoFNBA/3Ozo2JQvGsE0J8SdrJAWGfZQRSHqvKaqgmY042Su4gXQLqvAzgr55S9DI1l9TiU/5WDuh8IE86d/g==", "dev": true, "requires": { - "@commitlint/top-level": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/top-level": "^17.0.0", + "@commitlint/types": "^17.0.0", "fs-extra": "^10.0.0", - "git-raw-commits": "^2.0.0" + "git-raw-commits": "^2.0.0", + "minimist": "^1.2.6" } }, "@commitlint/resolve-extends": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-16.2.1.tgz", - "integrity": "sha512-NbbCMPKTFf2J805kwfP9EO+vV+XvnaHRcBy6ud5dF35dxMsvdJqke54W3XazXF1ZAxC4a3LBy4i/GNVBAthsEg==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.1.0.tgz", + "integrity": "sha512-jqKm00LJ59T0O8O4bH4oMa4XyJVEOK4GzH8Qye9XKji+Q1FxhZznxMV/bDLyYkzbTodBt9sL0WLql8wMtRTbqQ==", "dev": true, "requires": { - "@commitlint/config-validator": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/config-validator": "^17.1.0", + "@commitlint/types": "^17.0.0", "import-fresh": "^3.0.0", "lodash": "^4.17.19", "resolve-from": "^5.0.0", @@ -10109,40 +9459,40 @@ } }, "@commitlint/rules": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-16.2.1.tgz", - "integrity": "sha512-ZFezJXQaBBso+BOTre/+1dGCuCzlWVaeLiVRGypI53qVgPMzQqZhkCcrxBFeqB87qeyzr4A4EoG++IvITwwpIw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.0.0.tgz", + "integrity": "sha512-45nIy3dERKXWpnwX9HeBzK5SepHwlDxdGBfmedXhL30fmFCkJOdxHyOJsh0+B0RaVsLGT01NELpfzJUmtpDwdQ==", "dev": true, "requires": { - "@commitlint/ensure": "^16.2.1", - "@commitlint/message": "^16.2.1", - "@commitlint/to-lines": "^16.2.1", - "@commitlint/types": "^16.2.1", + "@commitlint/ensure": "^17.0.0", + "@commitlint/message": "^17.0.0", + "@commitlint/to-lines": "^17.0.0", + "@commitlint/types": "^17.0.0", "execa": "^5.0.0" } }, "@commitlint/to-lines": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-16.2.1.tgz", - "integrity": "sha512-9/VjpYj5j1QeY3eiog1zQWY6axsdWAc0AonUUfyZ7B0MVcRI0R56YsHAfzF6uK/g/WwPZaoe4Lb1QCyDVnpVaQ==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-17.0.0.tgz", + "integrity": "sha512-nEi4YEz04Rf2upFbpnEorG8iymyH7o9jYIVFBG1QdzebbIFET3ir+8kQvCZuBE5pKCtViE4XBUsRZz139uFrRQ==", "dev": true }, "@commitlint/top-level": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-16.2.1.tgz", - "integrity": "sha512-lS6GSieHW9y6ePL73ied71Z9bOKyK+Ib9hTkRsB8oZFAyQZcyRwq2w6nIa6Fngir1QW51oKzzaXfJL94qwImyw==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-17.0.0.tgz", + "integrity": "sha512-dZrEP1PBJvodNWYPOYiLWf6XZergdksKQaT6i1KSROLdjf5Ai0brLOv5/P+CPxBeoj3vBxK4Ax8H1Pg9t7sHIQ==", "dev": true, "requires": { "find-up": "^5.0.0" } }, "@commitlint/types": { - "version": "16.2.1", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-16.2.1.tgz", - "integrity": "sha512-7/z7pA7BM0i8XvMSBynO7xsB3mVQPUZbVn6zMIlp/a091XJ3qAXRXc+HwLYhiIdzzS5fuxxNIHZMGHVD4HJxdA==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.0.0.tgz", + "integrity": "sha512-hBAw6U+SkAT5h47zDMeOu3HSiD0SODw4Aq7rRNh1ceUmL7GyLKYhPbUvlRWqZ65XjBLPHZhFyQlRaPNz8qvUyQ==", "dev": true, "requires": { - "chalk": "^4.0.0" + "chalk": "^4.1.0" }, "dependencies": { "ansi-styles": { @@ -10194,21 +9544,15 @@ "has-flag": "^4.0.0" } } - } - }, - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + } }, "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "requires": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" } }, "@emmetio/extract-abbreviation": { @@ -10218,26 +9562,26 @@ "dev": true }, "@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", + "integrity": "sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", + "espree": "^9.4.0", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "dependencies": { "globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -10252,23 +9596,23 @@ } }, "@esm-bundle/chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/@esm-bundle/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-6Tx35wWiNw7X0nLY9RMx8v3EL8SacCFW+eEZOE9Hc+XxmU5HFE2AFEg+GehUZpiyDGwVvPH75ckGlqC7coIPnA==", + "version": "4.3.4-fix.0", + "resolved": "https://registry.npmjs.org/@esm-bundle/chai/-/chai-4.3.4-fix.0.tgz", + "integrity": "sha512-26SKdM4uvDWlY8/OOOxSB1AqQWeBosCX3wRYUZO7enTAj03CtVxIiCimYVG2WpULcyV51qapK4qTovwkUr5Mlw==", "dev": true, "requires": { "@types/chai": "^4.2.12" } }, "@github/time-elements": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.2.tgz", - "integrity": "sha512-YVtZVLBikP6I7na22kfB9PKIseISwX41MFJ7lPuNz1VVH2IR5cpRRU6F1X6kcchPChljuvMUR4OiwMWHOJQ8kQ==" + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@github/time-elements/-/time-elements-3.1.4.tgz", + "integrity": "sha512-DTe/w0uKVeciKzGtYadNdfS8D86pXdGF+OrKg+vi8PKlotJ45zAc26zNpmmfCcMblBBg2+uoi3OxmUm7am/0sg==" }, "@humanwhocodes/config-array": { - "version": "0.9.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz", - "integrity": "sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", + "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", @@ -10276,6 +9620,18 @@ "minimatch": "^3.0.4" } }, + "@humanwhocodes/gitignore-to-minimatch": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", + "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", + "dev": true + }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -10283,25 +9639,22 @@ "dev": true }, "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", - "dev": true, - "peer": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true }, "@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true, - "peer": true + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, - "peer": true, "requires": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -10561,330 +9914,84 @@ } }, "@open-wc/dedupe-mixin": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@open-wc/dedupe-mixin/-/dedupe-mixin-1.3.0.tgz", - "integrity": "sha512-UfdK1MPnR6T7f3svzzYBfu3qBkkZ/KsPhcpc3JYhsUY4hbpwNF9wEQtD4Z+/mRqMTJrKg++YSxIxE0FBhY3RIw==" + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@open-wc/dedupe-mixin/-/dedupe-mixin-1.3.1.tgz", + "integrity": "sha512-ukowSvzpZQDUH0Y3znJTsY88HkiGk3Khc0WGpIPhap1xlerieYi27QBg6wx/nTurpWfU6XXXsx9ocxDYCdtw0Q==" }, "@open-wc/eslint-config": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@open-wc/eslint-config/-/eslint-config-7.0.0.tgz", - "integrity": "sha512-iuWgs5XSPqb9zhdHIeKDSzepnjRyhoYSoS6RI+vyLMfVFRxZoqt0Yv4Q8xJ8yByXbJyakmvpukTyEKbcuIQ7Uw==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@open-wc/eslint-config/-/eslint-config-8.0.2.tgz", + "integrity": "sha512-ymOFXtsAXv1tkpW48touNZVGfV6X/ii/Ir+IZfFQi3KicJ/HF5wqK1x8Un4ZZzXravGqPqGfXCycKeyJf8s+pg==", "dev": true, "requires": { - "eslint": "^7.6.0", - "eslint-config-airbnb-base": "^14.0.0", + "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-html": "^6.0.0", - "eslint-plugin-import": "^2.18.2", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-lit": "^1.2.0", - "eslint-plugin-lit-a11y": "^2.1.0", + "eslint-plugin-lit-a11y": "^2.2.2", "eslint-plugin-no-only-tests": "^2.4.0", "eslint-plugin-wc": "^1.2.0" - }, - "dependencies": { - "@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", - "dev": true, - "requires": { - "@babel/highlight": "^7.10.4" - } - }, - "@eslint/eslintrc": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", - "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.1.1", - "espree": "^7.3.0", - "globals": "^13.9.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - } - }, - "@humanwhocodes/config-array": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", - "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.0", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - } - }, - "acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "eslint": { - "version": "7.32.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", - "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", - "dev": true, - "requires": { - "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.3", - "@humanwhocodes/config-array": "^0.5.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^2.0.0", - "espree": "^7.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.1.2", - "globals": "^13.6.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^6.0.9", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - } - }, - "eslint-config-airbnb-base": { - "version": "14.2.1", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz", - "integrity": "sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==", - "dev": true, - "requires": { - "confusing-browser-globals": "^1.0.10", - "object.assign": "^4.1.2", - "object.entries": "^1.1.2" - } - }, - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, - "espree": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", - "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", - "dev": true, - "requires": { - "acorn": "^7.4.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^1.3.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, - "globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - } } }, "@open-wc/scoped-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@open-wc/scoped-elements/-/scoped-elements-2.0.1.tgz", - "integrity": "sha512-JS6ozxUFwFX3+Er91v9yQzNIaFn7OnE0iESKTbFvkkKdNwvAPtp1fpckBKIvWk8Ae9ZcoI9DYZuT2DDbMPcadA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@open-wc/scoped-elements/-/scoped-elements-2.1.3.tgz", + "integrity": "sha512-WoQD5T8Me9obek+iyjgrAMw9wxZZg4ytIteIN1i9LXW2KohezUp0LTOlWgBajWJo0/bpjUKiODX73cMYL2i3hw==", "dev": true, "requires": { "@lit/reactive-element": "^1.0.0", - "@open-wc/dedupe-mixin": "^1.3.0", - "@webcomponents/scoped-custom-element-registry": "^0.0.3" + "@open-wc/dedupe-mixin": "^1.3.0" }, "dependencies": { "@lit/reactive-element": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.3.1.tgz", - "integrity": "sha512-nOJARIr3pReqK3hfFCSW2Zg/kFcFsSAlIE7z4a0C9D2dPrgD/YSn3ZP2ET/rxKB65SXyG7jJbkynBRm+tGlacw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.4.1.tgz", + "integrity": "sha512-qDv4851VFSaBWzpS02cXHclo40jsbAjRXnebNXpm0uVg32kCneZPo9RYVQtrTNICtZ+1wAYHu1ZtxWSWMbKrBw==", "dev": true } } }, "@open-wc/semantic-dom-diff": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.19.5.tgz", - "integrity": "sha512-Wi0Fuj3dzqlWClU0y+J4k/nqTcH0uwgOWxZXPyeyG3DdvuyyjgiT4L4I/s6iVShWQvvEsyXnj7yVvixAo3CZvg==", + "version": "0.19.7", + "resolved": "https://registry.npmjs.org/@open-wc/semantic-dom-diff/-/semantic-dom-diff-0.19.7.tgz", + "integrity": "sha512-ahwHb7arQXXnkIGCrOsM895FJQrU47VWZryCsSSzl5nB3tJKcJ8yjzQ3D/yqZn6v8atqOz61vaY05aNsqoz3oA==", "dev": true, "requires": { - "@types/chai": "^4.2.11", - "@web/test-runner-commands": "^0.5.7" + "@types/chai": "^4.3.1", + "@web/test-runner-commands": "^0.6.1" } }, "@open-wc/testing": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@open-wc/testing/-/testing-3.1.2.tgz", - "integrity": "sha512-2KjEszLItrIEZwCLFjWOSy4rnLzLOpgckrKfZjNA39PpFR3xD9bqYU30TTnLRHBk2B/0ZUbHglyca3iwcF964w==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/@open-wc/testing/-/testing-3.1.6.tgz", + "integrity": "sha512-MIf9cBtac4/UBE5a+R5cXiRhOGfzetsV+ZPFc188AfkPDPbmffHqjrRoCyk4B/qS6fLEulSBMLSaQ+6ze971gQ==", "dev": true, "requires": { - "@esm-bundle/chai": "^4.3.4", + "@esm-bundle/chai": "^4.3.4-fix.0", "@open-wc/chai-dom-equals": "^0.12.36", - "@open-wc/semantic-dom-diff": "^0.19.5", + "@open-wc/semantic-dom-diff": "^0.19.7", "@open-wc/testing-helpers": "^2.1.2", "@types/chai": "^4.2.11", - "@types/chai-dom": "^0.0.9", + "@types/chai-dom": "^0.0.12", "@types/sinon-chai": "^3.2.3", "chai-a11y-axe": "^1.3.2" } }, "@open-wc/testing-helpers": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@open-wc/testing-helpers/-/testing-helpers-2.1.2.tgz", - "integrity": "sha512-NEdsV47DnOWaw3Wpp85p4qZ6bdubtGPdlTiblk8vSf2HJ2sR4b3ckyRWzsj/k+pcxrDGt8z0Awz71p+048Rrfg==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@open-wc/testing-helpers/-/testing-helpers-2.1.3.tgz", + "integrity": "sha512-hQujGaWncmWLx/974jq5yf2jydBNNTwnkISw2wLGiYgX34+3R6/ns301Oi9S3Il96Kzd8B7avdExp/gDgqcF5w==", "dev": true, "requires": { - "@open-wc/scoped-elements": "^2.0.1", + "@open-wc/scoped-elements": "^2.1.3", "lit": "^2.0.0", "lit-html": "^2.0.0" }, "dependencies": { "lit-html": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.2.1.tgz", - "integrity": "sha512-AiJ/Rs0awjICs2FioTnHSh+Np5dhYSkyRczKy3wKjp8qjLhr1Ov+GiHrUQNdX8ou1LMuznpIME990AZsa/tR8g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.3.1.tgz", + "integrity": "sha512-FyKH6LTW6aBdkfNhNSHyZTnLgJSTe5hMk7HFtc/+DcN1w74C215q8B+Cfxc2OuIEpBNcEKxgF64qL8as30FDHA==", "dev": true, "requires": { "@types/trusted-types": "^2.0.2" @@ -10893,31 +10000,28 @@ } }, "@pawel-up/data-mock": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@pawel-up/data-mock/-/data-mock-0.1.7.tgz", - "integrity": "sha512-1sCVyyiJvN3bAjr5ZPWs4iALchm6v1hZfmowenjabduMVxvx+dAEkeowSyL07F+wWtnFTLvRNvf7DiK6OuwzVA==" + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@pawel-up/data-mock/-/data-mock-0.3.2.tgz", + "integrity": "sha512-OtnZGTpINoY75crmQiJ4jlokxAGSPx+1fLK7vWMizSG/1Vbtau17x6vfOt6GtTjw7tJ4Bkbj11bmjYumLT0r6w==", + "requires": { + "@types/har-format": "^1.2.7" + } }, "@pawel-up/html.md": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@pawel-up/html.md/-/html.md-0.1.0.tgz", "integrity": "sha512-xJjiWGJUOaTZd9W5KgFfrwnjQTDT46lHs3i4zFkBi+nCGk5M/WRDX1RGEfjRAIE5BKvGn/kXeKXbjefNnT6msQ==" }, - "@polymer/font-roboto": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@polymer/font-roboto/-/font-roboto-3.0.2.tgz", - "integrity": "sha512-tx5TauYSmzsIvmSqepUPDYbs4/Ejz2XbZ1IkD7JEGqkdNUJlh+9KU85G56Tfdk/xjEZ8zorFfN09OSwiMrIQWA==", - "dev": true - }, "@rollup/plugin-node-resolve": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", - "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz", + "integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", "deepmerge": "^4.2.2", + "is-builtin-module": "^3.1.0", "is-module": "^1.0.0", "resolve": "^1.19.0" } @@ -10943,9 +10047,9 @@ } }, "@sinonjs/fake-timers": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.1.tgz", - "integrity": "sha512-Wp5vwlZ0lOqpSYGKqr53INws9HLkt6JDc/pDZcPf7bchQnrXJMXPns8CXx0hFikMSGSWfvtvvpb2gtMVfkWagA==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz", + "integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==", "dev": true, "requires": { "@sinonjs/commons": "^1.7.0" @@ -10963,33 +10067,33 @@ } }, "@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz", + "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, "@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", "dev": true }, "@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", "dev": true }, "@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", "dev": true }, "@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", "dev": true }, "@types/accepts": { @@ -11018,15 +10122,15 @@ } }, "@types/chai": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz", - "integrity": "sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", "dev": true }, "@types/chai-dom": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@types/chai-dom/-/chai-dom-0.0.9.tgz", - "integrity": "sha512-jj4F2NJog2/GBYsyJ8+NvhnWUBbPY4MUAKLdPJE6+568rw12GGXvj0ycUuP5nndVrnJgozmJAoMTvxvjJATXWw==", + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@types/chai-dom/-/chai-dom-0.0.12.tgz", + "integrity": "sha512-4rE7sDw713cV61TYzQbMrPjC4DjNk3x4vk9nAVRNXcSD4p0/5lEEfm0OgoCz5eNuWUXNKA0YiKiH/JDTuKivkA==", "dev": true, "requires": { "@types/chai": "*" @@ -11058,9 +10162,9 @@ } }, "@types/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-0mPF08jn9zYI0n0Q/Pnz7C4kThdSt+6LD4amsrYDDpgBfrVWa3TcCOxKX1zkGgYniGagRv8heN2cbh+CAn+uuQ==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.5.tgz", + "integrity": "sha512-v6LCdKfK6BwcqMo+wYW05rLS12S0ZO0Fl4w1h4aaZMD7bqT3gVUns6FvLJKGZHQmYn3SX55JWGpziwJRwVgutA==", "dev": true }, "@types/convert-source-map": { @@ -11087,6 +10191,15 @@ "integrity": "sha512-epMsEE85fi4lfmJUH/89/iV/LI+F5CvNIvmgs5g5jYFPfhO2S/ae8WSsLOKWdwtoaZw9Q2IhJ4tQ5tFCcS/4HA==", "dev": true }, + "@types/dompurify": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-2.3.4.tgz", + "integrity": "sha512-EXzDatIb5EspL2eb/xPGmaC8pePcTHrkDCONjeisusLFrVfl38Pjea/R0YJGu3k9ZQadSvMqW0WXPI2hEo2Ajg==", + "dev": true, + "requires": { + "@types/trusted-types": "*" + } + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -11094,9 +10207,9 @@ "dev": true }, "@types/express": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", - "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.14.tgz", + "integrity": "sha512-TEbt+vaPFQ+xpxFLFssxUDXj5cWCxZJjIcB7Yg0k0GMHGtgtQgpvx/MUQUeAkNbA9AAGrwkAsoeItdTgS7FMyg==", "dev": true, "requires": { "@types/body-parser": "*", @@ -11106,9 +10219,9 @@ } }, "@types/express-serve-static-core": { - "version": "4.17.28", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz", - "integrity": "sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==", + "version": "4.17.31", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", + "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", "dev": true, "requires": { "@types/node": "*", @@ -11116,6 +10229,11 @@ "@types/range-parser": "*" } }, + "@types/har-format": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.8.tgz", + "integrity": "sha512-OP6L9VuZNdskgNN3zFQQ54ceYD8OLq5IbqO4VK91ORLfOm7WdT/CiT/pHEBSQEqCInJ2y3O6iCm/zGtPElpgJQ==" + }, "@types/http-assert": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.3.tgz", @@ -11152,10 +10270,16 @@ "@types/istanbul-lib-report": "*" } }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, "@types/keygrip": { @@ -11165,9 +10289,9 @@ "dev": true }, "@types/koa": { - "version": "2.13.4", - "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.13.4.tgz", - "integrity": "sha512-dfHYMfU+z/vKtQB7NUrthdAEiSvnLebvBjwHtfFmpZmB7em2N3WVQdHgnFq+xvyVgxW5jKDmjWfLD3lw4g4uTw==", + "version": "2.13.5", + "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.13.5.tgz", + "integrity": "sha512-HSUOdzKz3by4fnqagwthW/1w/yJspTgppyyalPVbgZf8jQWvdIXcVW5h2DGtw4zYntOaeRGx49r1hxoPWrD4aA==", "dev": true, "requires": { "@types/accepts": "*", @@ -11190,9 +10314,9 @@ } }, "@types/mime": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", - "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", + "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==", "dev": true }, "@types/minimist": { @@ -11208,9 +10332,9 @@ "dev": true }, "@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "version": "18.7.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.18.tgz", + "integrity": "sha512-m+6nTEOadJZuTPkKR/SYK3A2d7FZrgElol9UP1Kae90VVU4a6mxnPuLiIW1m4Cq4gZ/nWb9GrdVXJCoCazDAbg==", "dev": true }, "@types/normalize-package-data": { @@ -11253,19 +10377,19 @@ } }, "@types/serve-static": { - "version": "1.13.10", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", - "integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", "dev": true, "requires": { - "@types/mime": "^1", + "@types/mime": "*", "@types/node": "*" } }, "@types/sinon": { - "version": "10.0.11", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", - "integrity": "sha512-dmZsHlBsKUtBpHriNjlK0ndlvEh8dcb9uV9Afsbt89QIyydpC7NcR+nWlAhASfy3GHnxTl4FX/aKE7XZUt/B4g==", + "version": "10.0.13", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.13.tgz", + "integrity": "sha512-UVjDqJblVNQYvVNUsj0PuYYw0ELRmgt1Nt5Vk0pT5f16ROGfcKJY8o1HVuMOJOpD727RrGB9EGvoaTQE5tgxZQ==", "dev": true, "requires": { "@types/sinonjs__fake-timers": "*" @@ -11282,9 +10406,9 @@ } }, "@types/sinonjs__fake-timers": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.1.tgz", - "integrity": "sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz", + "integrity": "sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA==", "dev": true }, "@types/trusted-types": { @@ -11302,15 +10426,140 @@ } }, "@types/yauzl": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz", - "integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==", "dev": true, "optional": true, "requires": { "@types/node": "*" } }, + "@typescript-eslint/eslint-plugin": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.38.0.tgz", + "integrity": "sha512-GgHi/GNuUbTOeoJiEANi0oI6fF3gBQc3bGFYj40nnAPCbhrtEDf2rjBmefFadweBmO1Du1YovHeDP2h5JLhtTQ==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/type-utils": "5.38.0", + "@typescript-eslint/utils": "5.38.0", + "debug": "^4.3.4", + "ignore": "^5.2.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "dependencies": { + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/parser": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.38.0.tgz", + "integrity": "sha512-/F63giJGLDr0ms1Cr8utDAxP2SPiglaD6V+pCOcG35P2jCqdfR7uuEhz1GIC3oy4hkUF8xA1XSXmd9hOh/a5EA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/typescript-estree": "5.38.0", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.38.0.tgz", + "integrity": "sha512-ByhHIuNyKD9giwkkLqzezZ9y5bALW8VNY6xXcP+VxoH4JBDKjU5WNnsiD4HJdglHECdV+lyaxhvQjTUbRboiTA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/visitor-keys": "5.38.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.38.0.tgz", + "integrity": "sha512-iZq5USgybUcj/lfnbuelJ0j3K9dbs1I3RICAJY9NZZpDgBYXmuUlYQGzftpQA9wC8cKgtS6DASTvF3HrXwwozA==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "5.38.0", + "@typescript-eslint/utils": "5.38.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.38.0.tgz", + "integrity": "sha512-HHu4yMjJ7i3Cb+8NUuRCdOGu2VMkfmKyIJsOr9PfkBVYLYrtMCK/Ap50Rpov+iKpxDTfnqvDbuPLgBE5FwUNfA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.38.0.tgz", + "integrity": "sha512-6P0RuphkR+UuV7Avv7MU3hFoWaGcrgOdi8eTe1NwhMp2/GjUJoODBTRWzlHpZh6lFOaPmSvgxGlROa0Sg5Zbyg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/visitor-keys": "5.38.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "dependencies": { + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/utils": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.38.0.tgz", + "integrity": "sha512-6sdeYaBgk9Fh7N2unEXGz+D+som2QCQGPAf1SxrkEr+Z32gMreQ0rparXTNGRRfYUWk/JzbGdcM8NSSd6oqnTA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.38.0", + "@typescript-eslint/types": "5.38.0", + "@typescript-eslint/typescript-estree": "5.38.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.38.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.38.0.tgz", + "integrity": "sha512-MxnrdIyArnTi+XyFLR+kt/uNAcdOnmT+879os7qDRI+EYySR4crXJq9BXPfRzzLGq0wgxkwidrCJ9WCAoacm1w==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.38.0", + "eslint-visitor-keys": "^3.3.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "dev": true + } + } + }, "@web/browser-logs": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/@web/browser-logs/-/browser-logs-0.2.5.tgz", @@ -11330,9 +10579,9 @@ }, "dependencies": { "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -11341,16 +10590,16 @@ } }, "@web/dev-server": { - "version": "0.1.30", - "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.1.30.tgz", - "integrity": "sha512-nUKR+lq06gaCvH6vKmfhPe/Kka1Xp7yN1FN5NEx+Yk4+9CyxZ3UJt2eHXedrcz+XCafxExW114ElEDgCahJowg==", + "version": "0.1.34", + "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.1.34.tgz", + "integrity": "sha512-+te6iwxAQign1KyhHpkR/a3+5qw/Obg/XWCES2So6G5LcZ86zIKXbUpWAJuNOqiBV6eGwqEB1AozKr2Jj7gj/Q==", "dev": true, "requires": { "@babel/code-frame": "^7.12.11", "@types/command-line-args": "^5.0.0", "@web/config-loader": "^0.1.3", - "@web/dev-server-core": "^0.3.17", - "@web/dev-server-rollup": "^0.3.13", + "@web/dev-server-core": "^0.3.19", + "@web/dev-server-rollup": "^0.3.19", "camelcase": "^6.2.0", "command-line-args": "^5.1.1", "command-line-usage": "^6.1.1", @@ -11363,9 +10612,9 @@ } }, "@web/dev-server-core": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.3.17.tgz", - "integrity": "sha512-vN1dwQ8yDHGiAvCeUo9xFfjo+pFl8TW+pON7k9kfhbegrrB8CKhJDUxmHbZsyQUmjf/iX57/LhuWj1xGhRL8AA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.3.19.tgz", + "integrity": "sha512-Q/Xt4RMVebLWvALofz1C0KvP8qHbzU1EmdIA2Y1WMPJwiFJFhPxdr75p9YxK32P2t0hGs6aqqS5zE0HW9wYzYA==", "dev": true, "requires": { "@types/koa": "^2.11.6", @@ -11373,7 +10622,7 @@ "@web/parse5-utils": "^1.2.0", "chokidar": "^3.4.3", "clone": "^2.1.2", - "es-module-lexer": "^0.9.0", + "es-module-lexer": "^1.0.0", "get-stream": "^6.0.0", "is-stream": "^2.0.0", "isbinaryfile": "^4.0.6", @@ -11389,16 +10638,16 @@ } }, "@web/dev-server-rollup": { - "version": "0.3.15", - "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.3.15.tgz", - "integrity": "sha512-hhxvBmNIY19vXeocYB1IBOuhpVpy1L7jbwBarmvC0QJKZsgkxssNTzXJ8iga70c2+H0c/rBz1xUaKuAcov0uOA==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.3.19.tgz", + "integrity": "sha512-IwiwI+fyX0YuvAOldStlYJ+Zm/JfSCk9OSGIs7+fWbOYysEHwkEVvBwoPowaclSZA44Tobvqt+6ej9udbbZ/WQ==", "dev": true, "requires": { - "@rollup/plugin-node-resolve": "^11.0.1", - "@web/dev-server-core": "^0.3.16", + "@rollup/plugin-node-resolve": "^13.0.4", + "@web/dev-server-core": "^0.3.19", "nanocolors": "^0.2.1", "parse5": "^6.0.1", - "rollup": "^2.66.1", + "rollup": "^2.67.0", "whatwg-url": "^11.0.0" } }, @@ -11413,17 +10662,17 @@ } }, "@web/test-runner": { - "version": "0.13.27", - "resolved": "https://registry.npmjs.org/@web/test-runner/-/test-runner-0.13.27.tgz", - "integrity": "sha512-yVhXK9sPJE2VQs1/KPTIeQvUxh+02OZkn+tgcr0+W8ovvrFD4ucF2X26cpeOTuD+Y67ERUi/EopIze3aelw6sg==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@web/test-runner/-/test-runner-0.14.0.tgz", + "integrity": "sha512-9xVKnsviCqXL/xi48l0GpDDfvdczZsKHfEhmZglGMTL+I5viDMAj0GGe7fD9ygJ6UT2+056a3RzyIW5x9lZTDQ==", "dev": true, "requires": { "@web/browser-logs": "^0.2.2", "@web/config-loader": "^0.1.3", - "@web/dev-server": "^0.1.24", + "@web/dev-server": "^0.1.33", "@web/test-runner-chrome": "^0.10.7", - "@web/test-runner-commands": "^0.6.0", - "@web/test-runner-core": "^0.10.22", + "@web/test-runner-commands": "^0.6.3", + "@web/test-runner-core": "^0.10.27", "@web/test-runner-mocha": "^0.7.5", "camelcase": "^6.2.0", "command-line-args": "^5.1.1", @@ -11434,24 +10683,6 @@ "nanocolors": "^0.2.1", "portfinder": "^1.0.28", "source-map": "^0.7.3" - }, - "dependencies": { - "@web/test-runner-commands": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.6.1.tgz", - "integrity": "sha512-P4aQqp0duumeGdGxQ8TwLnplkrXzpLqb47eSEEqBRS//C1H7s6VskaqEng+k0dbk+cSpEa4RuZGY/G5k8aTjTw==", - "dev": true, - "requires": { - "@web/test-runner-core": "^0.10.20", - "mkdirp": "^1.0.4" - } - }, - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } } }, "@web/test-runner-chrome": { @@ -11467,19 +10698,19 @@ } }, "@web/test-runner-commands": { - "version": "0.5.13", - "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.5.13.tgz", - "integrity": "sha512-FXnpUU89ALbRlh9mgBd7CbSn5uzNtr8gvnQZPOvGLDAJ7twGvZdUJEAisPygYx2BLPSFl3/Mre8pH8zshJb8UQ==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@web/test-runner-commands/-/test-runner-commands-0.6.5.tgz", + "integrity": "sha512-W+wLg10jEAJY9N6tNWqG1daKmAzxGmTbO/H9fFfcgOgdxdn+hHiR4r2/x1iylKbFLujHUQlnjNQeu2d6eDPFqg==", "dev": true, "requires": { - "@web/test-runner-core": "^0.10.20", + "@web/test-runner-core": "^0.10.27", "mkdirp": "^1.0.4" } }, "@web/test-runner-core": { - "version": "0.10.25", - "resolved": "https://registry.npmjs.org/@web/test-runner-core/-/test-runner-core-0.10.25.tgz", - "integrity": "sha512-gH8VXyZbwf+sqPiH4cnXYf86SqwBLtou+0LFFCLaDQRbMlrfi5byAISt39fNX2ejd46bF1cZn6DK+mzb/Xjccw==", + "version": "0.10.27", + "resolved": "https://registry.npmjs.org/@web/test-runner-core/-/test-runner-core-0.10.27.tgz", + "integrity": "sha512-ClV/hSxs4wDm/ANFfQOdRRFb/c0sYywC1QfUXG/nS4vTp3nnt7x7mjydtMGGLmvK9f6Zkubkc1aa+7ryfmVwNA==", "dev": true, "requires": { "@babel/code-frame": "^7.12.11", @@ -11490,7 +10721,7 @@ "@types/istanbul-lib-coverage": "^2.0.3", "@types/istanbul-reports": "^3.0.0", "@web/browser-logs": "^0.2.1", - "@web/dev-server-core": "^0.3.16", + "@web/dev-server-core": "^0.3.18", "chokidar": "^3.4.3", "cli-cursor": "^3.1.0", "co-body": "^6.1.0", @@ -11507,21 +10738,13 @@ "nanoid": "^3.1.25", "open": "^8.0.2", "picomatch": "^2.2.2", - "source-map": "^0.7.3" - }, - "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } + "source-map": "^0.7.3" } }, "@web/test-runner-coverage-v8": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/@web/test-runner-coverage-v8/-/test-runner-coverage-v8-0.4.8.tgz", - "integrity": "sha512-Ib0AscR8Xf9E/V7rf3XOVQTe4vKIbwSTupxV1xGgzj3x4RKUuMUg9FLz9EigZ5iN0mOzZKDllyRS523hbdhDtA==", + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/@web/test-runner-coverage-v8/-/test-runner-coverage-v8-0.4.9.tgz", + "integrity": "sha512-y9LWL4uY25+fKQTljwr0XTYjeWIwU4h8eYidVuLoW3n1CdFkaddv+smrGzzF5j8XY+Mp6TmV9NdxjvMWqVkDdw==", "dev": true, "requires": { "@web/test-runner-core": "^0.10.20", @@ -11541,22 +10764,16 @@ } }, "@web/test-runner-playwright": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/@web/test-runner-playwright/-/test-runner-playwright-0.8.8.tgz", - "integrity": "sha512-bhb0QVldfDoPJqOj5mm1hpE6FReyddc/iIuAkVf/kbJvgggTCT2bWGxUvXJlGzf+4epmDhU+hSTfEoLL9R2vGw==", + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@web/test-runner-playwright/-/test-runner-playwright-0.8.10.tgz", + "integrity": "sha512-DEnPihsxjJAPU/UPe3Wb6GVES4xICUrue0UVVxJL651m4zREuUHwSFm4S+cVq78qYcro3WuvCAnucdVB8bUCNw==", "dev": true, "requires": { "@web/test-runner-core": "^0.10.20", "@web/test-runner-coverage-v8": "^0.4.8", - "playwright": "^1.14.0" + "playwright": "^1.22.2" } }, - "@webcomponents/scoped-custom-element-registry": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@webcomponents/scoped-custom-element-registry/-/scoped-custom-element-registry-0.0.3.tgz", - "integrity": "sha512-lpSzgDCGbM99dytb3+J3Suo4+Bk1E13MPnWB42JK8GwxSAxFz+tC7TTv2hhDSIE2IirGNKNKCf3m08ecu6eAsQ==", - "dev": true - }, "accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -11568,9 +10785,9 @@ } }, "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", "dev": true }, "acorn-jsx": { @@ -11618,11 +10835,12 @@ } }, "amf-client-js": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/amf-client-js/-/amf-client-js-5.0.5.tgz", - "integrity": "sha512-WLCfA2DtN5RsdnDSxRyH5R2VaDagR+Foe6Na42P57FdLUN6UXJM4xjazcK/FCdHqI23RZmOXlceArIHFZt8HOA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/amf-client-js/-/amf-client-js-5.1.0.tgz", + "integrity": "sha512-3/6jyw3i4IlPlPZJX5pEXPzya/TFG2JklVo065hUCHKOQB2u9DTtBCbZyS6HufK30P2ofxyhKEBJbqSULn2TPw==", "dev": true, "requires": { + "@aml-org/amf-antlr-parsers": "0.5.17", "ajv": "6.12.6" } }, @@ -11632,10 +10850,12 @@ "integrity": "sha512-Gz5GIJum35HD1GCsr89nWIIbYsPH1khB8FZGPEJdKXXIi3ReG4ODKY9jlxd5Bb4Lu+f0J4KV2aIyVJ9GWiTQZg==" }, "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "optional": true, + "peer": true }, "ansi-escapes": { "version": "4.3.2", @@ -11702,18 +10922,18 @@ "array-ify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==", "dev": true }, "array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", "get-intrinsic": "^1.1.1", "is-string": "^1.0.7" } @@ -11725,20 +10945,21 @@ "dev": true }, "array.prototype.flat": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz", - "integrity": "sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", "dev": true, "requires": { "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.19.0" + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" } }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", "dev": true }, "astral-regex": { @@ -11748,18 +10969,18 @@ "dev": true }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dev": true, "requires": { "lodash": "^4.17.14" } }, "axe-core": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.1.tgz", - "integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.3.tgz", + "integrity": "sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w==", "dev": true }, "axobject-query": { @@ -11816,20 +11037,6 @@ "fill-range": "^7.0.1" } }, - "browserslist": { - "version": "4.20.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.2.tgz", - "integrity": "sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA==", - "dev": true, - "peer": true, - "requires": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" - } - }, "buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -11843,13 +11050,13 @@ "buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", "dev": true }, "builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true }, "bytes": { @@ -11909,13 +11116,6 @@ } } }, - "caniuse-lite": { - "version": "1.0.30001317", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001317.tgz", - "integrity": "sha512-xIZLh8gBm4dqNX0gkzrBeyI86J2eCjWzYAs40q88smG844YIrN4tVQl/RhquHvKEKImWWFIVh1Lxe5n1G/N+GQ==", - "dev": true, - "peer": true - }, "chai-a11y-axe": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/chai-a11y-axe/-/chai-a11y-axe-1.4.0.tgz", @@ -11959,9 +11159,9 @@ "dev": true }, "chrome-launcher": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz", - "integrity": "sha512-ZQqX5kb9H0+jy1OqLnWampfocrtSZaGl7Ny3F9GRha85o4odbL8x55paUzh51UC7cEmZ5obp3H2Mm70uC2PpRA==", + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.1.tgz", + "integrity": "sha512-UugC8u59/w2AyX5sHLZUHoxBAiSiunUhZa3zZwMH6zPVis0C3dDKiRWyUGIo14tTbZHGVviWxv3PQWZ7taZ4fg==", "dev": true, "requires": { "@types/node": "*", @@ -12042,13 +11242,13 @@ "clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", "dev": true }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true }, "co-body": { @@ -12075,19 +11275,13 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, "colorette": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", - "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==", - "dev": true - }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, "command-line-args": { @@ -12103,14 +11297,14 @@ } }, "command-line-usage": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.1.tgz", - "integrity": "sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.3.tgz", + "integrity": "sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==", "dev": true, "requires": { - "array-back": "^4.0.1", + "array-back": "^4.0.2", "chalk": "^2.4.2", - "table-layout": "^1.0.1", + "table-layout": "^1.0.2", "typical": "^5.2.0" }, "dependencies": { @@ -12129,9 +11323,9 @@ } }, "commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz", + "integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==", "dev": true }, "compare-func": { @@ -12147,9 +11341,88 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "concurrently": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-7.4.0.tgz", + "integrity": "sha512-M6AfrueDt/GEna/Vg9BqQ+93yuvzkSKmoTixnwEJkH0LlcGrRC2eCmjeG1tLLHIYfpYJABokqSGyMcXjm96AFA==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "date-fns": "^2.29.1", + "lodash": "^4.17.21", + "rxjs": "^7.0.0", + "shell-quote": "^1.7.3", + "spawn-command": "^0.0.2-1", + "supports-color": "^8.1.0", + "tree-kill": "^1.2.2", + "yargs": "^17.3.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "confusing-browser-globals": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", @@ -12190,9 +11463,9 @@ } }, "conventional-changelog-conventionalcommits": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.3.tgz", - "integrity": "sha512-LTTQV4fwOM4oLPad317V/QNQ1FY4Hju5qeBIM1uTHbrnCE+Eg4CdRZ3gO2pUeR+tzWdp80M2j3qFFEDWVqOV4g==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", + "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", "dev": true, "requires": { "compare-func": "^2.0.0", @@ -12234,9 +11507,9 @@ } }, "core-js-pure": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz", - "integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==", + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.25.2.tgz", + "integrity": "sha512-ItD7YpW1cUB4jaqFLZXe1AXkyqIxz6GqPnsDV4uF4hVcWh/WAGIqSqw5p0/WdsILM0Xht9s3Koyw05R3K6RtiA==", "dev": true }, "cosmiconfig": { @@ -12253,14 +11526,11 @@ } }, "cosmiconfig-typescript-loader": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-1.0.6.tgz", - "integrity": "sha512-2nEotziYJWtNtoTjKbchj9QrdTT6DBxCvqjNKoDKARw+e2yZmTQCa07uRrykLIZuvSgp69YXLH89UHc0WhdMfQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-4.1.0.tgz", + "integrity": "sha512-HbWIuR5O+XO5Oj9SZ5bzgrD4nN+rfhrm2PMb0FVx+t+XIvC45n8F0oTNnztXtspWGw0i2IzHaUWFD5LzV1JB4A==", "dev": true, - "requires": { - "cosmiconfig": "^7", - "ts-node": "^10.6.0" - } + "requires": {} }, "create-require": { "version": "1.1.1", @@ -12294,6 +11564,12 @@ "integrity": "sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==", "dev": true }, + "date-fns": { + "version": "2.29.3", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", + "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", + "dev": true + }, "debounce": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", @@ -12301,9 +11577,9 @@ "dev": true }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -12312,13 +11588,13 @@ "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", "dev": true }, "decamelize-keys": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "integrity": "sha512-ocLWuYzRPoS9bfiSdDd3cxvrzovVMZnRDVEzAs+hWIVXGDbHxWMECij2OBuyB/An0FFW/nLuq6Kv1i/YC5Qfzg==", "dev": true, "requires": { "decamelize": "^1.1.0", @@ -12328,7 +11604,7 @@ "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", "dev": true } } @@ -12336,7 +11612,7 @@ "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", "dev": true }, "deep-extend": { @@ -12364,18 +11640,19 @@ "dev": true }, "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, "requires": { - "object-keys": "^1.0.12" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" } }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", "dev": true }, "depd": { @@ -12391,21 +11668,21 @@ "dev": true }, "destroy": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.1.1.tgz", - "integrity": "sha512-jxwFW+yrVOLdwqIWvowFOM8UPdhZnvOF6mhXQQLXMxBDLtv2JVJlVJPEwkDv9prqscEtGtmnxuuI6pQKStK1vA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", "dev": true }, "devtools-protocol": { - "version": "0.0.969999", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.969999.tgz", - "integrity": "sha512-6GfzuDWU0OFAuOvBokXpXPLxjOJ5DZ157Ue3sGQQM3LgAamb8m0R0ruSfN0DDu+XG5XJgT50i6zZ/0o8RglreQ==", + "version": "0.0.981744", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", + "integrity": "sha512-0cuGS8+jhR67Fy7qG3i3Pc7Aw494sb9yG9QgpG97SFVWwolgYjlhJg7n+UaHxOQT30d1TYu/EYe9k01ivLErIg==", "dev": true }, "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true }, "dir-glob": { @@ -12427,9 +11704,9 @@ } }, "dom-serializer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", - "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", "dev": true, "requires": { "domelementtype": "^2.0.1", @@ -12459,7 +11736,7 @@ "@types/parse5": { "version": "2.2.34", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-2.2.34.tgz", - "integrity": "sha1-44cKEOgnNacg9i1x3NGDunjvOp0=", + "integrity": "sha512-p3qOvaRsRpFyEmaS36RtLzpdxZZnmxGuT1GMgzkTtTJVFuEw7KFjGK83MFODpJExgX1bEzy9r0NYjMC3IMfi7w==", "dev": true, "requires": { "@types/node": "*" @@ -12474,24 +11751,24 @@ } }, "domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true }, "domhandler": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.0.tgz", - "integrity": "sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", "dev": true, "requires": { "domelementtype": "^2.2.0" } }, "dompurify": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.6.tgz", - "integrity": "sha512-OFP2u/3T1R5CEgWCEONuJ1a5+MFKnOYpkywpUSxv/dj1LeBT1erK+JwM7zK0ROy2BRhqVCf0LRw/kHqKuMkVGg==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.4.0.tgz", + "integrity": "sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA==" }, "domutils": { "version": "2.8.0", @@ -12522,16 +11799,9 @@ "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "dev": true }, - "electron-to-chromium": { - "version": "1.4.85", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.85.tgz", - "integrity": "sha512-K9AsQ41WS2bjZUFpRWfvaS4RjEcRCamEkBJN1Z1TQILBfP1H8QnJ9ti0wiLiMv0sRjX3EHKzgs9jDnmGFx2jXg==", - "dev": true, - "peer": true - }, "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -12541,7 +11811,7 @@ "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "dev": true }, "end-of-stream": { @@ -12558,6 +11828,8 @@ "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", "dev": true, + "optional": true, + "peer": true, "requires": { "ansi-colors": "^4.1.1" } @@ -12584,39 +11856,51 @@ "dev": true }, "es-abstract": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", - "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.2.tgz", + "integrity": "sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==", "dev": true, "requires": { "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.2", "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.2", + "has-property-descriptors": "^1.0.0", + "has-symbols": "^1.0.3", "internal-slot": "^1.0.3", "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.1", + "is-negative-zero": "^2.0.2", "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.1", + "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", - "is-weakref": "^1.0.1", - "object-inspect": "^1.11.0", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.2", "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" } }, "es-module-lexer": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", - "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.0.3.tgz", + "integrity": "sha512-iC67eXHToclrlVhQfpRawDiF8D8sQxNxmbqw5oebegOaJkyx/w9C/k57/5e6yJR2zIByRt9OXdqX50DV2t6ZKw==", "dev": true }, + "es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -12637,23 +11921,25 @@ "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "dev": true }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true }, "eslint": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", - "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.1.tgz", + "integrity": "sha512-w7C1IXCc6fNqjpuYd0yPlcTKKmHlHHktRkzmBPZ+7cvNBQuiNjx0xaMTjAJGCafJhQkrFJooREv0CtrVzmHwqg==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.2.1", - "@humanwhocodes/config-array": "^0.9.2", + "@eslint/eslintrc": "^1.3.2", + "@humanwhocodes/config-array": "^0.10.4", + "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@humanwhocodes/module-importer": "^1.0.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -12663,30 +11949,32 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.4.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", + "find-up": "^5.0.0", "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "globals": "^13.15.0", + "globby": "^11.1.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "dependencies": { "ansi-styles": { @@ -12761,9 +12049,9 @@ } }, "globals": { - "version": "13.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", - "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -12792,6 +12080,18 @@ } } }, + "eslint-config-airbnb-base": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", + "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", + "dev": true, + "requires": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.5", + "semver": "^6.3.0" + } + }, "eslint-config-prettier": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", @@ -12821,13 +12121,12 @@ } }, "eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", + "integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==", "dev": true, "requires": { - "debug": "^3.2.7", - "find-up": "^2.1.0" + "debug": "^3.2.7" }, "dependencies": { "debug": { @@ -12838,49 +12137,6 @@ "requires": { "ms": "^2.1.1" } - }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true } } }, @@ -12894,9 +12150,9 @@ } }, "eslint-plugin-import": { - "version": "2.25.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz", - "integrity": "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", "dev": true, "requires": { "array-includes": "^3.1.4", @@ -12904,14 +12160,14 @@ "debug": "^2.6.9", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.2", + "eslint-module-utils": "^2.7.3", "has": "^1.0.3", - "is-core-module": "^2.8.0", + "is-core-module": "^2.8.1", "is-glob": "^4.0.3", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "object.values": "^1.1.5", - "resolve": "^1.20.0", - "tsconfig-paths": "^3.12.0" + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" }, "dependencies": { "debug": { @@ -12935,7 +12191,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -12952,9 +12208,9 @@ } }, "eslint-plugin-lit-a11y": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-lit-a11y/-/eslint-plugin-lit-a11y-2.2.0.tgz", - "integrity": "sha512-1Vy9mR7UGigPnOHj5qJMU3uEK+Qul7dQOg9I6YKEYrw3C3HUx1FS/FbICjZI+n/v+2qvvJhw+5Tghuld2QWUJw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-lit-a11y/-/eslint-plugin-lit-a11y-2.2.2.tgz", + "integrity": "sha512-9dJfnwPOOA6x7Ow/+GFoOt1hr4mSNrF6KBWQ2OFFAY/9aBYtyBX4fRbpxqS2y3ld66/bjWru2+LGWgNVr5GxzQ==", "dev": true, "requires": { "aria-query": "^4.2.2", @@ -12994,13 +12250,6 @@ "js-levenshtein-esm": "^1.2.0" } }, - "eslint-rule-composer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", - "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", - "dev": true, - "peer": true - }, "eslint-rule-extender": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/eslint-rule-extender/-/eslint-rule-extender-0.0.1.tgz", @@ -13033,13 +12282,13 @@ "dev": true }, "espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", + "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", "dev": true, "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "dependencies": { @@ -13051,12 +12300,6 @@ } } }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, "esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", @@ -13112,7 +12355,7 @@ "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "dev": true }, "execa": { @@ -13162,9 +12405,9 @@ "dev": true }, "fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -13183,7 +12426,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "fastq": { @@ -13198,7 +12441,7 @@ "fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", "dev": true, "requires": { "pend": "~1.2.0" @@ -13252,15 +12495,15 @@ } }, "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "dev": true }, "fs-constants": { @@ -13270,9 +12513,9 @@ "dev": true }, "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "requires": { "graceful-fs": "^4.2.0", @@ -13283,7 +12526,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { @@ -13299,18 +12542,23 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", "dev": true, - "peer": true + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + } + }, + "functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true }, "get-caller-file": { "version": "2.0.5", @@ -13319,14 +12567,14 @@ "dev": true }, "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.3" } }, "get-stream": { @@ -13359,15 +12607,15 @@ } }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -13384,19 +12632,12 @@ "global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "integrity": "sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==", "dev": true, "requires": { "ini": "^1.3.4" } }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "peer": true - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -13412,9 +12653,15 @@ } }, "graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, "hard-rejection": { @@ -13433,17 +12680,26 @@ } }, "has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.1" + } + }, "has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -13512,15 +12768,15 @@ "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", "dev": true } } }, "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "requires": { "agent-base": "6", @@ -13534,9 +12790,9 @@ "dev": true }, "husky": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", - "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true }, "iconv-lite": { @@ -13581,7 +12837,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true }, "indent-string": { @@ -13593,13 +12849,13 @@ "inflation": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.0.0.tgz", - "integrity": "sha1-i0F+R8KPklpFEz2RTKH9OJEH8w8=", + "integrity": "sha512-m3xv4hJYR2oXw4o4Y5l6P5P16WYmazYof+el6Al3f+YlggGj6qT9kImBAnzDelRALnP5d3h4jGBPKzYCizjZZw==", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -13630,15 +12886,15 @@ } }, "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", "dev": true }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, "is-bigint": { @@ -13669,16 +12925,25 @@ "has-tostringtag": "^1.0.0" } }, + "is-builtin-module": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", + "dev": true, + "requires": { + "builtin-modules": "^3.3.0" + } + }, "is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.6.tgz", + "integrity": "sha512-krO72EO2NptOGAX2KYyqbP9vYMlNAXdB53rq6f8LXY6RY7JdSR/3BD6wLUlPHSAesmY9vstNrjvqGaCiRK/91Q==", "dev": true }, "is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", "dev": true, "requires": { "has": "^1.0.3" @@ -13702,7 +12967,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -13732,7 +12997,7 @@ "is-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", "dev": true }, "is-negative-zero": { @@ -13748,9 +13013,9 @@ "dev": true }, "is-number-object": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", - "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, "requires": { "has-tostringtag": "^1.0.0" @@ -13765,7 +13030,7 @@ "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", "dev": true }, "is-potential-custom-element-name": { @@ -13785,10 +13050,13 @@ } }, "is-shared-array-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz", - "integrity": "sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==", - "dev": true + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } }, "is-stream": { "version": "2.0.1", @@ -13817,7 +13085,7 @@ "is-text-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", + "integrity": "sha512-xFuJpne9oFz5qDaodwmmG08e3CawH/2ZV8Qqza1Ko7Sk8POWbkRdwIoAWVhqvq0XeUzANEhKo2n0IXUGBm7A/w==", "dev": true, "requires": { "text-extensions": "^1.0.0" @@ -13826,7 +13094,7 @@ "is-valid-element-name": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-valid-element-name/-/is-valid-element-name-1.0.0.tgz", - "integrity": "sha1-Ju8/12zfHxItEFQG4y01sN4AWYE=", + "integrity": "sha512-GZITEJY2LkSjQfaIPBha7eyZv+ge0PhBR7KITeCCWvy7VBQrCUdFkvpI+HrAPQjVtVjy1LvlEkqQTHckoszruw==", "dev": true, "requires": { "is-potential-custom-element-name": "^1.0.0" @@ -13853,19 +13121,19 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "isbinaryfile": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.8.tgz", - "integrity": "sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "istanbul-lib-coverage": { @@ -13903,27 +13171,27 @@ } }, "istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", "dev": true, "requires": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" } }, - "jpeg-js": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.3.tgz", - "integrity": "sha512-ru1HWKek8octvUHFHvE5ZzQ1yAsJmIvRdGWvSoKV52XKyuyYA437QWDttXT8eZXDSbuMpHlLzPDZUPd6idIz+Q==", - "dev": true - }, "js-levenshtein-esm": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/js-levenshtein-esm/-/js-levenshtein-esm-1.2.0.tgz", "integrity": "sha512-fzreKVq1eD7eGcQr7MtRpQH94f8gIfhdrc7yeih38xh684TNMK9v5aAu2wxfIRMk/GpAJRrzcirMAPIaSDaByQ==", "dev": true }, + "js-sdsl": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.4.tgz", + "integrity": "sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -13939,13 +13207,6 @@ "argparse": "^2.0.1" } }, - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, - "peer": true - }, "json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -13961,17 +13222,16 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, - "peer": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.0" } }, "jsonc-parser": { @@ -13993,7 +13253,7 @@ "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", "dev": true }, "JSONStream": { @@ -14007,9 +13267,9 @@ } }, "jsrsasign": { - "version": "10.5.12", - "resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-10.5.12.tgz", - "integrity": "sha512-YE03UOxqAkF7smFH/WKsDO8uPsvK3n+OUaT4qV77YwGJ+IiWwNyBh7XILQ+k1BSIdrsMWsEb2vyoBAw6aP5EBQ==", + "version": "10.5.27", + "resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-10.5.27.tgz", + "integrity": "sha512-1F4LmDeJZHYwoVvB44jEo2uZL3XuwYNzXCDOu53Ui6vqofGQ/gCYDmaxfVZtN0TGd92UKXr/BONcfrPonUIcQQ==", "peer": true }, "just-extend": { @@ -14122,15 +13382,15 @@ } }, "language-subtag-registry": { - "version": "0.3.21", - "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz", - "integrity": "sha512-L0IqwlIXjilBVVYKFT37X9Ih11Um5NEl9cbJIuU/SwP/zEEAbBPOnEeeuxVMf45ydWQRDQN3Nqc96OgbH1K+Pg==", + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", + "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==", "dev": true }, "language-tags": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", - "integrity": "sha1-0yHbxNowuovzAk4ED6XBRmH5GTo=", + "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", "dev": true, "requires": { "language-subtag-registry": "~0.3.2" @@ -14168,15 +13428,15 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } }, "lilconfig": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.4.tgz", - "integrity": "sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.5.tgz", + "integrity": "sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==", "dev": true }, "lines-and-columns": { @@ -14186,30 +13446,95 @@ "dev": true }, "lint-staged": { - "version": "12.3.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.5.tgz", - "integrity": "sha512-oOH36RUs1It7b9U/C7Nl/a0sLfoIBcMB8ramiB3nuJ6brBqzsWiUAFSR5DQ3yyP/OR7XKMpijtgKl2DV1lQ3lA==", + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.0.3.tgz", + "integrity": "sha512-9hmrwSCFroTSYLjflGI8Uk+GWAwMB4OlpU4bMJEAT5d/llQwtYKoim4bLOyLCuWFAhWEupE0vkIFqtw/WIsPug==", "dev": true, "requires": { "cli-truncate": "^3.1.0", - "colorette": "^2.0.16", - "commander": "^8.3.0", - "debug": "^4.3.3", - "execa": "^5.1.1", - "lilconfig": "2.0.4", - "listr2": "^4.0.1", - "micromatch": "^4.0.4", + "colorette": "^2.0.17", + "commander": "^9.3.0", + "debug": "^4.3.4", + "execa": "^6.1.0", + "lilconfig": "2.0.5", + "listr2": "^4.0.5", + "micromatch": "^4.0.5", "normalize-path": "^3.0.0", - "object-inspect": "^1.12.0", + "object-inspect": "^1.12.2", + "pidtree": "^0.6.0", "string-argv": "^0.3.1", - "supports-color": "^9.2.1", - "yaml": "^1.10.2" + "yaml": "^2.1.1" }, "dependencies": { - "supports-color": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.2.1.tgz", - "integrity": "sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ==", + "execa": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz", + "integrity": "sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^3.0.1", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + } + }, + "human-signals": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", + "integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==", + "dev": true + }, + "is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true + }, + "mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true + }, + "npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dev": true, + "requires": { + "path-key": "^4.0.0" + } + }, + "onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "requires": { + "mimic-fn": "^4.0.0" + } + }, + "path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true + }, + "strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true + }, + "yaml": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", "dev": true } } @@ -14301,33 +13626,33 @@ } }, "lit": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit/-/lit-2.2.1.tgz", - "integrity": "sha512-dSe++R50JqrvNGXmI9OE13de1z5U/Y3J2dTm/9GC86vedI8ILoR8ZGnxfThFpvQ9m0lR0qRnIR4IiKj/jDCfYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.3.1.tgz", + "integrity": "sha512-TejktDR4mqG3qB32Y8Lm5Lye3c8SUehqz7qRsxe1PqGYL6me2Ef+jeQAEqh20BnnGncv4Yxy2njEIT0kzK1WCw==", "requires": { - "@lit/reactive-element": "^1.3.0", + "@lit/reactive-element": "^1.4.0", "lit-element": "^3.2.0", - "lit-html": "^2.2.0" + "lit-html": "^2.3.0" }, "dependencies": { "@lit/reactive-element": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.3.1.tgz", - "integrity": "sha512-nOJARIr3pReqK3hfFCSW2Zg/kFcFsSAlIE7z4a0C9D2dPrgD/YSn3ZP2ET/rxKB65SXyG7jJbkynBRm+tGlacw==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.4.1.tgz", + "integrity": "sha512-qDv4851VFSaBWzpS02cXHclo40jsbAjRXnebNXpm0uVg32kCneZPo9RYVQtrTNICtZ+1wAYHu1ZtxWSWMbKrBw==" }, "lit-element": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.2.0.tgz", - "integrity": "sha512-HbE7yt2SnUtg5DCrWt028oaU4D5F4k/1cntAFHTkzY8ZIa8N0Wmu92PxSxucsQSOXlODFrICkQ5x/tEshKi13g==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.2.2.tgz", + "integrity": "sha512-6ZgxBR9KNroqKb6+htkyBwD90XGRiqKDHVrW/Eh0EZ+l+iC+u+v+w3/BA5NGi4nizAVHGYvQBHUDuSmLjPp7NQ==", "requires": { "@lit/reactive-element": "^1.3.0", "lit-html": "^2.2.0" } }, "lit-html": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.2.1.tgz", - "integrity": "sha512-AiJ/Rs0awjICs2FioTnHSh+Np5dhYSkyRczKy3wKjp8qjLhr1Ov+GiHrUQNdX8ou1LMuznpIME990AZsa/tR8g==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.3.1.tgz", + "integrity": "sha512-FyKH6LTW6aBdkfNhNSHyZTnLgJSTe5hMk7HFtc/+DcN1w74C215q8B+Cfxc2OuIEpBNcEKxgF64qL8as30FDHA==", "requires": { "@types/trusted-types": "^2.0.2" } @@ -14365,13 +13690,13 @@ "lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", "dev": true }, "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, "lodash.merge": { @@ -14380,12 +13705,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "lodash.truncate": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", - "dev": true - }, "log-update": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", @@ -14500,20 +13819,20 @@ "dev": true }, "marked": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", - "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz", + "integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==" }, "marky": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.4.tgz", - "integrity": "sha512-zd2/GiSn6U3/jeFVZ0J9CA1LzQ8RfIVvXkb/U0swFHF/zT+dVohTAWjmo2DcIuofmIIIROlwTbd+shSeXmxr0w==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz", + "integrity": "sha512-q9JtQJKjpsVxCRVgQ+WapguSbKC3SQ5HEzFGPAJMStgh3QjCawp00UKv3MTTAArTmGmmPUvllHZoNbZ3gs0I+Q==", "dev": true }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", "dev": true }, "meow": { @@ -14556,21 +13875,15 @@ "dev": true }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" } }, - "mime": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", - "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", - "dev": true - }, "mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -14608,9 +13921,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "minimist-options": { @@ -14654,15 +13967,15 @@ "dev": true }, "nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", "dev": true }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "negotiator": { @@ -14696,19 +14009,19 @@ "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, "requires": { "tr46": "~0.0.3", @@ -14717,13 +14030,6 @@ } } }, - "node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", - "dev": true, - "peer": true - }, "normalize-package-data": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", @@ -14737,9 +14043,9 @@ }, "dependencies": { "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -14763,9 +14069,9 @@ } }, "object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", "dev": true }, "object-keys": { @@ -14775,14 +14081,14 @@ "dev": true }, "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", "dev": true, "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", "object-keys": "^1.1.1" } }, @@ -14820,7 +14126,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -14838,7 +14144,7 @@ "only": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", - "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=", + "integrity": "sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==", "dev": true }, "open": { @@ -14894,9 +14200,9 @@ } }, "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "parent-module": { @@ -14950,7 +14256,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -14983,38 +14289,20 @@ "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, - "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true, - "peer": true - }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, - "pixelmatch": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.2.1.tgz", - "integrity": "sha512-WjcAdYSnKrrdDdqTcVEY7aB7UhhwjYQKYhHiBXdJef0MOaQeYpUdQ+iVyBLa5YBKS8MPVPPMX7rpOByISLpeEQ==", - "dev": true, - "requires": { - "pngjs": "^4.0.1" - }, - "dependencies": { - "pngjs": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-4.0.1.tgz", - "integrity": "sha512-rf5+2/ioHeQxR6IxuYNYGFytUyG3lma/WW1nsmjeHlWwtb2aByla6dkVc8pmJ9nplzkTA0q2xx7mMWrOTqT4Gg==", - "dev": true - } - } + "pidtree": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", + "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", + "dev": true }, "pkg-dir": { "version": "4.2.0", @@ -15061,74 +14349,33 @@ "requires": { "p-limit": "^2.2.0" } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true } } }, "playwright": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.20.0.tgz", - "integrity": "sha512-YcFXhXttk9yvpc8PMbfvts6KEopXjxdBh47BdOiA7xhjF/gkXeSM0Hs9CSdbL9mp2xtlB5xqE7+D+F2soQOjbA==", + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.26.0.tgz", + "integrity": "sha512-XxTVlvFEYHdatxUkh1KiPq9BclNtFKMi3BgQnl/aactmhN4G9AkZUXwt0ck6NDAOrDFlfibhbM7A1kZwQJKSBw==", "dev": true, "requires": { - "playwright-core": "1.20.0" + "playwright-core": "1.26.0" } }, "playwright-core": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.20.0.tgz", - "integrity": "sha512-d25IRcdooS278Cijlp8J8A5fLQZ+/aY3dKRJvgX5yjXA69N0huIUdnh3xXSgn+LsQ9DCNmB7Ngof3eY630jgdA==", - "dev": true, - "requires": { - "colors": "1.4.0", - "commander": "8.3.0", - "debug": "4.3.3", - "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", - "jpeg-js": "0.4.3", - "mime": "3.0.0", - "pixelmatch": "5.2.1", - "pngjs": "6.0.0", - "progress": "2.0.3", - "proper-lockfile": "4.1.2", - "proxy-from-env": "1.1.0", - "rimraf": "3.0.2", - "socks-proxy-agent": "6.1.1", - "stack-utils": "2.0.5", - "ws": "8.4.2", - "yauzl": "2.10.0", - "yazl": "2.5.1" - }, - "dependencies": { - "ws": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz", - "integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==", - "dev": true, - "requires": {} - } - } - }, - "pngjs": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz", - "integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==", + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.26.0.tgz", + "integrity": "sha512-p8huU8eU4gD3VkJd3DA1nA7R3XA6rFvFL+1RYS96cSljCF2yJE9CWEHTPF4LqX8KN9MoWCrAfVKP5381X3CZqg==", "dev": true }, "portfinder": { - "version": "1.0.28", - "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz", - "integrity": "sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==", + "version": "1.0.32", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", + "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==", "dev": true, "requires": { - "async": "^2.6.2", - "debug": "^3.1.1", - "mkdirp": "^0.5.5" + "async": "^2.6.4", + "debug": "^3.2.7", + "mkdirp": "^0.5.6" }, "dependencies": { "debug": { @@ -15141,12 +14388,12 @@ } }, "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } } } @@ -15158,9 +14405,9 @@ "dev": true }, "prismjs": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz", - "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==" + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" }, "progress": { "version": "2.0.3", @@ -15168,17 +14415,6 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, - "proper-lockfile": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", - "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.4", - "retry": "^0.12.0", - "signal-exit": "^3.0.2" - } - }, "proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -15202,16 +14438,16 @@ "dev": true }, "puppeteer-core": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.5.1.tgz", - "integrity": "sha512-dobVqWjV34ilyfQHR3BBnCYaekBYTi5MgegEYBRYd3s3uFy8jUpZEEWbaFjG9ETm+LGzR5Lmr0aF6LLuHtiuCg==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.7.0.tgz", + "integrity": "sha512-rXja4vcnAzFAP1OVLq/5dWNfwBGuzcOARJ6qGV7oAZhnLmVRU8G5MsdeQEAOy332ZhkIOnn9jp15R89LKHyp2Q==", "dev": true, "requires": { "cross-fetch": "3.1.5", - "debug": "4.3.3", - "devtools-protocol": "0.0.969999", + "debug": "4.3.4", + "devtools-protocol": "0.0.981744", "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", + "https-proxy-agent": "5.0.1", "pkg-dir": "4.2.0", "progress": "2.0.3", "proxy-from-env": "1.1.0", @@ -15233,13 +14469,13 @@ "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", "dev": true }, "qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dev": true, "requires": { "side-channel": "^1.0.4" @@ -15382,12 +14618,6 @@ "p-limit": "^2.2.0" } }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, "type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -15438,6 +14668,17 @@ "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", "dev": true }, + "regexp.prototype.flags": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" + } + }, "regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -15447,7 +14688,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-from-string": { @@ -15463,12 +14704,12 @@ "dev": true }, "resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "requires": { - "is-core-module": "^2.8.1", + "is-core-module": "^2.9.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" } @@ -15491,7 +14732,7 @@ "resolve-path": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", - "integrity": "sha1-xL2p9e+y/OZSR4c6s2u02DT+Fvc=", + "integrity": "sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==", "dev": true, "requires": { "http-errors": "~1.6.2", @@ -15501,13 +14742,13 @@ "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", "dev": true }, "http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "requires": { "depd": "~1.1.2", @@ -15519,7 +14760,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "setprototypeof": { @@ -15540,12 +14781,6 @@ "signal-exit": "^3.0.2" } }, - "retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", - "dev": true - }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -15568,9 +14803,9 @@ } }, "rollup": { - "version": "2.70.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.1.tgz", - "integrity": "sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==", + "version": "2.79.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz", + "integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -15586,9 +14821,9 @@ } }, "rxjs": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", - "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.6.tgz", + "integrity": "sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw==", "dev": true, "requires": { "tslib": "^2.1.0" @@ -15633,6 +14868,12 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, + "shell-quote": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", + "dev": true + }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -15651,13 +14892,13 @@ "dev": true }, "sinon": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-13.0.1.tgz", - "integrity": "sha512-8yx2wIvkBjIq/MGY1D9h1LMraYW+z1X0mb648KZnKSdvLasvDu7maa0dFaNYdTDczFgbjNw2tOmWdTk9saVfwQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz", + "integrity": "sha512-ugA6BFmE+WrJdh0owRZHToLd32Uw3Lxq6E6LtNRU+xTVBefx632h03Q7apXWRsRdZAJ41LB8aUfn2+O4jsDNMw==", "dev": true, "requires": { "@sinonjs/commons": "^1.8.3", - "@sinonjs/fake-timers": "^9.0.0", + "@sinonjs/fake-timers": "^9.1.2", "@sinonjs/samsam": "^6.1.1", "diff": "^5.0.0", "nise": "^5.1.1", @@ -15698,46 +14939,24 @@ }, "dependencies": { "ansi-styles": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.0.tgz", - "integrity": "sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.1.1.tgz", + "integrity": "sha512-qDOv24WjnYuL+wbwHdlsYZFy+cgPtrYw0Tn7GLORicQp9BkQLzrgI3Pm4VyR9ERZ41YTn7KlMPuL1n05WdZvmg==", "dev": true } } }, - "smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", "dev": true }, - "socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", - "dev": true, - "requires": { - "ip": "^1.1.5", - "smart-buffer": "^4.2.0" - } - }, - "socks-proxy-agent": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", - "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", - "dev": true, - "requires": { - "agent-base": "^6.0.2", - "debug": "^4.3.1", - "socks": "^2.6.1" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "peer": true + "spawn-command": { + "version": "0.0.2-1", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", + "integrity": "sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==", + "dev": true }, "spdx-correct": { "version": "3.1.1", @@ -15766,9 +14985,9 @@ } }, "spdx-license-ids": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz", + "integrity": "sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==", "dev": true }, "split2": { @@ -15780,33 +14999,10 @@ "readable-stream": "^3.0.0" } }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "stack-utils": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz", - "integrity": "sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA==", - "dev": true, - "requires": { - "escape-string-regexp": "^2.0.0" - }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - } - } - }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", "dev": true }, "string_decoder": { @@ -15861,23 +15057,25 @@ } }, "string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" } }, "string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" } }, "strip-ansi": { @@ -15892,7 +15090,7 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true }, "strip-final-newline": { @@ -15931,97 +15129,6 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, - "table": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", - "integrity": "sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA==", - "dev": true, - "requires": { - "ajv": "^8.0.1", - "lodash.truncate": "^4.4.2", - "slice-ansi": "^4.0.0", - "string-width": "^4.2.3", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "ajv": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, - "slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - } - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - } - } - }, "table-layout": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.2.tgz", @@ -16082,13 +15189,13 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "through2": { @@ -16100,13 +15207,6 @@ "readable-stream": "3" } }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true, - "peer": true - }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -16131,6 +15231,12 @@ "punycode": "^2.1.1" } }, + "tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true + }, "trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", @@ -16138,12 +15244,12 @@ "dev": true }, "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "requires": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -16154,7 +15260,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "dependencies": { @@ -16167,32 +15273,21 @@ } }, "tsconfig-paths": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz", - "integrity": "sha512-cg/1jAZoL57R39+wiw4u/SCC6Ic9Q5NqjBOb+9xISedOYurfog9ZNmKJSxAnb2m/5Bq4lE9lhUcau33Ml8DM0g==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", "dev": true, "requires": { "@types/json5": "^0.0.29", "json5": "^1.0.1", - "minimist": "^1.2.0", + "minimist": "^1.2.6", "strip-bom": "^3.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - } } }, "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, "tsscmp": { "version": "1.0.6", @@ -16200,6 +15295,23 @@ "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==", "dev": true }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } + } + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -16232,9 +15344,9 @@ } }, "typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", "dev": true }, "typescript-lit-html-plugin": { @@ -16262,9 +15374,9 @@ } }, "typescript-template-language-service-decorator": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/typescript-template-language-service-decorator/-/typescript-template-language-service-decorator-2.2.0.tgz", - "integrity": "sha512-xiolqt1i7e22rpqMaprPgSFVgU64u3b9n6EJlAaUYE61jumipKAdI1+O5khPlWslpTUj80YzjUKjJ2jxT0D74w==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/typescript-template-language-service-decorator/-/typescript-template-language-service-decorator-2.3.1.tgz", + "integrity": "sha512-+Q5+cvBtPO4VKNyyI6O+XnIne+/hq/WfNhBaF4hJP8nB8TbikTg+2h9uBMsqduwX1+kVfwG9SBSwMTtvi2Ep7w==", "dev": true }, "typical": { @@ -16274,14 +15386,14 @@ "dev": true }, "unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "requires": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" } }, @@ -16304,7 +15416,7 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "dev": true }, "uri-js": { @@ -16319,25 +15431,19 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true }, "v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "v8-to-istanbul": { @@ -16349,14 +15455,6 @@ "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^1.6.0", "source-map": "^0.7.3" - }, - "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } } }, "validate-npm-package-license": { @@ -16372,7 +15470,7 @@ "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", "dev": true }, "vscode-css-languageservice": { @@ -16408,9 +15506,9 @@ } }, "vscode-languageserver-types": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz", - "integrity": "sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==", + "version": "3.17.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", + "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==", "dev": true }, "vscode-nls": { @@ -16550,13 +15648,13 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "dev": true, "requires": {} }, @@ -16579,9 +15677,9 @@ "dev": true }, "yargs": { - "version": "17.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", - "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "version": "17.5.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", + "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", "dev": true, "requires": { "cliui": "^7.0.2", @@ -16617,9 +15715,9 @@ } }, "yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true } } @@ -16633,26 +15731,17 @@ "yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "dev": true, "requires": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, - "yazl": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", - "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==", - "dev": true, - "requires": { - "buffer-crc32": "~0.2.3" - } - }, "ylru": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.2.1.tgz", - "integrity": "sha512-faQrqNMzcPCHGVC2aaOINk13K+aaBDUPjGWl0teOXywElLjyVAB6Oe2jj62jHYtwsU49jXhScYbvPENK+6zAvQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.3.2.tgz", + "integrity": "sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==", "dev": true }, "yn": { diff --git a/package.json b/package.json index 03432e3..ebb1b51 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "@api-components/amf-components", "description": "A set of web components based on LitElement that creates the visualization layer on top of the AMF's graph model.", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "license": "Apache-2.0", + "type": "module", "main": "index.js", "module": "index.js", "keywords": [ @@ -30,78 +31,54 @@ "email": "arc@mulesoft.com" }, "dependencies": { - "@advanced-rest-client/base": "^0.1.0", - "@advanced-rest-client/events": "^0.2.22", - "@advanced-rest-client/highlight": "^2.0.1", - "@advanced-rest-client/http-code-snippets": "^4.0.0", + "@advanced-rest-client/base": "^0.1.10", + "@advanced-rest-client/events": "^18.0.2", + "@advanced-rest-client/highlight": "^2.0.2", + "@advanced-rest-client/http-code-snippets": "^4.0.1", "@advanced-rest-client/icons": "^4.0.0", - "@advanced-rest-client/oauth": "^0.1.0", + "@advanced-rest-client/oauth": "^0.2.1", "@advanced-rest-client/uuid": "^4.0.0", - "@anypoint-web-components/awc": "^1.0.5", - "@api-client/context-menu": "^0.2.0", - "@open-wc/dedupe-mixin": "^1.3.0", - "@pawel-up/data-mock": "^0.1.7", + "@anypoint-web-components/awc": "^3.0.12", + "@api-client/context-menu": "^0.4.1", + "@open-wc/dedupe-mixin": "^1.3.1", + "@pawel-up/data-mock": "^0.3.2", "amf-json-ld-lib": "0.0.14", - "dompurify": "^2.3.3", - "lit-element": "^2.5.1", - "lit-html": "^1.4.1" + "dompurify": "^2.4.0", + "lit": "^2.3.1" }, "devDependencies": { - "@advanced-rest-client/arc-demo-helper": "^5.0.1", - "@commitlint/cli": "^16.2.1", - "@commitlint/config-conventional": "^16.2.1", - "@open-wc/eslint-config": "^7.0.0", - "@open-wc/testing": "^3.0.1", - "@web/dev-server": "^0.1.25", - "@web/test-runner": "^0.13.20", - "@web/test-runner-playwright": "^0.8.8", - "amf-client-js": "^5.0.5", - "eslint": "^8.1.0", - "eslint-config-prettier": "^8.3.0", - "husky": "^7.0.4", - "lint-staged": "^12.3.5", - "sinon": "^13.0.1", - "typescript": "^4.4.4", + "@commitlint/cli": "^17.1.2", + "@commitlint/config-conventional": "^17.1.0", + "@open-wc/eslint-config": "^8.0.2", + "@open-wc/testing": "^3.1.6", + "@types/dompurify": "^2.3.4", + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@typescript-eslint/parser": "^5.22.0", + "@web/dev-server": "^0.1.34", + "@web/test-runner": "^0.14.0", + "@web/test-runner-playwright": "^0.8.10", + "amf-client-js": "^5.1.0", + "concurrently": "^7.4.0", + "eslint": "^8.23.1", + "eslint-config-prettier": "^8.5.0", + "husky": "^8.0.1", + "lint-staged": "^13.0.3", + "sinon": "^14.0.0", + "tslib": "^2.4.0", + "typescript": "^4.8.3", "typescript-lit-html-plugin": "^0.9.0", - "uuid": "^8.3.2" + "uuid": "^9.0.0" }, "scripts": { - "start": "web-dev-server", - "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore", - "format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore", - "lint:types": "tsc", - "lint": "npm run lint:eslint", - "format": "npm run format:eslint", - "test": "web-test-runner test/**/*.test.js --coverage --node-resolve --playwright --browsers chromium webkit", - "test:all": "web-test-runner test/**/*.test.js --coverage --node-resolve --playwright --browsers chromium firefox webkit", - "test:watch": "web-test-runner --node-resolve --watch --playwright --browsers chromium", - "gen:wc": "wca analyze \"*.js\" --outFile custom-elements.json", - "prepare": "husky install && node demo/model.mjs" - }, - "eslintConfig": { - "extends": [ - "@open-wc/eslint-config", - "eslint-config-prettier" - ], - "overrides": [ - { - "files": [ - "demo/**/*.js", - "test/**/*.js", - "dev/**/*.js", - "dev/**/*.mjs", - "**/demo/**/*.html" - ], - "rules": { - "no-console": "off", - "no-unused-expressions": "off", - "no-plusplus": "off", - "no-param-reassing": "off", - "class-methods-use-this": "off", - "import/no-extraneous-dependencies": "off" - } - } - ] + "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"", + "build": "tsc && npm run analyze -- --exclude dist", + "prepublish": "tsc && npm run analyze -- --exclude dist", + "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore", + "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore", + "test": "tsc && wtr --coverage --playwright --browsers chromium", + "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch --playwright --browsers chromium\"", + "prepare": "husky install && node demo/model.mjs", + "tsc:watch": "tsc --watch" }, "husky": { "hooks": { @@ -111,6 +88,9 @@ "lint-staged": { "*.js": [ "eslint --fix" + ], + "*.ts": [ + "eslint --fix" ] } } diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..9a82ea8 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,51 @@ +export { default as ApiOperationDocumentElement } from './elements/ApiOperationDocumentElement.js'; +export { default as ApiParameterDocumentElement } from './elements/ApiParameterDocumentElement.js'; +export { default as ApiPayloadDocumentElement } from './elements/ApiPayloadDocumentElement.js'; +export { default as ApiRequestDocumentElement } from './elements/ApiRequestDocumentElement.js'; +export { default as ApiResourceDocumentElement } from './elements/ApiResourceDocumentElement.js'; +export { default as ApiResponseDocumentElement } from './elements/ApiResponseDocumentElement.js'; +export { default as ApiSchemaDocumentElement } from './elements/ApiSchemaDocumentElement.js'; +export { default as ApiDocumentationDocumentElement } from './elements/ApiDocumentationDocumentElement.js'; +export { default as ApiChannelDocumentElement } from './elements/ApiChannelDocumentElement.js'; +export { default as ApiAnnotationDocumentElement } from './elements/ApiAnnotationDocumentElement.js'; +export { default as ApiSummaryElement } from './elements/ApiSummaryElement.js'; +export { default as XhrSimpleRequestElement } from './elements/XhrSimpleRequestElement.js'; +export { default as XhrSimpleRequestTransportElement } from './elements/XhrSimpleRequestTransportElement.js'; +export { default as ApiRequestElement } from './elements/ApiRequestElement.js'; +export { default as ApiRequestEditorElement } from './elements/ApiRequestEditorElement.js'; +export { default as ApiAuthorizationEditorElement } from './elements/ApiAuthorizationEditorElement.js'; +export { default as ApiAuthorizationMethodElement } from './elements/ApiAuthorizationMethodElement.js'; +export { default as ApiServerSelectorElement } from './elements/ApiServerSelectorElement.js'; +export { default as ApiNavigationElement } from './elements/ApiNavigationElement.js'; +export { default as ApiNavigationLegacyElement } from './elements/ApiNavigationLegacyElement.js'; +export { default as ApiSecurityDocumentElement } from './elements/ApiSecurityDocumentElement.js'; +export { default as ApiParametrizedSecuritySchemeElement } from './elements/ApiParametrizedSecuritySchemeElement.js'; +export { default as ApiSecurityRequirementDocumentElement } from './elements/ApiSecurityRequirementDocumentElement.js'; +export { default as ApiDocumentationElement } from './elements/ApiDocumentationElement.js'; +export * as InputCache from './lib/InputCache.js'; +export * as UrlLib from './lib/UrlUtils.js'; +export * as Utils from './lib/Utils.js'; +export { SecurityProcessor } from './lib/SecurityProcessor.js'; +export * from './types.js' +export { AmfHelperMixin } from './helpers/AmfHelperMixin.js'; +export { AmfSerializer } from './helpers/AmfSerializer.js'; +export { ns } from './helpers/Namespace.js'; +export * as Amf from './helpers/amf.js'; +export * as Api from './helpers/api.js'; +export { ApiExampleGenerator } from './schema/ApiExampleGenerator.js'; +export { ApiMonacoSchemaGenerator } from './schema/ApiMonacoSchemaGenerator.js'; +export { ApiSchemaValues } from './schema/ApiSchemaValues.js'; +export { ApiSchemaGenerator } from './schema/ApiSchemaGenerator.js'; +export { EventTypes as ApiEventTypes } from './events/EventTypes.js'; +export { Events as ApiEvents } from './events/Events.js'; +export { ApiNavigationEventDetail } from './events/NavigationEvents.js'; +export { ReportingErrorEventDetail } from './events/ReportingEvents.js'; +export { AbortRequestEvent, ApiRequestEvent, ApiResponseEvent } from './events/RequestEvents.js'; +export { ServerChangeEvent, ServerChangeEventDetail, ServerCountChangeEvent, ServerCountChangeEventDetail } from './events/ServerEvents.js'; +export { TelemetryCustomMetric, TelemetryCustomValue, TelemetryDetail, TelemetryEventDetail, TelemetryExceptionDetail, TelemetryScreenViewDetail, TelemetrySocialDetail, TelemetryTimingDetail } from './events/TelemetryEvents.js'; +export { DomEventsAmfStore } from './store/DomEventsAmfStore.js'; +export { AmfStore } from './store/AmfStore.js'; +export { AmfStoreDomEventsMixin } from './store/mixins/AmfStoreDomEventsMixin.js'; +export { InMemAmfGraphStore } from './store/InMemAmfGraphStore.js'; +export { NavigationContextMenu } from './plugins/NavigationContextMenu.js'; +export { default as NavigationContextMenuCommands } from './plugins/NavigationCommands.js'; diff --git a/src/lib/AmfInputParser.js b/src/lib/AmfInputParser.ts similarity index 55% rename from src/lib/AmfInputParser.js rename to src/lib/AmfInputParser.ts index cf689ea..c183d90 100644 --- a/src/lib/AmfInputParser.js +++ b/src/lib/AmfInputParser.ts @@ -1,31 +1,21 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-continue */ /* eslint-disable no-param-reassign */ /* eslint-disable class-methods-use-this */ import { ApiSchemaValues } from '../schema/ApiSchemaValues.js'; import { ns } from '../helpers/Namespace.js'; +import { ApiArrayShape, ApiParameter, ApiScalarShape, ApiShapeUnion, ApiUnionShape } from '../helpers/api.js'; -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../helpers/api').ApiFileShape} ApiFileShape */ -/** @typedef {import('../helpers/api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('@anypoint-web-components/awc').SupportedInputTypes} SupportedInputTypes */ - +export interface ParametersSerializationReport { + valid: boolean; + invalid: string[]; + header: Record; + query: Record; + path: Record; + cookie: Record; +} -/** - * @typedef ParametersSerializationReport - * @property {boolean} valid - * @property {string[]} invalid - * @property {Record} header - * @property {Record} query - * @property {Record} path - * @property {Record} cookie - */ +export type BindingType = Pick; /** * A utility class with helper functions to process user input according on AMF schema. @@ -40,34 +30,33 @@ export class AmfInputParser { * * All optional parameters that have no value or have invalid value ar ignored. * - * @param {ApiParameter[]} parameters The input parameters for the operation - * @param {Map} values The collected values for all parameters. - * @param {string[]=} [nillable=[]] The list of parameter ids that are marked as nil values. - * @param {any=} [defaultNil=null] The nil value to insert when the parameter is in the nillable list. - * @returns {ParametersSerializationReport} + * @param parameters The input parameters for the operation + * @param values The collected values for all parameters. + * @param nillable The list of parameter ids that are marked as nil values. + * @param defaultNil The nil value to insert when the parameter is in the nillable list. */ - static reportRequestInputs(parameters, values, nillable=[], defaultNil=null) { - const report = /** @type ParametersSerializationReport */ ({ + static reportRequestInputs(parameters: ApiParameter[], values: Map, nillable: string[]=[], defaultNil: any=null): ParametersSerializationReport { + const report: ParametersSerializationReport = { valid: true, invalid: [], header: {}, query: {}, path: {}, cookie: {}, - }); + }; parameters.forEach((param) => { - const { id, required, schema, binding, name, paramName } = param; + const { id, required, schema, binding = '', name, paramName } = param; const parameterName = paramName || name; if (!parameterName) { return; } - if (!report[binding]) { + if (!report[binding as keyof ParametersSerializationReport]) { // for custom shapes - report[binding] = {}; + report[binding as keyof BindingType] = {}; } if (nillable.includes(id)) { - report[binding][parameterName] = defaultNil; + report[binding as keyof BindingType][parameterName] = defaultNil; return; } let value = values.get(id); @@ -77,7 +66,7 @@ export class AmfInputParser { } if (jsType === 'undefined') { if (schema && schema.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - value = ApiSchemaValues.readInputValue(param, /** @type ApiScalarShape */ (schema)); + value = ApiSchemaValues.readInputValue(param, schema as ApiScalarShape); } } if (!schema) { @@ -85,13 +74,13 @@ export class AmfInputParser { if (Array.isArray(value)) { // this is a huge assumption here. // Todo: this should be done recursively. - report[binding][parameterName] = value.map(i => i === undefined ? i : String(i)); + report[binding as keyof BindingType][parameterName] = value.map(i => i === undefined ? i : String(i)); } else { const isScalar = jsType !== 'undefined' && jsType !== 'object' && value !== null; - report[binding][parameterName] = isScalar ? String(value) : value; + report[binding as keyof BindingType][parameterName] = isScalar ? String(value) : value; } } else { - const valid = AmfInputParser.addReportItem(report[binding], parameterName, schema, value, required); + const valid = AmfInputParser.addReportItem(report[binding as keyof BindingType], parameterName, schema, value, required); if (!valid) { report.valid = false; report.invalid.push(id); @@ -103,37 +92,33 @@ export class AmfInputParser { } /** - * @param {Record} reportGroup - * @param {string} name - * @param {ApiShapeUnion} schema - * @param {any} value - * @param {boolean} required Whether the parameter is required. - * @returns {boolean} `true` when the parameter is valid and `false` otherwise. + * @param reportGroup + * @param name + * @param schema + * @param value + * @param required Whether the parameter is required. + * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportItem(reportGroup, name, schema, value, required) { + static addReportItem(reportGroup: Record, name: string, schema: ApiShapeUnion, value: any, required?: boolean): boolean { const { types } = schema; if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return AmfInputParser.addReportScalarItem(reportGroup, name, value, /** @type ApiScalarShape */ (schema), required); + return AmfInputParser.addReportScalarItem(reportGroup, name, value, (schema as ApiScalarShape), required); } if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return AmfInputParser.addReportArrayItem(reportGroup, name, value, /** @type ApiArrayShape */ (schema), required); + return AmfInputParser.addReportArrayItem(reportGroup, name, value, (schema as ApiArrayShape), required); } if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return AmfInputParser.addReportUnionItem(reportGroup, name, value, /** @type ApiUnionShape */ (schema), required); + return AmfInputParser.addReportUnionItem(reportGroup, name, value, (schema as ApiUnionShape), required); } // ignored parameters are valid (from the form POV). return true; } /** - * @param {Record} reportGroup - * @param {string} name - * @param {any} value - * @param {ApiScalarShape} schema - * @param {boolean=} required Whether the parameter is required. - * @returns {boolean} `true` when the parameter is valid and `false` otherwise. + * @param required Whether the parameter is required. + * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportScalarItem(reportGroup, name, value, schema, required) { + static addReportScalarItem(reportGroup: Record, name: string, value: any, schema: ApiScalarShape, required?: boolean): boolean { const type = typeof value; const isScalar = type !== 'undefined' && type !== 'object' && value !== null; reportGroup[name] = isScalar ? ApiSchemaValues.parseScalarInput(value, schema) : value; @@ -141,14 +126,14 @@ export class AmfInputParser { } /** - * @param {Record} reportGroup - * @param {string} name - * @param {any} value - * @param {ApiArrayShape} schema - * @param {boolean} required Whether the parameter is required. - * @returns {boolean} `true` when the parameter is valid and `false` otherwise. + * @param reportGroup + * @param name + * @param value + * @param schema + * @param required Whether the parameter is required. + * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportArrayItem(reportGroup, name, value, schema, required) { + static addReportArrayItem(reportGroup: Record, name: string, value: any, schema: ApiArrayShape, required?: boolean): boolean { if (!Array.isArray(reportGroup[name])) { reportGroup[name] = []; } @@ -157,7 +142,7 @@ export class AmfInputParser { return !required; } const { items } = schema; - /** @type any[] */ (value).forEach((item) => { + value.forEach((item) => { if (item === undefined) { // the UI generates a default input for array items. We now ignore all // items that are undefined. This means the item was added but the user never provided any @@ -179,16 +164,15 @@ export class AmfInputParser { } /** - * @param {Record} reportGroup - * @param {string} name - * @param {any} value - * @param {ApiUnionShape} schema - * @param {boolean} required Whether the parameter is required. - * @returns {boolean} `true` when the parameter is valid and `false` otherwise. + * @param reportGroup + * @param name + * @param value + * @param schema + * @param required Whether the parameter is required. + * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportUnionItem(reportGroup, name, value, schema, required) { - const typed = /** @type ApiUnionShape */ (schema); - const { anyOf } = typed; + static addReportUnionItem(reportGroup: Record, name: string, value: any, schema: ApiUnionShape, required?: boolean): boolean { + const { anyOf } = schema; if (!anyOf || !anyOf.length) { return !required; } @@ -196,7 +180,7 @@ export class AmfInputParser { if (nil && anyOf.length === 2) { // this item is not marked as nil (or we wouldn't get to this line) so use the only schema left. const scalar = anyOf.find(shape => shape !== nil); - return AmfInputParser.addReportScalarItem(reportGroup, name, value, /** @type ApiScalarShape */ (scalar)); + return AmfInputParser.addReportScalarItem(reportGroup, name, value, scalar as ApiScalarShape); } // we are iterating over each schema in the union. Ignoring non-scalar schemas it parses user input // for each schema and if the result is set (non-undefined) then this value is used. diff --git a/src/lib/AmfParameterMixin.d.ts b/src/lib/AmfParameterMixin.d.ts deleted file mode 100644 index 3644c47..0000000 --- a/src/lib/AmfParameterMixin.d.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { SupportedInputTypes } from '@anypoint-web-components/awc'; -import { - ApiAnyShape, - ApiArrayShape, - ApiParameter, - ApiScalarShape, - ApiShapeUnion, - ApiTupleShape, - ApiUnionShape, -} from '../helpers/api'; -import { TemplateResult } from 'lit-element'; -import { OperationParameter, ShapeTemplateOptions, ParameterRenderOptions } from '../types'; - -export declare function AmfParameterMixin {}>(base: T): T & AmfParameterMixinConstructor; - -interface AmfParameterMixinConstructor { - new(...args: any[]): AmfParameterMixin; - constructor(...args: any[]): AmfParameterMixin; -} - -/** - * This mixin adds support for rendering operation parameter inputs. - * It support: - * - rendering inputs - * - caching user input - * - restoring cache input. - */ -export declare interface AmfParameterMixin { - /** - * By default the element stores user input in a map that is associated with the specific - * instance of this element. This way the element can be used multiple times in the same document. - * However, this way parameter values generated by the generators or entered by the user won't - * get populated in different operations. - * - * By setting this value the element prefers a global cache for values. Once the user enter - * a value it is registered in the global cache and restored when the same parameter is used again. - * - * Do not use this option when the element is embedded multiple times in the page. It will result - * in generating request data from the cache and not what's in the form inputs and these may not be in sync. - * - * These values are stored in memory only. Listen to the `change` event to learn that something changed. - * @attribute; - */ - globalCache: boolean; - parametersValue: OperationParameter[]; - nilValues: string[]; - - /** - * A function to be overwritten by child classes to execute an action when a parameter has changed. - * @param key The key of the property that changed. - */ - paramChanged(key: string): void; - - /** - * Clears previously set values in the cache storage. - */ - clearCache(): void; - - connectedCallback(): void; - - addArrayValueHandler(e: Event): void; - - /** - * Reads the value to be set on an input. - * - * @param isArray Whether the value should be read for an array. - * @returns The value to set on the input. Note, it is not cast to the type. - */ - readInputValue(parameter: ApiParameter, schema: ApiScalarShape, isArray?: boolean): any; - paramChangeHandler(e: Event): void; - booleanHandler(e: Event): void; - /** - * A handler for the remove param button click. - */ - deleteParamHandler(e: Event): void; - enumSelectionHandler(e: Event): void; - /** - * Handler for the nil value toggle. - */ - nilHandler(e: Event): void; - /** - * @returns The template for the request parameter form control. - */ - parameterTemplate(param: OperationParameter, opts?: ParameterRenderOptions): TemplateResult | string; - - /** - * @returns The template for the request parameter form control. - */ - parameterSchemaTemplate(parameter: ApiParameter, schema: ApiShapeUnion, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; - - /** - * @returns The template for the schema parameter. - */ - scalarShapeTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; - - /** - * @return A template for an input form item for the given type and schema - */ - textInputTemplate(parameter: ApiParameter, schema: ApiScalarShape, type?: SupportedInputTypes, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; - - /** - * @param paramId The ApiParameter id. - * @param arrayIndex When this is an array item, the index on the array. - * @returns The template for the param remove button. - */ - deleteParamTemplate(paramId: string, arrayIndex?: number): TemplateResult; - - /** - * @returns The template for the enum input. - */ - enumTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; - - /** - * @returns The template for the checkbox input. - */ - booleanTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts?: ShapeTemplateOptions): TemplateResult; - - /** - * @returns The template for the nil checkbox input. - */ - nillInputTemplate(parameter: ApiParameter): TemplateResult; - - /** - * or now we do not support union shapes. There's no way to learn how to serialize - * the Node shape to a string. - * @returns The template for the node shape. - */ - nodeShapeTemplate(): TemplateResult | string; - - /** - * @returns The template for the union shape. - */ - unionShapeTemplate(parameter: ApiParameter, schema: ApiUnionShape): TemplateResult | string; - - /** - * This situation makes not sense as there's no mechanism to describe how to - * put a file into a path, query, or headers. - * @returns The template for the file shape. - */ - fileShapeTemplate(): TemplateResult | string; - - /** - * For now we do not support union shapes. There's no way to learn how to serialize - * the Schema shape to a string. - * @returns The template for the schema shape. - */ - schemaShapeTemplate(): TemplateResult | string; - - /** - * @returns The template for the array shape. - */ - arrayShapeTemplate(parameter: ApiParameter, schema: ApiArrayShape): TemplateResult | string; - - /** - * @returns The template for the tuple shape. - */ - tupleShapeTemplate(parameter: ApiParameter, schema: ApiTupleShape): TemplateResult | string; - - /** - * @returns The template for the Any shape. - */ - anyShapeTemplate(parameter: ApiParameter, schema: ApiAnyShape): TemplateResult | string; - - /** - * @param {string} id The id of the parameter to add the value to. - * @returns The template for the adding an array item button - */ - addArrayItemTemplate(id: string): TemplateResult; -} diff --git a/src/lib/AmfParameterMixin.js b/src/lib/AmfParameterMixin.ts similarity index 58% rename from src/lib/AmfParameterMixin.js rename to src/lib/AmfParameterMixin.ts index f93fc77..3e21f1a 100644 --- a/src/lib/AmfParameterMixin.js +++ b/src/lib/AmfParameterMixin.ts @@ -1,41 +1,32 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable no-unused-vars */ /* eslint-disable class-methods-use-this */ /* eslint-disable arrow-body-style */ // eslint-disable-next-line no-unused-vars -import { html } from 'lit-element'; +import { html, TemplateResult } from 'lit'; import { dedupeMixin } from '@open-wc/dedupe-mixin'; -import '@anypoint-web-components/awc/anypoint-dropdown-menu.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; -import '@anypoint-web-components/awc/anypoint-input.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-button.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; -import '@anypoint-web-components/awc/anypoint-switch.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dropdown-menu.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-input.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-switch.js'; +import { AnypointListboxElement, SupportedInputTypes, AnypointCheckboxElement, AnypointSwitchElement } from '@anypoint-web-components/awc'; import '@advanced-rest-client/icons/arc-icon.js'; -import { ifDefined } from 'lit-html/directives/if-defined.js' -import { classMap } from 'lit-html/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js' +import { classMap } from 'lit/directives/class-map.js'; import { ApiSchemaValues } from '../schema/ApiSchemaValues.js'; import { ns } from '../helpers/Namespace.js'; import * as InputCache from './InputCache.js'; import { readLabelValue } from './Utils.js'; +import { OperationParameter, ShapeTemplateOptions, ParameterRenderOptions } from '../types.js'; +import { ApiAnyShape, ApiArrayShape, ApiParameter, ApiScalarNode, ApiScalarShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../helpers/api.js'; -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('@anypoint-web-components/awc').AnypointListboxElement} AnypointListbox */ -/** @typedef {import('@anypoint-web-components/awc').SupportedInputTypes} SupportedInputTypes */ -/** @typedef {import('@anypoint-web-components/awc').AnypointCheckboxElement} AnypointCheckbox */ -/** @typedef {import('@anypoint-web-components/awc').AnypointSwitchElement} AnypointSwitch */ -/** @typedef {import('../types').OperationParameter} OperationParameter */ -/** @typedef {import('../types').ShapeTemplateOptions} ShapeTemplateOptions */ -/** @typedef {import('../types').ParameterRenderOptions} ParameterRenderOptions */ +type Constructor = new (...args: any[]) => T; export const customParamTemplate = Symbol('customParamTemplate'); export const customParamChangeHandler = Symbol('customParamChangeHandler'); @@ -43,21 +34,179 @@ export const deleteParamHandler = Symbol('deleteParamHandler'); export const correctDateTimeParameter = Symbol('correctDateTimeParameter'); /** - * @param {any} base + * This mixin adds support for rendering operation parameter inputs. + * It support: + * - rendering inputs + * - caching user input + * - restoring cache input. + * + * @mixin */ -const mxFunction = base => { - class AmfParameterMixin extends base { - constructor(init) { - super(init); - /** @type {boolean} */ - this.globalCache = undefined; - /** - * @type {OperationParameter[]} - */ +export interface AmfParameterMixinInterface { + /** + * By default the element stores user input in a map that is associated with the specific + * instance of this element. This way the element can be used multiple times in the same document. + * However, this way parameter values generated by the generators or entered by the user won't + * get populated in different operations. + * + * By setting this value the element prefers a global cache for values. Once the user enter + * a value it is registered in the global cache and restored when the same parameter is used again. + * + * Do not use this option when the element is embedded multiple times in the page. It will result + * in generating request data from the cache and not what's in the form inputs and these may not be in sync. + * + * These values are stored in memory only. Listen to the `change` event to learn that something changed. + * @attribute; + */ + globalCache: boolean; + parametersValue: OperationParameter[]; + nilValues: string[]; + + /** + * A function to be overwritten by child classes to execute an action when a parameter has changed. + * @param key The key of the property that changed. + */ + paramChanged(key: string): void; + + /** + * Clears previously set values in the cache storage. + */ + clearCache(): void; + + connectedCallback(): void; + + addArrayValueHandler(e: Event): void; + + /** + * Reads the value to be set on an input. + * + * @param isArray Whether the value should be read for an array. + * @returns The value to set on the input. Note, it is not cast to the type. + */ + readInputValue(parameter: ApiParameter, schema: ApiScalarShape, isArray?: boolean): any; + paramChangeHandler(e: Event): void; + booleanHandler(e: Event): void; + /** + * A handler for the remove param button click. + */ + deleteParamHandler(e: Event): void; + enumSelectionHandler(e: Event): void; + /** + * Handler for the nil value toggle. + */ + nilHandler(e: Event): void; + /** + * @returns The template for the request parameter form control. + */ + parameterTemplate(param: OperationParameter, opts?: ParameterRenderOptions): TemplateResult | string; + + /** + * @returns The template for the request parameter form control. + */ + parameterSchemaTemplate(parameter: ApiParameter, schema: ApiShapeUnion, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; + + /** + * @returns The template for the schema parameter. + */ + scalarShapeTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; + + /** + * @return A template for an input form item for the given type and schema + */ + textInputTemplate(parameter: ApiParameter, schema: ApiScalarShape, type?: SupportedInputTypes, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; + + /** + * @param paramId The ApiParameter id. + * @param arrayIndex When this is an array item, the index on the array. + * @returns The template for the param remove button. + */ + deleteParamTemplate(paramId: string, arrayIndex?: number): TemplateResult; + + /** + * @returns The template for the enum input. + */ + enumTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; + + /** + * @returns The template for the checkbox input. + */ + booleanTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts?: ShapeTemplateOptions): TemplateResult; + + /** + * @returns The template for the nil checkbox input. + */ + nillInputTemplate(parameter: ApiParameter): TemplateResult; + + /** + * or now we do not support union shapes. There's no way to learn how to serialize + * the Node shape to a string. + * @returns The template for the node shape. + */ + nodeShapeTemplate(): TemplateResult | string; + + /** + * @returns The template for the union shape. + */ + unionShapeTemplate(parameter: ApiParameter, schema: ApiUnionShape): TemplateResult | string; + + /** + * This situation makes not sense as there's no mechanism to describe how to + * put a file into a path, query, or headers. + * @returns The template for the file shape. + */ + fileShapeTemplate(): TemplateResult | string; + + /** + * For now we do not support union shapes. There's no way to learn how to serialize + * the Schema shape to a string. + * @returns The template for the schema shape. + */ + schemaShapeTemplate(): TemplateResult | string; + + /** + * @returns The template for the array shape. + */ + arrayShapeTemplate(parameter: ApiParameter, schema: ApiArrayShape): TemplateResult | string; + + /** + * @returns The template for the tuple shape. + */ + tupleShapeTemplate(parameter: ApiParameter, schema: ApiTupleShape): TemplateResult | string; + + /** + * @returns The template for the Any shape. + */ + anyShapeTemplate(parameter: ApiParameter, schema: ApiAnyShape): TemplateResult | string; + + /** + * @param {string} id The id of the parameter to add the value to. + * @returns The template for the adding an array item button + */ + addArrayItemTemplate(id: string): TemplateResult; +} + +/** + * This mixin adds support for rendering operation parameter inputs. + * It support: + * - rendering inputs + * - caching user input + * - restoring cache input. + * + * @mixin + */ +export const AmfParameterMixin = dedupeMixin(>(superClass: T): Constructor & T => { + + + class AmfParameterMixinClass extends superClass { + + parametersValue: OperationParameter[]; + + nilValues: string[]; + + constructor(...args: any[]) { + super(...args); + this.globalCache = false; this.parametersValue = []; - /** - * @type {string[]} - */ this.nilValues = []; this.addArrayValueHandler = this.addArrayValueHandler.bind(this); @@ -71,25 +220,24 @@ const mxFunction = base => { /** * A function to be overwritten by child classes to execute an action when a parameter has changed. - * @param {string} key The key of the property that changed. + * @param key The key of the property that changed. */ - paramChanged(key) {} + paramChanged(key: string): void { + // ... + } /** * Clears previously set values in the cache storage. */ - clearCache() { + clearCache(): void { const params = this.parametersValue; (params || []).forEach((param) => { InputCache.remove(this.target, param.paramId, this.globalCache) }); } - /** - * @param {Event} e - */ - addArrayValueHandler(e) { - const button = /** @type HTMLElement */ (e.target); + addArrayValueHandler(e: Event): void { + const button = e.target as HTMLElement; const { id } = button.dataset; if (!id) { return; @@ -97,7 +245,7 @@ const mxFunction = base => { if (!InputCache.has(this.target, id, this.globalCache)) { InputCache.set(this.target, id, [], this.globalCache); } - const items = /** @type any[] */ (InputCache.get(this.target, id, this.globalCache)); + const items = (InputCache.get(this.target, id, this.globalCache)) as any[]; items.push(undefined); this.requestUpdate(); this.paramChanged(id); @@ -106,12 +254,12 @@ const mxFunction = base => { /** * Reads the value to be set on an input. * - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {boolean=} [isArray=false] Whether the value should be read for an array. - * @returns {any} The value to set on the input. Note, it is not cast to the type. + * @param parameter + * @param schema + * @param isArray Whether the value should be read for an array. + * @returns The value to set on the input. Note, it is not cast to the type. */ - readInputValue(parameter, schema, isArray=false) { + readInputValue(parameter: ApiParameter, schema: ApiScalarShape, isArray=false): any { const { id } = parameter; if (InputCache.has(this.target, id, this.globalCache)) { return InputCache.get(this.target, id, this.globalCache); @@ -131,11 +279,8 @@ const mxFunction = base => { return result; } - /** - * @param {Event} e - */ - paramChangeHandler(e) { - const input = /** @type HTMLInputElement */ (e.target); + paramChangeHandler(e: Event): void { + const input = e.target as HTMLInputElement; const { value, dataset } = input; const { domainId, isArray, index } = dataset; if (!domainId) { @@ -146,17 +291,14 @@ const mxFunction = base => { return; } // sets cached value of the input. - const typed = ApiSchemaValues.parseUserInput(value, param.schema); + const typed = ApiSchemaValues.parseUserInput(value, param.schema as ApiShapeUnion); InputCache.set(this.target, domainId, typed, this.globalCache, isArray === 'true', index ? Number(index) : undefined); this.notifyChange(); this.paramChanged(domainId); } - /** - * @param {Event} e - */ - booleanHandler(e) { - const input = /** @type AnypointCheckbox */ (e.target); + booleanHandler(e: Event): void { + const input = e.target as AnypointCheckboxElement; const { checked, dataset } = input; const { domainId, isArray, index } = dataset; if (!domainId) { @@ -173,10 +315,9 @@ const mxFunction = base => { /** * A handler for the remove param button click. - * @param {Event} e */ - [deleteParamHandler](e) { - const button = /** @type HTMLElement */ (e.currentTarget); + [deleteParamHandler](e: Event): void { + const button = e.currentTarget as HTMLElement; const { dataset } = button; const { domainId, index, deleteParam } = dataset; if (!domainId) { @@ -199,12 +340,9 @@ const mxFunction = base => { } } - /** - * @param {Event} e - */ - enumSelectionHandler(e) { - const list = /** @type AnypointListbox */ (e.target); - const select = /** @type HTMLElement */ (list.parentElement); + enumSelectionHandler(e: Event): void { + const list = e.target as AnypointListboxElement; + const select = list.parentElement as HTMLElement; const { domainId, isArray, index } = select.dataset; if (!domainId) { return; @@ -213,9 +351,9 @@ const mxFunction = base => { if (!param) { return; } - const enumValues = /** @type ApiScalarNode[] */ (param.schema.values); - const { value } = enumValues[list.selected]; - const typed = ApiSchemaValues.parseUserInput(value, param.schema); + const enumValues = ((param.schema as ApiShapeUnion).values as ApiScalarNode[]); + const { value } = enumValues[list.selected as number]; + const typed = ApiSchemaValues.parseUserInput(value, param.schema as ApiShapeUnion); InputCache.set(this.target, domainId, typed, this.globalCache, isArray === 'true', index ? Number(index) : undefined); this.notifyChange(); this.paramChanged(domainId); @@ -223,10 +361,9 @@ const mxFunction = base => { /** * Handler for the nil value toggle. - * @param {Event} e */ - nilHandler(e) { - const button = /** @type AnypointCheckbox */ (e.target); + nilHandler(e: Event): void { + const button = e.target as AnypointCheckboxElement; const { checked, dataset } = button; const { domainId } = dataset; if (!domainId) { @@ -247,11 +384,11 @@ const mxFunction = base => { } /** - * @param {OperationParameter} param The parameter to render. - * @param {ParameterRenderOptions=} [opts={}] Render options - * @returns {TemplateResult|string} The template for the request parameter form control. + * @param param The parameter to render. + * @param opts Render options + * @returns The template for the request parameter form control. */ - parameterTemplate(param, opts={}) { + parameterTemplate(param: OperationParameter, opts: ParameterRenderOptions={}): TemplateResult | string { const { schema, parameter, source } = param; if (source === 'custom') { return this[customParamTemplate](param); @@ -263,21 +400,21 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiShapeUnion} schema - * @param {ShapeTemplateOptions=} [opts=[]] Internal Process options - * @returns {TemplateResult|string} The template for the request parameter form control. + * @param parameter + * @param schema + * @param opts Internal Process options + * @returns The template for the request parameter form control. */ - parameterSchemaTemplate(parameter, schema, opts={}) { + parameterSchemaTemplate(parameter: ApiParameter, schema: ApiShapeUnion, opts: ShapeTemplateOptions={}): TemplateResult | string { const { types } = schema; if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this.scalarShapeTemplate(parameter, /** @type ApiScalarShape */ (schema), opts); + return this.scalarShapeTemplate(parameter, schema as ApiScalarShape, opts); } if (types.includes(ns.w3.shacl.NodeShape)) { return this.nodeShapeTemplate(); } if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this.unionShapeTemplate(parameter, /** @type ApiUnionShape */ (schema)); + return this.unionShapeTemplate(parameter, schema as ApiUnionShape); } if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { return this.fileShapeTemplate(); @@ -286,22 +423,22 @@ const mxFunction = base => { return this.schemaShapeTemplate(); } if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this.arrayShapeTemplate(parameter, /** @type ApiArrayShape */ (schema)); + return this.arrayShapeTemplate(parameter, schema as ApiArrayShape); } if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this.tupleShapeTemplate(parameter, /** @type ApiTupleShape */ (schema)); + return this.tupleShapeTemplate(parameter, schema as ApiTupleShape); } - return this.anyShapeTemplate(parameter, /** @type ApiAnyShape */ (schema)); + return this.anyShapeTemplate(parameter, schema as ApiAnyShape); } /** - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {ShapeTemplateOptions=} opts - * @returns {TemplateResult|string} The template for the schema parameter. + * @param parameter + * @param schema + * @param opts + * @returns The template for the schema parameter. */ - scalarShapeTemplate(parameter, schema, opts={}) { - const { readOnly, values, dataType } = schema; + scalarShapeTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { + const { readOnly, values, dataType='text' } = schema; if (readOnly) { return ''; } @@ -318,16 +455,13 @@ const mxFunction = base => { /** * Corrects the `http://www.w3.org/2001/XMLSchema#dateTime` schema with the `date-time` or `rfc3339` formats * to remove the last `.ZZZ` part which is not recognizable by the `` element. - * @param {ApiScalarShape} schema - * @param {any} value - * @returns {any} */ - [correctDateTimeParameter](schema, value) { + [correctDateTimeParameter](schema: ApiScalarShape, value: any): any { if (!value) { return value; } if (schema.dataType === ns.w3.xmlSchema.dateTime) { - if (['date-time', 'rfc3339'].includes(schema.format)) { + if (['date-time', 'rfc3339'].includes(schema.format || '')) { return String(value).replace(/(\.\d\d\d)Z/, '$1'); } } @@ -335,20 +469,20 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {SupportedInputTypes=} type The input type. - * @param {ShapeTemplateOptions=} opts - * @return {TemplateResult} A template for an input form item for the given type and schema + * @param parameter + * @param schema + * @param type The input type. + * @param opts + * @returns A template for an input form item for the given type and schema */ - textInputTemplate(parameter, schema, type, opts={}) { + textInputTemplate(parameter: ApiParameter, schema: ApiScalarShape, type?: SupportedInputTypes, opts: ShapeTemplateOptions={}): TemplateResult { const { id, binding, } = parameter; const { pattern, minimum, minLength, maxLength, maximum, multipleOf } = schema; - let required; + let required = false; if (typeof opts.required === 'boolean') { required = opts.required; } else { - required = parameter.required; + required = parameter.required || false; } const label = readLabelValue(parameter, schema); const { allowEmptyValue, } = parameter; @@ -362,9 +496,8 @@ const mxFunction = base => { value = ApiSchemaValues.parseScalarInput(value, schema); value = this[correctDateTimeParameter](schema, value); } - /** @type number */ - let step; - if (['time', 'datetime-local'].includes(type)) { + let step: number | undefined; + if (['time', 'datetime-local'].includes(type || '')) { step = 1; } else if (typeof multipleOf !== 'undefined') { step = Number(multipleOf); @@ -384,26 +517,25 @@ const mxFunction = base => { data-is-array="${ifDefined(opts.arrayItem)}" data-index="${ifDefined(opts.index)}" data-binding="${ifDefined(binding)}" - name="${parameter.name || schema.name}" + name="${parameter.name || schema.name || ''}" class="form-input" ?required="${required && !allowEmptyValue}" ?autoValidate="${required && !allowEmptyValue}" .value="${value}" .pattern="${pattern}" - .min="${typeof minimum !== 'undefined' ? String(minimum) : undefined}" + .min="${typeof minimum !== 'undefined' ? minimum : undefined}" .minLength="${minLength}" - .max="${typeof maximum !== 'undefined' ? String(maximum) : undefined}" + .max="${typeof maximum !== 'undefined' ? maximum : undefined}" .maxLength="${maxLength}" - .step="${step}" + .step="${ifDefined(step)}" type="${ifDefined(type)}" title="${ifDefined(title)}" @change="${this.paramChangeHandler}" ?disabled="${nillDisabled}" ?anypoint="${this.anypoint}" ?outlined="${this.outlined}" - > - - + label="${label}" + > ${opts.nillable ? this.nillInputTemplate(parameter) : ''} ${opts.arrayItem ? this.deleteParamTemplate(id, opts.index) : ''} @@ -411,11 +543,11 @@ const mxFunction = base => { } /** - * @param {string} paramId The ApiParameter id. - * @param {number=} arrayIndex When this is an array item, the index on the array. - * @returns {TemplateResult} The template for the param remove button. + * @param paramId The ApiParameter id. + * @param arrayIndex When this is an array item, the index on the array. + * @returns The template for the param remove button. */ - deleteParamTemplate(paramId, arrayIndex) { + deleteParamTemplate(paramId: string, arrayIndex?: number): TemplateResult { const { anypoint } = this; const title = 'Removes this parameter.'; return html` @@ -433,21 +565,21 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {ShapeTemplateOptions=} opts - * @returns {TemplateResult|string} The template for the enum input. + * @param parameter + * @param schema + * @param opts + * @returns The template for the enum input. */ - enumTemplate(parameter, schema, opts={}) { + enumTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { const { anypoint } = this; - let required; + let required = false; if (typeof opts.required === 'boolean') { required = opts.required; } else { - required = parameter.required; + required = parameter.required || false; } const label = readLabelValue(parameter, schema); - const enumValues = /** @type ApiScalarNode[] */ (schema.values || []); + const enumValues = (schema.values || []) as ApiScalarNode[]; const selectedValue = this.readInputValue(parameter, schema); const selected = enumValues.findIndex(i => i.value === selectedValue); const { id, binding } = parameter; @@ -463,7 +595,7 @@ const mxFunction = base => {
{ .selected="${selected}" @selected="${this.enumSelectionHandler}" > - ${enumValues.map((value) => html`${value.value}`)} + ${enumValues.map((value) => html`${value.value}`)} ${opts.nillable ? this.nillInputTemplate(parameter) : ''} @@ -491,16 +623,12 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {ShapeTemplateOptions=} opts - * @returns {TemplateResult|string} The template for the checkbox input. + * @returns The template for the checkbox input. */ - booleanTemplate(parameter, schema, opts={}) { + booleanTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { const label = readLabelValue(parameter, schema); const { id } = parameter; - /** @type {boolean} */ - let value; + let value: boolean; if (opts.arrayItem) { value = opts.value || ''; } else { @@ -511,7 +639,7 @@ const mxFunction = base => { const nillDisabled = !!opts.nillable && nillable.includes(id); const classes = { 'form-item': true, - required: parameter.required, + required: parameter.required || false, optional: !parameter.required, }; // note, don't mark a checkbox as required. A checkbox also produces `false` value @@ -521,7 +649,7 @@ const mxFunction = base => {
{ } /** - * @param {ApiParameter} parameter - * @returns {TemplateResult|string} The template for the nil checkbox input. + * @returns The template for the nil checkbox input. */ - nillInputTemplate(parameter) { + nillInputTemplate(parameter: ApiParameter): TemplateResult | string { return html` { * the Node shape to a string. * @returns {TemplateResult|string} The template for the node shape. */ - nodeShapeTemplate() { + nodeShapeTemplate(): TemplateResult | string { return ''; } /** - * @param {ApiParameter} parameter - * @param {ApiUnionShape} schema - * @returns {TemplateResult|string} The template for the union shape. + * @returns The template for the union shape. */ - unionShapeTemplate(parameter, schema) { + unionShapeTemplate(parameter: ApiParameter, schema: ApiUnionShape): TemplateResult | string { const { anyOf } = schema; if (!anyOf || !anyOf.length) { return ''; @@ -574,7 +699,7 @@ const mxFunction = base => { if (nil && anyOf.length === 2) { // this is a case where a scalar is marked as nillable instead of not required // (which for some reason is a common practice among RAML developers). - const scalar = anyOf.find(shape => shape !== nil); + const scalar = anyOf.find(shape => shape !== nil) as ApiShapeUnion; return this.parameterSchemaTemplate(parameter, scalar, { nillable: true, }); @@ -588,8 +713,7 @@ const mxFunction = base => { // at this point only scalars are possible. For that we render a regular text field // and while serializing the values we figure out what type it should be giving the // value provided and available types in the union. - /** @type ShapeTemplateOptions */ - let opts; + let opts: ShapeTemplateOptions | undefined; if (nil) { opts = { nillable: true }; } @@ -599,39 +723,37 @@ const mxFunction = base => { /** * This situation makes not sense as there's no mechanism to describe how to * put a file into a path, query, or headers. - * @returns {TemplateResult|string} The template for the file shape. + * @returns The template for the file shape. */ - fileShapeTemplate() { + fileShapeTemplate(): TemplateResult | string { return ''; } /** * For now we do not support union shapes. There's no way to learn how to serialize * the Schema shape to a string. - * @returns {TemplateResult|string} The template for the schema shape. + * @returns The template for the schema shape. */ - schemaShapeTemplate() { + schemaShapeTemplate(): TemplateResult | string { return ''; } /** - * @param {ApiParameter} parameter - * @param {ApiArrayShape} schema - * @returns {TemplateResult|string} The template for the array shape. + * @returns The template for the array shape. */ - arrayShapeTemplate(parameter, schema) { + arrayShapeTemplate(parameter: ApiParameter, schema: ApiArrayShape): TemplateResult | string { const { items } = schema; if (!items) { return ''; } const { id } = parameter; const label = readLabelValue(parameter, schema); - const values = /** @type any[] */ (this.readInputValue(parameter, schema, true)); + const values = (this.readInputValue(parameter, schema, true)) as any[]; const options = { arrayItem: true, }; const inputs = (values || []).map((value, index) => this.parameterSchemaTemplate(parameter, items, { ...options, value, index })); const classes = { 'array-form-item': true, - required: parameter.required, + required: !!parameter.required, optional: !parameter.required, }; return html` @@ -644,11 +766,9 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiTupleShape} schema - * @returns {TemplateResult|string} The template for the tuple shape. + * @returns The template for the tuple shape. */ - tupleShapeTemplate(parameter, schema) { + tupleShapeTemplate(parameter: ApiParameter, schema: ApiTupleShape): TemplateResult | string { const { items } = schema; if (!items) { return ''; @@ -658,19 +778,17 @@ const mxFunction = base => { } /** - * @param {ApiParameter} parameter - * @param {ApiAnyShape} schema - * @returns {TemplateResult|string} The template for the Any shape. + * @returns The template for the Any shape. */ - anyShapeTemplate(parameter, schema) { + anyShapeTemplate(parameter: ApiParameter, schema: ApiAnyShape): TemplateResult | string { return this.textInputTemplate(parameter, schema, 'text'); } /** - * @param {string} id The id of the parameter to add the value to. - * @returns {TemplateResult} The template for the adding an array item button + * @param id The id of the parameter to add the value to. + * @returns The template for the adding an array item button */ - addArrayItemTemplate(id) { + addArrayItemTemplate(id: string): TemplateResult | string { return html` Add new value `; @@ -678,10 +796,9 @@ const mxFunction = base => { /** * Handler for a custom parameter input change. - * @param {Event} e */ - [customParamChangeHandler](e) { - const input = /** @type HTMLInputElement */ (e.target); + [customParamChangeHandler](e: Event): void { + const input = e.target as HTMLInputElement; const { value, name, dataset } = input; const { domainId } = dataset; if (!domainId || !['paramName', 'paramValue'].includes(name)) { @@ -701,11 +818,11 @@ const mxFunction = base => { } /** - * @param {OperationParameter} param The parameter to render - * @returns {TemplateResult} The template for a custom parameter + * @param param The parameter to render + * @returns The template for a custom parameter */ - [customParamTemplate](param) { - const value = InputCache.get(this.target, param.paramId, this.globalCache); + [customParamTemplate](param: OperationParameter): TemplateResult { + const value = InputCache.get(this.target, param.paramId, this.globalCache) as string; const classes = { 'form-item': true, 'custom-item': true, @@ -743,9 +860,8 @@ const mxFunction = base => { ?anypoint="${this.anypoint}" ?outlined="${this.outlined}" noLabelFloat - > - - + label="${nameLabel}" + > { ?anypoint="${this.anypoint}" ?outlined="${this.outlined}" noLabelFloat - > - - + label="${valueLabel}" + > ${this.deleteParamTemplate(param.paramId)}
`; } } - return AmfParameterMixin; -} -/** - * This mixin adds support for rendering operation parameter inputs. - * It support: - * - rendering inputs - * - caching user input - * - restoring cache input. - * - * @mixin - */ -export const AmfParameterMixin = dedupeMixin(mxFunction); + return AmfParameterMixinClass as Constructor & T; +}); diff --git a/src/lib/ApiAuthDataHelper.js b/src/lib/ApiAuthDataHelper.js deleted file mode 100644 index 00d5218..0000000 --- a/src/lib/ApiAuthDataHelper.js +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable no-unused-vars */ -/* eslint-disable no-param-reassign */ -import { AuthUiDataHelper } from '@advanced-rest-client/base/api.js'; -import CustomAuth from './auth-ui/CustomAuth.js'; -import ApiKeyAuth from './auth-ui/ApiKeyAuth.js'; -import PassThroughAuth from './auth-ui/PassThroughAuth.js'; -import OAuth2Auth from './auth-ui/OAuth2Auth.js'; -import OAuth1Auth from './auth-ui/OAuth1Auth.js'; - -/** @typedef {import('@advanced-rest-client/base').AuthUiInit} AuthUiInit */ -/** @typedef {import('../elements/ApiAuthorizationMethodElement').default} ApiAuthorizationElement */ - -export class ApiAuthDataHelper extends AuthUiDataHelper { - /** - * @param {ApiAuthorizationElement} element - * @param {AuthUiInit} init - */ - static setupCustom(element, init) { - const i = new CustomAuth(init); - i.security = element.security; - i.descriptionOpened = element.descriptionOpened; - i.globalCache = element.globalCache; - i.anypoint = element.anypoint; - return i; - } - - /** - * @param {ApiAuthorizationElement} element - * @param {CustomAuth} ui - */ - static populateCustom(element, ui) { - // ... - } - - /** - * @param {ApiAuthorizationElement} element - * @param {AuthUiInit} init - */ - static setupApiKey(element, init) { - const i = new ApiKeyAuth(init); - i.security = element.security; - i.globalCache = element.globalCache; - return i; - } - - /** - * @param {ApiAuthorizationElement} element - * @param {ApiKeyAuth} ui - */ - static populateApiKey(element, ui) { - // ... - } - - /** - * @param {ApiAuthorizationElement} element - * @param {AuthUiInit} init - */ - static setupPassThrough(element, init) { - const i = new PassThroughAuth(init); - i.security = element.security; - i.descriptionOpened = element.descriptionOpened; - i.globalCache = element.globalCache; - i.anypoint = element.anypoint; - return i; - } - - /** - * @param {ApiAuthorizationElement} element - * @param {PassThroughAuth} ui - */ - static populatePassThrough(element, ui) { - // ... - } - - /** - * @param {ApiAuthorizationElement} element - * @param {AuthUiInit} init - */ - static setupOauth2(element, init) { - const i = new OAuth2Auth(init); - i.security = element.security; - i.globalCache = element.globalCache; - // @ts-ignore - AuthUiDataHelper.setOAuth2Values(element, init); - return i; - } - - /** - * @param {ApiAuthorizationElement} element - * @param {AuthUiInit} init - * @returns {any} - */ - static setupOauth1(element, init) { - // @ts-ignore - const i = new OAuth1Auth(init); - i.security = element.security; - // @ts-ignore - AuthUiDataHelper.setupOauth1(element, init); - return i; - } -} diff --git a/src/lib/ApiAuthDataHelper.ts b/src/lib/ApiAuthDataHelper.ts new file mode 100644 index 0000000..a5e2115 --- /dev/null +++ b/src/lib/ApiAuthDataHelper.ts @@ -0,0 +1,56 @@ +/* eslint-disable no-unused-vars */ +/* eslint-disable no-param-reassign */ +import { AuthUiDataHelper, AuthUiInit } from '@advanced-rest-client/base/api.js'; +import CustomAuth from './auth-ui/CustomAuth.js'; +import ApiKeyAuth from './auth-ui/ApiKeyAuth.js'; +import PassThroughAuth from './auth-ui/PassThroughAuth.js'; +import OAuth2Auth from './auth-ui/OAuth2Auth.js'; + +/** @typedef {import('../elements/ApiAuthorizationMethodElement').default} ApiAuthorizationElement */ + +export class ApiAuthDataHelper extends AuthUiDataHelper { + static setupCustom(element: ApiAuthorizationElement, init: AuthUiInit): CustomAuth { + const i = new CustomAuth(init); + i.security = element.security; + i.descriptionOpened = element.descriptionOpened; + i.globalCache = element.globalCache; + i.anypoint = element.anypoint; + return i; + } + + static populateCustom(element: ApiAuthorizationElement, ui: CustomAuth): void { + // ... + } + + static setupApiKey(element: ApiAuthorizationElement, init: AuthUiInit): ApiKeyAuth { + const i = new ApiKeyAuth(init); + i.security = element.security; + i.globalCache = element.globalCache; + return i; + } + + static populateApiKey(element: ApiAuthorizationElement, ui: ApiKeyAuth): void { + // ... + } + + static setupPassThrough(element: ApiAuthorizationElement, init: AuthUiInit): PassThroughAuth { + const i = new PassThroughAuth(init); + i.security = element.security; + i.descriptionOpened = element.descriptionOpened; + i.globalCache = element.globalCache; + i.anypoint = element.anypoint; + return i; + } + + static populatePassThrough(element: ApiAuthorizationElement, ui: PassThroughAuth): void { + // ... + } + + static setupOauth2(element: ApiAuthorizationElement, init: AuthUiInit): OAuth2Auth { + const i = new OAuth2Auth(init); + i.security = element.security; + i.globalCache = element.globalCache; + AuthUiDataHelper.setOAuth2Values(element, init); + return i; + } +} diff --git a/src/lib/InputCache.d.ts b/src/lib/InputCache.d.ts deleted file mode 100644 index 5972f4f..0000000 --- a/src/lib/InputCache.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * A cache of provided by the user values to the input fields. - * This is used to restore data when the user switches between different operations. - */ -export const globalValues: Map; -/** - * A cache for "local" values cached per instance of the component. - */ -export const localValues: WeakMap>; - -export function getStore(element: HTMLElement, globalCache: boolean): Map; - -/** - * Reads a value from the store. - * @param element - * @param key The key to use - * @param globalCache Whether to use the global cache. - * @returns {any} - */ -export function get(element: HTMLElement, key: string, globalCache: boolean): any; - -/** - * Sets a value in a cache. - * @param element - * @param key The key to use - * @param value The value to store - * @param globalCache Whether to use the global cache. - * @param isArray Whether the value is an array. - * @param index The array index. - */ -export function set(element: HTMLElement, key: string, value: any, globalCache: boolean, isArray?: boolean, index?: number): void; - -/** - * @param element - * @param key The key to use - * @param globalCache Whether to use the global cache. - */ -export function has(element: HTMLElement, key: string, globalCache: boolean): boolean; - -/** - * Registers an element in a non-global store. - */ -export function registerLocal(element: HTMLElement): void; - -/** - * Un-registers an element in a non-global store. - */ -export function unregisterLocal(element: HTMLElement): void; - -/** - * Removes a value from the store. - * @param element - * @param key The key to use - * @param globalCache Whether to use the global cache. - * @param index When set to a number it expects the value to be array and removes an item on the specified index. - */ -export function remove(element: HTMLElement, key: string, globalCache: boolean, index?: number): void; diff --git a/src/lib/InputCache.js b/src/lib/InputCache.js deleted file mode 100644 index 0a7faaf..0000000 --- a/src/lib/InputCache.js +++ /dev/null @@ -1,107 +0,0 @@ -/* eslint-disable no-param-reassign */ - -/** - * A cache of provided by the user values to the input fields. - * This is used to restore data when the user switches between different operations. - * @type {Map} - */ -export const globalValues = new Map(); -/** - * A cache for "local" values cached per instance of the component. - * - * @type {WeakMap>} - */ -export const localValues = new WeakMap(); - -/** - * @param {HTMLElement} element - * @param {boolean} globalCache Whether to use the global cache. - * @returns {Map} - */ -export function getStore(element, globalCache) { - if (globalCache) { - return globalValues; - } - return localValues.get(element); -} - -/** - * @param {HTMLElement} element - * @param {string} key The key to use - * @param {boolean} globalCache Whether to use the global cache. - * @returns {any} - */ -export function get(element, key, globalCache) { - const store = getStore(element, globalCache); - if (store && store.has(key)) { - return store.get(key); - } - return undefined; -} - -/** - * @param {HTMLElement} element - * @param {string} key The key to use - * @param {any} value The value to store - * @param {boolean} globalCache Whether to use the global cache. - * @param {boolean=} isArray Whether the value is an array. - * @param {number=} index The array index. - */ -export function set(element, key, value, globalCache, isArray, index) { - const store = getStore(element, globalCache); - if (isArray) { - if (!store.has(key)) { - store.set(key, []); - } - if (typeof index === "number" && !Number.isNaN(index)) { - store.get(key)[index] = value; - } else { - store.get(key).push(value); - } - } else { - store.set(key, value); - } -} - -/** - * @param {HTMLElement} element - * @param {string} key The key to use - * @param {boolean} globalCache Whether to use the global cache. - * @returns {boolean} - */ -export function has(element, key, globalCache) { - const store = getStore(element, globalCache); - return store.has(key); -} - -/** - * @param {HTMLElement} element - */ -export function registerLocal(element) { - localValues.set(element, new Map()); -} - -/** - * @param {HTMLElement} element - */ -export function unregisterLocal(element) { - localValues.delete(element); -} - -/** - * @param {HTMLElement} element - * @param {string} key The key to use - * @param {boolean} globalCache Whether to use the global cache. - * @param {number=} index When set to a number it expects the value to be array and removes an item on the specified index. - */ -export function remove(element, key, globalCache, index) { - const store = getStore(element, globalCache); - if (typeof index === "number" && !Number.isNaN(index)) { - const value = /** @type any[] */ (store.get(key)); - if (Array.isArray(value)) { - value.splice(index, 1); - } - } else { - store.delete(key); - } -} diff --git a/src/lib/InputCache.ts b/src/lib/InputCache.ts new file mode 100644 index 0000000..9711c7a --- /dev/null +++ b/src/lib/InputCache.ts @@ -0,0 +1,96 @@ +/* eslint-disable no-param-reassign */ + +/** + * A cache of provided by the user values to the input fields. + * This is used to restore data when the user switches between different operations. + */ +export const globalValues: Map = new Map(); +/** + * A cache for "local" values cached per instance of the component. + */ +export const localValues: WeakMap> = new WeakMap(); + +/** + * @param element + * @param globalCache Whether to use the global cache. + */ +export function getStore(element: HTMLElement, globalCache: boolean): Map { + if (globalCache) { + return globalValues; + } + return localValues.get(element) as Map; +} + +/** + * @param element + * @param key The key to use + * @param globalCache Whether to use the global cache. + */ +export function get(element: HTMLElement, key: string, globalCache: boolean): unknown { + const store = getStore(element, globalCache); + if (store && store.has(key)) { + return store.get(key); + } + return undefined; +} + +/** + * @param element + * @param key The key to use + * @param value The value to store + * @param globalCache Whether to use the global cache. + * @param isArray Whether the value is an array. + * @param index The array index. + */ +export function set(element: HTMLElement, key: string, value: unknown, globalCache: boolean, isArray?: boolean, index?: number): void { + const store = getStore(element, globalCache); + if (isArray) { + if (!store.has(key)) { + store.set(key, []); + } + if (typeof index === "number" && !Number.isNaN(index)) { + (store.get(key) as unknown[])[index] = value; + } else { + (store.get(key) as unknown[]).push(value); + } + } else { + store.set(key, value); + } +} + +/** + * @param element + * @param key The key to use + * @param globalCache Whether to use the global cache. + */ +export function has(element: HTMLElement, key: string, globalCache: boolean): boolean { + const store = getStore(element, globalCache); + return store.has(key); +} + + +export function registerLocal(element: HTMLElement): void { + localValues.set(element, new Map()); +} + +export function unregisterLocal(element: HTMLElement): void { + localValues.delete(element); +} + +/** + * @param element + * @param key The key to use + * @param globalCache Whether to use the global cache. + * @param index When set to a number it expects the value to be array and removes an item on the specified index. + */ +export function remove(element: HTMLElement, key: string, globalCache: boolean, index?: number): void { + const store = getStore(element, globalCache); + if (typeof index === "number" && !Number.isNaN(index)) { + const value = store.get(key); + if (Array.isArray(value)) { + value.splice(index, 1); + } + } else { + store.delete(key); + } +} diff --git a/src/lib/Oauth2RamlCustomData.js b/src/lib/Oauth2RamlCustomData.ts similarity index 59% rename from src/lib/Oauth2RamlCustomData.js rename to src/lib/Oauth2RamlCustomData.ts index fccce9a..bd384cf 100644 --- a/src/lib/Oauth2RamlCustomData.js +++ b/src/lib/Oauth2RamlCustomData.ts @@ -1,13 +1,5 @@ /* eslint-disable class-methods-use-this */ -/** @typedef {import('../helpers/api').ApiDataNodeUnion} ApiDataNodeUnion */ -/** @typedef {import('../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../helpers/api').ApiObjectNode} ApiObjectNode */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiShape} ApiShape */ - +import { ApiArrayShape, ApiDataNodeUnion, ApiObjectNode, ApiParameter, ApiScalarNode, ApiScalarShape, ApiShape, ApiShapeUnion } from '../helpers/api.js'; import { ns } from '../helpers/Namespace.js'; /** @@ -16,19 +8,15 @@ import { ns } from '../helpers/Namespace.js'; * https://github.com/raml-org/raml-annotations/tree/master/annotations/security-schemes */ export class Oauth2RamlCustomData { - /** - * @param {{[key: string]: ApiDataNodeUnion}} properties - * @returns {ApiParameter[]} - */ - readParams(properties) { - const result = []; + readParams(properties: {[key: string]: ApiDataNodeUnion}): ApiParameter[] { + const result: ApiParameter[] = []; Object.keys(properties).forEach((key) => { const definition = properties[key]; if (definition.types.includes(ns.aml.vocabularies.data.Object)) { - const property = this.getProperty(/** @type ApiObjectNode */ (definition)); + const property = this.getProperty((definition as ApiObjectNode)); result.push(property); } else if (definition.types.includes(ns.aml.vocabularies.data.Scalar)) { - const property = this.getPropertyScalar(/** @type ApiScalarNode */ (definition)); + const property = this.getPropertyScalar((definition as ApiScalarNode)); result.push(property); } }); @@ -38,25 +26,23 @@ export class Oauth2RamlCustomData { /** * Creates an ApiParameter for an annotation that has properties. * This expects the properties to be defined like RAML's type definition. - * - * @param {ApiObjectNode} definition - * @returns {ApiParameter} */ - getProperty(definition) { + getProperty(definition: ApiObjectNode): ApiParameter { const { properties={}, id, name } = definition; - const result = /** @type ApiParameter */ ({ + const result: ApiParameter = { id, name, examples: [], payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], - }); + customDomainProperties: [], + }; const schema = this.readSchema(definition); if (schema) { result.schema = schema; } if (properties.required) { - const req = /** @type ApiScalarNode */ (properties.required); + const req = properties.required as ApiScalarNode; result.required = req.value === 'true'; } return result; @@ -65,20 +51,18 @@ export class Oauth2RamlCustomData { /** * Creates an ApiParameter for an annotation that has no properties but rather a simplified * notation of `propertyName: dataType`. - * - * @param {ApiScalarNode} definition - * @returns {ApiParameter} */ - getPropertyScalar(definition) { - const { dataType, id, name } = definition; - const result = /** @type ApiParameter */ ({ + getPropertyScalar(definition: ApiScalarNode): ApiParameter { + const { dataType = '', id, name } = definition; + const result: ApiParameter = { id, name, examples: [], payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], - }); - const schema = /** @type ApiScalarShape */ (this.createSchema()); + customDomainProperties: [], + }; + const schema = this.createSchema() as ApiScalarShape; schema.types = [ns.aml.vocabularies.shapes.ScalarShape]; schema.id = id; schema.name = name; @@ -87,19 +71,14 @@ export class Oauth2RamlCustomData { return result; } - /** - * @param {ApiObjectNode} property - * @returns {ApiShapeUnion} - */ - readSchema(property) { + readSchema(property: ApiObjectNode): ApiShapeUnion | undefined { const { properties={}, name, id } = property; // const { example, examples, } = properties; - const isArray = this.readIsSchemaArray(/** @type ApiScalarNode */ (properties.type), /** @type ApiScalarNode */ (properties.items)); - const type = this.readSchemaType(/** @type ApiScalarNode */ (properties.type), /** @type ApiScalarNode */ (properties.items)); - /** @type ApiShapeUnion */ - let schema; + const isArray = this.readIsSchemaArray((properties.type as ApiScalarNode), (properties.items as ApiScalarNode)); + const type = this.readSchemaType((properties.type as ApiScalarNode), (properties.items as ApiScalarNode)); + let schema: ApiShapeUnion | undefined; if (isArray) { - const s = /** @type ApiArrayShape */ (this.createSchema()); + const s = this.createSchema() as ApiArrayShape; s.types = [ns.aml.vocabularies.shapes.ArrayShape]; s.id = id; s.name = name; @@ -111,12 +90,7 @@ export class Oauth2RamlCustomData { return schema; } - /** - * @param {string} type - * @param {ApiObjectNode} object - * @returns {ApiShapeUnion} - */ - createTypedSchema(type, object) { + createTypedSchema(type: string, object: ApiObjectNode): ApiShapeUnion | undefined { switch (type) { case 'string': case 'number': @@ -134,87 +108,78 @@ export class Oauth2RamlCustomData { } } - /** - * @returns {ApiShape} - */ - createSchema() { - return /** @type ApiShape */ ({ + createSchema(): ApiShape { + return { id: '', types: [], and: [], - examples: [], name: '', inherits: [], or: [], values: [], xone: [], customDomainProperties: [], - }); + }; } - /** - * @param {ApiObjectNode} object - * @param {string} type - * @returns {ApiScalarShape} - */ - createScalarSchema(object, type) { + createScalarSchema(object: ApiObjectNode, type: string): ApiScalarShape { const { properties={}, name, id } = object; - const schema = /** @type ApiScalarShape */ (this.createSchema()); + const schema = this.createSchema() as ApiScalarShape; schema.types = [ns.aml.vocabularies.shapes.ScalarShape]; schema.id = id; schema.name = name; schema.dataType = this.typeToSchemaType(type); if (properties.format) { - const item = /** @type ApiScalarNode */ (properties.format); + const item = properties.format as ApiScalarNode; schema.format = item.value; } if (properties.default) { - const item = /** @type ApiScalarNode */ (properties.default); + const item = properties.default as ApiScalarNode; schema.defaultValueStr = item.value; // schema.defaultValue = item.value; } if (properties.description) { - const item = /** @type ApiScalarNode */ (properties.description); + const item = (properties.description as ApiScalarNode); schema.description = item.value; } if (properties.displayName) { - const item = /** @type ApiScalarNode */ (properties.displayName); + const item = (properties.displayName as ApiScalarNode); schema.displayName = item.value; } if (properties.pattern) { - const item = /** @type ApiScalarNode */ (properties.pattern); + const item = (properties.pattern as ApiScalarNode); schema.pattern = item.value; } if (properties.maximum) { - const item = /** @type ApiScalarNode */ (properties.maximum); + const item = (properties.maximum as ApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.maximum = value; } } if (properties.minimum) { - const item = /** @type ApiScalarNode */ (properties.minimum); + const item = (properties.minimum as ApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.minimum = value; } } if (properties.multipleOf) { - const item = /** @type ApiScalarNode */ (properties.multipleOf); + const item = (properties.multipleOf as ApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.multipleOf = value; } } if (properties.maxLength) { - const item = /** @type ApiScalarNode */ (properties.maxLength); + const item = (properties.maxLength as ApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.maxLength = value; } } if (properties.minLength) { - const item = /** @type ApiScalarNode */ (properties.minLength); + const item = (properties.minLength as ApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.minLength = value; @@ -224,11 +189,10 @@ export class Oauth2RamlCustomData { } /** - * @param {ApiScalarNode} object - * @param {ApiScalarNode=} items The definition of the `items` property that corresponds to RAML's items property of an array - * @returns {string} + * @param object + * @param items The definition of the `items` property that corresponds to RAML's items property of an array */ - readSchemaType(object, items) { + readSchemaType(object: ApiScalarNode, items?: ApiScalarNode): string { if (object.dataType !== ns.w3.xmlSchema.string) { return ns.w3.xmlSchema.string; } @@ -243,11 +207,7 @@ export class Oauth2RamlCustomData { } - /** - * @param {string} type - * @returns {string} - */ - typeToSchemaType(type) { + typeToSchemaType(type: string): string { switch (type) { case 'boolean': return ns.w3.xmlSchema.boolean; case 'number': return ns.w3.xmlSchema.number; @@ -265,11 +225,11 @@ export class Oauth2RamlCustomData { /** * Checks whether the custom property represents an array. - * @param {ApiScalarNode} type - * @param {ApiScalarNode} items The definition of the `items` property that corresponds to RAML's items property of an array - * @returns {boolean} True when the schema is an array. + * @param type + * @param items The definition of the `items` property that corresponds to RAML's items property of an array + * @returns True when the schema is an array. */ - readIsSchemaArray(type, items) { + readIsSchemaArray(type: ApiScalarNode, items: ApiScalarNode): boolean { if (!type && items) { return true; } diff --git a/src/lib/PayloadUtils.d.ts b/src/lib/PayloadUtils.d.ts deleted file mode 100644 index adfe2f3..0000000 --- a/src/lib/PayloadUtils.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ApiTypes } from '@advanced-rest-client/events'; -import { ApiPayload } from '../helpers/api'; - -export interface PayloadInfo { - value: string|FormData|Blob; - model?: ApiTypes.ApiType[]; - schemas?: any; -} - -export function getPayloadValue(payload: ApiPayload): PayloadInfo; - -/** - * @param id The ApiPayload id. - * @param value The value to cache. - * @param model Optional model to set. - */ -export function cachePayloadValue(id: string, value: string, model?: ApiTypes.ApiType[]): void; -/** - * @param id Payload id to read the value. - */ -export function readCachePayloadValue(id: string): PayloadInfo; diff --git a/src/lib/PayloadUtils.js b/src/lib/PayloadUtils.ts similarity index 62% rename from src/lib/PayloadUtils.js rename to src/lib/PayloadUtils.ts index f0b1dd6..e8dab72 100644 --- a/src/lib/PayloadUtils.js +++ b/src/lib/PayloadUtils.ts @@ -1,42 +1,51 @@ +import { ApiType } from '@advanced-rest-client/events/src/models/ApiTypes.js'; +import { ApiAnyShape, ApiPayload } from '../helpers/api.js'; import { ApiExampleGenerator } from '../schema/ApiExampleGenerator.js'; import { ApiMonacoSchemaGenerator } from '../schema/ApiMonacoSchemaGenerator.js'; import { ApiSchemaGenerator } from '../schema/ApiSchemaGenerator.js'; +export interface PayloadInfo { + value: string|FormData|Blob; + model?: ApiType[]; + schemas?: any; +} + /** @typedef {import('@advanced-rest-client/events').ApiTypes.ApiType} ApiType */ /** @typedef {import('../helpers/api').ApiPayload} ApiPayload */ /** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ /** @typedef {import('../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('./PayloadUtils').PayloadInfo} PayloadInfo */ -/** @type {Map} */ -const cache = new Map(); +const cache: Map = new Map(); -/** - * @param {ApiPayload} payload - * @returns {PayloadInfo} - */ -export function getPayloadValue(payload) { +export function getPayloadValue(payload: ApiPayload): PayloadInfo { if (cache.has(payload.id)) { - return cache.get(payload.id); + return cache.get(payload.id) as PayloadInfo; } const { id, mediaType='text/plain', schema } = payload; + if (mediaType === 'multipart/form-data') { // schema generators don't support this yet, - const info = /** @type PayloadInfo */ ({ value: new FormData(), schemas: [] }); + const info = { value: new FormData(), schemas: [] } as PayloadInfo; + cache.set(id, info); + return info; + } + if (!schema) { + const info = { value: '', schemas: [] }; cache.set(id, info); return info; } + const schemaFactory = new ApiMonacoSchemaGenerator(); const monacoSchemes = schemaFactory.generate(schema, id); let { examples } = payload; if (!Array.isArray(examples) || !examples.length) { - examples = /** @type ApiAnyShape */ (schema).examples; + examples = (schema as ApiAnyShape).examples; } if (Array.isArray(examples) && examples.length) { const [example] = examples; const generator = new ApiExampleGenerator(); const value = generator.read(example, mediaType); - const info = { value, schemas: monacoSchemes }; + const info = { value, schemas: monacoSchemes } as PayloadInfo; cache.set(id, info); return info; } @@ -58,13 +67,13 @@ export function getPayloadValue(payload) { } /** - * @param {string} id The ApiPayload id. - * @param {string} value The value to cache. - * @param {ApiType[]=} model Optional model to set. + * @param id The ApiPayload id. + * @param value The value to cache. + * @param model Optional model to set. */ -export function cachePayloadValue(id, value, model) { +export function cachePayloadValue(id: string, value: string, model?: ApiType[]): void { if (cache.has(id)) { - const info = cache.get(id); + const info = cache.get(id) as PayloadInfo; info.value = value; if (model) { info.model = model; @@ -75,9 +84,8 @@ export function cachePayloadValue(id, value, model) { } /** - * @param {string} id Payload id to read the value. - * @returns {PayloadInfo} + * @param id Payload id to read the value. */ -export function readCachePayloadValue(id) { +export function readCachePayloadValue(id: string): PayloadInfo | undefined { return cache.get(id); } diff --git a/src/lib/QueryParameterProcessor.js b/src/lib/QueryParameterProcessor.ts similarity index 57% rename from src/lib/QueryParameterProcessor.js rename to src/lib/QueryParameterProcessor.ts index eb48d10..8aaeddc 100644 --- a/src/lib/QueryParameterProcessor.js +++ b/src/lib/QueryParameterProcessor.ts @@ -1,5 +1,7 @@ /* eslint-disable class-methods-use-this */ +import { ApiArrayShape, ApiNodeShape, ApiParameter, ApiPropertyShape, ApiScalarShape, ApiShapeUnion, ApiUnionShape } from '../helpers/api.js'; import { ns } from '../helpers/Namespace.js'; +import { OperationParameter } from '../types.js'; /** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ /** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ @@ -15,31 +17,30 @@ import { ns } from '../helpers/Namespace.js'; */ export class QueryParameterProcessor { /** - * @param {ApiShapeUnion} schema - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter[]} + * @param schema + * @param binding The parameter binding. + * @param source Optional parameter source. */ - collectOperationParameters(schema, binding, source) { - let result = []; + collectOperationParameters(schema: ApiShapeUnion, binding: string, source?: string): OperationParameter[] { + let result: OperationParameter[] = []; if (!schema) { return result; } const { types } = schema; if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - result.push(this.scalarShapeOperationParameter(/** @type ApiScalarShape */ (schema), binding, source)); + result.push(this.scalarShapeOperationParameter((schema as ApiScalarShape), binding, source)); } else if (types.includes(ns.w3.shacl.NodeShape)) { - const params = this.nodeShapeOperationParameter(/** @type ApiNodeShape */ (schema), binding, source); + const params = this.nodeShapeOperationParameter((schema as ApiNodeShape), binding, source); result = result.concat(params); } else if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) { - const arrResult = this.arrayShapeOperationParameter(/** @type ApiArrayShape */ (schema), binding, source); + const arrResult = this.arrayShapeOperationParameter((schema as ApiArrayShape), binding, source); if (Array.isArray(arrResult)) { result = result.concat(arrResult); } else if (arrResult) { result.push(arrResult); } } else if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - const params = this.unionShapeOperationParameter(/** @type ApiUnionShape */ (schema), binding, source); + const params = this.unionShapeOperationParameter((schema as ApiUnionShape), binding, source); if (params) { result = result.concat(params); } @@ -48,14 +49,13 @@ export class QueryParameterProcessor { } /** - * @param {ApiScalarShape} shape - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter} + * @param shape + * @param binding The parameter binding. + * @param source Optional parameter source. */ - scalarShapeOperationParameter(shape, binding, source) { + scalarShapeOperationParameter(shape: ApiScalarShape, binding: string, source?: string): OperationParameter { const { id, name } = shape; - const constructed = /** @type ApiParameter */ ({ + const constructed: ApiParameter = { id, binding, schema: shape, @@ -64,26 +64,25 @@ export class QueryParameterProcessor { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: false, - }); + customDomainProperties: [], + }; return { binding, paramId: id, parameter: constructed, - source, + source: source || '', schemaId: id, - // @ts-ignore schema: shape, }; } /** - * @param {ApiNodeShape} shape - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter[]} + * @param shape + * @param binding The parameter binding. + * @param source Optional parameter source. */ - nodeShapeOperationParameter(shape, binding, source) { - const result = []; + nodeShapeOperationParameter(shape: ApiNodeShape, binding: string, source?: string): OperationParameter[] { + const result: OperationParameter[] = []; const { properties=[] } = shape; if (!properties.length) { return result; @@ -95,14 +94,13 @@ export class QueryParameterProcessor { } /** - * @param {ApiPropertyShape} property The property to build the parameter for. - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter} + * @param property The property to build the parameter for. + * @param binding The parameter binding. + * @param source Optional parameter source. */ - parameterOperationParameter(property, binding, source) { - const { id, range, name, minCount } = property; - const constructed = /** @type ApiParameter */ ({ + parameterOperationParameter(property: ApiPropertyShape, binding: string, source?: string): OperationParameter { + const { id, range, name, minCount=0 } = property; + const constructed: ApiParameter = { id, binding, schema: range, @@ -111,31 +109,31 @@ export class QueryParameterProcessor { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: minCount > 0, - }); + customDomainProperties: [], + }; return { binding, paramId: id, parameter: constructed, - source, + source: source || '', schemaId: property.id, schema: range, }; } /** - * @param {ApiArrayShape} shape - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter|OperationParameter[]} + * @param shape + * @param binding The parameter binding. + * @param source Optional parameter source. */ - arrayShapeOperationParameter(shape, binding, source) { + arrayShapeOperationParameter(shape: ApiArrayShape, binding: string, source?: string): OperationParameter|OperationParameter[] { const target = shape.items || shape; if (target.types.includes(ns.w3.shacl.NodeShape)) { - const typed = /** @type ApiNodeShape */ (shape.items); + const typed = (shape.items as ApiNodeShape); return this.collectOperationParameters(typed, binding, source); } const { id, name, } = target; - const constructed = /** @type ApiParameter */ ({ + const constructed: ApiParameter = { id, binding, schema: shape, @@ -144,27 +142,27 @@ export class QueryParameterProcessor { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: false, - }); + customDomainProperties: [], + }; return { binding, paramId: id, parameter: constructed, - source, + source: source || '', schemaId: id, schema: shape, }; } /** - * @param {ApiUnionShape} shape - * @param {string} binding The parameter binding. - * @param {string=} source Optional parameter source. - * @returns {OperationParameter[]|undefined} + * @param shape + * @param binding The parameter binding. + * @param source Optional parameter source. */ - unionShapeOperationParameter(shape, binding, source) { + unionShapeOperationParameter(shape: ApiUnionShape, binding: string, source?: string): OperationParameter[]|undefined { const { anyOf=[], or=[], and=[], xone=[] } = shape; if (and.length) { - let result = []; + let result: OperationParameter[] = []; and.forEach((item) => { const itemResult = this.collectOperationParameters(item, binding, source); if (itemResult) { diff --git a/src/lib/SecurityProcessor.d.ts b/src/lib/SecurityProcessor.d.ts deleted file mode 100644 index 93f34f1..0000000 --- a/src/lib/SecurityProcessor.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { ArcRequest, Authorization } from '@advanced-rest-client/events'; -import { ApiSecurityRequirement } from '../helpers/api'; -import { SecuritySelectorListItem, ApiConsoleRequest } from '../types'; - -export class SecurityProcessor { - static readSecurityList(security: ApiSecurityRequirement[]): SecuritySelectorListItem[]; - static readSecurityListItem(item: ApiSecurityRequirement): SecuritySelectorListItem; - - /** - * Applies authorization configuration to the API Console request object. - */ - static applyAuthorization(request: ApiConsoleRequest, authorization: ArcRequest.RequestAuthorization[]): void; - - /** - * Injects basic auth header into the request headers. - */ - static applyBasicAuth(request: ApiConsoleRequest, config: Authorization.BasicAuthorization): void; - - /** - * Injects oauth 2 auth header into the request headers. - */ - static applyOAuth2(request: ApiConsoleRequest, config: Authorization.OAuth2Authorization): void; - - /** - * Injects OpenID Connect auth header into the request headers. - */ - static applyOpenId(request: ApiConsoleRequest, config: Authorization.OidcAuthorization): void; - - /** - * Injects bearer auth header into the request headers. - */ - static applyBearer(request: ApiConsoleRequest, config: Authorization.BearerAuthorization): void; - - /** - * Injects the RAML custom configuration into the request - */ - static applyCustomAuth(request: ApiConsoleRequest, config: Authorization.RamlCustomAuthorization): void; - - /** - * Injects the ApiKey configuration into the request - */ - static applyApiKeys(request: ApiConsoleRequest, config: Authorization.ApiKeyAuthorization): void; - - /** - * Injects the PassThrough configuration into the request - */ - static applyPassThrough(request: ApiConsoleRequest, config: Authorization.PassThroughAuthorization): void; - - /* - @jarrodek The OAuth1 logic is enclosed in a custom element. - I don't want to move it to a separate class and maintain to be - able to apply here OAuth 1. So far we have no usage signs from anyone - (and it's been years since this logic works here). - If there's a request from a customer, in the `@advanced-rest-client/base` - module create a class that extracts the logic from the oauth 1 component - and sign the request. - */ - - // /** - // * Signs the OAuth 1 request. - // */ - // static applyOAuth1(request: ApiConsoleRequest, config: Authorization.OAuth1Authorization): void; -} diff --git a/src/lib/SecurityProcessor.js b/src/lib/SecurityProcessor.ts similarity index 61% rename from src/lib/SecurityProcessor.js rename to src/lib/SecurityProcessor.ts index 3b6e515..d61a972 100644 --- a/src/lib/SecurityProcessor.js +++ b/src/lib/SecurityProcessor.ts @@ -1,30 +1,21 @@ /* eslint-disable no-continue */ import { ArcHeaders, UrlParser, AuthorizationUtils } from '@advanced-rest-client/base/api.js'; +import { BasicAuthorization, OidcAuthorization, OAuth2Authorization, BearerAuthorization, RamlCustomAuthorization, ApiKeyAuthorization, PassThroughAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; +import { RequestAuthorization } from '@advanced-rest-client/events/src/request/ArcRequest.js'; import { METHOD_CUSTOM, METHOD_PASS_THROUGH, METHOD_API_KEY, } from '../elements/ApiAuthorizationMethodElement.js'; - -/** @typedef {import('../helpers/api').ApiSecurityRequirement} ApiSecurityRequirement */ -/** @typedef {import('@advanced-rest-client/events').ArcRequest.RequestAuthorization} RequestAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.BasicAuthorization} BasicAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Authorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth1Authorization} OAuth1Authorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.BearerAuthorization} BearerAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OidcAuthorization} OidcAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.RamlCustomAuthorization} RamlCustomAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.ApiKeyAuthorization} ApiKeyAuthorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.PassThroughAuthorization} PassThroughAuthorization */ -/** @typedef {import('../types').SecuritySelectorListItem} SecuritySelectorListItem */ -/** @typedef {import('../types').ApiConsoleRequest} ApiConsoleRequest */ +import { ApiSecurityRequirement } from '../helpers/api.js'; +import { ApiConsoleRequest, SecuritySelectorListItem } from '../types.js'; /** * Applies a map of query parameters to the request object. - * @param {ApiConsoleRequest} request The request object - * @param {Record} params A map of query parameters to apply to the request + * @param request The request object + * @param params A map of query parameters to apply to the request */ -function applyQueryParams(request, params) { +function applyQueryParams(request: ApiConsoleRequest, params?: Record): void { if (typeof params !== 'object') { return; } @@ -33,7 +24,7 @@ function applyQueryParams(request, params) { return; } const parser = new UrlParser(request.url); - const sParams = parser.searchParams; + const sParams = parser.searchParams as string[][]; keys.forEach((name) => { const value = params[name]; const index = sParams.findIndex((item) => item[0] === name); @@ -48,10 +39,10 @@ function applyQueryParams(request, params) { /** * Applies a map of headers to the request object. - * @param {ApiConsoleRequest} request The request object - * @param {Record} headers A map of headers to apply to the request + * @param request The request object + * @param headers A map of headers to apply to the request */ -function applyHeaders(request, headers) { +function applyHeaders(request: ApiConsoleRequest, headers?: Record): void { if (typeof headers !== 'object') { return; } @@ -68,12 +59,8 @@ function applyHeaders(request, headers) { } export class SecurityProcessor { - /** - * @param {ApiSecurityRequirement[]} security - * @returns {SecuritySelectorListItem[]} - */ - static readSecurityList(security) { - const result = /** @type SecuritySelectorListItem[] */ ([]); + static readSecurityList(security: ApiSecurityRequirement[]): SecuritySelectorListItem[] { + const result: SecuritySelectorListItem[] = [] if (!Array.isArray(security) || !security.length) { return result; } @@ -87,17 +74,13 @@ export class SecurityProcessor { return result; } - /** - * @param {ApiSecurityRequirement} item - * @returns {SecuritySelectorListItem} - */ - static readSecurityListItem(item) { + static readSecurityListItem(item: ApiSecurityRequirement): SecuritySelectorListItem { const { schemes } = item; - const result = /** @type SecuritySelectorListItem */ ({ + const result: SecuritySelectorListItem = { types: [], labels: [], security: item, - }); + }; schemes.forEach((scheme) => { const { name, scheme: settings } = scheme; if (name === 'null') { @@ -117,10 +100,8 @@ export class SecurityProcessor { /** * Applies authorization configuration to the API Console request object. - * @param {ApiConsoleRequest} request - * @param {RequestAuthorization[]} authorization */ - static applyAuthorization(request, authorization) { + static applyAuthorization(request: ApiConsoleRequest, authorization: RequestAuthorization[]): void { if (!Array.isArray(authorization) || !authorization.length) { return; } @@ -131,35 +112,35 @@ export class SecurityProcessor { } switch (AuthorizationUtils.normalizeType(auth.type)) { case AuthorizationUtils.METHOD_BASIC: - SecurityProcessor.applyBasicAuth(request, /** @type BasicAuthorization */ (auth.config)); + SecurityProcessor.applyBasicAuth(request, (auth.config as BasicAuthorization)); auth.enabled = false; break; case AuthorizationUtils.METHOD_OAUTH2: - SecurityProcessor.applyOAuth2(request, /** @type OAuth2Authorization */ (auth.config)); + SecurityProcessor.applyOAuth2(request, (auth.config as OAuth2Authorization)); auth.enabled = false; break; case AuthorizationUtils.METHOD_OIDC: - SecurityProcessor.applyOpenId(request, /** @type OidcAuthorization */ (auth.config)); + SecurityProcessor.applyOpenId(request, (auth.config as OidcAuthorization)); auth.enabled = false; break; case AuthorizationUtils.METHOD_BEARER: - SecurityProcessor.applyBearer(request, /** @type BearerAuthorization */ (auth.config)); + SecurityProcessor.applyBearer(request, (auth.config as BearerAuthorization)); auth.enabled = false; break; case METHOD_CUSTOM: - SecurityProcessor.applyCustomAuth(request, /** @type RamlCustomAuthorization */ (auth.config)); + SecurityProcessor.applyCustomAuth(request, (auth.config as RamlCustomAuthorization)); auth.enabled = false; break; case METHOD_API_KEY: - SecurityProcessor.applyApiKeys(request, /** @type ApiKeyAuthorization */ (auth.config)); + SecurityProcessor.applyApiKeys(request, (auth.config as ApiKeyAuthorization)); auth.enabled = false; break; case METHOD_PASS_THROUGH: - SecurityProcessor.applyPassThrough(request, /** @type PassThroughAuthorization */ (auth.config)); + SecurityProcessor.applyPassThrough(request, (auth.config as PassThroughAuthorization)); auth.enabled = false; break; // case METHOD_OAUTH1: - // SecurityProcessor.applyOAuth1(request, /** @type OAuth1Authorization */ (auth.config)); + // SecurityProcessor.applyOAuth1(request, (auth.config as OAuth1Authorization)); // auth.enabled = false; // break; default: @@ -169,10 +150,8 @@ export class SecurityProcessor { /** * Injects basic auth header into the request headers. - * @param {ApiConsoleRequest} request - * @param {BasicAuthorization} config */ - static applyBasicAuth(request, config) { + static applyBasicAuth(request: ApiConsoleRequest, config: BasicAuthorization): void { const { username, password } = config; if (!username) { return; @@ -186,10 +165,8 @@ export class SecurityProcessor { /** * Injects oauth 2 auth header into the request headers. - * @param {ApiConsoleRequest} request - * @param {OAuth2Authorization} config */ - static applyOAuth2(request, config) { + static applyOAuth2(request: ApiConsoleRequest, config: OAuth2Authorization): void { const { accessToken, tokenType='Bearer', deliveryMethod='header', deliveryName='authorization' } = config; if (!accessToken) { return; @@ -213,10 +190,8 @@ export class SecurityProcessor { /** * Injects OpenID Connect auth header into the request headers. - * @param {ApiConsoleRequest} request - * @param {OidcAuthorization} config */ - static applyOpenId(request, config) { + static applyOpenId(request: ApiConsoleRequest, config: OidcAuthorization): void { const { accessToken } = config; if (accessToken) { SecurityProcessor.applyOAuth2(request, config); @@ -227,10 +202,8 @@ export class SecurityProcessor { /** * Injects bearer auth header into the request headers. - * @param {ApiConsoleRequest} request - * @param {BearerAuthorization} config */ - static applyBearer(request, config) { + static applyBearer(request: ApiConsoleRequest, config: BearerAuthorization): void { const { token } = config; const value = `Bearer ${token}`; @@ -241,10 +214,8 @@ export class SecurityProcessor { /** * Injects the RAML custom configuration into the request - * @param {ApiConsoleRequest} request - * @param {RamlCustomAuthorization} config */ - static applyCustomAuth(request, config) { + static applyCustomAuth(request: ApiConsoleRequest, config: RamlCustomAuthorization): void { const { header, query } = config; applyQueryParams(request, query); applyHeaders(request, header); @@ -252,10 +223,8 @@ export class SecurityProcessor { /** * Injects the ApiKey configuration into the request - * @param {ApiConsoleRequest} request - * @param {ApiKeyAuthorization} config */ - static applyApiKeys(request, config) { + static applyApiKeys(request: ApiConsoleRequest, config: ApiKeyAuthorization): void { const { header, query, } = config; applyQueryParams(request, query); applyHeaders(request, header); @@ -263,10 +232,8 @@ export class SecurityProcessor { /** * Injects the PassThrough configuration into the request - * @param {ApiConsoleRequest} request - * @param {PassThroughAuthorization} config */ - static applyPassThrough(request, config) { + static applyPassThrough(request: ApiConsoleRequest, config: PassThroughAuthorization): void { const { header, query, } = config; applyQueryParams(request, query); applyHeaders(request, header); @@ -287,7 +254,7 @@ export class SecurityProcessor { // * @param {ApiConsoleRequest} request // * @param {OAuth1Authorization} config // */ - // static applyOAuth1(request, config) { + // static applyOAuth1(request: ApiConsoleRequest, config: OAuth1Authorization): void { // ... // } } diff --git a/src/lib/UrlUtils.d.ts b/src/lib/UrlUtils.d.ts deleted file mode 100644 index 120f324..0000000 --- a/src/lib/UrlUtils.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { ComputeBaseUriOptions } from '../types'; - -/** - * Computes the base URI value for the API/endpoint/operation. - * - * @param options The computation options - * @returns Base uri value. Can be empty string. - */ -export function computeApiBaseUri(options: ComputeBaseUriOptions): string; - -/** - * Computes the base URI value for the API/endpoint/operation. - * - * @param options The computation options - * @returns Base uri value. Can be empty string. - */ -export function computeEndpointUri(options: ComputeBaseUriOptions): string; - -/** - * @param str A key or value to encode as x-www-form-urlencoded. - * @param replacePlus When set it replaces `%20` with `+`. - */ -export function wwwFormUrlEncode(str: string, replacePlus: boolean): string; - -/** - * @param url The current URL - * @param variables The path variables to apply. - * @param encode Whether to encode parameters. - */ -export function applyUrlVariables(url: string, variables: Record, encode: boolean): string; - -/** - * @param url The current URL - * @param params The query parameters to apply. - * @param encode Whether to encode parameters. - */ -export function applyUrlParameters(url: string, params: Record, encode: boolean): string; - -/** - * Applies query parameter values to an object. - * Repeated parameters will have array value instead of string value. - * - * @param param Query parameter value as string. Eg `name=value` - * @param obj Target for values - */ -export function applyQueryParamStringToObject(param: string, obj: Record): void; diff --git a/src/lib/UrlUtils.js b/src/lib/UrlUtils.ts similarity index 68% rename from src/lib/UrlUtils.js rename to src/lib/UrlUtils.ts index b783f9f..8fc9792 100644 --- a/src/lib/UrlUtils.js +++ b/src/lib/UrlUtils.ts @@ -1,6 +1,8 @@ /* eslint-disable prefer-destructuring */ /* eslint-disable no-param-reassign */ +import { ComputeBaseUriOptions } from "../types.js"; + /** @typedef {import('../helpers/api').ApiEndPoint} ApiEndPoint */ /** @typedef {import('../helpers/api').ApiServer} ApiServer */ /** @typedef {import('../types').ComputeBaseUriOptions} ComputeBaseUriOptions */ @@ -8,11 +10,11 @@ /** * Computes the base URI value for the API/endpoint/operation. * - * @param {string} url The url to check for protocol information. - * @param {ComputeBaseUriOptions} options The computation options - * @returns {string} The base uri value with a protocol, + * @param url The url to check for protocol information. + * @param options The computation options + * @returns The base uri value with a protocol, */ -export function setProtocol(url='', options={}) { +export function setProtocol(url='', options: ComputeBaseUriOptions={}): string { const { server, protocols=[] } = options; const schemes = [...protocols]; if (server && server.protocol) { @@ -33,10 +35,10 @@ export function setProtocol(url='', options={}) { /** * Computes the base URI value for the API/endpoint/operation. * - * @param {ComputeBaseUriOptions} options The computation options - * @returns {string} Base uri value. Can be empty string. + * @param options The computation options + * @returns Base uri value. Can be empty string. */ -export function computeApiBaseUri(options={}) { +export function computeApiBaseUri(options: ComputeBaseUriOptions={}): string { const { baseUri, server, version } = options; if (baseUri) { let result = baseUri; @@ -62,10 +64,10 @@ export function computeApiBaseUri(options={}) { /** * Computes the base URI value for the API/endpoint/operation. * - * @param {ComputeBaseUriOptions} options The computation options - * @returns {string} Base uri value. Can be empty string. + * @param options The computation options + * @returns Base uri value. Can be empty string. */ -export function computeEndpointUri(options={}) { +export function computeEndpointUri(options: ComputeBaseUriOptions={}): string { let result = computeApiBaseUri(options); if (options.endpoint) { let { path='' } = options.endpoint; @@ -81,11 +83,10 @@ export function computeEndpointUri(options={}) { } /** - * @param {string} str A key or value to encode as x-www-form-urlencoded. - * @param {boolean} replacePlus When set it replaces `%20` with `+`. - * @returns {string} . + * @param str A key or value to encode as x-www-form-urlencoded. + * @param replacePlus When set it replaces `%20` with `+`. */ -export function wwwFormUrlEncode(str, replacePlus) { +export function wwwFormUrlEncode(str: string, replacePlus: boolean): string { // Spec says to normalize newlines to \r\n and replace %20 spaces with +. // jQuery does this as well, so this is likely to be widely compatible. if (!str) { @@ -100,10 +101,9 @@ export function wwwFormUrlEncode(str, replacePlus) { /** * Creates a RegExp object to replace template variable from the base string - * @param {string} name Name of the parameter to be replaced - * @returns {RegExp} + * @param name Name of the parameter to be replaced */ -function createUrlReplaceRegex(name) { +function createUrlReplaceRegex(name: string): RegExp { if (name[0] === '+' || name[0] === '#') { // eslint-disable-next-line no-param-reassign name = `\\${name}`; @@ -112,11 +112,11 @@ function createUrlReplaceRegex(name) { } /** - * @param {string} url The current URL - * @param {Record} variables The path variables to apply. - * @param {boolean} encode Whether to encode parameters. + * @param url The current URL + * @param variables The path variables to apply. + * @param encode Whether to encode parameters. */ -export function applyUrlVariables(url, variables, encode) { +export function applyUrlVariables(url: string, variables: Record, encode: boolean): string { let result = url || ''; Object.keys(variables).forEach((variable) => { let value = variables[variable]; @@ -143,20 +143,16 @@ export function applyUrlVariables(url, variables, encode) { } /** - * @param {Record} params The query parameters to use to generate the query string. - * @param {boolean} encode Whether to encode query parameters. - * @returns {string} The query string. + * @param params The query parameters to use to generate the query string. + * @param encode Whether to encode query parameters. + * @returns The query string. */ -function generateQueryString(params, encode) { +function generateQueryString(params: Record, encode: boolean): string { if (typeof params !== 'object') { return ''; } - const parts = []; - /** - * @param {string} name - * @param {any} value - */ - function addPart(name, value) { + const parts: string[] = []; + function addPart(name: string, value: any): void { if (value === undefined) { value = ''; } else { @@ -186,11 +182,11 @@ function generateQueryString(params, encode) { } /** - * @param {string} url The current URL - * @param {Record} params The query parameters to apply. - * @param {boolean} encode Whether to encode parameters. + * @param url The current URL + * @param params The query parameters to apply. + * @param encode Whether to encode parameters. */ -export function applyUrlParameters(url, params, encode) { +export function applyUrlParameters(url: string, params: Record, encode: boolean): string { const query = generateQueryString(params, encode); if (!query) { return url; @@ -205,10 +201,10 @@ export function applyUrlParameters(url, params, encode) { * Applies query parameter values to an object. * Repeated parameters will have array value instead of string value. * - * @param {string} param Query parameter value as string. Eg `name=value` - * @param {Record} obj Target for values + * @param param Query parameter value as string. Eg `name=value` + * @param obj Target for values */ -export function applyQueryParamStringToObject(param, obj) { +export function applyQueryParamStringToObject(param: string, obj: Record): void { if (!param || !obj || typeof param !== 'string') { return; } @@ -216,9 +212,9 @@ export function applyQueryParamStringToObject(param, obj) { const name = parts[0]; if (name in obj) { if (!Array.isArray(obj[name])) { - obj[name] = [/** @type string */(obj[name])]; + obj[name] = [obj[name] as string]; } - /** @type string[] */(obj[name]).push(parts[1]); + (obj[name] as string[]).push(parts[1]); } else { obj[name] = parts[1]; } diff --git a/src/lib/Utils.js b/src/lib/Utils.ts similarity index 72% rename from src/lib/Utils.js rename to src/lib/Utils.ts index 9160b94..a86d6f3 100644 --- a/src/lib/Utils.js +++ b/src/lib/Utils.ts @@ -1,5 +1,6 @@ import { HeadersParser } from '@advanced-rest-client/base/api.js'; import sanitizer from 'dompurify'; +import { ApiArrayShape, ApiNodeShape, ApiParameter, ApiParametrizedDeclaration, ApiScalarShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../helpers/api.js'; import { ns } from '../helpers/Namespace.js'; /** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ @@ -17,18 +18,18 @@ import { ns } from '../helpers/Namespace.js'; /** * Stops an event and cancels it. - * @param {Event} e The event to stop + * @param e The event to stop */ -export function cancelEvent(e) { +export function cancelEvent(e: Event): void { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); } /** - * @param {string[]} types Shape's types + * @param types Shape's types */ -export function isScalarType(types=[]) { +export function isScalarType(types: string[] = []): boolean { const { shapes } = ns.aml.vocabularies; return types.includes(shapes.ScalarShape) || types.includes(shapes.NilShape) || @@ -36,9 +37,9 @@ export function isScalarType(types=[]) { } /** - * @param {string} value The value from the graph model to use to read the value from + * @param value The value from the graph model to use to read the value from */ -export function schemaToType(value) { +export function schemaToType(value: string): string { const typed = String(value); let index = typed.lastIndexOf('#'); if (index === -1) { @@ -53,11 +54,11 @@ export function schemaToType(value) { /** * Reads the label for a data type for a shape union. - * @param {ApiShapeUnion} schema - * @param {boolean=} [isArray] Used internally - * @returns {string|undefined} Computed label for a shape. + * @param schema + * @param isArray Used internally + * @returns Computed label for a shape. */ -export function readPropertyTypeLabel(schema, isArray=false) { +export function readPropertyTypeLabel(schema: ApiShapeUnion, isArray=false): string|undefined { if (!schema) { return undefined; } @@ -66,11 +67,11 @@ export function readPropertyTypeLabel(schema, isArray=false) { return 'Nil'; } if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - const scalar = /** @type ApiScalarShape */ (schema); + const scalar = schema as ApiScalarShape; return schemaToType(scalar.dataType || ''); } if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - const array = /** @type ApiTupleShape */ (schema); + const array = schema as ApiTupleShape; if (!array.items || !array.items.length) { return undefined; } @@ -78,7 +79,7 @@ export function readPropertyTypeLabel(schema, isArray=false) { return `List of ${label}`; } if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) { - const array = /** @type ApiArrayShape */ (schema); + const array = schema as ApiArrayShape; if (!array.items) { return undefined; } @@ -89,10 +90,10 @@ export function readPropertyTypeLabel(schema, isArray=false) { return `List of ${label}`; } if (types.includes(ns.w3.shacl.NodeShape)) { - let { name } = /** @type ApiNodeShape */ (schema); - const { properties } = /** @type ApiNodeShape */ (schema); + let { name } = schema as ApiNodeShape; + const { properties } = schema as ApiNodeShape; if (isArray && properties && properties.length === 1) { - const potentialScalar = /** @type ApiScalarShape */ (properties[0].range); + const potentialScalar = properties[0].range as ApiScalarShape; if (potentialScalar.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { return schemaToType(potentialScalar.dataType || ''); } @@ -104,7 +105,7 @@ export function readPropertyTypeLabel(schema, isArray=false) { return name || 'Object'; } if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - const union = /** @type ApiUnionShape */ (schema); + const union = schema as ApiUnionShape; const items = union.anyOf.map(i => readPropertyTypeLabel(i)); return items.join(' or '); } @@ -115,18 +116,18 @@ export function readPropertyTypeLabel(schema, isArray=false) { } /** - * @param {ApiShapeUnion[]} shapes - * @returns {boolean} true when all of passed shapes are scalar. + * @param shapes + * @returns true when all of passed shapes are scalar. */ -function isAllScalar(shapes=[]) { +function isAllScalar(shapes: ApiShapeUnion[] = []): boolean { return !shapes.some(i => !isScalarType(i.types)); } /** - * @param {ApiUnionShape} shape - * @returns {boolean} true when the passed union type consists of scalar values only. Nil counts as scalar. + * @param shape + * @returns true when the passed union type consists of scalar values only. Nil counts as scalar. */ -export function isScalarUnion(shape) { +export function isScalarUnion(shape: ApiUnionShape): boolean { const { anyOf=[], or=[], and=[], xone=[] } = shape; if (anyOf.length) { return isAllScalar(anyOf); @@ -143,11 +144,7 @@ export function isScalarUnion(shape) { return true; } -/** - * @param {string} HTML - * @returns {string} - */ -export function sanitizeHTML(HTML) { +export function sanitizeHTML(HTML: string): string { const result = sanitizer.sanitize(HTML, { ADD_ATTR: ['target', 'href'], ALLOWED_TAGS: ['a'], @@ -162,10 +159,7 @@ export function sanitizeHTML(HTML) { return result.toString(); } -/** - * @param {ApiParametrizedDeclaration[]} traits - */ -export function joinTraitNames(traits) { +export function joinTraitNames(traits: ApiParametrizedDeclaration[]): string { const names = traits.map(trait => trait.name).filter(i => !!i); let value = ''; if (names.length === 2) { @@ -180,11 +174,7 @@ export function joinTraitNames(traits) { return value; } -/** - * @param {Record} params - * @returns {string} - */ - export function generateHeaders(params) { +export function generateHeaders(params: Record): string { if (typeof params !== 'object') { return ''; } @@ -207,10 +197,10 @@ export function joinTraitNames(traits) { /** * Ensures the headers have content type header. - * @param {string} headers The generated headers string - * @param {string} mime The expected by the selected payload media type. If not set then it does nothing. + * @param headers The generated headers string + * @param mime The expected by the selected payload media type. If not set then it does nothing. */ -export function ensureContentType(headers, mime) { +export function ensureContentType(headers: string, mime: string): string { if (!mime) { return headers; } @@ -223,12 +213,12 @@ export function ensureContentType(headers, mime) { } /** - * @param {ApiParameter} parameter - * @param {ApiShapeUnion} schema - * @returns {string} The name to use in the input. + * @param parameter + * @param schema + * @returns The name to use in the input. */ -export function readLabelValue(parameter, schema) { - let label = parameter.paramName || schema.displayName || parameter.name || schema.name; +export function readLabelValue(parameter: ApiParameter, schema: ApiShapeUnion): string { + let label = parameter.paramName || schema.displayName || parameter.name || schema.name || ''; const { required } = parameter; if (required) { label += '*'; diff --git a/src/lib/auth-ui/ApiKeyAuth.js b/src/lib/auth-ui/ApiKeyAuth.ts similarity index 75% rename from src/lib/auth-ui/ApiKeyAuth.js rename to src/lib/auth-ui/ApiKeyAuth.ts index fda3911..3e1cfb3 100644 --- a/src/lib/auth-ui/ApiKeyAuth.js +++ b/src/lib/auth-ui/ApiKeyAuth.ts @@ -1,19 +1,16 @@ /* eslint-disable class-methods-use-this */ -import { html } from 'lit-html'; +import { html, TemplateResult } from 'lit'; +import { ApiKeyAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; - -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('../../helpers/api').ApiSecurityApiKeySettings} ApiSecurityApiKeySettings */ -/** @typedef {import('@advanced-rest-client/events').Authorization.ApiKeyAuthorization} ApiKeyAuthorization */ -/** @typedef {import('../../types').OperationParameter} OperationParameter */ +import { ApiParameter, ApiSecurityApiKeySettings, ApiShapeUnion } from '../../helpers/api.js'; export default class ApiKeyAuth extends ApiUiBase { - async initializeApiModel() { + async initializeApiModel(): Promise { const { security } = this; const source = 'settings'; - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = (this.parametersValue); this.parametersValue = list.filter(item => item.source !== source); if (!security) { @@ -30,11 +27,11 @@ export default class ApiKeyAuth extends ApiUiBase { if (!type || !type.startsWith('Api Key')) { return; } - const config = /** @type ApiSecurityApiKeySettings */ (scheme.settings); + const config = scheme.settings as ApiSecurityApiKeySettings | undefined; if (!config) { return; } - const { in: binding, id } = config; + const { in: binding = '', id } = config; if (!InputCache.has(this.target, id, this.globalCache)) { InputCache.set(this.target, id, '', this.globalCache); } @@ -42,10 +39,10 @@ export default class ApiKeyAuth extends ApiUiBase { params.push({ binding, paramId: id, - parameter: { ... /** @type any */ (config), binding }, + parameter: { ... (config as ApiParameter), binding }, source: 'settings', schemaId: scheme.id, - schema: /** @type any */ (scheme), + schema: (scheme as unknown as ApiShapeUnion), }); await this.requestUpdate(); @@ -61,7 +58,7 @@ export default class ApiKeyAuth extends ApiUiBase { * @param {string} name The name of the changed parameter * @param {string} newValue A value to apply. May be empty but must be defined. */ - updateQueryParameter(name, newValue) { + updateQueryParameter(name: string, newValue: string): void { const list = /** @type OperationParameter[] */ (this.parametersValue); const param = list.find(i => i.binding === 'query' && i.parameter.name === name); if (param) { @@ -80,7 +77,7 @@ export default class ApiKeyAuth extends ApiUiBase { * @param {string} name The name of the changed header * @param {string} newValue A value to apply. May be empty but must be defined. */ - updateHeader(name, newValue) { + updateHeader(name: string, newValue: string): void { const list = /** @type OperationParameter[] */ (this.parametersValue); const param = list.find(i => i.binding === 'header' && i.parameter.name === name); if (param) { @@ -98,7 +95,7 @@ export default class ApiKeyAuth extends ApiUiBase { * @param {string} name The name of the changed cookie * @param {string} newValue A value to apply. May be empty but must be defined. */ - updateCookie(name, newValue) { + updateCookie(name: string, newValue: string): void { const list = /** @type OperationParameter[] */ (this.parametersValue); const param = list.find(i => i.binding === 'cookie' && i.parameter.name === name); if (param) { @@ -106,7 +103,7 @@ export default class ApiKeyAuth extends ApiUiBase { } } - reset() { + reset(): void { const params = this.parametersValue; (params || []).forEach((param) => { InputCache.set(this.target, param.paramId, '', this.globalCache) @@ -115,9 +112,8 @@ export default class ApiKeyAuth extends ApiUiBase { /** * Restores previously serialized values - * @param {ApiKeyAuthorization} state */ - restore(state) { + restore(state: ApiKeyAuthorization): void { if (!state) { return; } @@ -127,15 +123,11 @@ export default class ApiKeyAuth extends ApiUiBase { this.requestUpdate(); } - /** - * @param {string} binding - * @param {ApiKeyAuthorization} restored - */ - restoreModelValue(binding, restored) { + restoreModelValue(binding: string, restored?: ApiKeyAuthorization): void { if (!restored) { return; } - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = this.parametersValue; const params = list.filter(i => i.binding === binding); if (!params) { return; @@ -143,22 +135,19 @@ export default class ApiKeyAuth extends ApiUiBase { Object.keys(restored).forEach((name) => { const param = params.find(i => i.parameter.name === name); if (param) { - InputCache.set(this.target, param.paramId, restored[name], this.globalCache); + InputCache.set(this.target, param.paramId, restored[name as keyof ApiKeyAuthorization], this.globalCache); } }); } - /** - * @returns {ApiKeyAuthorization} - */ - serialize() { - const params = /** @type OperationParameter[] */ (this.parametersValue); - const result = /** @type ApiKeyAuthorization */ ({}); + serialize(): ApiKeyAuthorization { + const params = this.parametersValue; + const result: ApiKeyAuthorization = {}; (params || []).forEach((param) => { - if (!result[param.binding]) { - result[param.binding] = {}; + if (!result[param.binding as keyof ApiKeyAuthorization]) { + result[param.binding as keyof ApiKeyAuthorization] = {}; } - let value = InputCache.get(this.target, param.paramId, this.globalCache); + let value = InputCache.get(this.target, param.paramId, this.globalCache) as string | boolean; if (value === '' || value === undefined) { if (param.parameter.required === false) { return; @@ -171,17 +160,14 @@ export default class ApiKeyAuth extends ApiUiBase { if (value === null) { value = ''; } - result[param.binding][param.parameter.name] = value; + (result[param.binding as keyof ApiKeyAuthorization] as Record)[param.parameter.name || ''] = value as string; }); - return /** @type ApiKeyAuthorization */ (result); + return result; } - /** - * @returns {boolean} - */ - validate() { + validate(): boolean { const nils = this.nilValues; - const params = /** @type OperationParameter[] */ (this.parametersValue); + const params = this.parametersValue; return !params.some((param) => { if (nils.includes(param.paramId)) { return true; @@ -191,7 +177,7 @@ export default class ApiKeyAuth extends ApiUiBase { }); } - render() { + render(): TemplateResult { return html` ${this.titleTemplate()}
@@ -204,10 +190,8 @@ export default class ApiKeyAuth extends ApiUiBase { /** * Method that renders scheme's title - * - * @return {TemplateResult} */ - titleTemplate() { + titleTemplate(): TemplateResult { return html`
Scheme: Api Key @@ -217,10 +201,10 @@ export default class ApiKeyAuth extends ApiUiBase { /** * Method that renders headers, if any * - * @return {TemplateResult|string} Empty string is returned when the section + * @returns Empty string is returned when the section * should not be rendered, as documented in `lit-html` library. */ - headersTemplate() { + headersTemplate(): TemplateResult|string { const headers = this.parametersValue.filter(item => item.binding === 'header'); if (!headers.length) { return ''; @@ -236,10 +220,10 @@ export default class ApiKeyAuth extends ApiUiBase { /** * Method that renders query parameters, if any * - * @return {TemplateResult|string} Empty string is returned when the section + * @returns Empty string is returned when the section * should not be rendered, as documented in `lit-html` library. */ - queryTemplate() { + queryTemplate(): TemplateResult|string { const headers = this.parametersValue.filter(item => item.binding === 'query'); if (!headers.length) { return ''; @@ -255,10 +239,10 @@ export default class ApiKeyAuth extends ApiUiBase { /** * Method that renders cookies, if any * - * @return {TemplateResult|string} Empty string is returned when the section + * @returns Empty string is returned when the section * should not be rendered, as documented in `lit-html` library. */ - cookieTemplate() { + cookieTemplate(): TemplateResult|string { const headers = this.parametersValue.filter(item => item.binding === 'cookie'); if (!headers.length) { return ''; diff --git a/src/lib/auth-ui/ApiUiBase.js b/src/lib/auth-ui/ApiUiBase.ts similarity index 63% rename from src/lib/auth-ui/ApiUiBase.js rename to src/lib/auth-ui/ApiUiBase.ts index 65234c8..fc3ad11 100644 --- a/src/lib/auth-ui/ApiUiBase.js +++ b/src/lib/auth-ui/ApiUiBase.ts @@ -1,4 +1,4 @@ -/* eslint-disable no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable class-methods-use-this */ import AuthUiBase from "@advanced-rest-client/base/src/elements/authorization/ui/AuthUiBase.js"; import '@anypoint-web-components/awc/anypoint-dropdown-menu.js'; @@ -10,26 +10,18 @@ import '@anypoint-web-components/awc/anypoint-button.js'; import '@anypoint-web-components/awc/anypoint-icon-button.js'; import '@advanced-rest-client/icons/arc-icon.js'; import { AmfParameterMixin } from '../AmfParameterMixin.js'; - -/** @typedef {import('@advanced-rest-client/base').AuthUiInit} AuthUiInit */ -/** @typedef {import('../../helpers/amf').DomainElement} DomainElement */ -/** @typedef {import('../../helpers/api').ApiParametrizedSecurityScheme} ApiParametrizedSecurityScheme */ +import { ApiParametrizedSecurityScheme } from "../../helpers/api.js"; const securityValue = Symbol("securityValue"); -const apiValue = Symbol("apiValue"); export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { - /** - * @returns {ApiParametrizedSecurityScheme} - */ - get security() { + [securityValue]?: ApiParametrizedSecurityScheme; + + get security(): ApiParametrizedSecurityScheme | undefined { return this[securityValue]; } - /** - * @param {ApiParametrizedSecurityScheme} value - */ - set security(value) { + set security(value: ApiParametrizedSecurityScheme | undefined) { const old = this[securityValue]; if (old === value) { return; @@ -43,7 +35,7 @@ export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { * Called when the `security` value change. Should be used * to initialize the UI after setting AMF models. */ - initializeApiModel() { + initializeApiModel(): void { // ... } @@ -53,10 +45,10 @@ export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { * This does nothing if the query parameter has not been defined for the current * scheme. * - * @param {string} name The name of the changed parameter - * @param {string} newValue A value to apply. May be empty but must be defined. + * @param name The name of the changed parameter + * @param newValue A value to apply. May be empty but must be defined. */ - updateQueryParameter(name, newValue) { + updateQueryParameter(name: string, newValue: string): void { // ... } @@ -68,10 +60,10 @@ export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { * This does nothing if the header has not been defined for current * scheme. * - * @param {string} name The name of the changed header - * @param {string} newValue A value to apply. May be empty but must be defined. + * @param name The name of the changed header + * @param newValue A value to apply. May be empty but must be defined. */ - updateHeader(name, newValue) { + updateHeader(name: string, newValue: string): void { // ... } @@ -82,18 +74,18 @@ export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { * This does nothing if the cookie has not been defined for current * scheme. * - * @param {string} name The name of the changed cookie - * @param {string} newValue A value to apply. May be empty but must be defined. + * @param name The name of the changed cookie + * @param newValue A value to apply. May be empty but must be defined. */ - updateCookie(name, newValue) { + updateCookie(name: string, newValue: string): void { // ... } /** * To be implemented by the child classes. - * @returns {boolean} True when the UI is in valid state. + * @returns True when the UI is in valid state. */ - validate() { + validate(): boolean { return true; } } diff --git a/src/lib/auth-ui/CustomAuth.js b/src/lib/auth-ui/CustomAuth.ts similarity index 69% rename from src/lib/auth-ui/CustomAuth.js rename to src/lib/auth-ui/CustomAuth.ts index d849da2..55a1ec1 100644 --- a/src/lib/auth-ui/CustomAuth.js +++ b/src/lib/auth-ui/CustomAuth.ts @@ -1,51 +1,46 @@ /* eslint-disable class-methods-use-this */ -import { html } from 'lit-html'; +import { html, TemplateResult } from 'lit'; import '@advanced-rest-client/highlight/arc-marked.js'; +import { RamlCustomAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; +import { AuthUiInit } from '@advanced-rest-client/base/api.js'; import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; - -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('@advanced-rest-client/base').AuthUiInit} AuthUiInit */ -/** @typedef {import('@advanced-rest-client/events').Authorization.RamlCustomAuthorization} RamlCustomAuthorization */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../../types').OperationParameter} OperationParameter */ +import { ApiNodeShape, ApiParameter, ApiPropertyShape, ApiShapeUnion } from '../../helpers/api.js'; +import { OperationParameter } from '../../types.js'; export default class CustomAuth extends ApiUiBase { - /** - * @param {AuthUiInit} init - */ - constructor(init) { + + schemeName?: string; + + schemeDescription?: string; + + descriptionOpened?: boolean; + + constructor(init: AuthUiInit) { super(init); this.clearInit(); this.toggleDescription = this.toggleDescription.bind(this); } - clearInit() { - /** @type {string} */ + clearInit(): void { this.schemeName = undefined; - /** @type {string} */ this.schemeDescription = undefined; - /** @type {boolean} */ - this.anypoint = undefined; - /** @type {boolean} */ + this.anypoint = false; this.descriptionOpened = undefined; } - reset() { + reset(): void { this.clearInit(); this.clearCache(); } - initializeApiModel() { + initializeApiModel(): void { const { security } = this; this.clearInit(); const source = 'settings'; - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = this.parametersValue; this.parametersValue = list.filter(item => item.source !== source); if (!security) { @@ -68,7 +63,7 @@ export default class CustomAuth extends ApiUiBase { headers.forEach((p) => { const param = { ...p, required: true }; params.push({ - binding: param.binding, + binding: param.binding || '', paramId: param.id, parameter: param, source, @@ -83,7 +78,7 @@ export default class CustomAuth extends ApiUiBase { addedParameters = true; const param = { ...p, required: true }; params.push({ - binding: param.binding, + binding: param.binding || '', paramId: param.id, parameter: param, source, @@ -93,7 +88,7 @@ export default class CustomAuth extends ApiUiBase { }); } if (!addedParameters && queryString) { - const shape = /** @type ApiNodeShape */ (queryString); + const shape = queryString as ApiNodeShape; const { properties } = shape; const binding = 'query'; if (!properties) { @@ -110,15 +105,9 @@ export default class CustomAuth extends ApiUiBase { this.notifyChange(); } - /** - * @param {ApiShapeUnion} shape - * @param {string} binding - * @param {string} source - * @returns {OperationParameter} - */ - createParameterFromSchema(shape, binding, source) { + createParameterFromSchema(shape: ApiShapeUnion, binding: string, source: string): OperationParameter { const { id, name } = shape; - const constructed = /** @type ApiParameter */ ({ + const constructed: ApiParameter = { id, binding, schema: shape, @@ -127,27 +116,21 @@ export default class CustomAuth extends ApiUiBase { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: false, - }); + customDomainProperties: [], + }; return { binding, paramId: id, parameter: constructed, source, schemaId: id, - // @ts-ignore schema: shape, }; } - /** - * @param {ApiPropertyShape} property - * @param {string} binding - * @param {string} source - * @returns {OperationParameter} - */ - createParameterFromProperty(property, binding, source) { - const { id, range, name, minCount } = property; - const constructed = /** @type ApiParameter */ ({ + createParameterFromProperty(property: ApiPropertyShape, binding: string, source: string): OperationParameter { + const { id, range, name, minCount=0 } = property; + const constructed: ApiParameter = { id, binding, schema: range, @@ -156,15 +139,15 @@ export default class CustomAuth extends ApiUiBase { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: minCount > 0, - }); + customDomainProperties: [], + }; return { binding, paramId: id, parameter: constructed, source, schemaId: property.id, - // @ts-ignore - schema: property, + schema: property as ApiShapeUnion, }; } @@ -174,10 +157,10 @@ export default class CustomAuth extends ApiUiBase { * This does nothing if the query parameter has not been defined for the current * scheme. * - * @param {string} name The name of the changed parameter - * @param {string} newValue A value to apply. May be empty but must be defined. + * @param name The name of the changed parameter + * @param newValue A value to apply. May be empty but must be defined. */ - updateQueryParameter(name, newValue) { + updateQueryParameter(name: string, newValue: string): void { const list = /** @type OperationParameter[] */ (this.parametersValue); const param = list.find(i => i.binding === 'query' && i.parameter.name === name); if (param) { @@ -193,22 +176,18 @@ export default class CustomAuth extends ApiUiBase { * This does nothing if the header has not been defined for current * scheme. * - * @param {string} name The name of the changed header - * @param {string} newValue A value to apply. May be empty but must be defined. + * @param name The name of the changed header + * @param newValue A value to apply. May be empty but must be defined. */ - updateHeader(name, newValue) { - const list = /** @type OperationParameter[] */ (this.parametersValue); + updateHeader(name: string, newValue: string): void { + const list = this.parametersValue; const param = list.find(i => i.binding === 'header' && i.parameter.name === name); if (param) { InputCache.set(this.target, param.paramId, newValue, this.globalCache); } } - /** - * Restores previously serialized values - * @param {RamlCustomAuthorization} state - */ - restore(state) { + restore(state: RamlCustomAuthorization): void { if (!state) { return; } @@ -217,15 +196,11 @@ export default class CustomAuth extends ApiUiBase { this.requestUpdate(); } - /** - * @param {string} binding - * @param {RamlCustomAuthorization} restored - */ - restoreModelValue(binding, restored) { + restoreModelValue(binding: string, restored?: RamlCustomAuthorization): void { if (!restored) { return; } - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = this.parametersValue; const params = list.filter(i => i.binding === binding); if (!params) { return; @@ -233,22 +208,19 @@ export default class CustomAuth extends ApiUiBase { Object.keys(restored).forEach((name) => { const param = params.find(i => i.parameter.name === name); if (param) { - InputCache.set(this.target, param.paramId, restored[name], this.globalCache); + InputCache.set(this.target, param.paramId, restored[name as keyof RamlCustomAuthorization], this.globalCache); } }); } - /** - * @returns {RamlCustomAuthorization} - */ - serialize() { - const params = /** @type OperationParameter[] */ (this.parametersValue); - const result = /** @type RamlCustomAuthorization */ ({}); + serialize(): RamlCustomAuthorization { + const params = this.parametersValue; + const result: RamlCustomAuthorization = {}; (params || []).forEach((param) => { - if (!result[param.binding]) { - result[param.binding] = {}; + if (!result[param.binding as keyof RamlCustomAuthorization]) { + result[param.binding as keyof RamlCustomAuthorization] = {}; } - let value = InputCache.get(this.target, param.paramId, this.globalCache); + let value = InputCache.get(this.target, param.paramId, this.globalCache) as string | boolean; if (value === '' || value === undefined) { if (param.parameter.required === false) { return; @@ -261,17 +233,14 @@ export default class CustomAuth extends ApiUiBase { if (value === null) { value = ''; } - result[param.binding][param.parameter.name] = value; + (result[param.binding as keyof RamlCustomAuthorization] as Record)[param.parameter.name || ''] = value as string; }); - return /** @type RamlCustomAuthorization */ (result); + return result; } - /** - * @returns {boolean} - */ - validate() { + validate(): boolean { const nils = this.nilValues; - const params = /** @type OperationParameter[] */ (this.parametersValue); + const params = this.parametersValue; return !params.some((param) => { if (nils.includes(param.paramId)) { return false; @@ -290,15 +259,12 @@ export default class CustomAuth extends ApiUiBase { * This is a utility method for UI event handling. Use `descriptionOpened` * attribute directly instead of this method. */ - toggleDescription() { + toggleDescription(): void { this.descriptionOpened = !this.descriptionOpened; this.requestUpdate(); } - /** - * @returns {TemplateResult} - */ - render() { + render(): TemplateResult { return html` ${this.titleTemplate()} @@ -308,7 +274,7 @@ export default class CustomAuth extends ApiUiBase { `; } - titleTemplate() { + titleTemplate(): TemplateResult | string { const { schemeName, schemeDescription, @@ -338,7 +304,7 @@ export default class CustomAuth extends ApiUiBase {
` : ''}`; } - headersTemplate() { + headersTemplate(): TemplateResult | string { const headers = this.parametersValue.filter(item => item.binding === 'header'); if (!headers.length) { return ''; @@ -351,7 +317,7 @@ export default class CustomAuth extends ApiUiBase { `; } - queryTemplate() { + queryTemplate(): TemplateResult | string { const params = this.parametersValue.filter(item => item.binding === 'query'); if (!params.length) { return ''; diff --git a/src/lib/auth-ui/OAuth1Auth.js b/src/lib/auth-ui/OAuth1Auth.js deleted file mode 100644 index 908be7a..0000000 --- a/src/lib/auth-ui/OAuth1Auth.js +++ /dev/null @@ -1,81 +0,0 @@ -/* eslint-disable no-param-reassign */ -/* eslint-disable no-plusplus */ -/* eslint-disable class-methods-use-this */ -import Oauth1, { defaultSignatureMethods } from '@advanced-rest-client/base/src/elements/authorization/ui/OAuth1.js'; -import { ns } from '../../helpers/Namespace.js'; - -const securityValue = Symbol("securityValue"); - -/** @typedef {import('../../helpers/api').ApiSecurityOAuth1Settings} ApiSecurityOAuth1Settings */ -/** @typedef {import('../../helpers/api').ApiParametrizedSecurityScheme} ApiParametrizedSecurityScheme */ -/** @typedef {import('../../helpers/amf').DomainElement} DomainElement */ - -export default class OAuth1Auth extends Oauth1 { - /** - * @returns {ApiParametrizedSecurityScheme} - */ - get security() { - return this[securityValue]; - } - - /** - * @param {ApiParametrizedSecurityScheme} value - */ - set security(value) { - const old = this[securityValue]; - if (old === value) { - return; - } - this[securityValue] = value; - this.initializeApiModel(); - } - - reset() { - this.signatureMethods = defaultSignatureMethods; - // @ts-ignore - this.requestUpdate(); - // @ts-ignore - this.notifyChange(); - } - - initializeApiModel() { - const { security } = this; - if (!security) { - this.reset(); - return; - } - if (!security.types.includes(ns.aml.vocabularies.security.ParametrizedSecurityScheme)) { - this.reset(); - return; - } - const { scheme } = security; - if (!scheme) { - this.reset(); - return; - } - const { type } = scheme; - if (!type || type !== 'OAuth 1.0') { - this.reset(); - return; - } - const config = /** @type ApiSecurityOAuth1Settings */ (scheme.settings); - if (!config) { - this.reset(); - return; - } - - this.requestTokenUri = config.requestTokenUri; - this.authorizationUri = config.authorizationUri; - this.accessTokenUri = config.tokenCredentialsUri; - const { signatures } = config; - if (!signatures || !signatures.length) { - this.reset(); - } else { - this.signatureMethods = signatures; - } - // @ts-ignore - this.requestUpdate(); - // @ts-ignore - this.notifyChange(); - } -} diff --git a/src/lib/auth-ui/OAuth2Auth.js b/src/lib/auth-ui/OAuth2Auth.ts similarity index 68% rename from src/lib/auth-ui/OAuth2Auth.js rename to src/lib/auth-ui/OAuth2Auth.ts index 0b72b98..34571f7 100644 --- a/src/lib/auth-ui/OAuth2Auth.js +++ b/src/lib/auth-ui/OAuth2Auth.ts @@ -1,49 +1,32 @@ +/* eslint-disable default-param-last */ /* eslint-disable no-param-reassign */ /* eslint-disable no-plusplus */ /* eslint-disable class-methods-use-this */ -import { html } from 'lit-html'; +import { html, TemplateResult } from 'lit'; import Oauth2, { oauth2GrantTypes } from '@advanced-rest-client/base/src/elements/authorization/ui/OAuth2.js' +import { OAuth2CustomParameter } from '@advanced-rest-client/oauth'; +import { OAuth2Authorization, OAuth2DeliveryMethod, Oauth2GrantType } from '@advanced-rest-client/events/src/authorization/Authorization.js'; import { ns } from '../../helpers/Namespace.js'; import * as InputCache from '../InputCache.js'; -import { AmfInputParser } from '../AmfInputParser.js'; +import { AmfInputParser, BindingType } from '../AmfInputParser.js'; import { Oauth2RamlCustomData } from '../Oauth2RamlCustomData.js'; import { AmfParameterMixin } from '../AmfParameterMixin.js'; +import { ApiArrayNode, ApiCustomDomainProperty, ApiDataNodeUnion, ApiObjectNode, ApiParameter, ApiParametrizedSecurityScheme, ApiScalarNode, ApiSecurityOAuth2Flow, ApiSecurityOAuth2Settings, ApiSecurityScheme, ApiSecurityScope } from '../../helpers/api.js'; +import { OperationParameter } from '../../types.js'; const securityValue = Symbol("securityValue"); const gtValue = Symbol("gtValue"); -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('@advanced-rest-client/base').AuthUiInit} AuthUiInit */ -/** @typedef {import('../../helpers/api').ApiParametrizedSecurityScheme} ApiParametrizedSecurityScheme */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../../helpers/api').ApiSecurityScheme} ApiSecurityScheme */ -/** @typedef {import('../../helpers/api').ApiSecurityOAuth2Settings} ApiSecurityOAuth2Settings */ -/** @typedef {import('../../helpers/api').ApiSecurityOAuth2Flow} ApiSecurityOAuth2Flow */ -/** @typedef {import('../../helpers/api').ApiCustomDomainProperty} ApiCustomDomainProperty */ -/** @typedef {import('../../helpers/api').ApiObjectNode} ApiObjectNode */ -/** @typedef {import('../../helpers/api').ApiArrayNode} ApiArrayNode */ -/** @typedef {import('../../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../../helpers/api').ApiSecurityScope} ApiSecurityScope */ -/** @typedef {import('../../helpers/api').ApiDataNodeUnion} ApiDataNodeUnion */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Authorization */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2CustomParameter} OAuth2CustomParameter */ -/** @typedef {import('@advanced-rest-client/events').Authorization.Oauth2GrantType} Oauth2GrantType */ -/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2DeliveryMethod} OAuth2DeliveryMethod */ -/** @typedef {import('../../types').OperationParameter} OperationParameter */ - export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { - /** - * @returns {ApiParametrizedSecurityScheme} - */ - get security() { + [securityValue]?: ApiParametrizedSecurityScheme; + + [gtValue]?: string; + + get security(): ApiParametrizedSecurityScheme | undefined { return this[securityValue]; } - /** - * @param {ApiParametrizedSecurityScheme} value - */ - set security(value) { + set security(value: ApiParametrizedSecurityScheme | undefined) { const old = this[securityValue]; if (old === value) { return; @@ -52,9 +35,8 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { this.initializeApiModel(); } - // @ts-ignore - get grantType() { - return this[gtValue]; + get grantType(): string { + return this[gtValue] || ''; } set grantType(value) { @@ -65,19 +47,11 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } } - /** - * @param {AuthUiInit} init - */ - constructor(init) { - super(init); + overrideAuthorizationUri?: string; - /** @type string */ - this.overrideAuthorizationUri = undefined; - /** @type string */ - this.overrideAccessTokenUri = undefined; - } + overrideAccessTokenUri?: string; - initializeApiModel() { + initializeApiModel(): void { const { security } = this; if (!security) { this.setupOAuthDeliveryMethod(); @@ -102,7 +76,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { return; } this.setupOAuthDeliveryMethod(scheme); - const config = /** @type ApiSecurityOAuth2Settings */ (scheme.settings); + const config = scheme.settings as ApiSecurityOAuth2Settings; if (!config) { return; } @@ -111,10 +85,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { this.requestUpdate(); } - /** - * @returns {OAuth2Authorization} - */ - serialize() { + serialize(): OAuth2Authorization { const result = super.serialize(); result.customData = { auth: {}, @@ -144,16 +115,13 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { return result; } - /** - * @param {ApiSecurityScheme=} scheme - */ - setupOAuthDeliveryMethod(scheme) { + setupOAuthDeliveryMethod(scheme?: ApiSecurityScheme): void { const info = this.getOauth2DeliveryMethod(scheme); if (this.oauthDeliveryMethod !== info.method) { - this.oauthDeliveryMethod = info.method; + this.oauthDeliveryMethod = info.method as OAuth2DeliveryMethod; } if (this.ccDeliveryMethod !== info.method) { - this.ccDeliveryMethod = /** @type OAuth2DeliveryMethod */ (info.method); + this.ccDeliveryMethod = info.method as OAuth2DeliveryMethod; } if (this.oauthDeliveryName !== info.name) { this.oauthDeliveryName = info.name; @@ -166,10 +134,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * reads API spec to get this information or provides default if * not specifies. * - * @param {ApiSecurityScheme} info Security AMF model - * @returns {{method: string, name: string}} + * @param info Security AMF model */ - getOauth2DeliveryMethod(info) { + getOauth2DeliveryMethod(info?: ApiSecurityScheme): { method: string, name: string } { const result = { method: 'header', name: 'authorization' @@ -179,12 +146,12 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } if (Array.isArray(info.headers) && info.headers.length) { const [header] = info.headers; - result.name = header.name; + result.name = header.name as string; return result; } if (Array.isArray(info.queryParameters) && info.queryParameters.length) { const [param] = info.queryParameters; - result.name = param.name; + result.name = param.name as string; result.method = 'query'; return result; } @@ -195,10 +162,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * Updates list of OAuth grant types supported by current endpoint. * The information should be available in RAML file. * - * @param {string[]=} supportedTypes List of supported types. If empty + * @param supportedTypes List of supported types. If empty * or not set then all available types will be displayed. */ - updateGrantTypes(supportedTypes) { + updateGrantTypes(supportedTypes?: string[]): void { const available = this.computeGrantList(supportedTypes); this.grantTypes = available; // check if current selection is still available @@ -217,19 +184,16 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Computes list of grant types to render in the form. * - * @param {string[]=} allowed List of types allowed by the + * @param allowed List of types allowed by the * component configuration or API spec applied to this element. If empty * or not set then all OAuth 2.0 default types are returned. - * @returns {Oauth2GrantType[]} */ - computeGrantList(allowed) { - let defaults = /** @type Oauth2GrantType[] */ (Array.from(oauth2GrantTypes)); + computeGrantList(allowed?: string[]): Oauth2GrantType[] { + let defaults = Array.from(oauth2GrantTypes); if (!allowed || !allowed.length) { return defaults; } - // eslint-disable-next-line no-param-reassign allowed = Array.from(allowed); - // eslint-disable-next-line no-plusplus for (let i = defaults.length - 1; i >= 0; i--) { const index = allowed.indexOf(defaults[i].type); if (index === -1) { @@ -239,14 +203,11 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } } if (allowed.length) { - // @ts-ignore - // eslint-disable-next-line no-param-reassign - allowed = allowed.map((item) => ({ + const mapped: Oauth2GrantType[] = allowed.map((item) => ({ label: item, type: item })); - // @ts-ignore - defaults = defaults.concat(allowed); + defaults = defaults.concat(mapped); } return defaults; } @@ -273,10 +234,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * working. It tests whether there's a single grant type and this grant type * has no AMF's `security:flow` property. * - * @param {ApiSecurityOAuth2Flow[]} flows List of current flows loaded with the AMF model. - * @return {boolean} True if current model should be treated as RAML's model. + * @param flows List of current flows loaded with the AMF model. + * @returns True if current model should be treated as RAML's model. */ - isRamlFlow(flows) { + isRamlFlow(flows: ApiSecurityOAuth2Flow[]): boolean { if (!Array.isArray(flows)) { return true; } @@ -294,10 +255,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * Reads API security definition and applies in to the view as predefined * values. * - * @param {ApiSecurityOAuth2Settings} model AMF model describing settings of the security + * @param model AMF model describing settings of the security * scheme */ - preFillAmfData(model){ + preFillAmfData(model: ApiSecurityOAuth2Settings): void { if (!model) { return; } @@ -308,12 +269,12 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } const [flow] = flows; - this.authorizationUri = this.overrideAuthorizationUri || flow.authorizationUri; + this.authorizationUri = (this.overrideAuthorizationUri || flow.authorizationUri) as string; this.accessTokenUri = this.overrideAccessTokenUri || flow.accessTokenUri || ''; - this.scopes = (flow.scopes || []).map(s => s.name); + this.scopes = (flow.scopes || []).map(s => s.name) as string[]; const settingsExtension = this.findOauth2CustomSettings(model); const grants = this.computeGrants(authorizationGrants, settingsExtension); - + if (grants.length) { const index = grants.indexOf('code'); if (index !== -1) { @@ -324,7 +285,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { this.updateGrantTypes(); } this.setupAnnotationParameters(settingsExtension); - this.pkce = this.readPkceValue(model); + this.pkce = this.readPkceValue(model) || false; } /** @@ -333,15 +294,14 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * This reads (RAML) annotations to build the UI for these settings. * - * @param {ApiSecurityOAuth2Settings} model AMF model describing settings of the security - * scheme - * @returns {ApiCustomDomainProperty|null} The extension definition or null + * @param model AMF model describing settings of the security scheme + * @returns The extension definition or null */ - findOauth2CustomSettings(model) { - const { customDomainProperties=[] } = model; + findOauth2CustomSettings(model: ApiSecurityOAuth2Settings): ApiCustomDomainProperty | undefined { + const { customDomainProperties = [] } = model; const properties = ['accessTokenSettings', 'authorizationGrants', 'authorizationSettings']; return customDomainProperties.find((property) => { - const node = /** @type ApiObjectNode */ (property.extension); + const node = (property.extension as ApiObjectNode); if (!node.properties || !node.types.includes(ns.aml.vocabularies.data.Object)) { return false; } @@ -353,25 +313,25 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * Computes the final list of authorization grants defined in the spec and with applied annotation defined in * https://github.com/raml-org/raml-annotations/blob/master/annotations/security-schemes/oauth-2-custom-settings.raml * - * @param {string[]} grans The API spec annotation grants - * @param {ApiCustomDomainProperty=} customProperty The domain extension with the custom data - * @returns {string[]} The list of authorization grants to apply to the current operation. + * @param grans The API spec annotation grants + * @param customProperty The domain extension with the custom data + * @returns The list of authorization grants to apply to the current operation. */ - computeGrants(grans=[], customProperty) { + computeGrants(grans: string[] = [], customProperty?: ApiCustomDomainProperty): string[] { if (!customProperty || !customProperty.extension || !customProperty.extension.types.includes(ns.aml.vocabularies.data.Object)) { return grans; } - const typed = /** @type ApiObjectNode */ (customProperty.extension); + const typed = customProperty.extension as ApiObjectNode; if (!typed.properties.authorizationGrants) { return grans; } - const array = /** @type ApiArrayNode */ (typed.properties.authorizationGrants); - const addedGrants = []; + const array = typed.properties.authorizationGrants as ApiArrayNode; + const addedGrants: string[] = []; array.members.forEach((g) => { if (!g.types.includes(ns.aml.vocabularies.data.Scalar)) { return; } - const scalar = /** @type ApiScalarNode */ (g); + const scalar = g as ApiScalarNode; if (scalar.value) { addedGrants.push(scalar.value); } @@ -394,9 +354,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * Note, flow data are applied when `grantType` change. * - * @param {ApiSecurityOAuth2Flow[]} flows List of flows in the authorization description. + * @param flows List of flows in the authorization description. */ - preFillFlowData(flows) { + preFillFlowData(flows: ApiSecurityOAuth2Flow[]): void { // first step is to select the right flow. // If the user already selected a grant type before then it this looks // for a flow for already selected grant type. If its not present then @@ -413,11 +373,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Searches for a flow in the list of flows for given name. * - * @param {ApiSecurityOAuth2Flow[]} flows List of flows to search in. - * @param {string=} type Grant type - * @return {any|undefined} + * @param flows List of flows to search in. + * @param type Grant type */ - flowForType(flows, type) { + flowForType(flows: ApiSecurityOAuth2Flow[], type?: string): any | undefined { if (!type) { return undefined; } @@ -440,10 +399,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Reads list of scopes from a flow. * - * @param {ApiSecurityOAuth2Flow} flow A flow to process. - * @return {string[]} List of scopes required by an endpoint / API. + * @param flow A flow to process. + * @returns List of scopes required by an endpoint / API. */ - readFlowScopes(flow) { + readFlowScopes(flow: ApiSecurityOAuth2Flow): string[] | undefined { const { security } = this; let scopes = this.readSecurityScopes(flow.scopes); if (scopes || !security) { @@ -451,7 +410,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } // if scopes are not defined in the operation then they may be defined in // security settings. - const config = /** @type ApiSecurityOAuth2Settings */ (security.scheme.settings); + const config = security.scheme && security.scheme.settings as ApiSecurityOAuth2Settings | undefined; if (!config || !config.flows) { return undefined; } @@ -465,13 +424,16 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Reads list of grant types from the list of flows. * - * @param {ApiSecurityOAuth2Flow[]} flows List of flows to process. - * @return {string[]} Grant types supported by this authorization. + * @param flows List of flows to process. + * @returns Grant types supported by this authorization. */ - readFlowsTypes(flows) { - const grants = []; + readFlowsTypes(flows: ApiSecurityOAuth2Flow[]): string[] { + const grants: string[] = []; flows.forEach((flow) => { let type = flow.flow; + if (!type) { + return; + } if (type === 'authorizationCode') { type = 'authorization_code'; } else if (type === 'clientCredentials') { @@ -488,9 +450,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * This function is called each time a grant type change. If current settings * does not contain flows then this is ignored. * - * @param {string=} name Set grant type + * @param name Set grant type */ - applyFlow(name) { + applyFlow(name?: string): void { if (!name) { return; } @@ -498,7 +460,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { if (!security || !security.scheme || !security.scheme.settings) { return; } - const config = /** @type ApiSecurityOAuth2Settings */ (security.scheme.settings); + const config = security.scheme.settings as ApiSecurityOAuth2Settings; const { flows } = config; if (!Array.isArray(flows) || this.isRamlFlow(flows)) { return; @@ -510,21 +472,19 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } const flow = flows.find(team => team.flow === name); // sets basic oauth properties. - this.scopes = flow ? this.readFlowScopes(flow) : []; - this.authorizationUri = this.overrideAuthorizationUri || flow.authorizationUri || ''; - this.accessTokenUri = this.overrideAccessTokenUri || flow.accessTokenUri || ''; + this.scopes = (flow ? this.readFlowScopes(flow) : []) as string[]; + this.authorizationUri = this.overrideAuthorizationUri || flow && flow.authorizationUri || ''; + this.accessTokenUri = this.overrideAccessTokenUri || flow && flow.accessTokenUri || ''; } /** * Extracts scopes list from the security definition - * @param {ApiSecurityScope[]} scopes - * @return {string[]|undefined} */ - readSecurityScopes(scopes) { + readSecurityScopes(scopes: ApiSecurityScope[]): string[] | undefined { if (!scopes) { return undefined; } - const result = scopes.map(s => s.name).filter(s => !!s); + const result = scopes.map(s => s.name).filter(s => !!s) as string[]; if (!result.length) { return undefined; } @@ -534,10 +494,10 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Checks whether the security scheme is annotated with the `pkce` annotation. * This annotation is published at https://github.com/raml-org/raml-annotations/tree/master/annotations/security-schemes - * @param {ApiSecurityOAuth2Settings} model Model for the security settings - * @returns {boolean|undefined} True if the security settings are annotated with PKCE extension + * @param model Model for the security settings + * @returns True if the security settings are annotated with PKCE extension */ - readPkceValue(model) { + readPkceValue(model: ApiSecurityOAuth2Settings): boolean | undefined { const { customDomainProperties } = model; if (!Array.isArray(customDomainProperties) || !customDomainProperties.length) { return undefined; @@ -546,7 +506,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { if (!pkce) { return undefined; } - const info = /** @type ApiScalarNode */ (pkce.extension); + const info = pkce.extension as ApiScalarNode; if (info.dataType === ns.w3.xmlSchema.boolean) { return info.value === 'true'; } @@ -560,10 +520,16 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param {OAuth2Authorization} detail Token request detail object. The object is passed * by reference so no need for return value */ - computeAuthCustomData(detail) { - const all = /** @type OperationParameter[] */ (this.parametersValue); + computeAuthCustomData(detail: OAuth2Authorization): void { + const all = this.parametersValue; const params = all.filter(p => p.binding === 'authQuery'); if (params.length) { + if (!detail.customData) { + detail.customData = {}; + } + if (!detail.customData.auth) { + detail.customData.auth = {}; + } detail.customData.auth.parameters = this.computeCustomParameters(params, 'authQuery'); } } @@ -572,14 +538,23 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * Adds `customData` property values that can be applied to the * token request. * - * @param {OAuth2Authorization} detail Token request detail object. The object is passed + * @param detail Token request detail object. The object is passed * by reference so no need for return value */ - computeTokenCustomData(detail) { - const params = /** @type OperationParameter[] */ (this.parametersValue); + computeTokenCustomData(detail: OAuth2Authorization): void { + const params = this.parametersValue; const tqp = params.filter(p => p.binding === 'tokenQuery'); const th = params.filter(p => p.binding === 'tokenHeader'); const tb = params.filter(p => p.binding === 'tokenBody'); + if (!detail.customData) { + detail.customData = {}; + } + if (!detail.customData.token) { + detail.customData.token = {}; + } + if (!detail.customData.token) { + detail.customData.token = {}; + } if (tqp.length) { detail.customData.token.parameters = this.computeCustomParameters(tqp, 'tokenQuery'); } @@ -599,27 +574,27 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * - token headers * - token body * - * @param {ApiCustomDomainProperty} customProperty Annotation applied to the OAuth settings + * @param customProperty Annotation applied to the OAuth settings */ - setupAnnotationParameters(customProperty) { - this.parametersValue = /** @type OperationParameter[] */ ([]); + setupAnnotationParameters(customProperty?: ApiCustomDomainProperty): void { + this.parametersValue = []; /* istanbul ignore if */ if (!customProperty || !customProperty.extension) { return; } - const typed = /** @type ApiObjectNode */ (customProperty.extension); - const authSettings = /** @type ApiObjectNode */ (typed.properties.authorizationSettings); - const tokenSettings = /** @type ApiObjectNode */ (typed.properties.accessTokenSettings); + const typed = customProperty.extension as ApiObjectNode; + const authSettings = (typed.properties.authorizationSettings as ApiObjectNode | undefined); + const tokenSettings = (typed.properties.accessTokenSettings as ApiObjectNode | undefined); if (authSettings) { - const qp = /** @type ApiObjectNode */ (authSettings.properties.queryParameters); + const qp = (authSettings.properties.queryParameters as ApiObjectNode | undefined); if (qp && qp.properties) { this.setupAuthRequestQueryParameters(qp.properties); } } if (tokenSettings) { - const qp = /** @type ApiObjectNode */ (tokenSettings.properties.queryParameters); - const headerParams = /** @type ApiObjectNode */ (tokenSettings.properties.headers); - const bodyParams = /** @type ApiObjectNode */ (tokenSettings.properties.body); + const qp = (tokenSettings.properties.queryParameters as ApiObjectNode | undefined); + const headerParams = (tokenSettings.properties.headers as ApiObjectNode | undefined); + const bodyParams = (tokenSettings.properties.body as ApiObjectNode | undefined); if (qp && qp.properties) { this.setupTokenRequestQueryParameters(qp.properties); } @@ -634,10 +609,8 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Appends a list of parameters to the list of rendered parameters - * @param {ApiParameter[]} list - * @param {string} source */ - appendToParams(list, source) { + appendToParams(list: ApiParameter[], source: string): void { const params = this.parametersValue; if (Array.isArray(list)) { list.forEach((param) => { @@ -656,9 +629,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Sets up query parameters to be used with authorization request. * - * @param {{[key: string]: ApiDataNodeUnion}} properties List of parameters from the annotation. + * @param properties List of parameters from the annotation. */ - setupAuthRequestQueryParameters(properties) { + setupAuthRequestQueryParameters(properties: { [key: string]: ApiDataNodeUnion }): void { const source = 'authQuery'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -669,9 +642,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Sets up query parameters to be used with token request. * - * @param {{[key: string]: ApiDataNodeUnion}} properties List of parameters from the annotation. + * @param properties List of parameters from the annotation. */ - setupTokenRequestQueryParameters(properties) { + setupTokenRequestQueryParameters(properties: { [key: string]: ApiDataNodeUnion }): void { const source = 'tokenQuery'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -682,9 +655,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Sets up headers to be used with token request. * - * @param {{[key: string]: ApiDataNodeUnion}} properties params List of parameters from the annotation. + * @param properties params List of parameters from the annotation. */ - setupTokenRequestHeaders(properties) { + setupTokenRequestHeaders(properties: { [key: string]: ApiDataNodeUnion }): void { const source = 'tokenHeader'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -695,9 +668,9 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Sets up body parameters to be used with token request. * - * @param {{[key: string]: ApiDataNodeUnion}} properties params List of parameters from the annotation. + * @param properties params List of parameters from the annotation. */ - setupTokenRequestBody(properties) { + setupTokenRequestBody(properties: { [key: string]: ApiDataNodeUnion }): void { const source = 'tokenBody'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -711,13 +684,12 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * This function ignores empty values if they are not required. * Required property are always included, even if the value is not set. * - * @param {OperationParameter[]} params Model for form inputs. - * @param {string} reportKey The key name in the report. - * @return {OAuth2CustomParameter[]|undefined} Array of objects with `name` and `value` - * properties or undefined if `params` is empty or no values are available. + * @param params Model for form inputs. + * @param reportKey The key name in the report. + * @returns Array of objects with `name` and `value` properties or undefined if `params` is empty or no values are available. */ - computeCustomParameters(params, reportKey) { - const result = /** @type OAuth2CustomParameter[] */ ([]); + computeCustomParameters(params: OperationParameter[], reportKey: keyof BindingType): OAuth2CustomParameter[] { + const result: OAuth2CustomParameter[] = []; const report = AmfInputParser.reportRequestInputs(params.map(p => p.parameter), InputCache.getStore(this.target, this.globalCache), this.nilValues); const values = report[reportKey]; if (!values) { @@ -725,24 +697,24 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } Object.keys(values).forEach((key) => { const value = values[key]; - const info = params.find(p => p.parameter.name === key); + const info = params.find(p => p.parameter.name === key) as OperationParameter; if (info.parameter.required !== true) { const type = typeof value; if (type === 'number') { if (!value && value !== 0) { return; } - } + } if (type === 'string') { if (!value) { return; } - } + } if (Array.isArray(value)) { if (!value[0]) { return; } - } + } if (type === 'undefined') { return; } @@ -755,8 +727,8 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { return result; } - oauth2CustomPropertiesTemplate() { - const params = /** @type OperationParameter[] */ (this.parametersValue); + oauth2CustomPropertiesTemplate(): TemplateResult { + const params = this.parametersValue; const aqp = params.filter(p => p.binding === 'authQuery'); const tqp = params.filter(p => p.binding === 'tokenQuery'); const th = params.filter(p => p.binding === 'tokenHeader'); diff --git a/src/lib/auth-ui/PassThroughAuth.js b/src/lib/auth-ui/PassThroughAuth.ts similarity index 70% rename from src/lib/auth-ui/PassThroughAuth.js rename to src/lib/auth-ui/PassThroughAuth.ts index ba8facf..bfcebd5 100644 --- a/src/lib/auth-ui/PassThroughAuth.js +++ b/src/lib/auth-ui/PassThroughAuth.ts @@ -1,48 +1,37 @@ /* eslint-disable class-methods-use-this */ -import { html } from 'lit-html'; +import { html, TemplateResult } from 'lit'; +import { AuthUiInit } from '@advanced-rest-client/base/api.js'; import '@advanced-rest-client/highlight/arc-marked.js'; +import { PassThroughAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; - -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('@advanced-rest-client/base').AuthUiInit} AuthUiInit */ -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('@advanced-rest-client/events').Authorization.PassThroughAuthorization} PassThroughAuthorization */ -/** @typedef {import('../../types').OperationParameter} OperationParameter */ +import { ApiNodeShape, ApiParameter, ApiShapeUnion } from '../../helpers/api.js'; export default class PassThroughAuth extends ApiUiBase { - /** - * @param {AuthUiInit} init - */ - constructor(init) { - super(init); - /** @type {string} */ - this.schemeName = undefined; - /** @type {string} */ - this.schemeDescription = undefined; - /** @type {boolean} */ - this.anypoint = undefined; - /** @type {boolean} */ - this.descriptionOpened = undefined; + schemeName?: string; + + schemeDescription?: string; + + descriptionOpened?: boolean; + constructor(init: AuthUiInit) { + super(init); this.toggleDescription = this.toggleDescription.bind(this); } - reset() { - const params = /** @type OperationParameter[] */ (this.parametersValue); + reset(): void { + const params = this.parametersValue; (params || []).forEach((param) => { InputCache.set(this.target, param.paramId, '', this.globalCache) }); } - initializeApiModel() { + initializeApiModel(): void { const { security } = this; this.reset(); const source = 'settings'; - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = (this.parametersValue); this.parametersValue = list.filter(item => item.source !== source); if (!security) { return; @@ -70,17 +59,14 @@ export default class PassThroughAuth extends ApiUiBase { this.requestUpdate(); } - /** - * @param {ApiShapeUnion} queryString - */ - appendQueryString(queryString) { - const object = /** @type ApiNodeShape */ (queryString); + appendQueryString(queryString: ApiShapeUnion): void { + const object = queryString as ApiNodeShape; if (!object.properties || !object.properties.length) { return; } const list = object.properties.map((item) => { - const { id, range, name, minCount } = item; - return /** @type ApiParameter */ ({ + const { id, range, name, minCount = 0 } = item; + return { id, binding: 'query', schema: range, @@ -89,18 +75,19 @@ export default class PassThroughAuth extends ApiUiBase { payloads: [], types: [ns.aml.vocabularies.apiContract.Parameter], required: minCount > 0, - }); + customDomainProperties: [], + } as ApiParameter; }); this.appendToParams(list, 'query', true); } /** * Appends a list of parameters to the list of rendered parameters. - * @param {ApiParameter[]} list - * @param {string} source - * @param {boolean=} clear When set it clears the previously set parameters + * @param list + * @param source + * @param clear When set it clears the previously set parameters */ - appendToParams(list, source, clear=false) { + appendToParams(list: ApiParameter[], source: string, clear=false): void { let params = this.parametersValue; if (clear) { params = params.filter(p => p.source !== source); @@ -110,7 +97,7 @@ export default class PassThroughAuth extends ApiUiBase { params.push({ paramId: param.id, parameter: param, - binding: param.binding, + binding: param.binding || '', source, schema: param.schema, schemaId: param.schema && param.schema.id ? param.schema.id : undefined, @@ -129,8 +116,8 @@ export default class PassThroughAuth extends ApiUiBase { * @param {string} name The name of the changed parameter * @param {string} newValue A value to apply. May be empty but must be defined. */ - updateQueryParameter(name, newValue) { - const list = /** @type OperationParameter[] */ (this.parametersValue); + updateQueryParameter(name: string, newValue: string): void { + const list = (this.parametersValue); const param = list.find(i => i.binding === 'query' && i.parameter.name === name); if (param) { InputCache.set(this.target, param.paramId, newValue, this.globalCache); @@ -148,19 +135,15 @@ export default class PassThroughAuth extends ApiUiBase { * @param {string} name The name of the changed header * @param {string} newValue A value to apply. May be empty but must be defined. */ - updateHeader(name, newValue) { - const list = /** @type OperationParameter[] */ (this.parametersValue); + updateHeader(name: string, newValue: string): void { + const list = (this.parametersValue); const param = list.find(i => i.binding === 'header' && i.parameter.name === name); if (param) { InputCache.set(this.target, param.paramId, newValue, this.globalCache); } } - /** - * Restores previously serialized values - * @param {PassThroughAuthorization} state - */ - restore(state) { + restore(state: PassThroughAuthorization): void { if (!state) { return; } @@ -169,15 +152,11 @@ export default class PassThroughAuth extends ApiUiBase { this.requestUpdate(); } - /** - * @param {string} binding - * @param {PassThroughAuthorization} restored - */ - restoreModelValue(binding, restored) { + restoreModelValue(binding: string, restored?: PassThroughAuthorization): void { if (!restored) { return; } - const list = /** @type OperationParameter[] */ (this.parametersValue); + const list = (this.parametersValue); const params = list.filter(i => i.binding === binding); if (!params) { return; @@ -185,22 +164,19 @@ export default class PassThroughAuth extends ApiUiBase { Object.keys(restored).forEach((name) => { const param = params.find(i => i.parameter.name === name); if (param) { - InputCache.set(this.target, param.paramId, restored[name], this.globalCache); + InputCache.set(this.target, param.paramId, restored[name as keyof PassThroughAuthorization], this.globalCache); } }); } - /** - * @returns {PassThroughAuthorization} - */ - serialize() { - const params = /** @type OperationParameter[] */ (this.parametersValue); - const result = /** @type PassThroughAuthorization */ ({}); + serialize(): PassThroughAuthorization { + const params = (this.parametersValue); + const result: PassThroughAuthorization = {}; (params || []).forEach((param) => { - if (!result[param.binding]) { - result[param.binding] = {}; + if (!result[param.binding as keyof PassThroughAuthorization]) { + result[param.binding as keyof PassThroughAuthorization] = {}; } - let value = InputCache.get(this.target, param.paramId, this.globalCache); + let value = InputCache.get(this.target, param.paramId, this.globalCache) as string | boolean; if (value === '' || value === undefined) { if (param.parameter.required === false) { return; @@ -213,17 +189,14 @@ export default class PassThroughAuth extends ApiUiBase { if (value === null) { value = ''; } - result[param.binding][param.parameter.name] = value; + (result[param.binding as keyof PassThroughAuthorization] as Record)[param.parameter.name as keyof PassThroughAuthorization] = value as string; }); - return /** @type PassThroughAuthorization */ (result); + return result; } - /** - * @returns {boolean} - */ - validate() { + validate(): boolean { const nils = this.nilValues; - const params = /** @type OperationParameter[] */ (this.parametersValue); + const params = (this.parametersValue); const hasInvalid = params.some((param) => { if (nils.includes(param.paramId)) { return false; @@ -243,15 +216,12 @@ export default class PassThroughAuth extends ApiUiBase { * This is a utility method for UI event handling. Use `descriptionOpened` * attribute directly instead of this method. */ - toggleDescription() { + toggleDescription(): void { this.descriptionOpened = !this.descriptionOpened; this.requestUpdate(); } - /** - * @returns {TemplateResult} - */ - render() { + render(): TemplateResult { return html` ${this.titleTemplate()} @@ -261,7 +231,7 @@ export default class PassThroughAuth extends ApiUiBase { `; } - titleTemplate() { + titleTemplate(): TemplateResult | string { const { schemeName, schemeDescription, @@ -291,7 +261,7 @@ export default class PassThroughAuth extends ApiUiBase {
` : ''}`; } - headersTemplate() { + headersTemplate(): TemplateResult | string { const headers = this.parametersValue.filter(item => item.binding === 'header'); if (!headers.length) { return ''; @@ -304,7 +274,7 @@ export default class PassThroughAuth extends ApiUiBase { `; } - queryTemplate() { + queryTemplate(): TemplateResult | string { const params = this.parametersValue.filter(item => item.binding === 'query'); if (!params.length) { return ''; diff --git a/src/lib/navigation-layout/ApiSorting.d.ts b/src/lib/navigation-layout/ApiSorting.d.ts deleted file mode 100644 index 0625cb8..0000000 --- a/src/lib/navigation-layout/ApiSorting.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ApiEndPointListItem } from "../../types"; - -export declare class ApiSorting { - /** - * Sorts endpoints by path. - */ - static sortEndpointsByPath(list: ApiEndPointListItem[]): ApiEndPointListItem[]; -} diff --git a/src/lib/navigation-layout/ApiSorting.js b/src/lib/navigation-layout/ApiSorting.ts similarity index 55% rename from src/lib/navigation-layout/ApiSorting.js rename to src/lib/navigation-layout/ApiSorting.ts index eec1741..8ae649c 100644 --- a/src/lib/navigation-layout/ApiSorting.js +++ b/src/lib/navigation-layout/ApiSorting.ts @@ -1,12 +1,10 @@ -/** @typedef {import('../../types').ApiEndPointListItem} ApiEndPointListItem */ +import { ApiEndPointListItem } from "../../types.js"; export class ApiSorting { /** * Sorts endpoints by path. - * @param {ApiEndPointListItem[]} list - * @returns {ApiEndPointListItem[]} */ - static sortEndpointsByPath(list) { + static sortEndpointsByPath(list: ApiEndPointListItem[]): ApiEndPointListItem[] { list.sort((a,b) => { if (a.path < b.path){ return -1; diff --git a/src/lib/navigation-layout/EndpointsTree.d.ts b/src/lib/navigation-layout/EndpointsTree.d.ts deleted file mode 100644 index e731e5e..0000000 --- a/src/lib/navigation-layout/EndpointsTree.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ApiEndPointListItem, ApiEndpointsTreeItem } from "../../types"; - -export interface CommonRootInfo { - index: number; - item: ApiEndpointsTreeItem; - common: string; -} - -/** - * A class that transforms the list of endpoints and methods into - * a tree structure with indentation - */ -export declare class EndpointsTree { - result: ApiEndpointsTreeItem[]; - indents: Record; - constructor(); - - /** - * @param list Sorted list of endpoints. - */ - create(list: ApiEndPointListItem[]): ApiEndpointsTreeItem[]; - - /** - * @param parts Path parts of the currently evaluated endpoint - */ - findParentEndpoint(parts: string[]): string|undefined; - - /** - * @param parts Path parts of the currently evaluated endpoint - */ - findCommonRootInfo(parts: string[]): CommonRootInfo|undefined; - - prepareLabel(item: ApiEndpointsTreeItem, prevPath?: string): ApiEndpointsTreeItem; - - /** - * Updates paths and indentation of children after inserting a new (abstract) parent. - */ - postInsertParent(parent: ApiEndpointsTreeItem): void; -} diff --git a/src/lib/navigation-layout/EndpointsTree.js b/src/lib/navigation-layout/EndpointsTree.ts similarity index 78% rename from src/lib/navigation-layout/EndpointsTree.js rename to src/lib/navigation-layout/EndpointsTree.ts index 540536f..ab4c5d3 100644 --- a/src/lib/navigation-layout/EndpointsTree.js +++ b/src/lib/navigation-layout/EndpointsTree.ts @@ -2,42 +2,46 @@ /* eslint-disable no-continue */ /* eslint-disable no-plusplus */ /* eslint-disable class-methods-use-this */ -/** @typedef {import('../../types').ApiEndPointListItem} ApiEndPointListItem */ -/** @typedef {import('../../types').ApiEndpointsTreeItem} ApiEndpointsTreeItem */ -/** @typedef {import('./EndpointsTree').CommonRootInfo} CommonRootInfo */ + +import { ApiEndpointsTreeItem, ApiEndPointListItem } from "../../types.js"; + +export interface CommonRootInfo { + index: number; + item: ApiEndpointsTreeItem; + common: string; +} /** * A class that transforms the list of endpoints and methods into * a tree structure with indentation */ export class EndpointsTree { + result: ApiEndpointsTreeItem[]; + + indents: Record; + constructor() { - /** - * @type ApiEndpointsTreeItem[] - */ this.result = []; - /** @type Record */ this.indents = {}; } /** - * @param {ApiEndPointListItem[]} list Sorted list of endpoints. - * @returns {ApiEndpointsTreeItem[]} + * @param list Sorted list of endpoints. */ - create(list) { + create(list: ApiEndPointListItem[]): ApiEndpointsTreeItem[] { if (!Array.isArray(list) || !list.length) { return []; } const { result, indents } = this; - let prev = /** @type ApiEndpointsTreeItem */ (null); + let prev: ApiEndpointsTreeItem | undefined; for (let i = 0, len = list.length; i < len; i++) { - const item = /** @type ApiEndpointsTreeItem */ ({ ...list[i], indent: 0, label: '' }); + const item = ({ ...list[i], indent: 0, label: '' }) as ApiEndpointsTreeItem; const { path } = item; const parts = path.split('/'); const hasParts = parts.length > 1 && !(parts.length === 2 && !parts[0]); if (i === 0) { if (hasParts) { - const parent = { + const parent: ApiEndpointsTreeItem = { indent: 0, path: parts.slice(0, parts.length - 1).join('/'), label: undefined, @@ -55,8 +59,11 @@ export class EndpointsTree { continue; } } + if (!prev) { + continue; + } // this is similar to the next block but is faster when the previous item is parent. - if (path.startsWith(prev.path)) { + if (path.startsWith(prev.path || '')) { item.indent = prev.indent + 1; prev.hasChildren = true; indents[item.path] = item.indent; @@ -67,7 +74,7 @@ export class EndpointsTree { const upPath = this.findParentEndpoint(parts); if (upPath) { item.indent = indents[upPath] + 1; - const parent = result.find((p) => p.path === upPath); + const parent = result.find((p) => p.path === upPath) as ApiEndpointsTreeItem; parent.hasChildren = true; indents[item.path] = item.indent; result.push(this.prepareLabel(item, upPath)); @@ -76,7 +83,7 @@ export class EndpointsTree { const info = this.findCommonRootInfo(parts); if (info) { // this is an abstract item, it's not actually an endpoint - const parent = { + const parent: ApiEndpointsTreeItem = { indent: info.item.indent, path: info.common, label: info.common, @@ -102,9 +109,9 @@ export class EndpointsTree { } /** - * @param {string[]} parts Path parts of the currently evaluated endpoint + * @param parts Path parts of the currently evaluated endpoint */ - findParentEndpoint(parts) { + findParentEndpoint(parts: string[]): string | undefined { const { indents } = this; const list = Array.from(parts); const compare = Object.keys(indents).reverse(); @@ -128,9 +135,8 @@ export class EndpointsTree { /** * @param {string[]} parts Path parts of the currently evaluated endpoint - * @returns {CommonRootInfo|undefined} */ - findCommonRootInfo(parts) { + findCommonRootInfo(parts: string[]): CommonRootInfo|undefined { const { result } = this; const list = Array.from(parts); // eslint-disable-next-line no-constant-condition @@ -155,12 +161,7 @@ export class EndpointsTree { return undefined; } - /** - * @param {ApiEndpointsTreeItem} item - * @param {string=} prevPath - * @returns {ApiEndpointsTreeItem} - */ - prepareLabel(item, prevPath) { + prepareLabel(item: ApiEndpointsTreeItem, prevPath?: string): ApiEndpointsTreeItem { const { name, path, indent } = item; item.label = path; if (name) { @@ -168,7 +169,7 @@ export class EndpointsTree { } else if (indent > 0 && prevPath) { let label = item.label.replace(prevPath, ''); if (label.startsWith('-')) { - label = label.substr(1); + label = label.substring(1); } item.label = label item.hasShortPath = true; @@ -181,15 +182,14 @@ export class EndpointsTree { /** * Updates paths and indentation of children after inserting a new (abstract) parent. - * @param {ApiEndpointsTreeItem} parent */ - postInsertParent(parent) { + postInsertParent(parent: ApiEndpointsTreeItem): void { const { result } = this; result.forEach((item) => { const { path } = item; if (path.startsWith(parent.path)) { item.indent += 1; - item.label = item.label.replace(parent.path, ''); + item.label = (item.label || '').replace(parent.path, ''); } }); } diff --git a/src/types.d.ts b/src/types.ts similarity index 96% rename from src/types.d.ts rename to src/types.ts index 4f5ffeb..c07618a 100644 --- a/src/types.d.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ import { HTTPRequest, RequestAuthorization } from '@advanced-rest-client/events/src/request/ArcRequest'; -import { ApiParameter, ApiShapeUnion, ApiSecurityRequirement, ApiServer, ApiEndPoint, ApiExample, ApiDocumentation } from './helpers/api'; -import { default as XhrSimpleRequestTransportElement } from './elements/XhrSimpleRequestTransportElement'; +import { ApiParameter, ApiShapeUnion, ApiSecurityRequirement, ApiServer, ApiEndPoint, ApiExample, ApiDocumentation } from './helpers/api.js'; +import XhrSimpleRequestTransportElement from './elements/XhrSimpleRequestTransportElement.js'; export declare interface ApiConsoleRequest extends HTTPRequest { /** @@ -99,8 +99,8 @@ export interface OperationParameter { } export interface SecuritySelectorListItem { - types: string[]; - labels: string[]; + types: (string | undefined)[]; + labels: (string | undefined)[]; security: ApiSecurityRequirement; } @@ -154,14 +154,14 @@ export interface ComputeBaseUriOptions { forceHttpProtocol?: boolean; } -export interface OperationParameter { - parameter: ApiParameter; - schema?: ApiShapeUnion; - paramId: string; - schemaId?: string; - binding: string; - source: string; -} +// export interface OperationParameter { +// parameter: ApiParameter; +// schema?: ApiShapeUnion; +// paramId: string; +// schemaId?: string; +// binding: string; +// source: string; +// } export declare interface SelectionInfo { /** @@ -249,7 +249,7 @@ export interface ApiOperationListItem { } export interface ApiEndpointsTreeItem extends ApiEndPointWithOperationsListItem { - label: string; + label: string | undefined; indent: number; hasShortPath?: boolean; hasChildren?: boolean; diff --git a/tsconfig.json b/tsconfig.json index fbea4c9..9f6c1d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,27 @@ { "compilerOptions": { - "target": "esnext", + "target": "ES2021", "module": "esnext", "moduleResolution": "node", - "lib": ["es2017", "dom"], - "allowJs": true, - "checkJs": true, - "noEmit": true, - "strict": false, + "noEmitOnError": true, + "lib": ["es2021", "dom"], + "strict": true, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "importHelpers": true, + "outDir": "./dist", + "rootDir": "./src", + "sourceMap": true, + "inlineSources": true, + "declaration": true, + "incremental": true, "noImplicitThis": true, "alwaysStrict": true, - "esModuleInterop": true, - "plugins": [ - { - "name": "typescript-lit-html-plugin" - } - ] + "declarationMap": true, + "pretty": true, + "skipLibCheck": true }, - "include": [ "**/*.js", "node_modules/@open-wc/**/*.js", "index.d.ts" ], + "include": ["src/**/*.ts"], "exclude": ["node_modules/!(@open-wc)"] } diff --git a/web-dev-server.config.mjs b/web-dev-server.config.mjs index 234d0e2..cd67c88 100644 --- a/web-dev-server.config.mjs +++ b/web-dev-server.config.mjs @@ -1,13 +1,41 @@ +import { esbuildPlugin } from '@web/dev-server-esbuild'; import { amfParserApi } from './dev/amf-server/api.mjs'; -/** @typedef {import('@web/dev-server').DevServerConfig} DevServerConfig */ +/** Use Hot Module replacement by adding --hmr to the start command */ +const hmr = process.argv.includes('--hmr'); + +export default /** @type {import('@web/dev-server').DevServerConfig} */ ({ + open: '/demo/', + /** Use regular watch mode if HMR is not enabled. */ + watch: !hmr, + /** Resolve bare module imports */ + nodeResolve: { + exportConditions: ['browser', 'development'], + }, + + // mimeTypes: { + // // serve all json files as js + // // '**/*.json': 'js', + // // serve .module.css files as js + // '**/monaco-editor/esm/vs/editor/standalone/**/.css': 'js', + // }, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto' + + /** Set appIndex to enable SPA routing */ + // appIndex: 'demo/index.html', + + plugins: [ + esbuildPlugin({ ts: true, target: 'es2020' }), + /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */ + // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }), + ], + + // preserveSymlinks: true, + + // See documentation for all available options -export default /** @type DevServerConfig */ ({ - open: true, - nodeResolve: true, - appIndex: 'demo/index.html', - rootDir: '.', - watch: true, middleware: [ amfParserApi, ], diff --git a/web-test-runner.config.mjs b/web-test-runner.config.mjs index 1bce097..c9bf833 100644 --- a/web-test-runner.config.mjs +++ b/web-test-runner.config.mjs @@ -1,12 +1,50 @@ -export default { - files: 'test/**/*.test.js', - // files: 'test/navigation/*.test.js', - // files: 'test/elements/ApiOperationDocumentElement.test.js', - // files: [ - // 'test/elements/ApiSecurityRequirementDocumentElement.test.js', - // 'test/elements/ApiOperationDocumentElement.test.js', +import { esbuildPlugin } from '@web/dev-server-esbuild'; + +const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode']; + +export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({ + /** Test files to run */ + files: 'test/**/**/*.test.ts', + + /** Resolve bare module imports */ + nodeResolve: { + exportConditions: ['browser', 'production'], + }, + + /** Filter out lit dev mode logs */ + filterBrowserLogs(log) { + for (const arg of log.args) { + if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) { + return false; + } + } + return true; + }, + + /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */ + // esbuildTarget: 'auto', + + /** Amount of browsers to run concurrently */ + concurrentBrowsers: 3, + + plugins: [ + esbuildPlugin({ ts: true, target: 'es2020' }), + ], + + /** Amount of test files per browser to test concurrently */ + concurrency: 1, + + /** Browsers to run tests on */ + // browsers: [ + // playwrightLauncher({ product: 'chromium' }), + // playwrightLauncher({ product: 'firefox' }), + // playwrightLauncher({ product: 'webkit' }), // ], - nodeResolve: true, + + // See documentation for all available options + + + testFramework: { config: { timeout: 600000, @@ -15,4 +53,4 @@ export default { browserStartTimeout: 20000, testsStartTimeout: 20000, testsFinishTimeout: 600000, -}; +}); From dd72e4b8fbe1c071f163909968d6c0ea2e32033a Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Wed, 21 Sep 2022 14:41:07 -0700 Subject: [PATCH 2/6] chore: adding demo API with a "not" schema Signed-off-by: Pawel Psztyc --- demo/apis/not-schema/not-schema.yaml | 38 ++++++++++++++++++++++++ demo/model.mjs | 1 + src/elements/ApiSchemaDocumentElement.js | 2 +- src/helpers/Namespace.js | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 demo/apis/not-schema/not-schema.yaml diff --git a/demo/apis/not-schema/not-schema.yaml b/demo/apis/not-schema/not-schema.yaml new file mode 100644 index 0000000..ba1a9d6 --- /dev/null +++ b/demo/apis/not-schema/not-schema.yaml @@ -0,0 +1,38 @@ +openapi: '3.0.2' +info: + title: Not schema + version: '1.0' + description: Test API for testing AMF service + contact: + name: API Support + url: http://www.example.com/support + email: support@example.com + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + +components: + schemas: + PetByType: + type: object + properties: + pet_type: + not: + type: integer + required: + - pet_type + +paths: + /pets: + patch: + description: Tests the behavior of the "not" schema + summary: Not schema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PetByType' + responses: + '200': + description: Updated + \ No newline at end of file diff --git a/demo/model.mjs b/demo/model.mjs index 114f55e..da58a24 100644 --- a/demo/model.mjs +++ b/demo/model.mjs @@ -135,6 +135,7 @@ config.set('simple-api/simple-api.raml', { type: 'RAML 1.0' }); config.set('example-generator-api/example-generator-api.raml', { type: "RAML 1.0" }); config.set('tracked-examples/tracked-to-linked.raml', { type: 'RAML 1.0' }); config.set('types-list/types-list.raml', { type: 'RAML 1.0' }); +config.set('not-schema/not-schema.yaml', { type: 'OAS 3.0' }); const srcFolder = path.join('demo', 'apis'); const descFolder = path.join('demo', 'models'); diff --git a/src/elements/ApiSchemaDocumentElement.js b/src/elements/ApiSchemaDocumentElement.js index 3c4fe03..03e2865 100644 --- a/src/elements/ApiSchemaDocumentElement.js +++ b/src/elements/ApiSchemaDocumentElement.js @@ -843,7 +843,7 @@ export default class ApiSchemaDocumentElement extends ApiDocumentationBase { ${detailsTemplate(range)} - + ${expanded ? html`
diff --git a/src/helpers/Namespace.js b/src/helpers/Namespace.js index 8c75208..bcbf33c 100644 --- a/src/helpers/Namespace.js +++ b/src/helpers/Namespace.js @@ -125,6 +125,7 @@ ns.aml.vocabularies.apiContract.Callback = `${contractKey}Callback`; ns.aml.vocabularies.apiContract.TemplatedLink = `${contractKey}TemplatedLink`; ns.aml.vocabularies.apiContract.IriTemplateMapping = `${contractKey}IriTemplateMapping`; ns.aml.vocabularies.apiContract.Tag = `${contractKey}Tag`; +ns.aml.vocabularies.apiContract.Message = `${contractKey}Message`; ns.aml.vocabularies.apiContract.header = `${contractKey}header`; ns.aml.vocabularies.apiContract.parameter = `${contractKey}parameter`; ns.aml.vocabularies.apiContract.paramName = `${contractKey}paramName`; @@ -158,7 +159,6 @@ ns.aml.vocabularies.apiContract.mapping = `${contractKey}mapping`; ns.aml.vocabularies.apiContract.operationId = `${contractKey}operationId`; ns.aml.vocabularies.apiContract.protocol = `${contractKey}protocol`; ns.aml.vocabularies.apiContract.protocolVersion = `${contractKey}protocolVersion`; -ns.aml.vocabularies.apiContract.Message = `${contractKey}Message`; ns.aml.vocabularies.apiContract.headerSchema = `${contractKey}headerSchema`; ns.aml.vocabularies.apiContract.contentType = `${contractKey}contentType`; ns.aml.vocabularies.apiContract.allowEmptyValue = `${contractKey}allowEmptyValue`; From d25ee8a85d8580a34a023c581d2fc296c46c2166 Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Wed, 21 Sep 2022 17:36:56 -0700 Subject: [PATCH 3/6] chore: moving helpers to TS Signed-off-by: Pawel Psztyc --- src/helpers/AmfHelperMixin.d.ts | 449 ----- src/helpers/AmfHelperMixin.js | 1242 ------------ src/helpers/AmfHelperMixin.ts | 1700 +++++++++++++++++ src/helpers/AmfSerializer.d.ts | 210 -- .../{AmfSerializer.js => AmfSerializer.ts} | 1046 ++++------ src/helpers/Namespace.d.ts | 373 ---- src/helpers/Namespace.js | 347 ---- src/helpers/Namespace.ts | 329 ++++ src/helpers/{amf.d.ts => amf.ts} | 4 +- src/helpers/{api.d.ts => api.ts} | 16 +- src/plugins/NavigationCommands.d.ts | 4 - ...ationCommands.js => NavigationCommands.ts} | 16 +- src/plugins/NavigationContextMenu.d.ts | 16 - ...ontextMenu.js => NavigationContextMenu.ts} | 15 +- src/store/AmfGraphStore.js | 68 - .../{AmfGraphStore.d.ts => AmfGraphStore.ts} | 37 +- src/store/AmfStore.d.ts | 133 -- src/store/{AmfStore.js => AmfStore.ts} | 130 +- src/store/DomEventsAmfStore.d.ts | 6 - ...EventsAmfStore.js => DomEventsAmfStore.ts} | 0 src/store/InMemAmfGraphStore.d.ts | 176 -- ...AmfGraphStore.js => InMemAmfGraphStore.ts} | 226 +-- src/types.ts | 5 +- 23 files changed, 2623 insertions(+), 3925 deletions(-) delete mode 100644 src/helpers/AmfHelperMixin.d.ts delete mode 100644 src/helpers/AmfHelperMixin.js create mode 100644 src/helpers/AmfHelperMixin.ts delete mode 100644 src/helpers/AmfSerializer.d.ts rename src/helpers/{AmfSerializer.js => AmfSerializer.ts} (64%) delete mode 100644 src/helpers/Namespace.d.ts delete mode 100644 src/helpers/Namespace.js create mode 100644 src/helpers/Namespace.ts rename src/helpers/{amf.d.ts => amf.ts} (99%) rename src/helpers/{api.d.ts => api.ts} (96%) delete mode 100644 src/plugins/NavigationCommands.d.ts rename src/plugins/{NavigationCommands.js => NavigationCommands.ts} (50%) delete mode 100644 src/plugins/NavigationContextMenu.d.ts rename src/plugins/{NavigationContextMenu.js => NavigationContextMenu.ts} (70%) delete mode 100644 src/store/AmfGraphStore.js rename src/store/{AmfGraphStore.d.ts => AmfGraphStore.ts} (50%) delete mode 100644 src/store/AmfStore.d.ts rename src/store/{AmfStore.js => AmfStore.ts} (51%) delete mode 100644 src/store/DomEventsAmfStore.d.ts rename src/store/{DomEventsAmfStore.js => DomEventsAmfStore.ts} (100%) delete mode 100644 src/store/InMemAmfGraphStore.d.ts rename src/store/{InMemAmfGraphStore.js => InMemAmfGraphStore.ts} (67%) diff --git a/src/helpers/AmfHelperMixin.d.ts b/src/helpers/AmfHelperMixin.d.ts deleted file mode 100644 index 666df40..0000000 --- a/src/helpers/AmfHelperMixin.d.ts +++ /dev/null @@ -1,449 +0,0 @@ -import { - AmfDocument, AsyncApi, DomainElement, EndPoint, Operation, Parameter, Payload, Request, Response, - SecurityScheme, Server, Shape, WebApi, Api -} from './amf'; -import { Namespace } from './Namespace'; -import { ServersQueryOptions } from './api'; - -export {AmfHelperMixin}; - -/** - * Common functions used by AMF components to compute AMF values. - */ -declare function AmfHelperMixin {}>(base: T): T & AmfHelperMixinConstructor; - -interface AmfHelperMixinConstructor { - new(...args: any[]): AmfHelperMixin; -} - -export {AmfHelperMixinConstructor}; - -export const expandKey: unique symbol; -export const findAmfType: unique symbol; -export const findReferenceObject: unique symbol; -export const getArrayItems: unique symbol; -export const computeReferenceSecurity: unique symbol; - -interface AmfHelperMixin { - - /** - * A namespace for AMF model. - */ - readonly ns: Namespace; - - /** - * Generated AMF json/ld model form the API spec. - * The element assumes the object of the first array item to be a - * type of `"http://raml.org/vocabularies/document#Document` - * on AMF vocabulary. - * - * It is only useful for the element to resolve references. - */ - amf: AmfDocument|undefined; - _amf: AmfDocument|undefined; - - /** - * This is an abstract method to be implemented by the components. - * If, instead, the component uses `amf` setter you must use `super.amf` to - * set the value. - * @param amf Current AMF model. Can be undefined. - */ - __amfChanged(amf: AmfDocument): void - /** - * Expands flattened AMF model - */ - _expand(amf: any): AmfDocument; - - /** - * Returns compact model key for given value. - * - * @param property AMF original property - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Compact model property name or the same value if - * value not found in the context. - */ - _getAmfKey(property: string|undefined, context?: Record): string|undefined; - - /** - * Ensures that the model is AMF object. - * - * @param amf AMF json/ld model - * @returns API spec - */ - _ensureAmfModel(amf: any): AmfDocument|undefined; - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param value An item to test - */ - _ensureArray(value: T): T[]|undefined; - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param value An item to test - */ - _ensureArray(value: T[]): T[]|undefined; - - /** - * Gets a single scalar value from a model. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for key - */ - _getValue(model: DomainElement, key: string, context?: Record): string|number|boolean|undefined|null; - - /** - * Gets values from a model as an array of `@value` properties. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for key - */ - _getValueArray(model: DomainElement, key: string, context?: Record): Array|undefined; - - /** - * Reads an array from the model. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for the key - */ - [getArrayItems](model: DomainElement, key: string, context?: Record): DomainElement[]|undefined; - - /** - * Reads the value of the `@id` property. - * @param model Amf model to extract the value from. - * @param key Model key to search for the @id - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValue(model: DomainElement, key: string, context?: Record): string|undefined; - - /** - * Reads the list of value for the `@id` property. - * @param model Amf model to extract the value from. - * @param key Model key to search for the `@id` - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValues(model: DomainElement, key: string, context?: Record): string[]|undefined; - - /** - * Checks if a model has a type. - * - * @param model Model to test - * @param type Type name - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns True if model has a type. - */ - _hasType(model: DomainElement, type: string, context?: Record): boolean|null; - - /** - * Checks if a shape has a property. - * - * @param shape The shape to test - * @param key Property name to test - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _hasProperty(shape: DomainElement, key: string, context?: Record): boolean|null; - - /** - * Computes array value of a property in a model (shape). - * - * @param shape AMF shape object - * @param key Property name - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computePropertyArray(shape: DomainElement, key: string, context?: Record): Array|undefined; - - /** - * Computes API version from the AMF model. - */ - _computeApiVersion(amf: AmfDocument, context?: Record): string|undefined; - - /** - * Computes model's `encodes` property. - * - * @param model AMF data model - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of encodes - */ - _computeEncodes(model: AmfDocument, context?: Record): Api|undefined; - - /** - * Computes list of declarations in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeDeclares(model: AmfDocument, context?: Record): DomainElement[]|undefined; - - /** - * Computes list of references in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeReferences(model: AmfDocument, context?: Record): DomainElement[]|undefined; - - /** - * Computes AMF's `http://schema.org/WebAPI` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Web API declaration. - */ - _computeWebApi(model: AmfDocument, context?: Record): WebApi|undefined; - - /** - * Computes AMF's `http://schema.org/API` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @return The API declaration. - */ - _computeApi(model: AmfDocument, context?: Record): AsyncApi|WebApi; - - /** - * Returns whether an AMF node is a WebAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isWebAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Returns whether an AMF node is an AsyncAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAsyncAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Returns whether an AMF node is an API node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Determines whether a partial model is valid for reading servers from - * Current valid values: - * - Operation - * - Endpoint - * @param model The partial model to evaluate - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Whether the model's type is part of the array of valid node types from which to read servers - */ - _isValidServerPartial(model: any, context?: Record): boolean; - - /** - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of servers for method, if defined, or endpoint, if defined, or root level - */ - _getServers(opts?: ServersQueryOptions, context?: Record): Server[]|undefined; - - /** - * Computes value for the `expects` property. - * - * @param method AMF `supportedOperation` model - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computeExpects(method: Operation, context?: Record): Request|undefined; - - /** - * Computes list of endpoints from a WebApi model. - * - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Always returns an array of endpoints. - */ - _computeEndpoints(webApi: WebApi, context?: Record): EndPoint[]|undefined; - - /** - * Computes model for an endpoint documentation. - * - * @param webApi Current value of `webApi` property - * @param id Selected shape ID - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint definition - */ - _computeEndpointModel(webApi: WebApi, id: string, context?: Record): EndPoint|undefined; - - /** - * Computes method for the method documentation. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A method definition - */ - _computeMethodModel(webApi: WebApi, selected: string, context?: Record): Operation|undefined; - - /** - * Computes an endpoint for a method. - * - * @param webApi The WebApi AMF model - * @param methodId Method id - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint model of undefined. - */ - _computeMethodEndpoint(webApi: WebApi, methodId: string, context?: Record): EndPoint|undefined; - - /** - * Computes a list of methods for an endpoint that contains a method with - * given id. - * - * @param webApi WebApi model - * @param methodId Method id. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A list of sibling methods or undefined. - */ - __computeMethodsListForMethod(webApi: WebApi, methodId: string, context?: Record): Operation[]|undefined; - - /** - * Computes a type documentation model. - * - * @param declares Current value of `declares` property - * @param references Current value of `references` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A type definition - */ - _computeType(declares: DomainElement[], references: DomainElement[], selected: string, context?: Record): Shape|undefined; - - /** - * Finds a type in the model declares and references. - * @param domainId The domain id of the type (AMF's shape). - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The AMF shape or undefined when not found. - */ - [findAmfType](domainId?: string, context?: Record): Shape|undefined; - - /** - * Searches for an object in model's references list. - * It does not resolve the object (useful for handling links correctly). - * - * @param domainId The domain of the object to find in the references. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The domain object or undefined. - */ - [findReferenceObject](domainId?: string, context?: Record): DomainElement|undefined; - - /** - * Computes a type model from a reference (library for example). - * - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - _computeReferenceType(reference: DomainElement, selected: string, context?: Record): Shape|undefined; - - /** - * Computes a documentation model. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A method definition - */ - _computeDocument(webApi: WebApi, selected: string, context?: Record): DomainElement|undefined; - - /** - * Resolves a reference to an external fragment. - * - * @param shape A shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape. - */ - _resolve(shape: T, context?: Record): T; - _getLinkTarget(amf: AmfDocument, id: string, context?: Record): DomainElement|undefined; - - /** - * Resolves the shape of a given reference. - * - * @param references References object to search in - * @param id Id of the shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape for given reference, undefined otherwise - */ - _obtainShapeFromReferences(references: DomainElement[], id: string, context?: Record): DomainElement|undefined; - - /** - * Searches a node with a given ID in an array - * - * @param array Array to search for a given ID - * @param id Id to search for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Node with the given ID when found, undefined otherwise - */ - _findById(array: DomainElement[], id: string): DomainElement|undefined; - _getReferenceId(amf: AmfDocument, id: string, context?: Record): DomainElement|undefined; - _resolveRecursive(shape: T, context?: Record): T; - - /** - * Merge two shapes together. If the resulting shape has one of the "special merge" keys, - * then the special merge function for that key will be used to match that property - * @param shapeA AMF node - * @param shapeB AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Merged AMF node - */ - _mergeShapes(shapeA: any, shapeB: any, context?: Record): any; - - /** - * Obtains source map sources value from two shapes and returns the merged result - * If neither shape has a sources node, then an empty object will be returned. - * Result is wrapped in an array as per AMF model standard - * @param AMF node - * @param AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Empty object or resulting merge, wrapped in an array - */ - _mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record): any[]; - - /** - * Expands the key property from compacted mode to full mode. - * @param value The value to process - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The expanded value. - */ - [expandKey](value: string, context?: Record): string; - /** - * Computes a security model from a reference (library for example). - * @param domainId Domain id of the security requirement to find. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - findSecurityScheme(domainId: string, context?: Record): SecurityScheme|undefined; - - /** - * Computes a security model from a reference (library for example). - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - [computeReferenceSecurity](reference: DomainElement, selected: string, context?: Record): SecurityScheme|undefined; - /** - * Collects domain objects by a domain type. - * @param source The element to search for declare/encoded objects. - * @param type The domain type - * @param context A context to use. If not set, it looks for the context of the passed model - */ - getByType(source: DomainElement, type: string, context?: Record): DomainElement[]; -} diff --git a/src/helpers/AmfHelperMixin.js b/src/helpers/AmfHelperMixin.js deleted file mode 100644 index adc436c..0000000 --- a/src/helpers/AmfHelperMixin.js +++ /dev/null @@ -1,1242 +0,0 @@ -/** -@license -Copyright 2018 The Advanced REST client authors -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at -http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -// @ts-ignore -import { AmfModelExpander, JsonLdOptions, JsonLd } from 'amf-json-ld-lib'; -import { ns } from './Namespace.js'; - -/** @typedef {import('./Namespace').ns} Namespace */ -/** @typedef {import('./amf').DomainElement} DomainElement */ -/** @typedef {import('./amf').AmfDocument} AmfDocument */ -/** @typedef {import('./amf').WebApi} WebApi */ -/** @typedef {import('./amf').AsyncApi} AsyncApi */ -/** @typedef {import('./amf').Server} Server */ -/** @typedef {import('./amf').EndPoint} EndPoint */ -/** @typedef {import('./amf').Operation} Operation */ -/** @typedef {import('./amf').Shape} Shape */ -/** @typedef {import('./amf').Parameter} Parameter */ -/** @typedef {import('./amf').Request} Request */ -/** @typedef {import('./amf').Response} Response */ -/** @typedef {import('./amf').Payload} Payload */ -/** @typedef {import('./amf').SecurityScheme} SecurityScheme */ -/** @typedef {import('./api').ServersQueryOptions} ServersQueryOptions */ -/** @typedef {import('./api').ServerQueryOptions} ServerQueryOptions */ -/** @typedef {import('./api').ComputeUriOptions} ComputeUriOptions */ - -export const expandKey = Symbol('expandKey'); -export const findAmfType = Symbol('findAmfType'); -export const findReferenceObject = Symbol('findReferenceObject'); -export const getArrayItems = Symbol('getArrayItems'); -export const computeReferenceSecurity = Symbol('computeReferenceSecurity'); - -/* eslint-disable class-methods-use-this */ -/* eslint-disable no-plusplus */ -/* eslint-disable no-continue */ - -/** - * Common functions used by AMF components to compute AMF values. - * @param {*} base - * @returns {*} - * @mixin - */ -export const AmfHelperMixin = (base) => class extends base { - static get properties() { - return { - /** - * Generated AMF json/ld model form the API spec. - * The element assumes the object of the first array item to be a - * type of `"http://raml.org/vocabularies/document#Document` - * on AMF vocabulary. - * - * It is only useful for the element to resolve references. - * - * @type {Object|Array} - */ - amf: { type: Object } - }; - } - - /** - * A namespace for AMF model. - * @returns {Namespace} - */ - get ns() { - return ns; - } - - get amf() { - return this._amf; - } - - set amf(value) { - const old = this._amf; - if (old === value) { - return; - } - let expanded; - if (!value || AmfModelExpander.isInExpandedForm(value)) { - this._flattenedAmf = undefined; - expanded = value; - } else { - const oldFlattened = this._flattenedAmf; - if (oldFlattened === value) { - return; - } - this._flattenedAmf = value; - expanded = this._expand(value); - } - // Cached keys cannot be static as this element can be using in the sane - // document with different AMF models - this.__cachedKeys = {}; - this._amf = expanded; - this.__amfChanged(expanded); - if (this.requestUpdate) { - this.requestUpdate('amf', old); - } - } - - /** - * This is an abstract method to be implemented by the components. - * If, instead, the component uses `amf` setter you must use `super.amf` to - * set the value. - * @param {Array|Object} amf Current AMF model. Can be undefined. - * @abstract - */ - /* eslint-disable-next-line no-unused-vars */ - __amfChanged(amf) {} - - /** - * Expands flattened AMF model - * @param {Object} amf - */ - _expand(amf) { - AmfModelExpander.preprocessLegacyRootNodeId(amf) - const linkEmbeddingFilter = key => !key.endsWith("fixPoint") - const rootNode = amf['@context'] ? '' : "amf://id"; - const options = JsonLdOptions.apply() - .withEmbeddedLinks(linkEmbeddingFilter) - .withCompactedIris() - .withExpandedStructure() - .withRootNode(rootNode) - return JsonLd.process(amf, options) - } - - /** - * Returns compact model key for given value. - * @param {string} property AMF original property - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {string} Compact model property name or the same value if - * value not found in the context. - */ - _getAmfKey(property, context) { - if (!property) { - return undefined; - } - let {amf} = this; - if (!amf && !context) { - return property; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - if (!this.__cachedKeys) { - this.__cachedKeys = {}; - } - const ctx = /** @type Record */ (context || amf['@context']); - if (!ctx || !property) { - return property; - } - const cache = this.__cachedKeys; - if (property in cache) { - return cache[property]; - } - /* eslint-disable-next-line no-param-reassign */ - property = String(property); - const hashIndex = property.indexOf('#'); - const hashProperty = property.substr(0, hashIndex + 1); - const keys = Object.keys(ctx); - for (let i = 0, len = keys.length; i < len; i++) { - const k = keys[i]; - if (ctx[k] === property) { - cache[property] = k; - return k; - } if (hashIndex === -1 && property.indexOf(ctx[k]) === 0) { - const result = property.replace(ctx[k], `${k}:`); - cache[property] = result; - return result; - } if (ctx[k] === hashProperty) { - const result = `${k}:${property.substr(hashIndex + 1)}`; - cache[property] = result; - return result; - } - } - return property; - } - - /** - * Ensures that the model is AMF object. - * - * @param {any} amf AMF json/ld model - * @returns {AmfDocument|undefined} API spec - */ - _ensureAmfModel(amf) { - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - /* eslint-disable-next-line no-param-reassign */ - [amf] = amf; - } - if (this._hasType(amf, ns.aml.vocabularies.document.Document)) { - return amf; - } - return undefined; - } - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param {Array|any} value An item to test - * @returns {Array|undefined} - */ - _ensureArray(value) { - if (!value) { - return undefined; - } - if (value instanceof Array) { - return value; - } - return [value]; - } - - /** - * Gets a single scalar value from a model. - * @param {DomainElement} model Amf model to extract the value from. - * @param {string} key Model key to search for the value - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {string|number|boolean|undefined|null} Value for key - */ - _getValue(model, key, context) { - /* eslint-disable-next-line no-param-reassign */ - key = this._getAmfKey(key, context); - let data = model && model[key]; - if (!data) { - // This includes "undefined", "false", "null" and "0" - return data; - } - if (Array.isArray(data)) { - /* eslint-disable-next-line no-param-reassign */ - [data] = data; - } - if (!data) { - return undefined; - } - const type = typeof data; - if (['string', 'number', 'boolean', 'undefined'].indexOf(type) !== -1) { - return data; - } - return data['@value']; - } - - /** - * Gets values from a model as an array of `@value` properties. - * @param {DomainElement} model Amf model to extract the value from. - * @param {string} key Model key to search for the value - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Array|undefined} Value for key - */ - _getValueArray(model, key, context) { - /* eslint-disable-next-line no-param-reassign */ - key = this._getAmfKey(key, context); - const data = model && this._ensureArray(model[key]); - if (!Array.isArray(data)) { - return undefined; - } - return data.map((item) => item['@value'] || item); - } - - /** - * Reads an array from the model. - * - * @param {DomainElement} model Amf model to extract the value from. - * @param {string} key Model key to search for the value - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement[]|undefined} Value for the key - */ - [getArrayItems](model, key, context) { - const k = this._getAmfKey(key, context); - const data = model && this._ensureArray(model[k]); - if (!Array.isArray(data)) { - return undefined; - } - return data; - } - - /** - * Reads the value of the `@id` property. - * @param {DomainElement} model Amf model to extract the value from. - * @param {string} key Model key to search for the @id - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {string|undefined} - */ - _getLinkValue(model, key, context) { - const k = this._getAmfKey(key, context); - let data = model && model[k]; - if (!data) { - return undefined; - } - if (Array.isArray(data)) { - [data] = data; - } - if (!data) { - return undefined; - } - return data['@id']; - } - - /** - * Reads the list of value for the `@id` property. - * @param {DomainElement} model Amf model to extract the value from. - * @param {string} key Model key to search for the @id - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {string[]|undefined} - */ - _getLinkValues(model, key, context) { - const k = this._getAmfKey(key, context); - let data = /** @type DomainElement[] */ (model && model[k]); - if (!data) { - return undefined; - } - if (!Array.isArray(data)) { - data = [data]; - } - return data.map(i => i['@id']); - } - - /** - * Checks if a model has a type. - * @param {DomainElement} model Model to test - * @param {string} type Type name - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} True if model has a type. - */ - _hasType(model, type, context) { - const types = this._ensureArray(model && model['@type']); - if (!types || !types.length) { - return false; - } - const key = this._getAmfKey(type, context); - for (let i = 0; i < types.length; i++) { - if (types[i] === key) { - return true; - } - } - return false; - } - - /** - * Checks if a shape has a property. - * @param {DomainElement} shape The shape to test - * @param {string} key Property name to test - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} - */ - _hasProperty(shape, key, context) { - /* eslint-disable-next-line no-param-reassign */ - key = this._getAmfKey(key, context); - return !!(shape && key && key in shape); - } - - /** - * Computes array value of a property in a model (shape). - * - * @param {DomainElement} shape AMF shape object - * @param {string} key Property name - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Array|undefined} - */ - _computePropertyArray(shape, key, context) { - if (!shape) { - return undefined; - } - /* eslint-disable-next-line no-param-reassign */ - key = this._getAmfKey(key, context); - const data = this._ensureArray(shape && shape[key]); - if (!data || !Array.isArray(data)) { - return undefined; - } - return data; - } - - /** - * Computes API version from the AMF model. - * - * @param {AmfDocument} amf - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {string} - */ - _computeApiVersion(amf, context) { - const api = this._computeApi(amf); - if (!api) { - return undefined; - } - return /** @type string */ (this._getValue(api, this.ns.aml.vocabularies.core.version, context)); - } - - /** - * Computes model's `encodes` property. - * - * @param {AmfDocument} model AMF data model - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement|undefined} List of encodes - */ - _computeEncodes(model, context) { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.encodes, context); - const data = model[key]; - if (data) { - return Array.isArray(data) ? data[0] : data; - } - return undefined; - } - - /** - * Computes list of declarations in the AMF api model. - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement[]|undefined} List of declarations - */ - _computeDeclares(model, context) { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.declares, context); - const data = this._ensureArray(model[key]); - return Array.isArray(data) ? data : undefined; - } - - /** - * Computes list of references in the AMF api model. - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement[]|undefined} List of declarations - */ - _computeReferences(model, context) { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.references, context); - const data = this._ensureArray(model[key]); - return data instanceof Array ? data : undefined; - } - - /** - * Computes AMF's `http://schema.org/WebAPI` model - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {WebApi|undefined} Web API declaration. - */ - _computeWebApi(model, context) { - const enc = this._computeEncodes(model, context); - if (!enc) { - return undefined; - } - if (this._hasType(enc, this.ns.schema.webApi, context)) { - return enc; - } - return undefined; - } - - /** - * Computes AMF's `http://schema.org/API` model - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {AsyncApi|WebApi} API declaration. - */ - _computeApi(model, context) { - const enc = this._computeEncodes(model, context); - if (!enc) { - return undefined; - } - if (this._isAPI(model, context) || this._isWebAPI(model, context) || this._isAsyncAPI(model, context)) { - return enc; - } - return undefined; - } - - /** - * Returns whether an AMF node is a WebAPI node - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} - */ - _isWebAPI(model, context) { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.WebAPI, context); - } - - /** - * Returns whether an AMF node is an AsyncAPI node - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} - */ - _isAsyncAPI(model, context) { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.AsyncAPI, context); - } - - /** - * Returns whether an AMF node is an API node - * - * @param {AmfDocument} model AMF json/ld model for an API - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} - */ - _isAPI(model, context) { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.API, context); - } - - /** - * Determines whether a partial model is valid for reading servers from - * Current valid values: - * - Operation - * - Endpoint - * @param {DomainElement} model The partial model to evaluate - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {boolean} Whether the model's type is part of the array of valid node types from which - * to read servers - * @private - */ - _isValidServerPartial(model, context) { - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return false; - } - const oKey = this.ns.aml.vocabularies.apiContract.Operation; - const eKey = this.ns.aml.vocabularies.apiContract.EndPoint; - const allowedPartialModelTypes = [this._getAmfKey(oKey, context), this._getAmfKey(eKey, context)]; - const types = model['@type']; - for (const type of types) { - if (allowedPartialModelTypes.indexOf(type) !== -1) { - return true; - } - } - return false; - } - - /** - * @param {ServersQueryOptions=} [options={}] Server query options - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Server[]} List of servers for method, if defined, or endpoint, if defined, or root level - */ - _getServers(options = {}, context) { - const { endpointId, methodId } = options; - const { amf } = this; - if (!amf) { - return undefined; - } - let api = this._computeApi(amf, context); - if (Array.isArray(api)) { - [api] = api; - } - if (!api) { - if (this._isValidServerPartial(amf, context)) { - api = amf; - } else { - return undefined; - } - } - - const serverKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.server, context); - - const getRootServers = () => /** @type Server[] */ (this[getArrayItems](api, serverKey, context)); - const getEndpointServers = () => { - const endpoint = this._computeEndpointModel(api, endpointId, context); - const servers = /** @type Server[] */ (this[getArrayItems](endpoint, serverKey, context)); - if (servers) { - return servers; - } - return getRootServers(); - }; - const getMethodServers = () => { - const method = this._computeMethodModel(api, methodId, context); - const servers = /** @type Server[] */ (this[getArrayItems](method, serverKey, context)); - if (servers) { - return servers; - } - return getEndpointServers(); - }; - - if (methodId) { - return getMethodServers(); - } if (endpointId) { - return getEndpointServers(); - } - return getRootServers(); - } - - /** - * Computes value for the `expects` property. - * - * @param {Operation} method AMF `supportedOperation` model - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Request} - */ - _computeExpects(method, context) { - const operationKey = this.ns.aml.vocabularies.apiContract.Operation; - const expectsKey = this.ns.aml.vocabularies.apiContract.expects; - if (this._hasType(method, operationKey, context)) { - const key = this._getAmfKey(expectsKey, context); - const expects = this._ensureArray(method[key]); - if (expects) { - return Array.isArray(expects) ? expects[0] : expects; - } - } - return undefined; - } - - /** - * Computes list of endpoints from a WebApi model. - * @param {WebApi} webApi - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {EndPoint[]|undefined} An array of endpoints. - */ - _computeEndpoints(webApi, context) { - if (!webApi) { - return []; - } - const endpointKey = this.ns.aml.vocabularies.apiContract.endpoint; - const key = this._getAmfKey(endpointKey, context); - return this._ensureArray(webApi[key]); - } - - /** - * Computes model for an endpoint documentation. - * - * @param {WebApi} webApi Current value of `webApi` property - * @param {string} id Selected shape ID - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {EndPoint} An endpoint definition - */ - _computeEndpointModel(webApi, id, context) { - if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { - return webApi; - } - const endpoints = this._computeEndpoints(webApi, context); - if (!endpoints) { - return undefined; - } - return endpoints.find((item) => item['@id'] === id); - } - - /** - * Computes method for the method documentation. - * - * @param {WebApi} webApi Current value of `webApi` property - * @param {string} selected Selected shape - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Operation} A method definition - */ - _computeMethodModel(webApi, selected, context) { - const methods = this.__computeMethodsListForMethod(webApi, selected, context); - if (!methods) { - return undefined; - } - return methods.find((item) => item['@id'] === selected); - } - - /** - * Computes an endpoint for a method. - * @param {WebApi} webApi The WebApi AMF model - * @param {string} methodId Method id - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {EndPoint|undefined} An endpoint model of undefined. - */ - _computeMethodEndpoint(webApi, methodId, context) { - if (!webApi || !methodId) { - return undefined; - } - if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { - return webApi; - } - const endpoints = this._computeEndpoints(webApi, context); - if (!endpoints) { - return undefined; - } - const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context); - for (let i = 0, len = endpoints.length; i < len; i++) { - const endpoint = endpoints[i]; - let methods = endpoint[opKey]; - if (!methods) { - continue; - } - if (!Array.isArray(methods)) { - methods = [methods]; - } - for (let j = 0, jLen = methods.length; j < jLen; j++) { - if (methods[j]['@id'] === methodId) { - return endpoint; - } - } - } - return undefined; - } - - /** - * Computes a list of methods for an endpoint that contains a method with - * given id. - * - * @param {WebApi} webApi WebApi model - * @param {string} methodId Method id. - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Operation[]|undefined} A list of sibling methods or undefined. - */ - __computeMethodsListForMethod(webApi, methodId, context) { - const endpoint = this._computeMethodEndpoint(webApi, methodId, context); - if (!endpoint) { - return undefined; - } - const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context); - return this._ensureArray(endpoint[opKey]); - } - - /** - * Computes a type documentation model. - * - * @param {DomainElement[]} declares Current value of `declares` property - * @param {DomainElement[]} references Current value of `references` property - * @param {string} selected Selected shape - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Shape} A type definition - */ - _computeType(declares, references, selected, context) { - if ((!declares && !references) || !selected) { - return undefined; - } - // In compact model some IDs are presented in long version (in source maps for examples) - // This must test for this case as well. - const compactId = selected.replace('amf://id', ''); - let type = declares && declares.find((item) => item['@id'] === selected || item['@id'] === compactId); - if (!type && references && references.length) { - for (let i = 0, len = references.length; i < len; i++) { - if (!this._hasType(references[i], this.ns.aml.vocabularies.document.Module)) { - continue; - } - type = this._computeReferenceType(references[i], selected, context); - if (type) { - break; - } - } - } - return type; - } - - /** - * Finds a type in the model declares and references. - * @param {string} domainId The domain id of the type (AMF's shape). - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Shape|undefined} The AMF shape or undefined when not found. - */ - [findAmfType](domainId, context) { - let { amf } = this; - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const declares = this._computeDeclares(amf, context); - const compactId = domainId.replace('amf://id', ''); - if (Array.isArray(declares)) { - const result = declares.find((item) => item['@id'] === domainId || item['@id'] === compactId); - if (result) { - return result; - } - } - return this[findReferenceObject](domainId); - } - - /** - * Searches for an object in model's references list. - * It does not resolve the object (useful for handling links correctly). - * - * @param {string} domainId The domain of the object to find in the references. - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement|undefined} The domain object or undefined. - */ - [findReferenceObject](domainId, context) { - let { amf } = this; - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const references = this._computeReferences(amf, context); - if (!Array.isArray(references) || !references.length) { - return undefined; - } - const compactId = domainId.replace('amf://id', ''); - for (let i = 0, len = references.length; i < len; i++) { - const ref = /** @type AmfDocument */ (references[i]); - const declares = this._computeDeclares(ref, context); - if (!Array.isArray(declares)) { - continue; - } - for (let j = 0, lenDecl = declares.length; j < lenDecl; j++) { - let declared = declares[j]; - if (Array.isArray(declared)) { - [declared] = declared; - } - if (declared['@id'] === domainId || declared['@id'] === compactId) { - return declared; - } - } - } - return undefined; - } - - /** - * Computes a type model from a reference (library for example). - * @param {DomainElement} reference AMF model for a reference to extract the data from - * @param {string} selected Node ID to look for - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {Shape|undefined} Type definition or undefined if not found. - */ - _computeReferenceType(reference, selected, context) { - const declare = this._computeDeclares(reference, context); - if (!declare) { - return undefined; - } - // In compact model some IDs are presented in long version (in source maps for examples) - // This must test for this case as well. - const compactId = selected.replace('amf://id', ''); - let result = declare.find((item) => { - if (Array.isArray(item)) { - /* eslint-disable-next-line no-param-reassign */ - [item] = item; - } - return item['@id'] === selected || item['@id'] === compactId; - }); - if (Array.isArray(result)) { - [result] = result; - } - return this._resolve(result); - } - - /** - * Computes a documentation model. - * - * @param {WebApi} webApi Current value of `webApi` property - * @param {string} selected Selected shape - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement|undefined} - */ - _computeDocument(webApi, selected, context) { - if (!webApi || !selected) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation, context); - const docs = this._ensureArray(webApi[key]); - return docs && docs.find((item) => item['@id'] === selected); - } - - /** - * Resolves a reference to an external fragment. - * - * @param {any} shape A shape to resolve - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {any} Resolved shape. - */ - _resolve(shape, context) { - const {amf} = this; - if (typeof shape !== 'object' || Array.isArray(shape) || !amf || shape.__apicResolved) { - return shape; - } - let refKey = this._getAmfKey(this.ns.aml.vocabularies.document.linkTarget, context); - let refValue = this._ensureArray(shape[refKey]); - let refData; - if (refValue) { - const rk = refValue[0]['@id']; - if (rk === shape['@id']) { - // recursive shape. - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - refData = this._getLinkTarget(amf, rk, context); - } else { - refKey = this._getAmfKey(this.ns.aml.vocabularies.document.referenceId, context); - refValue = this._ensureArray(shape[refKey]); - if (refValue) { - const rk = refValue[0]['@id']; - if (rk === shape['@id']) { - // recursive shape. - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - refData = this._getReferenceId(amf, rk, context); - } - } - if (!refData) { - this._resolveRecursive(shape); - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - const copy = { ...refData}; - delete copy['@id']; - const types = copy['@type']; - if (types) { - if (shape['@type']) { - /* eslint-disable-next-line no-param-reassign */ - shape['@type'] = shape['@type'].concat(types); - } else { - /* eslint-disable-next-line no-param-reassign */ - shape['@type'] = types; - } - delete copy['@type']; - } - this._mergeShapes(shape, copy, context); - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - this._resolveRecursive(shape); - return shape; - } - - /** - * @param {AmfDocument} amf References object to search in - * @param {string} id Id of the shape to resolve - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement | undefined} Resolved shape for given reference, undefined otherwise - */ - _getLinkTarget(amf, id, context) { - if (!amf || !id) { - return undefined; - } - let target; - const declares = this._computeDeclares(amf, context); - if (declares) { - target = this._findById(declares, id); - } - if (!target) { - const references = this._computeReferences(amf, context); - target = this._obtainShapeFromReferences(references, id, context); - } - if (!target) { - return undefined; - } - // Declaration may contain references - target = this._resolve(target); - return target; - } - - /** - * Resolves the shape of a given reference. - * - * @param {DomainElement[]} references References object to search in - * @param {string} id Id of the shape to resolve - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement | undefined} Resolved shape for given reference, undefined otherwise - */ - _obtainShapeFromReferences(references, id, context) { - if (!Array.isArray(references) || !references.length) { - return undefined; - } - let target; - for (let i = 0; i < references.length; i++) { - const _ref = references[i]; - // case of fragment that encodes the shape - const encoded = this._computeEncodes(_ref, context); - if (encoded && encoded['@id'] === id) { - target = encoded; - break; - } - // case of a library which declares types - if (!encoded) { - target = this._findById(this._computeDeclares(_ref, context), id); - if (target) break; - } - } - return target; - } - - /** - * Searches a node with a given ID in an array - * - * @param {DomainElement[]} array Array to search for a given ID - * @param {string} id Id to search for - * @returns {DomainElement | undefined} Node with the given ID when found, undefined otherwise - */ - _findById(array, id) { - if (!array) return undefined; - let target; - for (let i = 0; i < array.length; i++) { - const _current = array[i]; - if (_current && _current['@id'] === id) { - target = _current; - break; - } - } - return target; - } - - _getReferenceId(amf, id, context) { - if (!amf || !id) { - return undefined; - } - const refs = this._computeReferences(amf, context); - if (!refs) { - return undefined; - } - for (let i = 0; i < refs.length; i++) { - const _ref = refs[i]; - const enc = this._computeEncodes(_ref, context); - if (enc) { - if (enc['@id'] === id) { - return enc; - } - } - } - return undefined; - } - - _resolveRecursive(shape, context) { - Object.keys(shape).forEach((key) => { - const currentShape = shape[key]; - if (Array.isArray(currentShape)) { - for (let i = 0, len = currentShape.length; i < len; i++) { - currentShape[i] = this._resolve(currentShape[i]); - } - } else if (typeof currentShape === 'object') { - /* eslint-disable-next-line no-param-reassign */ - shape[key] = this._resolve(currentShape, context); - } - }); - } - - /** - * Merge two shapes together. If the resulting shape has one of the "special merge" keys, - * then the special merge function for that key will be used to match that property - * @param {any} shapeA AMF node - * @param {any} shapeB AMF node - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {*} Merged AMF node - * @private - */ - _mergeShapes(shapeA, shapeB, context) { - const merged = { ...shapeA, ...shapeB }; - const specialMerges = [ - { - key: this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context), - merger: this._mergeSourceMapsSources.bind(this) - }, - ]; - specialMerges.forEach(({ key, merger }) => { - if (this._hasProperty(merged, key, context)) { - merged[key] = merger(shapeA, shapeB, context); - } - }); - return Object.assign(shapeA, merged); - } - - /** - * Obtains source map sources value from two shapes and returns the merged result - * If neither shape has a sources node, then an empty object will be returned. - * Result is wrapped in an array as per AMF model standard - * @param shapeA AMF node - * @param shapeB AMF node - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {(*|{})[]} Empty object or resulting merge, wrapped in an array - * @private - */ - _mergeSourceMapsSources(shapeA, shapeB, context) { - const sourcesKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context); - let aSources = shapeA[sourcesKey] || {}; - if (Array.isArray(aSources)) { - /* eslint-disable prefer-destructuring */ - aSources = aSources[0]; - } - let bSources = shapeB[sourcesKey] || {}; - if (Array.isArray(bSources)) { - /* eslint-disable prefer-destructuring */ - bSources = bSources[0]; - } - return [Object.assign(aSources, bSources)]; - } - - /** - * Expands the key property from compacted mode to full mode. - * @param {string} value The value to process - * @param {Record=} context - * @returns {string} The expanded value. - */ - [expandKey](value, context) { - let { amf } = this; - if (!value || typeof value !== 'string' || (!amf && !context)) { - return value; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const ctx = context || amf['@context']; - if (!ctx) { - return value; - } - const [root, key] = value.split(':'); - if (!root || !key) { - return value; - } - const prefix = ctx[root]; - if (!prefix) { - return value; - } - return `${prefix}${key}`; - } - - /** - * Computes a security model from a reference (library for example). - * @param {string} domainId Domain id of the security requirement to find. - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {SecurityScheme|undefined} Type definition or undefined if not found. - */ - findSecurityScheme(domainId, context) { - const { amf } = this; - const declares = this._computeDeclares(amf, context); - let result; - if (declares) { - result = declares.find((item) => item['@id'] === domainId); - } - if (result) { - result = this._resolve(result); - return result; - } - const references = this._computeReferences(amf, context); - if (Array.isArray(references) && references.length) { - for (const ref of references) { - if (this._hasType(ref, this.ns.aml.vocabularies.document.Module, context)) { - result = this[computeReferenceSecurity](ref, domainId, context); - if (result) { - result = this._resolve(result); - return result; - } - } - } - } - return undefined; - } - - /** - * Computes a security model from a reference (library for example). - * @param {DomainElement} reference AMF model for a reference to extract the data from - * @param {string} selected Node ID to look for - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {SecurityScheme|undefined} Type definition or undefined if not found. - */ - [computeReferenceSecurity](reference, selected, context) { - const declare = this._computeDeclares(reference, context); - if (!declare) { - return undefined; - } - let result = declare.find((item) => { - let declared = item; - if (Array.isArray(declared)) { - [declared] = declared; - } - return declared['@id'] === selected; - }); - if (Array.isArray(result)) { - [result] = result; - } - return this._resolve(result); - } - - /** - * Collects domain objects by a domain type. - * @param {DomainElement} source The element to search for declare/encoded objects. - * @param {string} type The domain type - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {DomainElement[]} - */ - getByType(source, type, context) { - if (!source) { - return []; - } - let result = []; - const declares = this._computeDeclares(source); - const key = this._getAmfKey(type, context); - if (declares && declares.length) { - declares.forEach((declared) => { - if (this._hasType(declared, key)) { - result.push(declared); - } - }); - } - const references = this._computeReferences(source); - if (Array.isArray(references) && references.length) { - for (const ref of references) { - if (this._hasType(ref, this.ns.aml.vocabularies.document.Module)) { - const items = this.getByType(ref, type, context); - if (items.length) { - result = result.concat(items); - } - } - } - } - return result; - } -}; diff --git a/src/helpers/AmfHelperMixin.ts b/src/helpers/AmfHelperMixin.ts new file mode 100644 index 0000000..1653329 --- /dev/null +++ b/src/helpers/AmfHelperMixin.ts @@ -0,0 +1,1700 @@ +/* eslint-disable default-param-last */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable class-methods-use-this */ +/* eslint-disable no-plusplus */ +/* eslint-disable no-continue */ + +/** +@license +Copyright 2018 The Advanced REST client authors +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +*/ +// @ts-ignore +import { AmfModelExpander, JsonLdOptions, JsonLd } from 'amf-json-ld-lib'; +import { dedupeMixin } from '@open-wc/dedupe-mixin'; +import { ns as Namespace } from './Namespace.js'; +import { + AmfDocument, AsyncApi, DomainElement, EndPoint, Operation, Parameter, Payload, Request, Response, + SecurityScheme, Server, Shape, WebApi, Api +} from './amf.js'; +import { ServersQueryOptions } from './api.js'; + +/** @typedef {import('./Namespace').ns} Namespace */ +/** @typedef {import('./amf').DomainElement} DomainElement */ +/** @typedef {import('./amf').AmfDocument} AmfDocument */ +/** @typedef {import('./amf').WebApi} WebApi */ +/** @typedef {import('./amf').AsyncApi} AsyncApi */ +/** @typedef {import('./amf').Server} Server */ +/** @typedef {import('./amf').EndPoint} EndPoint */ +/** @typedef {import('./amf').Operation} Operation */ +/** @typedef {import('./amf').Shape} Shape */ +/** @typedef {import('./amf').Parameter} Parameter */ +/** @typedef {import('./amf').Request} Request */ +/** @typedef {import('./amf').Response} Response */ +/** @typedef {import('./amf').Payload} Payload */ +/** @typedef {import('./amf').SecurityScheme} SecurityScheme */ +/** @typedef {import('./api').ServersQueryOptions} ServersQueryOptions */ +/** @typedef {import('./api').ServerQueryOptions} ServerQueryOptions */ +/** @typedef {import('./api').ComputeUriOptions} ComputeUriOptions */ + +export const expandKey = Symbol('expandKey'); +export const findAmfType = Symbol('findAmfType'); +export const findReferenceObject = Symbol('findReferenceObject'); +export const getArrayItems = Symbol('getArrayItems'); +export const computeReferenceSecurity = Symbol('computeReferenceSecurity'); + +type Constructor = new (...args: any[]) => T; + +/** + * Common functions used by AMF components to compute AMF values. + */ +export interface AmfHelperMixinInterface { + /** + * A namespace for AMF model. + */ + readonly ns: typeof Namespace; + + /** + * Generated AMF json/ld model form the API spec. + * The element assumes the object of the first array item to be a + * type of `"http://raml.org/vocabularies/document#Document` + * on AMF vocabulary. + * + * It is only useful for the element to resolve references. + */ + amf: AmfDocument | undefined; + _amf: AmfDocument | undefined; + + /** + * This is an abstract method to be implemented by the components. + * If, instead, the component uses `amf` setter you must use `super.amf` to + * set the value. + * @param amf Current AMF model. Can be undefined. + */ + __amfChanged(amf: AmfDocument): void + /** + * Expands flattened AMF model + */ + _expand(amf: any): AmfDocument; + + /** + * Returns compact model key for given value. + * + * @param property AMF original property + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Compact model property name or the same value if + * value not found in the context. + */ + _getAmfKey(property: string | undefined, context?: Record): string | undefined; + + /** + * Ensures that the model is AMF object. + * + * @param amf AMF json/ld model + * @returns API spec + */ + _ensureAmfModel(amf: any): AmfDocument | undefined; + + /** + * Ensures that the value is an array. + * It returns undefined when there's no value. + * It returns the same array if the value is already an array. + * It returns new array of the item is not an array. + * + * @param value An item to test + */ + _ensureArray(value: T): T[] | undefined; + + /** + * Ensures that the value is an array. + * It returns undefined when there's no value. + * It returns the same array if the value is already an array. + * It returns new array of the item is not an array. + * + * @param value An item to test + */ + _ensureArray(value: T[]): T[] | undefined; + + /** + * Gets a single scalar value from a model. + * + * @param model Amf model to extract the value from. + * @param key Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Value for key + */ + _getValue(model: DomainElement, key: string, context?: Record): string | number | boolean | undefined | null; + + /** + * Gets values from a model as an array of `@value` properties. + * + * @param model Amf model to extract the value from. + * @param key Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Value for key + */ + _getValueArray(model: DomainElement, key: string, context?: Record): Array | undefined; + + /** + * Reads an array from the model. + * + * @param model Amf model to extract the value from. + * @param key Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Value for the key + */ + [getArrayItems](model: DomainElement, key: string, context?: Record): DomainElement[] | undefined; + + /** + * Reads the value of the `@id` property. + * @param model Amf model to extract the value from. + * @param key Model key to search for the @id + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _getLinkValue(model: DomainElement, key: string, context?: Record): string | undefined; + + /** + * Reads the list of value for the `@id` property. + * @param model Amf model to extract the value from. + * @param key Model key to search for the `@id` + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _getLinkValues(model: DomainElement, key: string, context?: Record): string[] | undefined; + + /** + * Checks if a model has a type. + * + * @param model Model to test + * @param type Type name + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns True if model has a type. + */ + _hasType(model: DomainElement, type: string, context?: Record): boolean | null; + + /** + * Checks if a shape has a property. + * + * @param shape The shape to test + * @param key Property name to test + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _hasProperty(shape: DomainElement, key: string, context?: Record): boolean | null; + + /** + * Computes array value of a property in a model (shape). + * + * @param shape AMF shape object + * @param key Property name + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _computePropertyArray(shape: DomainElement, key: string, context?: Record): Array | undefined; + + /** + * Computes API version from the AMF model. + */ + _computeApiVersion(amf: AmfDocument, context?: Record): string | undefined; + + /** + * Computes model's `encodes` property. + * + * @param model AMF data model + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of encodes + */ + _computeEncodes(model: AmfDocument, context?: Record): Api | undefined; + + /** + * Computes list of declarations in the AMF api model. + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of declarations + */ + _computeDeclares(model: AmfDocument, context?: Record): DomainElement[] | undefined; + + /** + * Computes list of references in the AMF api model. + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of declarations + */ + _computeReferences(model: AmfDocument, context?: Record): DomainElement[] | undefined; + + /** + * Computes AMF's `http://schema.org/WebAPI` model + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Web API declaration. + */ + _computeWebApi(model: AmfDocument, context?: Record): WebApi | undefined; + + /** + * Computes AMF's `http://schema.org/API` model + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @return The API declaration. + */ + _computeApi(model: AmfDocument, context?: Record): AsyncApi | WebApi; + + /** + * Returns whether an AMF node is a WebAPI node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isWebAPI(model: AmfDocument, context?: Record): boolean; + + /** + * Returns whether an AMF node is an AsyncAPI node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isAsyncAPI(model: AmfDocument, context?: Record): boolean; + + /** + * Returns whether an AMF node is an API node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isAPI(model: AmfDocument, context?: Record): boolean; + + /** + * Determines whether a partial model is valid for reading servers from + * Current valid values: + * - Operation + * - Endpoint + * @param model The partial model to evaluate + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Whether the model's type is part of the array of valid node types from which to read servers + */ + _isValidServerPartial(model: any, context?: Record): boolean; + + /** + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of servers for method, if defined, or endpoint, if defined, or root level + */ + _getServers(opts?: ServersQueryOptions, context?: Record): Server[] | undefined; + + /** + * Computes value for the `expects` property. + * + * @param method AMF `supportedOperation` model + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _computeExpects(method: Operation, context?: Record): Request | undefined; + + /** + * Computes list of endpoints from a WebApi model. + * + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Always returns an array of endpoints. + */ + _computeEndpoints(webApi: WebApi, context?: Record): EndPoint[] | undefined; + + /** + * Computes model for an endpoint documentation. + * + * @param webApi Current value of `webApi` property + * @param id Selected shape ID + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns An endpoint definition + */ + _computeEndpointModel(webApi: WebApi, id: string, context?: Record): EndPoint | undefined; + + /** + * Computes method for the method documentation. + * + * @param webApi Current value of `webApi` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A method definition + */ + _computeMethodModel(webApi: WebApi, selected: string, context?: Record): Operation | undefined; + + /** + * Computes an endpoint for a method. + * + * @param webApi The WebApi AMF model + * @param methodId Method id + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns An endpoint model of undefined. + */ + _computeMethodEndpoint(webApi: WebApi, methodId: string, context?: Record): EndPoint | undefined; + + /** + * Computes a list of methods for an endpoint that contains a method with + * given id. + * + * @param webApi WebApi model + * @param methodId Method id. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A list of sibling methods or undefined. + */ + __computeMethodsListForMethod(webApi: WebApi, methodId: string, context?: Record): Operation[] | undefined; + + /** + * Computes a type documentation model. + * + * @param declares Current value of `declares` property + * @param references Current value of `references` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A type definition + */ + _computeType(declares: DomainElement[], references: DomainElement[], selected: string, context?: Record): Shape | undefined; + + /** + * Finds a type in the model declares and references. + * @param domainId The domain id of the type (AMF's shape). + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The AMF shape or undefined when not found. + */ + [findAmfType](domainId?: string, context?: Record): Shape | undefined; + + /** + * Searches for an object in model's references list. + * It does not resolve the object (useful for handling links correctly). + * + * @param domainId The domain of the object to find in the references. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The domain object or undefined. + */ + [findReferenceObject](domainId?: string, context?: Record): DomainElement | undefined; + + /** + * Computes a type model from a reference (library for example). + * + * @param reference AMF model for a reference to extract the data from + * @param selected Node ID to look for + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + _computeReferenceType(reference: DomainElement, selected: string, context?: Record): Shape | undefined; + + /** + * Computes a documentation model. + * + * @param webApi Current value of `webApi` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A method definition + */ + _computeDocument(webApi: WebApi, selected: string, context?: Record): DomainElement | undefined; + + /** + * Resolves a reference to an external fragment. + * + * @param shape A shape to resolve + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Resolved shape. + */ + _resolve(shape: T, context?: Record): T; + _getLinkTarget(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined; + + /** + * Resolves the shape of a given reference. + * + * @param references References object to search in + * @param id Id of the shape to resolve + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Resolved shape for given reference, undefined otherwise + */ + _obtainShapeFromReferences(references: DomainElement[], id: string, context?: Record): DomainElement | undefined; + + /** + * Searches a node with a given ID in an array + * + * @param array Array to search for a given ID + * @param id Id to search for + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Node with the given ID when found, undefined otherwise + */ + _findById(array: DomainElement[], id: string): DomainElement | undefined; + _getReferenceId(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined; + _resolveRecursive(shape: T, context?: Record): T; + + /** + * Merge two shapes together. If the resulting shape has one of the "special merge" keys, + * then the special merge function for that key will be used to match that property + * @param shapeA AMF node + * @param shapeB AMF node + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Merged AMF node + */ + _mergeShapes(shapeA: any, shapeB: any, context?: Record): any; + + /** + * Obtains source map sources value from two shapes and returns the merged result + * If neither shape has a sources node, then an empty object will be returned. + * Result is wrapped in an array as per AMF model standard + * @param AMF node + * @param AMF node + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Empty object or resulting merge, wrapped in an array + */ + _mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record): any[]; + + /** + * Expands the key property from compacted mode to full mode. + * @param value The value to process + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The expanded value. + */ + [expandKey](value: string, context?: Record): string; + /** + * Computes a security model from a reference (library for example). + * @param domainId Domain id of the security requirement to find. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + findSecurityScheme(domainId: string, context?: Record): SecurityScheme | undefined; + + /** + * Computes a security model from a reference (library for example). + * @param reference AMF model for a reference to extract the data from + * @param selected Node ID to look for + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + [computeReferenceSecurity](reference: DomainElement, selected: string, context?: Record): SecurityScheme | undefined; + /** + * Collects domain objects by a domain type. + * @param source The element to search for declare/encoded objects. + * @param type The domain type + * @param context A context to use. If not set, it looks for the context of the passed model + */ + getByType(source: DomainElement, type: string, context?: Record): DomainElement[]; +} + +export const AmfHelperMixin = dedupeMixin(>(superClass: T): Constructor & T => { + class AmfHelperMixinClass extends superClass { + static get properties() { + return { + /** + * Generated AMF json/ld model form the API spec. + * The element assumes the object of the first array item to be a + * type of `"http://raml.org/vocabularies/document#Document` + * on AMF vocabulary. + * + * It is only useful for the element to resolve references. + */ + amf: { type: Object } + }; + } + + /** + * A namespace for AMF model. + */ + get ns(): typeof Namespace { + return Namespace; + } + + get amf() { + return this._amf; + } + + set amf(value) { + const old = this._amf; + if (old === value) { + return; + } + let expanded; + if (!value || AmfModelExpander.isInExpandedForm(value)) { + this._flattenedAmf = undefined; + expanded = value; + } else { + const oldFlattened = this._flattenedAmf; + if (oldFlattened === value) { + return; + } + this._flattenedAmf = value; + expanded = this._expand(value); + } + // Cached keys cannot be static as this element can be using in the sane + // document with different AMF models + this.__cachedKeys = {}; + this._amf = expanded; + this.__amfChanged(expanded); + if (this.requestUpdate) { + this.requestUpdate('amf', old); + } + } + + /** + * This is an abstract method to be implemented by the components. + * If, instead, the component uses `amf` setter you must use `super.amf` to + * set the value. + * @param amf Current AMF model. Can be undefined. + */ + __amfChanged(amf: any) { + // ... + } + + /** + * Expands flattened AMF model + */ + _expand(amf: any) { + AmfModelExpander.preprocessLegacyRootNodeId(amf) + const linkEmbeddingFilter = (key: string) => !key.endsWith("fixPoint") + const rootNode = amf['@context'] ? '' : "amf://id"; + const options = JsonLdOptions.apply() + .withEmbeddedLinks(linkEmbeddingFilter) + .withCompactedIris() + .withExpandedStructure() + .withRootNode(rootNode) + return JsonLd.process(amf, options) + } + + /** + * Returns compact model key for given value. + * @param property AMF original property + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Compact model property name or the same value if + * value not found in the context. + */ + _getAmfKey(property: string, context?: Record): string | undefined { + if (!property) { + return undefined; + } + let { amf } = this; + if (!amf && !context) { + return property; + } + if (Array.isArray(amf)) { + [amf] = amf; + } + if (!this.__cachedKeys) { + this.__cachedKeys = {}; + } + const ctx = (context || amf['@context']) as Record; + if (!ctx || !property) { + return property; + } + const cache = this.__cachedKeys; + if (property in cache) { + return cache[property]; + } + /* eslint-disable-next-line no-param-reassign */ + property = String(property); + const hashIndex = property.indexOf('#'); + const hashProperty = property.substr(0, hashIndex + 1); + const keys = Object.keys(ctx); + for (let i = 0, len = keys.length; i < len; i++) { + const k = keys[i]; + if (ctx[k] === property) { + cache[property] = k; + return k; + } if (hashIndex === -1 && property.indexOf(ctx[k]) === 0) { + const result = property.replace(ctx[k], `${k}:`); + cache[property] = result; + return result; + } if (ctx[k] === hashProperty) { + const result = `${k}:${property.substr(hashIndex + 1)}`; + cache[property] = result; + return result; + } + } + return property; + } + + /** + * Ensures that the model is AMF object. + * + * @param amf AMF json/ld model + * @returns API spec + */ + _ensureAmfModel(amf: any): AmfDocument | undefined { + if (!amf) { + return undefined; + } + if (Array.isArray(amf)) { + /* eslint-disable-next-line no-param-reassign */ + [amf] = amf; + } + if (this._hasType(amf, Namespace.aml.vocabularies.document.Document)) { + return amf; + } + return undefined; + } + + /** + * Ensures that the value is an array. + * It returns undefined when there's no value. + * It returns the same array if the value is already an array. + * It returns new array of the item is not an array. + * + * @param value An item to test + */ + _ensureArray(value: any): unknown { + if (!value) { + return undefined; + } + if (value instanceof Array) { + return value; + } + return [value]; + } + + /** + * Gets a single scalar value from a model. + * @param model Amf model to extract the value from. + * @param inKey Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The value for key + */ + _getValue(model: DomainElement, inKey: string, context?: Record): string | number | boolean | undefined | null { + /* eslint-disable-next-line no-param-reassign */ + const key = this._getAmfKey(inKey, context); + if (!key) { + return undefined; + } + let data = model && (model as any)[key] as any; + if (!data) { + // This includes "undefined", "false", "null" and "0" + return data; + } + if (Array.isArray(data)) { + /* eslint-disable-next-line no-param-reassign */ + [data] = data; + } + if (!data) { + return undefined; + } + const type = typeof data; + if (['string', 'number', 'boolean', 'undefined'].indexOf(type) !== -1) { + return data; + } + return data['@value']; + } + + /** + * Gets values from a model as an array of `@value` properties. + * @param model Amf model to extract the value from. + * @param inKey Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The value for key + */ + _getValueArray(model: DomainElement, inKey: string, context?: Record): Array | undefined { + const key = this._getAmfKey(inKey, context); + if (!key) { + return undefined; + } + const data = model && this._ensureArray((model as any)[key]); + if (!Array.isArray(data)) { + return undefined; + } + return data.map((item) => item['@value'] || item); + } + + /** + * Reads an array from the model. + * + * @param model Amf model to extract the value from. + * @param key Model key to search for the value + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The value for the key + */ + [getArrayItems](model: DomainElement, key: string, context?: Record): DomainElement[] | undefined { + const k = this._getAmfKey(key, context); + if (!k) { + return undefined; + } + const data = model && this._ensureArray((model as any)[k]); + if (!Array.isArray(data)) { + return undefined; + } + return data; + } + + /** + * Reads the value of the `@id` property. + * @param model Amf model to extract the value from. + * @param key Model key to search for the @id + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _getLinkValue(model: DomainElement, key: string, context?: Record): string | undefined { + const k = this._getAmfKey(key, context); + if (!k) { + return undefined; + } + let data = model && (model as any)[k]; + if (!data) { + return undefined; + } + if (Array.isArray(data)) { + [data] = data; + } + if (!data) { + return undefined; + } + return data['@id']; + } + + /** + * Reads the list of value for the `@id` property. + * @param model Amf model to extract the value from. + * @param inKey Model key to search for the @id + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _getLinkValues(model: DomainElement, inKey: string, context?: Record): string[] | undefined { + const k = this._getAmfKey(inKey, context); + if (!k) { + return undefined; + } + let data = (model && (model as any)[k]) as DomainElement[] | undefined; + if (!data) { + return undefined; + } + if (!Array.isArray(data)) { + data = [data]; + } + return data.map(i => i['@id']); + } + + /** + * Checks if a model has a type. + * @param model Model to test + * @param type Type name + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns True if model has a type. + */ + _hasType(model: DomainElement, type: string, context?: Record): boolean { + const types = this._ensureArray(model && model['@type']) as string[]; + if (!types || !types.length) { + return false; + } + const key = this._getAmfKey(type, context); + for (let i = 0; i < types.length; i++) { + if (types[i] === key) { + return true; + } + } + return false; + } + + /** + * Checks if a shape has a property. + * @param shape The shape to test + * @param inKey Property name to test + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _hasProperty(shape: DomainElement, inKey: string, context?: Record): boolean { + const k = this._getAmfKey(inKey, context); + if (!k) { + return false; + } + return !!(shape && k && k in shape); + } + + /** + * Computes array value of a property in a model (shape). + * + * @param shape AMF shape object + * @param inKey Property name + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _computePropertyArray(shape: DomainElement, inKey: string, context?: Record): Array | undefined { + if (!shape) { + return undefined; + } + const k = this._getAmfKey(inKey, context); + if (!k) { + return undefined; + } + const data = this._ensureArray(shape && (shape as any)[k]); + if (!data || !Array.isArray(data)) { + return undefined; + } + return data; + } + + /** + * Computes API version from the AMF model. + * + * @param amf + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns {string} + */ + _computeApiVersion(amf: AmfDocument, context?: Record) { + const api = this._computeApi(amf); + if (!api) { + return undefined; + } + return /** @type string */ (this._getValue(api, this.ns.aml.vocabularies.core.version, context)); + } + + /** + * Computes model's `encodes` property. + * + * @param model AMF data model + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of encodes + */ + _computeEncodes(model: AmfDocument, context?: Record): DomainElement | undefined { + if (!model) { + return undefined; + } + if (Array.isArray(model)) { + /* eslint-disable-next-line no-param-reassign */ + [model] = model; + } + const key = this._getAmfKey(this.ns.aml.vocabularies.document.encodes, context); + if (!key) { + return undefined; + } + const data = (model as any)[key]; + if (data) { + return Array.isArray(data) ? data[0] : data; + } + return undefined; + } + + /** + * Computes list of declarations in the AMF api model. + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of declarations + */ + _computeDeclares(model: AmfDocument, context?: Record): DomainElement[] | undefined { + if (!model) { + return undefined; + } + if (Array.isArray(model)) { + /* eslint-disable-next-line no-param-reassign */ + [model] = model; + } + if (!model) { + return undefined; + } + const key = this._getAmfKey(this.ns.aml.vocabularies.document.declares, context); + if (!key) { + return undefined; + } + const data = this._ensureArray((model as any)[key]); + return Array.isArray(data) ? data : undefined; + } + + /** + * Computes list of references in the AMF api model. + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of declarations + */ + _computeReferences(model: AmfDocument, context?: Record): DomainElement[] | undefined { + if (!model) { + return undefined; + } + if (Array.isArray(model)) { + /* eslint-disable-next-line no-param-reassign */ + [model] = model; + } + if (!model) { + return undefined; + } + const key = this._getAmfKey(this.ns.aml.vocabularies.document.references, context); + if (!key) { + return undefined; + } + const data = this._ensureArray((model as any)[key]) as DomainElement[] | undefined; + return data instanceof Array ? data : undefined; + } + + /** + * Computes AMF's `http://schema.org/WebAPI` model + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Web API declaration. + */ + _computeWebApi(model: AmfDocument, context?: Record): WebApi | undefined { + const enc = this._computeEncodes(model, context); + if (!enc) { + return undefined; + } + if (this._hasType(enc, this.ns.aml.vocabularies.apiContract.WebAPI, context)) { + return enc; + } + return undefined; + } + + /** + * Computes AMF's `http://schema.org/API` model + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns API declaration. + */ + _computeApi(model: AmfDocument, context?: Record): AsyncApi | WebApi | undefined { + const enc = this._computeEncodes(model, context); + if (!enc) { + return undefined; + } + if (this._isAPI(model, context) || this._isWebAPI(model, context) || this._isAsyncAPI(model, context)) { + return enc; + } + return undefined; + } + + /** + * Returns whether an AMF node is a WebAPI node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isWebAPI(model: AmfDocument, context?: Record): boolean { + const enc = this._computeEncodes(model, context); + if (!enc) { + return false; + } + return this._hasType(enc, this.ns.aml.vocabularies.apiContract.WebAPI, context); + } + + /** + * Returns whether an AMF node is an AsyncAPI node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isAsyncAPI(model: AmfDocument, context?: Record): boolean { + const enc = this._computeEncodes(model, context); + if (!enc) { + return false; + } + return this._hasType(enc, this.ns.aml.vocabularies.apiContract.AsyncAPI, context); + } + + /** + * Returns whether an AMF node is an API node + * + * @param model AMF json/ld model for an API + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _isAPI(model: AmfDocument, context?: Record): boolean { + const enc = this._computeEncodes(model, context); + if (!enc) { + return false; + } + return this._hasType(enc, this.ns.aml.vocabularies.apiContract.API, context); + } + + /** + * Determines whether a partial model is valid for reading servers from + * Current valid values: + * - Operation + * - Endpoint + * @param model The partial model to evaluate + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Whether the model's type is part of the array of valid node types from which + * to read servers + */ + _isValidServerPartial(model: DomainElement, context?: Record): boolean { + if (Array.isArray(model)) { + /* eslint-disable-next-line no-param-reassign */ + [model] = model; + } + if (!model) { + return false; + } + const oKey = this.ns.aml.vocabularies.apiContract.Operation; + const eKey = this.ns.aml.vocabularies.apiContract.EndPoint; + const allowedPartialModelTypes = [this._getAmfKey(oKey, context), this._getAmfKey(eKey, context)]; + const types = model['@type']; + for (const type of types) { + if (allowedPartialModelTypes.indexOf(type) !== -1) { + return true; + } + } + return false; + } + + /** + * @param options Server query options + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns List of servers for method, if defined, or endpoint, if defined, or root level + */ + _getServers(options: ServersQueryOptions = {}, context?: Record): Server[] | undefined { + const { endpointId, methodId } = options; + const { amf } = this; + if (!amf) { + return undefined; + } + let api = this._computeApi(amf, context); + if (Array.isArray(api)) { + [api] = api; + } + if (!api) { + if (this._isValidServerPartial(amf, context)) { + api = amf; + } else { + return undefined; + } + } + + const serverKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.server, context) as string; + const getRootServers = () => (this[getArrayItems](api as DomainElement, serverKey, context)) as Server[]; + const getEndpointServers = () => { + const endpoint = this._computeEndpointModel(api as WebApi, endpointId, context); + const servers = (this[getArrayItems](endpoint as EndPoint, serverKey, context)) as Server[]; + if (servers) { + return servers; + } + return getRootServers(); + }; + const getMethodServers = () => { + const method = this._computeMethodModel(api as WebApi, methodId as string, context); + const servers = (this[getArrayItems](method as Operation, serverKey, context)) as Server[]; + if (servers) { + return servers; + } + return getEndpointServers(); + }; + + if (methodId) { + return getMethodServers(); + } if (endpointId) { + return getEndpointServers(); + } + return getRootServers(); + } + + /** + * Computes value for the `expects` property. + * + * @param method AMF `supportedOperation` model + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _computeExpects(method: Operation, context?: Record): Request | undefined { + const operationKey = this.ns.aml.vocabularies.apiContract.Operation; + const expectsKey = this.ns.aml.vocabularies.apiContract.expects; + if (this._hasType(method, operationKey, context)) { + const key = this._getAmfKey(expectsKey, context); + if (!key) { + return undefined; + } + const expects = this._ensureArray((method as any)[key]); + if (expects) { + return Array.isArray(expects) ? expects[0] : expects; + } + } + return undefined; + } + + /** + * Computes list of endpoints from a WebApi model. + * @param webApi + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns An array of endpoints. + */ + _computeEndpoints(webApi: WebApi, context?: Record): EndPoint[] | undefined { + if (!webApi) { + return []; + } + const endpointKey = this.ns.aml.vocabularies.apiContract.endpoint; + const key = this._getAmfKey(endpointKey, context); + if (!key) { + return undefined; + } + return this._ensureArray((webApi as any)[key]) as EndPoint[]; + } + + /** + * Computes model for an endpoint documentation. + * + * @param webApi Current value of `webApi` property + * @param id Selected shape ID + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns An endpoint definition + */ + _computeEndpointModel(webApi: WebApi, id?: string, context?: Record): EndPoint | undefined { + if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { + return webApi; + } + const endpoints = this._computeEndpoints(webApi, context); + if (!endpoints) { + return undefined; + } + return endpoints.find((item) => item['@id'] === id); + } + + /** + * Computes method for the method documentation. + * + * @param webApi Current value of `webApi` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A method definition + */ + _computeMethodModel(webApi: WebApi, selected: string, context?: Record): Operation | undefined { + const methods = this.__computeMethodsListForMethod(webApi, selected, context); + if (!methods) { + return undefined; + } + return methods.find((item) => item['@id'] === selected); + } + + /** + * Computes an endpoint for a method. + * @param webApi The WebApi AMF model + * @param methodId Method id + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns An endpoint model of undefined. + */ + _computeMethodEndpoint(webApi: WebApi, methodId: string, context?: Record): EndPoint | undefined { + if (!webApi || !methodId) { + return undefined; + } + if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { + return webApi; + } + const endpoints = this._computeEndpoints(webApi, context); + if (!endpoints) { + return undefined; + } + const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context) as string; + for (let i = 0, len = endpoints.length; i < len; i++) { + const endpoint = endpoints[i]; + let methods = (endpoint as any)[opKey] as Operation[] | undefined; + if (!methods) { + continue; + } + if (!Array.isArray(methods)) { + methods = [methods]; + } + for (let j = 0, jLen = methods.length; j < jLen; j++) { + if (methods[j]['@id'] === methodId) { + return endpoint; + } + } + } + return undefined; + } + + /** + * Computes a list of methods for an endpoint that contains a method with + * given id. + * + * @param webApi WebApi model + * @param methodId Method id. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A list of sibling methods or undefined. + */ + __computeMethodsListForMethod(webApi: WebApi, methodId: string, context?: Record): Operation[] | undefined { + const endpoint = this._computeMethodEndpoint(webApi, methodId, context); + if (!endpoint) { + return undefined; + } + const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context); + if (!opKey) { + return undefined; + } + return this._ensureArray((endpoint as any)[opKey]) as Operation[]; + } + + /** + * Computes a type documentation model. + * + * @param declares Current value of `declares` property + * @param references Current value of `references` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns A type definition + */ + _computeType(declares: DomainElement[], references: DomainElement[], selected: string, context?: Record): Shape | undefined { + if ((!declares && !references) || !selected) { + return undefined; + } + // In compact model some IDs are presented in long version (in source maps for examples) + // This must test for this case as well. + const compactId = selected.replace('amf://id', ''); + let type = declares && declares.find((item) => item['@id'] === selected || item['@id'] === compactId); + if (!type && references && references.length) { + for (let i = 0, len = references.length; i < len; i++) { + if (!this._hasType(references[i], this.ns.aml.vocabularies.document.Module)) { + continue; + } + type = this._computeReferenceType(references[i], selected, context); + if (type) { + break; + } + } + } + return type; + } + + /** + * Finds a type in the model declares and references. + * @param domainId The domain id of the type (AMF's shape). + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The AMF shape or undefined when not found. + */ + [findAmfType](domainId: string, context?: Record): Shape | undefined { + let { amf } = this; + if (!amf) { + return undefined; + } + if (Array.isArray(amf)) { + [amf] = amf; + } + const declares = this._computeDeclares(amf, context); + const compactId = domainId.replace('amf://id', ''); + if (Array.isArray(declares)) { + const result = declares.find((item) => item['@id'] === domainId || item['@id'] === compactId); + if (result) { + return result; + } + } + return this[findReferenceObject](domainId); + } + + /** + * Searches for an object in model's references list. + * It does not resolve the object (useful for handling links correctly). + * + * @param domainId The domain of the object to find in the references. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The domain object or undefined. + */ + [findReferenceObject](domainId: string, context?: Record): DomainElement | undefined { + let { amf } = this; + if (!amf) { + return undefined; + } + if (Array.isArray(amf)) { + [amf] = amf; + } + const references = this._computeReferences(amf, context); + if (!Array.isArray(references) || !references.length) { + return undefined; + } + const compactId = domainId.replace('amf://id', ''); + for (let i = 0, len = references.length; i < len; i++) { + const ref = /** @type AmfDocument */ (references[i]); + const declares = this._computeDeclares(ref, context); + if (!Array.isArray(declares)) { + continue; + } + for (let j = 0, lenDecl = declares.length; j < lenDecl; j++) { + let declared = declares[j]; + if (Array.isArray(declared)) { + [declared] = declared; + } + if (declared['@id'] === domainId || declared['@id'] === compactId) { + return declared; + } + } + } + return undefined; + } + + /** + * Computes a type model from a reference (library for example). + * @param reference AMF model for a reference to extract the data from + * @param selected Node ID to look for + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + _computeReferenceType(reference: DomainElement, selected: string, context?: Record): Shape | undefined { + const declare = this._computeDeclares(reference, context); + if (!declare) { + return undefined; + } + // In compact model some IDs are presented in long version (in source maps for examples) + // This must test for this case as well. + const compactId = selected.replace('amf://id', ''); + let result = declare.find((item) => { + if (Array.isArray(item)) { + /* eslint-disable-next-line no-param-reassign */ + [item] = item; + } + return item['@id'] === selected || item['@id'] === compactId; + }); + if (Array.isArray(result)) { + [result] = result; + } + return this._resolve(result as Shape); + } + + /** + * Computes a documentation model. + * + * @param webApi Current value of `webApi` property + * @param selected Selected shape + * @param context A context to use. If not set, it looks for the context of the passed model + */ + _computeDocument(webApi: WebApi, selected: string, context?: Record): DomainElement | undefined { + if (!webApi || !selected) { + return undefined; + } + const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation, context) as string; + const docs = this._ensureArray((webApi as any)[key]) as DomainElement[]; + return docs && docs.find((item) => item['@id'] === selected); + } + + /** + * Resolves a reference to an external fragment. + * + * @param shape A shape to resolve + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Resolved shape. + */ + _resolve

(shape: P & { __apicResolved?: boolean }, context?: Record): P { + const { amf } = this; + if (!shape || typeof shape !== 'object' || Array.isArray(shape) || !amf || shape.__apicResolved) { + return shape; + } + let refKey = this._getAmfKey(this.ns.aml.vocabularies.document.linkTarget, context) as string; + let refValue = this._ensureArray((shape as any)[refKey]) as any[]; + let refData; + if (refValue) { + const rk = refValue[0]['@id']; + if (rk === (shape as any)['@id']) { + // recursive shape. + /* eslint-disable-next-line no-param-reassign */ + shape.__apicResolved = true; + return shape; + } + refData = this._getLinkTarget(amf, rk, context); + } else { + refKey = this._getAmfKey(this.ns.aml.vocabularies.document.referenceId, context) as string; + refValue = this._ensureArray((shape as any)[refKey]) as any[]; + if (refValue) { + const rk = refValue[0]['@id']; + if (rk === (shape as any)['@id']) { + // recursive shape. + /* eslint-disable-next-line no-param-reassign */ + shape.__apicResolved = true; + return shape; + } + refData = this._getReferenceId(amf, rk, context); + } + } + if (!refData) { + this._resolveRecursive(shape); + /* eslint-disable-next-line no-param-reassign */ + shape.__apicResolved = true; + return shape; + } + const copy = { ...refData }; + delete (copy as any)['@id']; + const types = copy['@type']; + if (types) { + if ((shape as any)['@type']) { + /* eslint-disable-next-line no-param-reassign */ + (shape as any)['@type'] = (shape as any)['@type'].concat(types); + } else { + /* eslint-disable-next-line no-param-reassign */ + (shape as any)['@type'] = types; + } + delete (copy as any)['@type']; + } + this._mergeShapes(shape, copy, context); + /* eslint-disable-next-line no-param-reassign */ + shape.__apicResolved = true; + this._resolveRecursive(shape); + return shape; + } + + /** + * @param amf References object to search in + * @param id Id of the shape to resolve + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Resolved shape for given reference, undefined otherwise + */ + _getLinkTarget(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined { + if (!amf || !id) { + return undefined; + } + let target; + const declares = this._computeDeclares(amf, context); + if (declares) { + target = this._findById(declares, id); + } + if (!target) { + const references = this._computeReferences(amf, context); + target = this._obtainShapeFromReferences(references as DomainElement[], id, context); + } + if (!target) { + return undefined; + } + // Declaration may contain references + target = this._resolve(target); + return target; + } + + /** + * Resolves the shape of a given reference. + * + * @param references References object to search in + * @param id Id of the shape to resolve + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Resolved shape for given reference, undefined otherwise + */ + _obtainShapeFromReferences(references: DomainElement[], id: string, context?: Record): DomainElement | undefined { + if (!Array.isArray(references) || !references.length) { + return undefined; + } + let target; + for (let i = 0; i < references.length; i++) { + const _ref = references[i]; + // case of fragment that encodes the shape + const encoded = this._computeEncodes(_ref, context); + if (encoded && encoded['@id'] === id) { + target = encoded; + break; + } + // case of a library which declares types + if (!encoded) { + const decl = this._computeDeclares(_ref, context) as DomainElement[]; + target = this._findById(decl, id); + if (target) break; + } + } + return target; + } + + /** + * Searches a node with a given ID in an array + * + * @param array Array to search for a given ID + * @param id Id to search for + * @returns Node with the given ID when found, undefined otherwise + */ + _findById(array: DomainElement[], id: string): DomainElement | undefined { + if (!array) return undefined; + let target; + for (let i = 0; i < array.length; i++) { + const _current = array[i]; + if (_current && _current['@id'] === id) { + target = _current; + break; + } + } + return target; + } + + _getReferenceId(amf: AmfDocument, id: string, context?: Record) { + if (!amf || !id) { + return undefined; + } + const refs = this._computeReferences(amf, context); + if (!refs) { + return undefined; + } + for (let i = 0; i < refs.length; i++) { + const _ref = refs[i]; + const enc = this._computeEncodes(_ref, context); + if (enc) { + if (enc['@id'] === id) { + return enc; + } + } + } + return undefined; + } + + _resolveRecursive(shape: any, context?: Record): void { + Object.keys(shape).forEach((key) => { + const currentShape = shape[key]; + if (Array.isArray(currentShape)) { + for (let i = 0, len = currentShape.length; i < len; i++) { + currentShape[i] = this._resolve(currentShape[i]); + } + } else if (typeof currentShape === 'object') { + /* eslint-disable-next-line no-param-reassign */ + shape[key] = this._resolve(currentShape, context); + } + }); + } + + /** + * Merge two shapes together. If the resulting shape has one of the "special merge" keys, + * then the special merge function for that key will be used to match that property + * @param shapeA AMF node + * @param shapeB AMF node + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Merged AMF node + */ + _mergeShapes(shapeA: any, shapeB: any, context?: Record): any { + const merged = { ...shapeA, ...shapeB }; + const specialMerges = [ + { + key: this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context) as string, + merger: this._mergeSourceMapsSources.bind(this) + }, + ]; + specialMerges.forEach(({ key, merger }) => { + if (this._hasProperty(merged, key, context)) { + merged[key] = merger(shapeA, shapeB, context); + } + }); + return Object.assign(shapeA, merged); + } + + /** + * Obtains source map sources value from two shapes and returns the merged result + * If neither shape has a sources node, then an empty object will be returned. + * Result is wrapped in an array as per AMF model standard + * @param shapeA AMF node + * @param shapeB AMF node + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Empty object or resulting merge, wrapped in an array + */ + _mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record): (any | {})[] { + const sourcesKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context) as string; + let aSources = shapeA[sourcesKey] || {}; + if (Array.isArray(aSources)) { + /* eslint-disable prefer-destructuring */ + aSources = aSources[0]; + } + let bSources = shapeB[sourcesKey] || {}; + if (Array.isArray(bSources)) { + /* eslint-disable prefer-destructuring */ + bSources = bSources[0]; + } + return [Object.assign(aSources, bSources)]; + } + + /** + * Expands the key property from compacted mode to full mode. + * @param value The value to process + * @param context + * @returns The expanded value. + */ + [expandKey](value: string, context?: Record): string { + let { amf } = this; + if (!value || typeof value !== 'string' || (!amf && !context)) { + return value; + } + if (Array.isArray(amf)) { + [amf] = amf; + } + const ctx = context || amf['@context']; + if (!ctx) { + return value; + } + const [root, key] = value.split(':'); + if (!root || !key) { + return value; + } + const prefix = ctx[root]; + if (!prefix) { + return value; + } + return `${prefix}${key}`; + } + + /** + * Computes a security model from a reference (library for example). + * @param domainId Domain id of the security requirement to find. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + findSecurityScheme(domainId: string, context?: Record): SecurityScheme | undefined { + const { amf } = this; + const declares = this._computeDeclares(amf, context); + let result; + if (declares) { + result = declares.find((item) => item['@id'] === domainId); + } + if (result) { + result = this._resolve(result); + return result; + } + const references = this._computeReferences(amf, context); + if (Array.isArray(references) && references.length) { + for (const ref of references) { + if (this._hasType(ref, this.ns.aml.vocabularies.document.Module, context)) { + result = this[computeReferenceSecurity](ref, domainId, context); + if (result) { + result = this._resolve(result); + return result; + } + } + } + } + return undefined; + } + + /** + * Computes a security model from a reference (library for example). + * @param reference AMF model for a reference to extract the data from + * @param selected Node ID to look for + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Type definition or undefined if not found. + */ + [computeReferenceSecurity](reference: DomainElement, selected: string, context?: Record): SecurityScheme | undefined { + const declare = this._computeDeclares(reference, context); + if (!declare) { + return undefined; + } + let result = declare.find((item) => { + let declared = item; + if (Array.isArray(declared)) { + [declared] = declared; + } + return declared['@id'] === selected; + }); + if (Array.isArray(result)) { + [result] = result; + } + return this._resolve(result as DomainElement) as SecurityScheme; + } + + /** + * Collects domain objects by a domain type. + * @param source The element to search for declare/encoded objects. + * @param type The domain type + * @param context A context to use. If not set, it looks for the context of the passed model + */ + getByType(source: DomainElement, type: string, context?: Record): DomainElement[] { + if (!source) { + return []; + } + let result: DomainElement[] = []; + const declares = this._computeDeclares(source); + const key = this._getAmfKey(type, context); + if (!key) { + return []; + } + if (declares && declares.length) { + declares.forEach((declared) => { + if (this._hasType(declared, key)) { + result.push(declared); + } + }); + } + const references = this._computeReferences(source); + if (Array.isArray(references) && references.length) { + for (const ref of references) { + if (this._hasType(ref, this.ns.aml.vocabularies.document.Module)) { + const items = this.getByType(ref, type, context); + if (items.length) { + result = result.concat(items); + } + } + } + } + return result; + } + } + return AmfHelperMixinClass as Constructor & T; +}); diff --git a/src/helpers/AmfSerializer.d.ts b/src/helpers/AmfSerializer.d.ts deleted file mode 100644 index acd85a5..0000000 --- a/src/helpers/AmfSerializer.d.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { AmfHelperMixin } from "./AmfHelperMixin.js"; -import { - AnyShape, ApiKeySettings, ArrayNode, ArrayShape, Callback, CreativeWork, DataArrangeShape, - DataNode, DocumentSourceMaps, DomainElement, EndPoint, Example, FileShape, HttpSettings, - IriTemplateMapping, NodeShape, OAuth1Settings, OAuth2Flow, OAuth2Settings, ObjectNode, - OpenIdConnectSettings, Operation, Parameter, ParametrizedSecurityScheme, Payload, - PropertyShape, RecursiveShape, Request, Response, ScalarNode, ScalarShape, SchemaShape, - Scope, SecurityRequirement, SecurityScheme, Server, Settings, Shape, SynthesizedField, - Tag, TemplatedLink, TupleShape, UnionShape, Api, WebApi, AsyncApi, Organization, License, - ParametrizedDeclaration, ParametrizedTrait, ParametrizedResourceType, VariableValue, AbstractDeclaration, -} from "./amf"; -import { - ApiAnyShape, ApiArrayNode, ApiArrayShape, ApiCallback, ApiCustomDomainProperty, ApiDataArrangeShape, - ApiDataNode, ApiDataNodeUnion, ApiDocumentation, ApiDocumentSourceMaps, ApiEndPoint, ApiExample, - ApiFileShape, ApiIriTemplateMapping, ApiNodeShape, ApiObjectNode, ApiOperation, ApiParameter, - ApiParametrizedSecurityScheme, ApiPayload, ApiPropertyShape, ApiRecursiveShape, ApiRequest, ApiResponse, - ApiScalarNode, ApiScalarShape, ApiSchemaShape, ApiSecurityApiKeySettings, ApiSecurityHttpSettings, - ApiSecurityOAuth1Settings, ApiSecurityOAuth2Flow, ApiSecurityOAuth2Settings, - ApiSecurityOpenIdConnectSettings, ApiSecurityRequirement, ApiSecurityScheme, ApiSecurityScope, - ApiSecuritySettings, ApiSecuritySettingsUnion, ApiServer, ApiShape, ApiShapeUnion, ApiSynthesizedField, - ApiTag, ApiTupleShape, ApiUnionShape, ApiXMLSerializer, ApiOrganization, ApiSummary, ApiBase, - ApiWeb, ApiAsync, ApiLicense, ApiParametrizedDeclaration, ApiParametrizedTrait, ApiParametrizedResourceType, - ApiVariableValue, ApiAbstractDeclaration, ShapeProcessingOptions, -} from "./api"; -import { - ApiEndPointWithOperationsListItem, - ApiOperationListItem, - ApiSecuritySchemeListItem, -} from '../types' - -/** - * A class that takes AMF's ld+json model and outputs JavaScript interface of it. - */ -export declare class AmfSerializer extends AmfHelperMixin(Object) { - /** - * @param graph Optional AMF generated graph model. - */ - constructor(graph?: DomainElement); - /** - * @param types THe list of graph object types. When not defined it returns an empty array. - * @returns The expanded types. - */ - readTypes(types: string[]): string[]; - /** - * @param object The API to serialize. - * @returns API summary, without complex objects. - */ - apiSummary(object: Api, context?: Record): ApiSummary; - api(object: Api, context?: Record): ApiBase; - webApi(object: WebApi, context?: Record): ApiWeb; - asyncApi(object: AsyncApi, context?: Record): ApiAsync; - provider(object: Organization, context?: Record): ApiOrganization; - license(object: License, context?: Record): ApiLicense; - - /** - * @param object The AMF Server to serialize. - * @returns Serialized Server - */ - server(object: Server, context?: Record): ApiServer; - - /** - * @param object The Parameter to serialize. - * @returns Serialized Parameter - */ - parameter(object: Parameter, context?: Record): ApiParameter; - unknownShape(object: Shape, options?: ShapeProcessingOptions, context?: Record): ApiShapeUnion; - isLink(object: DomainElement, context?: Record): boolean; - shape(object: Shape, context?: Record): ApiShape; - anyShape(object: AnyShape, options?: ShapeProcessingOptions, context?: Record): ApiAnyShape; - /** - * Filters examples that should be rendered for a payload identified by `trackedId`. - * - * This function is copied from old `api-example-generator/ExampleGenerator`. - */ - filterTrackedExamples(examples: Example[], trackedId: string, context?: Record): Example[]; - /** - * Kind of the opposite of the `filterTrackedExamples`. It gathers examples that only have been - * defined for the parent Shape (ed in the type declaration). It filters out all examples - * defined in a payload. - */ - filterNonTrackedExamples(examples: Example[], context?: Record): Example[]; - scalarShape(object: ScalarShape, options?: ShapeProcessingOptions, context?: Record): ApiScalarShape; - /** - * @param object The NodeShape to serialize - */ - nodeShape(object: NodeShape, options?: ShapeProcessingOptions, context?: Record): ApiNodeShape; - propertyShape(object: PropertyShape, context?: Record): ApiPropertyShape; - unionShape(object: UnionShape, options?: ShapeProcessingOptions, context?: Record): ApiUnionShape; - fileShape(object: FileShape, options?: ShapeProcessingOptions, context?: Record): ApiFileShape; - schemaShape(object: SchemaShape, options?: ShapeProcessingOptions, context?: Record): ApiSchemaShape; - recursiveShape(object: RecursiveShape, context?: Record): ApiRecursiveShape; - dataArrangeShape(object: DataArrangeShape, options?: ShapeProcessingOptions, context?: Record): ApiDataArrangeShape; - arrayShape(object: ArrayShape, options?: ShapeProcessingOptions, context?: Record): ApiArrayShape; - tupleShape(object: TupleShape, options?: ShapeProcessingOptions, context?: Record): ApiTupleShape; - /** - * @param object The CreativeWork to serialize. - * @returns Serialized CreativeWork - */ - documentation(object: CreativeWork, context?: Record): ApiDocumentation; - /** - * @param object The Example to serialize. - * @returns Serialized Example - */ - example(object: Example, context?: Record): ApiExample; - xmlSerializer(object: XMLSerializer, context?: Record): ApiXMLSerializer; - unknownDataNode(object: DataNode, context?: Record): ApiDataNodeUnion; - dataNode(object: DataNode, context?: Record): ApiDataNode; - scalarNode(object: ScalarNode, context?: Record): ApiScalarNode; - objectNode(object: ObjectNode, context?: Record): ApiObjectNode; - arrayNode(object: ArrayNode, context?: Record): ApiArrayNode; - - /** - * Adds the custom domain properties to the currently processed property, a.k.a annotations. - * @param object - * @returns The list of custom domain properties. - */ - customDomainProperties(object: DomainElement, context?: Record): ApiCustomDomainProperty[]; - - /** - * @param object The EndPoint to serialize. - * @returns Serialized EndPoint - */ - endPoint(object: EndPoint, context?: Record): ApiEndPoint; - - /** - * @param object The Operation to serialize. - * @returns Serialized Operation - */ - operation(object: Operation, context?: Record): ApiOperation; - tag(object: Tag, context?: Record): ApiTag; - callback(object: Callback, context?: Record): ApiCallback; - - /** - * @param object The API request to serialize. - * @returns Serialized API request - */ - request(object: Request, context?: Record): ApiRequest; - - /** - * @param object The Response to serialize. - * @returns Serialized Response - */ - response(object: Response, context?: Record): ApiResponse; - - /** - * @param object The Payload to serialize. - * @returns Serialized Payload - */ - payload(object: Payload, context?: Record): ApiPayload; - - /** - * @param object The TemplatedLink to serialize. - * @returns Serialized TemplatedLink - */ - templatedLink(object: TemplatedLink, context?: Record): TemplatedLink; - iriTemplateMapping(object: IriTemplateMapping, context?: Record): ApiIriTemplateMapping; - - /** - * @param object The ParametrizedSecurityScheme to serialize. - * @returns Serialized ParametrizedSecurityScheme - */ - parametrizedSecurityScheme(object: ParametrizedSecurityScheme, context?: Record): ApiParametrizedSecurityScheme; - /** - * @param object The SecurityScheme to serialize as a list item. - * @returns Serialized SecurityScheme - */ - securitySchemeListItem(object: SecurityScheme, context?: Record): ApiSecuritySchemeListItem; - /** - * @param object The SecurityScheme to serialize. - * @returns Serialized SecurityScheme - */ - securityScheme(object: SecurityScheme, context?: Record): ApiSecurityScheme; - - /** - * @param object The SecurityRequirement to serialize. - * @returns Serialized SecurityRequirement - */ - securityRequirement(object: SecurityRequirement, context?: Record): ApiSecurityRequirement; - securitySettings(object: Settings, context?: Record): ApiSecuritySettingsUnion; - settings(object: Settings, context?: Record): ApiSecuritySettings; - oAuth1Settings(object: OAuth1Settings, context?: Record): ApiSecurityOAuth1Settings; - oAuth2Settings(object: OAuth2Settings, context?: Record): ApiSecurityOAuth2Settings; - oAuth2Flow(object: OAuth2Flow, context?: Record): ApiSecurityOAuth2Flow; - scope(object: Scope, context?: Record): ApiSecurityScope; - apiKeySettings(object: ApiKeySettings, context?: Record): ApiSecurityApiKeySettings; - httpSettings(object: HttpSettings, context?: Record): ApiSecurityHttpSettings; - openIdConnectSettings(object: OpenIdConnectSettings, context?: Record): ApiSecurityOpenIdConnectSettings; - /** - * Serializes source maps, when available. - */ - sourceMap(object: DocumentSourceMaps, context?: Record): ApiDocumentSourceMaps | undefined; - synthesizedField(object: SynthesizedField, context?: Record): ApiSynthesizedField; - parametrizedDeclaration(object: ParametrizedDeclaration, context?: Record): ApiParametrizedDeclaration; - parametrizedTrait(object: ParametrizedTrait, context?: Record): ApiParametrizedTrait; - parametrizedResourceType(object: ParametrizedResourceType, context?: Record): ApiParametrizedResourceType; - variableValue(object: VariableValue, context?: Record): ApiVariableValue; - abstractDeclaration(object: AbstractDeclaration, context?: Record): ApiAbstractDeclaration; - - /** - * @param object The EndPoint to serialize as a list item. - * @returns Serialized EndPoint as a list item. - */ - endPointWithOperationsListItem(object: EndPoint, context?: Record): ApiEndPointWithOperationsListItem; - - /** - * @param object The Operation to serialize as a list item. - * @returns Serialized Operation as a list item. - */ - operationListItem(object: Operation, context?: Record): ApiOperationListItem; -} diff --git a/src/helpers/AmfSerializer.js b/src/helpers/AmfSerializer.ts similarity index 64% rename from src/helpers/AmfSerializer.js rename to src/helpers/AmfSerializer.ts index 0b12106..8afc5ca 100644 --- a/src/helpers/AmfSerializer.js +++ b/src/helpers/AmfSerializer.ts @@ -1,132 +1,46 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable default-param-last */ /* eslint-disable class-methods-use-this */ import { AmfHelperMixin, expandKey, findAmfType, getArrayItems } from "./AmfHelperMixin.js"; -/** @typedef {import('./api').ApiParametrizedSecurityScheme} ApiParametrizedSecurityScheme */ -/** @typedef {import('./api').ApiRequest} ApiRequest */ -/** @typedef {import('./api').ApiSecurityScheme} ApiSecurityScheme */ -/** @typedef {import('./api').ApiSecurityRequirement} ApiSecurityRequirement */ -/** @typedef {import('./api').ApiTemplatedLink} ApiTemplatedLink */ -/** @typedef {import('./api').ApiResponse} ApiResponse */ -/** @typedef {import('./api').ApiPayload} ApiPayload */ -/** @typedef {import('./api').ApiExample} ApiExample */ -/** @typedef {import('./api').ApiParameter} ApiParameter */ -/** @typedef {import('./api').ApiOperation} ApiOperation */ -/** @typedef {import('./api').ApiEndPoint} ApiEndPoint */ -/** @typedef {import('./api').ApiServer} ApiServer */ -/** @typedef {import('./api').ApiDocumentation} ApiDocumentation */ -/** @typedef {import('./api').ApiShape} ApiShape */ -/** @typedef {import('./api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('./api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('./api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('./api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('./api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('./api').ApiFileShape} ApiFileShape */ -/** @typedef {import('./api').ApiDataArrangeShape} ApiDataArrangeShape */ -/** @typedef {import('./api').ApiXMLSerializer} ApiXMLSerializer */ -/** @typedef {import('./api').ApiDataNode} ApiDataNode */ -/** @typedef {import('./api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('./api').ApiObjectNode} ApiObjectNode */ -/** @typedef {import('./api').ApiArrayNode} ApiArrayNode */ -/** @typedef {import('./api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('./api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('./api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('./api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('./api').ApiSecuritySettings} ApiSecuritySettings */ -/** @typedef {import('./api').ApiSecurityOAuth1Settings} ApiSecurityOAuth1Settings */ -/** @typedef {import('./api').ApiSecurityOAuth2Settings} ApiSecurityOAuth2Settings */ -/** @typedef {import('./api').ApiSecurityApiKeySettings} ApiSecurityApiKeySettings */ -/** @typedef {import('./api').ApiSecurityHttpSettings} ApiSecurityHttpSettings */ -/** @typedef {import('./api').ApiSecurityOpenIdConnectSettings} ApiSecurityOpenIdConnectSettings */ -/** @typedef {import('./api').ApiSecurityOAuth2Flow} ApiSecurityOAuth2Flow */ -/** @typedef {import('./api').ApiSecuritySettingsUnion} ApiSecuritySettingsUnion */ -/** @typedef {import('./api').ApiSecurityScope} ApiSecurityScope */ -/** @typedef {import('./api').ApiIriTemplateMapping} ApiIriTemplateMapping */ -/** @typedef {import('./api').ApiCallback} ApiCallback */ -/** @typedef {import('./api').ApiDomainProperty} ApiDomainProperty */ -/** @typedef {import('./api').ApiCustomDomainProperty} ApiCustomDomainProperty */ -/** @typedef {import('./api').ApiRecursiveShape} ApiRecursiveShape */ -/** @typedef {import('./api').ApiTag} ApiTag */ -/** @typedef {import('./api').ApiDataNodeUnion} ApiDataNodeUnion */ -/** @typedef {import('./api').ApiDocumentSourceMaps} ApiDocumentSourceMaps */ -/** @typedef {import('./api').ApiSynthesizedField} ApiSynthesizedField */ -/** @typedef {import('./api').ApiParametrizedDeclaration} ApiParametrizedDeclaration */ -/** @typedef {import('./api').ApiParametrizedTrait} ApiParametrizedTrait */ -/** @typedef {import('./api').ApiParametrizedResourceType} ApiParametrizedResourceType */ -/** @typedef {import('./api').ApiVariableValue} ApiVariableValue */ -/** @typedef {import('./api').ApiAbstractDeclaration} ApiAbstractDeclaration */ -/** @typedef {import('./api').ShapeProcessingOptions} ShapeProcessingOptions */ -/** @typedef {import('./api').ApiSummary} ApiSummary */ -/** @typedef {import('./api').ApiOrganization} ApiOrganization */ -/** @typedef {import('./api').ApiLicense} ApiLicense */ -/** @typedef {import('./api').ApiBase} ApiBase */ -/** @typedef {import('./api').ApiWeb} ApiWeb */ -/** @typedef {import('./api').ApiAsync} ApiAsync */ -/** @typedef {import('./amf').Api} Api */ -/** @typedef {import('./amf').WebApi} WebApi */ -/** @typedef {import('./amf').AsyncApi} AsyncApi */ -/** @typedef {import('./amf').Server} Server */ -/** @typedef {import('./amf').Parameter} Parameter */ -/** @typedef {import('./amf').Shape} Shape */ -/** @typedef {import('./amf').ScalarShape} ScalarShape */ -/** @typedef {import('./amf').NodeShape} NodeShape */ -/** @typedef {import('./amf').UnionShape} UnionShape */ -/** @typedef {import('./amf').FileShape} FileShape */ -/** @typedef {import('./amf').SchemaShape} SchemaShape */ -/** @typedef {import('./amf').ArrayShape} ArrayShape */ -/** @typedef {import('./amf').TupleShape} TupleShape */ -/** @typedef {import('./amf').AnyShape} AnyShape */ -/** @typedef {import('./amf').DomainElement} DomainElement */ -/** @typedef {import('./amf').PropertyShape} PropertyShape */ -/** @typedef {import('./amf').DataArrangeShape} DataArrangeShape */ -/** @typedef {import('./amf').CreativeWork} CreativeWork */ -/** @typedef {import('./amf').Example} Example */ -/** @typedef {import('./amf').XMLSerializer} XMLSerializer */ -/** @typedef {import('./amf').DataNode} DataNode */ -/** @typedef {import('./amf').ScalarNode} ScalarNode */ -/** @typedef {import('./amf').ArrayNode} ArrayNode */ -/** @typedef {import('./amf').ObjectNode} ObjectNode */ -/** @typedef {import('./amf').RecursiveShape} RecursiveShape */ -/** @typedef {import('./amf').EndPoint} EndPoint */ -/** @typedef {import('./amf').Operation} Operation */ -/** @typedef {import('./amf').Callback} Callback */ -/** @typedef {import('./amf').Request} Request */ -/** @typedef {import('./amf').Response} Response */ -/** @typedef {import('./amf').Payload} Payload */ -/** @typedef {import('./amf').TemplatedLink} TemplatedLink */ -/** @typedef {import('./amf').IriTemplateMapping} IriTemplateMapping */ -/** @typedef {import('./amf').ParametrizedSecurityScheme} ParametrizedSecurityScheme */ -/** @typedef {import('./amf').SecurityScheme} SecurityScheme */ -/** @typedef {import('./amf').SecurityRequirement} SecurityRequirement */ -/** @typedef {import('./amf').Settings} Settings */ -/** @typedef {import('./amf').OAuth1Settings} OAuth1Settings */ -/** @typedef {import('./amf').OAuth2Settings} OAuth2Settings */ -/** @typedef {import('./amf').OAuth2Flow} OAuth2Flow */ -/** @typedef {import('./amf').Scope} Scope */ -/** @typedef {import('./amf').ApiKeySettings} ApiKeySettings */ -/** @typedef {import('./amf').HttpSettings} HttpSettings */ -/** @typedef {import('./amf').OpenIdConnectSettings} OpenIdConnectSettings */ -/** @typedef {import('./amf').Tag} Tag */ -/** @typedef {import('./amf').DocumentSourceMaps} DocumentSourceMaps */ -/** @typedef {import('./amf').SynthesizedField} SynthesizedField */ -/** @typedef {import('./amf').ParametrizedDeclaration} ParametrizedDeclaration */ -/** @typedef {import('./amf').ParametrizedTrait} ParametrizedTrait */ -/** @typedef {import('./amf').ParametrizedResourceType} ParametrizedResourceType */ -/** @typedef {import('./amf').VariableValue} VariableValue */ -/** @typedef {import('./amf').AbstractDeclaration} AbstractDeclaration */ -/** @typedef {import('./amf').Organization} Organization */ -/** @typedef {import('./amf').License} License */ -/** @typedef {import('../types').ApiEndPointWithOperationsListItem} ApiEndPointWithOperationsListItem */ -/** @typedef {import('../types').ApiOperationListItem} ApiOperationListItem */ -/** @typedef {import('../types').ApiSecuritySchemeListItem} ApiSecuritySchemeListItem */ +import { + AnyShape, ApiKeySettings, ArrayNode, ArrayShape, Callback, CreativeWork, DataArrangeShape, + DataNode, DocumentSourceMaps, DomainElement, EndPoint, Example, FileShape, HttpSettings, + IriTemplateMapping, NodeShape, OAuth1Settings, OAuth2Flow, OAuth2Settings, ObjectNode, + OpenIdConnectSettings, Operation, Parameter, ParametrizedSecurityScheme, Payload, + PropertyShape, RecursiveShape, Request, Response, ScalarNode, ScalarShape, SchemaShape, + Scope, SecurityRequirement, SecurityScheme, Server, Settings, Shape, SynthesizedField, + Tag, TemplatedLink, TupleShape, UnionShape, Api, WebApi, AsyncApi, Organization, License, + ParametrizedDeclaration, ParametrizedTrait, ParametrizedResourceType, VariableValue, AbstractDeclaration, + XMLSerializer, +} from "./amf.js"; +import { + ApiAnyShape, ApiArrayNode, ApiArrayShape, ApiCallback, ApiCustomDomainProperty, ApiDataArrangeShape, + ApiDataNode, ApiDataNodeUnion, ApiDocumentation, ApiDocumentSourceMaps, ApiEndPoint, ApiExample, + ApiFileShape, ApiIriTemplateMapping, ApiNodeShape, ApiObjectNode, ApiOperation, ApiParameter, + ApiParametrizedSecurityScheme, ApiPayload, ApiPropertyShape, ApiRecursiveShape, ApiRequest, ApiResponse, + ApiScalarNode, ApiScalarShape, ApiSchemaShape, ApiSecurityApiKeySettings, ApiSecurityHttpSettings, + ApiSecurityOAuth1Settings, ApiSecurityOAuth2Flow, ApiSecurityOAuth2Settings, + ApiSecurityOpenIdConnectSettings, ApiSecurityRequirement, ApiSecurityScheme, ApiSecurityScope, + ApiSecuritySettings, ApiSecuritySettingsUnion, ApiServer, ApiShape, ApiShapeUnion, ApiSynthesizedField, + ApiTag, ApiTupleShape, ApiUnionShape, ApiXMLSerializer, ApiOrganization, ApiSummary, ApiBase, + ApiWeb, ApiAsync, ApiLicense, ApiParametrizedDeclaration, ApiParametrizedTrait, ApiParametrizedResourceType, + ApiVariableValue, ApiAbstractDeclaration, ShapeProcessingOptions, ApiTemplatedLink, +} from "./api.js"; +import { + ApiEndPointWithOperationsListItem, + ApiOperationListItem, + ApiSecuritySchemeListItem, +} from '../types.js' /** * A class that takes AMF's ld+json model and outputs JavaScript interface of it. */ export class AmfSerializer extends AmfHelperMixin(Object) { /** - * @param {DomainElement=} graph Optional AMF generated graph model. + * @param graph Optional AMF generated graph model. */ - constructor(graph) { + constructor(graph?: DomainElement) { super(); if (graph) { this.amf = graph; @@ -134,11 +48,10 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {string[]} types The list of graph object types. When not defined it returns an empty array. - * @param {Record=} context - * @returns {string[]} The expanded types. + * @param types The list of graph object types. When not defined it returns an empty array. + * @returns The expanded types. */ - readTypes(types, context) { + readTypes(types: string[], context?: Record): string[] { let target = types; if (typeof target === 'string') { target = [target]; @@ -150,12 +63,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Api} object The API to serialize. - * @returns {ApiSummary} API summary, without complex objects. + * @param object The API to serialize. + * @returns API summary, without complex objects. */ - apiSummary(object) { + apiSummary(object: Api): ApiSummary { const context = object['@context']; - const result = /** @type ApiSummary */ ({ + const result: ApiSummary = ({ id: object['@id'], types: this.readTypes(object['@type'], context), customDomainProperties: this.customDomainProperties(object, context), @@ -183,96 +96,78 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (termsOfService && typeof termsOfService === 'string') { result.termsOfService = termsOfService; } - const accepts = object[this._getAmfKey(ns.aml.vocabularies.apiContract.accepts, context)]; + const accepts = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.accepts, context) as string]; if (Array.isArray(accepts) && accepts.length) { - result.accepts = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, context)); + result.accepts = (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, context)) as string[]; } - const contentType = object[this._getAmfKey(ns.aml.vocabularies.apiContract.contentType, context)]; + const contentType = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.contentType, context) as string]; if (Array.isArray(contentType) && contentType.length) { - result.contentType = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, context)); + result.contentType = (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, context)) as string[]; } - const schemes = object[this._getAmfKey(ns.aml.vocabularies.apiContract.scheme, context)]; + const schemes = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.scheme, context) as string]; if (Array.isArray(schemes) && schemes.length) { - result.schemes = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, context)); + result.schemes = (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, context)) as string[]; } - let provider = object[this._getAmfKey(ns.aml.vocabularies.core.provider, context)]; + let provider = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.provider, context) as string]; if (Array.isArray(provider)) { [provider] = provider; } if (provider) { result.provider = this.provider(provider); } - let license = object[this._getAmfKey(ns.aml.vocabularies.core.license, context)]; + let license = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.license, context) as string]; if (Array.isArray(license)) { [license] = license; } if (license) { result.license = this.license(license); } - const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, context)]; + const tags = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, context) as string]; if (Array.isArray(tags) && tags.length) { result.tags = tags.map(t => this.tag(t)); } - const docs = object[this._getAmfKey(ns.aml.vocabularies.core.documentation, context)]; + const docs = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, context) as string]; if (Array.isArray(docs) && docs.length) { result.documentations = docs.map(d => this.documentation(d)); } return result; } - /** - * @param {Api} object - * @param {Record=} context - * @returns {ApiBase} - */ - api(object, context) { + api(object: Api, context?: Record): ApiBase { const objectContext = context || object['@context']; - const result = /** @type ApiBase */ (this.apiSummary(object)); + const result = this.apiSummary(object) as ApiBase; result.endPoints = []; result.servers = []; result.security = []; const { ns } = this; - const endPoints = object[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext)]; + const endPoints = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as string]; if (Array.isArray(endPoints) && endPoints.length) { result.endPoints = endPoints.map(e => this.endPoint(e, objectContext)); } - const servers = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)]; + const servers = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string]; if (Array.isArray(servers) && servers.length) { result.servers = servers.map(s => this.server(s, objectContext)); } - const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)]; + const security = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]; if (Array.isArray(security) && security.length) { result.security = security.map(s => this.securityRequirement(s, objectContext)); } return result; } - /** - * @param {WebApi} object - * @param {Record=} context - * @returns {ApiWeb} - */ - webApi(object, context) { - return this.api(object, context); + + webApi(object: WebApi, context?: Record): ApiWeb { + return this.api(object, context) as ApiWeb; } - /** - * @param {AsyncApi} object - * @param {Record=} context - * @returns {ApiAsync} - */ - asyncApi(object, context) { - return this.api(object, context); + + asyncApi(object: AsyncApi, context?: Record): ApiAsync { + return this.api(object, context) as ApiAsync; } - /** - * @param {Organization} object - * @param {Record=} context - * @returns {ApiOrganization} - */ - provider(object, context) { + provider(object: Organization, context?: Record): ApiOrganization { const objectContext = context || object['@context']; - const result = /** @type ApiOrganization */ ({ + const result: ApiOrganization = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -294,14 +189,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {License} object - * @param {Record=} context - * @returns {ApiLicense} - */ - license(object, context) { + license(object: License, context?: Record): ApiLicense { const objectContext = context || object['@context']; - const result = /** @type ApiLicense */ ({ + const result: ApiLicense = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -320,15 +210,14 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Server} object The AMF Server to serialize. - * @param {Record=} context - * @returns {ApiServer} Serialized Server + * @param object The AMF Server to serialize. + * @returns Serialized Server */ - server(object, context) { + server(object: Server, context?: Record): ApiServer { const objectContext = context || object['@context']; const { ns } = this; - const url = this._getValue(object, ns.aml.vocabularies.core.urlTemplate, objectContext) || ''; - const result = /** @type ApiServer */ ({ + const url = this._getValue(object, ns.aml.vocabularies.core.urlTemplate, objectContext) as string || ''; + const result: ApiServer = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), url, @@ -340,19 +229,19 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (description && typeof description === 'string') { result.description = description; } - const variables = /** @type Parameter[] */ (object[this._getAmfKey(ns.aml.vocabularies.apiContract.variable, objectContext)]); + const variables = ((object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.variable, objectContext) as string]) as Parameter[]; if (Array.isArray(variables) && variables.length) { result.variables = variables.map((p) => this.parameter(p, objectContext)); } - const protocol = /** @type string */ (this._getValue(object, ns.aml.vocabularies.apiContract.protocol, objectContext)); - const protocolVersion = /** @type string */ (this._getValue(object, ns.aml.vocabularies.apiContract.protocolVersion, objectContext)); + const protocol = (this._getValue(object, ns.aml.vocabularies.apiContract.protocol, objectContext)) as string | undefined; + const protocolVersion = (this._getValue(object, ns.aml.vocabularies.apiContract.protocolVersion, objectContext)) as string | undefined; if (protocol) { result.protocol = protocol; } if (protocolVersion) { result.protocolVersion = protocolVersion; } - const security = /** @type SecurityRequirement */ (object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)]); + const security = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]) as SecurityRequirement[]; if (Array.isArray(security) && security.length) { result.security = security.map((p) => this.securityRequirement(p, objectContext)); } @@ -360,13 +249,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Parameter} object The Parameter to serialize. - * @param {Record=} context - * @returns {ApiParameter} Serialized Parameter + * @param object The Parameter to serialize. + * @returns Serialized Parameter */ - parameter(object, context) { + parameter(object: Parameter, context?: Record): ApiParameter { const objectContext = context || object['@context']; - const result = /** @type ApiParameter */ ({ + const result: ApiParameter = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), payloads: [], @@ -415,104 +303,83 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (binding && typeof binding === 'string') { result.binding = binding; } - const schemas = object[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext)]; + const schemas = (object as any)[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as string]; if (Array.isArray(schemas) && schemas.length) { const [schema] = schemas; result.schema = this.unknownShape(schema, { trackedId: object['@id'], }, objectContext); } - const payloads = object[this._getAmfKey(ns.aml.vocabularies.apiContract.payload, objectContext)]; + const payloads = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.payload, objectContext) as string]; if (Array.isArray(payloads) && payloads.length) { result.payloads = payloads.map(p => this.payload(p, objectContext)); } - const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)]; + const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; if (Array.isArray(examples) && examples.length) { result.examples = examples.map(e => this.example(e, objectContext)); } return result; } - /** - * @param {Shape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiShapeUnion} - */ - unknownShape(object, options, context) { + unknownShape(object: Shape, options?: ShapeProcessingOptions, context?: Record): ApiShapeUnion { const objectContext = context || object['@context']; const types = this.readTypes(object['@type'], objectContext); const { ns } = this; if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this.scalarShape(/** @type ScalarShape */ (object), options, objectContext); + return this.scalarShape((object as ScalarShape), options, objectContext); } if (types.includes(ns.w3.shacl.NodeShape)) { - return this.nodeShape(/** @type NodeShape */ (object), options, objectContext); + return this.nodeShape((object as NodeShape), options, objectContext); } if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this.unionShape(/** @type UnionShape */ (object), options, objectContext); + return this.unionShape((object as UnionShape), options, objectContext); } if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { - return this.fileShape(/** @type FileShape */ (object), options, objectContext); + return this.fileShape((object as FileShape), options, objectContext); } if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) { - return this.schemaShape(/** @type SchemaShape */ (object), options, objectContext); + return this.schemaShape((object as SchemaShape), options, objectContext); } // this must be before the ArrayShape if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this.tupleShape(/** @type TupleShape */ (object), options, objectContext); + return this.tupleShape((object as TupleShape), options, objectContext); } if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this.arrayShape(/** @type ArrayShape */ (object), options, objectContext); + return this.arrayShape((object as ArrayShape), options, objectContext); } if (types.includes(ns.aml.vocabularies.shapes.RecursiveShape)) { - return this.recursiveShape(/** @type RecursiveShape */ (object), objectContext); + return this.recursiveShape((object as RecursiveShape), objectContext); } // recursiveShape - return this.anyShape(/** @type AnyShape */ (object), options, objectContext); + return this.anyShape((object as AnyShape), options, objectContext); } - /** - * @param {DomainElement} object - * @param {Record=} context - * @returns {boolean} - */ - isLink(object, context) { + isLink(object: DomainElement, context?: Record): boolean { const objectContext = context || object['@context']; return !!this._getLinkValue(object, this.ns.aml.vocabularies.document.linkTarget, objectContext); } - /** - * @param {DomainElement} object - * @param {Record=} context - * @returns {DomainElement|undefined} - */ - getLinkTarget(object, context) { + getLinkTarget(object: DomainElement, context?: Record): DomainElement|undefined { const objectContext = context || object['@context']; const id = this._getLinkValue(object, this.ns.aml.vocabularies.document.linkTarget, objectContext); return this[findAmfType](id, objectContext); } - /** - * @param {Shape} object - * @param {Record=} context - * @returns {ApiShape} - */ - shape(object, context) { + shape(object: Shape, context?: Record): ApiShape { const objectContext = context || object['@context']; this._resolve(object); - /** @type string */ - let linkLabel; + + let linkLabel: string | undefined; let target = object; if (this.isLink(target)) { - linkLabel = /** @type string */ (this._getValue(target, this.ns.aml.vocabularies.document.linkLabel, objectContext)); + linkLabel = (this._getValue(target, this.ns.aml.vocabularies.document.linkLabel, objectContext)) as string; const id = this._getLinkValue(target, this.ns.aml.vocabularies.document.linkTarget, objectContext); - const value = /** @type Shape */ (this[findAmfType](id, objectContext)); + const value = (this[findAmfType](id, objectContext)) as Shape; if (value) { target = value; } } - const result = /** @type ApiShape */ ({ + const result: ApiShape = ({ id: target['@id'], types: this.readTypes(object['@type'], objectContext), values: [], @@ -560,7 +427,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (typeof writeOnly === 'boolean') { result.writeOnly = writeOnly; } - const defValue = target[this._getAmfKey(ns.w3.shacl.defaultValue, objectContext)]; + const defValue = (target as any)[this._getAmfKey(ns.w3.shacl.defaultValue, objectContext) as string]; if (Array.isArray(defValue) && defValue.length) { result.defaultValue = this.unknownDataNode(defValue[0], objectContext); } @@ -568,26 +435,26 @@ export class AmfSerializer extends AmfHelperMixin(Object) { // if (Array.isArray(inherits) && inherits.length) { // result.inherits = inherits.map((item) => this.unknownShape(item)); // } - const orKey = this._getAmfKey(ns.w3.shacl.or, objectContext); - const orGroup = /** @type Shape[] */ (target[orKey]); + const orKey = this._getAmfKey(ns.w3.shacl.or, objectContext) as string; + const orGroup = /** @type */ ((target as any)[orKey]) as Shape[]; if (Array.isArray(orGroup) && orGroup.length) { result.or = orGroup.map((item) => this.unknownShape(item, undefined, objectContext)); } - const andKey = this._getAmfKey(ns.w3.shacl.and, objectContext); - const andGroup = /** @type Shape[] */ (target[andKey]); + const andKey = this._getAmfKey(ns.w3.shacl.and, objectContext) as string; + const andGroup = /** @type */ ((target as any)[andKey]) as Shape[]; if (Array.isArray(andGroup) && andGroup.length) { result.and = andGroup.map((item) => this.unknownShape(item, undefined, objectContext)); } - const xoneKey = this._getAmfKey(ns.w3.shacl.xone, objectContext); - const xone = /** @type Shape[] */ (target[xoneKey]); + const xoneKey = this._getAmfKey(ns.w3.shacl.xone, objectContext) as string; + const xone = ((target as any)[xoneKey]) as Shape[]; if (Array.isArray(xone) && xone.length) { result.xone = xone.map((item) => this.unknownShape(item, undefined, objectContext)); } - const valuesList = target[this._getAmfKey(ns.w3.shacl.in, objectContext)]; + const valuesList = (target as any)[this._getAmfKey(ns.w3.shacl.in, objectContext) as string]; if (Array.isArray(valuesList) && valuesList.length) { const [values] = valuesList; const prefix = this.ns.w3.rdfSchema.toString(); - const prefixCompact = this._getAmfKey(prefix, objectContext); + const prefixCompact = this._getAmfKey(prefix, objectContext) as string; Object.keys(values).forEach((key) => { if (key.startsWith(prefix) || key.startsWith(prefixCompact)) { let value = values[key]; @@ -595,33 +462,29 @@ export class AmfSerializer extends AmfHelperMixin(Object) { [value] = value; } const processed = this.unknownDataNode(value, objectContext); - result.values.push(processed); + if (processed) { + result.values.push(processed); + } } }); } - const notKey = this._getAmfKey(ns.w3.shacl.not, objectContext); - let not = /** @type Shape */ (target[notKey]); + const notKey = this._getAmfKey(ns.w3.shacl.not, objectContext) as string; + let not = ((target as any)[notKey]) as Shape | undefined; if (not) { if (Array.isArray(not)) { [not] = not; } - result.not = this.unknownShape(not, undefined, objectContext); + result.not = this.unknownShape(not as Shape, undefined, objectContext); } return result; } - /** - * @param {AnyShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiAnyShape} - */ - anyShape(object, options={}, context) { + anyShape(object: AnyShape, options: ShapeProcessingOptions={}, context?: Record): ApiAnyShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiAnyShape */ (this.shape(target, objectContext)); + const result = (this.shape(target, objectContext)) as ApiAnyShape; if (this.isLink(target)) { - const value = /** @type Shape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as Shape; if (value) { target = value; } @@ -629,7 +492,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { result.examples = []; const { ns } = this; - const examples = target[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)]; + const examples = (target as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; if (Array.isArray(examples) && examples.length) { if (options.trackedId) { const filtered = this.filterTrackedExamples(examples, options.trackedId, objectContext); @@ -639,12 +502,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { result.examples = filtered.map((item) => this.example(item, objectContext)); } } - const docs = target[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext)]; + const docs = (target as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as string]; if (Array.isArray(docs) && docs.length) { const [documentation] = docs; result.documentation = this.documentation(documentation, objectContext); } - const xml = target[this._getAmfKey(ns.aml.vocabularies.shapes.xmlSerialization, objectContext)]; + const xml = (target as any)[this._getAmfKey(ns.aml.vocabularies.shapes.xmlSerialization, objectContext) as string]; if (Array.isArray(xml) && xml.length) { result.xmlSerialization = this.xmlSerializer(xml[0], objectContext); } @@ -655,30 +518,25 @@ export class AmfSerializer extends AmfHelperMixin(Object) { * Filters examples that should be rendered for a payload identified by `trackedId`. * * This function is copied from old `api-example-generator/ExampleGenerator`. - * - * @param {Example[]} examples - * @param {string} trackedId - * @param {Record=} context - * @returns {Example[]} */ - filterTrackedExamples(examples, trackedId, context) { - const { docSourceMaps } = this.ns.raml.vocabularies; - const sourceKey = this._getAmfKey(docSourceMaps.sources, context); - const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context); + filterTrackedExamples(examples: Example[], trackedId: string, context?: Record): Example[] { + const { docSourceMaps } = this.ns.aml.vocabularies; + const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as string; + const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as string; const longId = trackedId.indexOf('amf') === -1 ? `amf://id${trackedId}` : trackedId; return examples.filter((item) => { let example = item; if (Array.isArray(example)) { [example] = example; } - let sm = example[sourceKey]; + let sm = (example as any)[sourceKey] as DocumentSourceMaps; if (!sm) { return true } if (Array.isArray(sm)) { [sm] = sm; } - let tracked = sm[trackedKey]; + let tracked = (sm as any)[trackedKey]; if (!tracked) { return true; } @@ -701,28 +559,24 @@ export class AmfSerializer extends AmfHelperMixin(Object) { * Kind of the opposite of the `filterTrackedExamples`. It gathers examples that only have been * defined for the parent Shape (ed in the type declaration). It filters out all examples * defined in a payload. - * - * @param {Example[]} examples - * @param {Record=} context - * @returns {Example[]} */ - filterNonTrackedExamples(examples, context) { - const { docSourceMaps } = this.ns.raml.vocabularies; - const sourceKey = this._getAmfKey(docSourceMaps.sources, context); - const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context); + filterNonTrackedExamples(examples: Example[], context?: Record): Example[] { + const { docSourceMaps } = this.ns.aml.vocabularies; + const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as string; + const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as string; return examples.filter((item) => { let example = item; if (Array.isArray(example)) { [example] = example; } - let sm = example[sourceKey]; + let sm = (example as any)[sourceKey] as DocumentSourceMaps; if (!sm) { return true } if (Array.isArray(sm)) { [sm] = sm; } - let tracked = sm[trackedKey]; + let tracked = (sm as any)[trackedKey]; if (!tracked) { return true; } @@ -737,18 +591,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { }); } - /** - * @param {ScalarShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiScalarShape} - */ - scalarShape(object, options={}, context) { + scalarShape(object: ScalarShape, options={}, context?: Record): ApiScalarShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiScalarShape */ (this.anyShape(target, options, objectContext)); + const result = (this.anyShape(target, options, objectContext)) as ApiScalarShape; if (this.isLink(target)) { - const value = /** @type ScalarShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as ScalarShape; if (value) { target = value; } @@ -797,12 +645,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { * @param {Record=} context * @returns {ApiNodeShape} */ - nodeShape(object, options={}, context) { + nodeShape(object: NodeShape, options={}, context?: Record): ApiNodeShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiNodeShape */ (this.anyShape(target, options, objectContext)); + const result = (this.anyShape(target, options, objectContext)) as ApiNodeShape; if (this.isLink(target)) { - const value = /** @type NodeShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as NodeShape; if (value) { target = value; } @@ -841,7 +689,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { // } else { // result.customShapePropertyDefinitions = []; // } - const properties = /** @type PropertyShape[] */ (target[this._getAmfKey(ns.w3.shacl.property, objectContext)]); + const properties = ((target as any)[this._getAmfKey(ns.w3.shacl.property, objectContext) as string]) as PropertyShape[]; if (Array.isArray(properties) && properties.length) { result.properties = properties.map((item) => this.propertyShape(item, objectContext)); } else { @@ -855,17 +703,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {PropertyShape} object - * @param {Record=} context - * @returns {ApiPropertyShape} - */ - propertyShape(object, context) { + propertyShape(object: PropertyShape, context?: Record): ApiPropertyShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiPropertyShape */ (this.shape(target, objectContext)); + const result = (this.shape(target, objectContext)) as ApiPropertyShape; if (this.isLink(target)) { - const value = /** @type PropertyShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as PropertyShape; if (value) { target = value; } @@ -887,7 +730,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { // result.patternName = patternName.value(); // } - const ranges = /** @type Shape[] */ (target[this._getAmfKey(ns.aml.vocabularies.shapes.range, objectContext)]); + const ranges = ((target as any)[this._getAmfKey(ns.aml.vocabularies.shapes.range, objectContext) as string]) as Shape[]; if (Array.isArray(ranges) && ranges.length) { const [range] = ranges; result.range = this.unknownShape(range, undefined, objectContext); @@ -895,16 +738,10 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {UnionShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiUnionShape} - */ - unionShape(object, options={}, context) { + unionShape(object: UnionShape, options: ShapeProcessingOptions={}, context?: Record): ApiUnionShape { const objectContext = context || object['@context']; - const anyOf = /** @type Shape[] */ (object[this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf, objectContext)]); - const result = /** @type ApiUnionShape */ (this.anyShape(object, options, objectContext)); + const anyOf = ((object as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf, objectContext) as string]) as Shape[]; + const result = (this.anyShape(object, options, objectContext)) as ApiUnionShape; if (Array.isArray(anyOf) && anyOf.length) { const opt = { ...options, trackedId: undefined }; result.anyOf = anyOf.map((shape) => this.unknownShape(shape, opt, objectContext)); @@ -914,18 +751,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {FileShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiFileShape} - */ - fileShape(object, options={}, context) { + fileShape(object: FileShape, options: ShapeProcessingOptions={}, context?: Record): ApiFileShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiFileShape */ (this.anyShape(target, options, objectContext)); + const result = (this.anyShape(target, options, objectContext)) as ApiFileShape; if (this.isLink(target)) { - const value = /** @type FileShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as FileShape; if (value) { target = value; } @@ -935,7 +766,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (pattern && typeof pattern === 'string') { result.pattern = pattern; } - const fileTypes = /** @type string[] */ (this._getValueArray(target, ns.aml.vocabularies.shapes.fileType, objectContext)); + const fileTypes = (this._getValueArray(target, ns.aml.vocabularies.shapes.fileType, objectContext)) as string[]; if (Array.isArray(fileTypes) && fileTypes.length) { result.fileTypes = fileTypes; } @@ -968,18 +799,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {SchemaShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiSchemaShape} - */ - schemaShape(object, options={}, context) { + + schemaShape(object: SchemaShape, options: ShapeProcessingOptions={}, context?: Record): ApiSchemaShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiSchemaShape */ (this.anyShape(target, options, objectContext)); + const result = (this.anyShape(target, options, objectContext)) as ApiSchemaShape; if (this.isLink(target)) { - const value = /** @type SchemaShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as SchemaShape; if (value) { target = value; } @@ -996,17 +822,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {RecursiveShape} object - * @param {Record=} context - * @returns {ApiRecursiveShape} - */ - recursiveShape(object, context) { + recursiveShape(object: RecursiveShape, context?: Record): ApiRecursiveShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiRecursiveShape */ (this.shape(target, objectContext)); + const result = (this.shape(target, objectContext)) as ApiRecursiveShape; if (this.isLink(target)) { - const value = /** @type RecursiveShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as RecursiveShape; if (value) { target = value; } @@ -1019,18 +840,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {DataArrangeShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiDataArrangeShape} - */ - dataArrangeShape(object, options={}, context) { + dataArrangeShape(object: DataArrangeShape, options={}, context?: Record): ApiDataArrangeShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiDataArrangeShape */ (this.anyShape(target, options, objectContext)); + const result = (this.anyShape(target, options, objectContext)) as ApiDataArrangeShape; if (this.isLink(target)) { - const value = /** @type DataArrangeShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as DataArrangeShape; if (value) { target = value; } @@ -1049,24 +864,18 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ArrayShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiArrayShape} - */ - arrayShape(object, options={}, context) { + arrayShape(object: ArrayShape, options: ShapeProcessingOptions={}, context?: Record): ApiArrayShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiArrayShape */ (this.dataArrangeShape(target, options, objectContext)); + const result = (this.dataArrangeShape(target, options, objectContext)) as ApiArrayShape; if (this.isLink(target)) { - const value = /** @type ArrayShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as ArrayShape; if (value) { target = value; } } - const items = target[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext)]; + const items = (target as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext) as string]; if (Array.isArray(items) && items.length) { const [item] = items; result.items = this.unknownShape(item, undefined, objectContext); @@ -1074,24 +883,18 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {TupleShape} object - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiTupleShape} - */ - tupleShape(object, options, context) { + tupleShape(object: TupleShape, options?: ShapeProcessingOptions, context?: Record): ApiTupleShape { const objectContext = context || object['@context']; let target = object; - const result = /** @type ApiTupleShape */ (this.dataArrangeShape(target, options, objectContext)); + const result = (this.dataArrangeShape(target, options, objectContext)) as ApiTupleShape; if (this.isLink(target)) { - const value = /** @type TupleShape */ (this.getLinkTarget(target, objectContext)); + const value = (this.getLinkTarget(target, objectContext)) as TupleShape; if (value) { target = value; } } - const items = target[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext)]; - const prefix = this._getAmfKey(this.ns.w3.rdfSchema.key, objectContext); + const items = (target as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext) as string]; + const prefix = this._getAmfKey(this.ns.w3.rdfSchema.key, objectContext) as string; if (Array.isArray(items) && items.length) { result.items = []; items.forEach((item) => { @@ -1115,13 +918,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {CreativeWork} object The CreativeWork to serialize. - * @param {Record=} context - * @returns {ApiDocumentation} Serialized CreativeWork + * @param object The CreativeWork to serialize. + * @returns Serialized CreativeWork */ - documentation(object, context) { + documentation(object: CreativeWork, context?: Record): ApiDocumentation { const objectContext = context || object['@context']; - const result = /** @type ApiDocumentation */ ({ + const result: ApiDocumentation = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1143,14 +945,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Example} object The Example to serialize. - * @param {Record=} context - * @returns {ApiExample} Serialized Example + * @param {} object The Example to serialize. + * @returns {} Serialized Example */ - example(object, context) { + example(object: Example, context?: Record): ApiExample { const objectContext = context || object['@context']; this._resolve(object); - const result = /** @type ApiExample */ ({ + const result: ApiExample = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1185,7 +986,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { // if (!mediaType.isNullOrEmpty) { // result.mediaType = mediaType.value(); // } - const structuredValue = object[this._getAmfKey(ns.aml.vocabularies.document.structuredValue, objectContext)]; + const structuredValue = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.structuredValue, objectContext) as string]; if (Array.isArray(structuredValue) && structuredValue.length) { const [value] = structuredValue; result.structuredValue = this.unknownDataNode(value, objectContext); @@ -1193,14 +994,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {XMLSerializer} object - * @param {Record=} context - * @returns {ApiXMLSerializer} - */ - xmlSerializer(object, context) { + xmlSerializer(object: XMLSerializer, context?: Record): ApiXMLSerializer { const objectContext = context || object['@context']; - const result = /** @type ApiXMLSerializer */ ({ + const result: ApiXMLSerializer = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1230,33 +1026,24 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {DataNode} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiDataNodeUnion} - */ - unknownDataNode(object, context) { + unknownDataNode(object: DataNode, context?: Record): ApiDataNodeUnion | undefined { const types = this.readTypes(object['@type'], context); const { ns } = this; if (types.includes(ns.aml.vocabularies.data.Scalar)) { - return this.scalarNode(/** @type ScalarNode */(object), context); + return this.scalarNode((object as ScalarNode), context); } if (types.includes(ns.aml.vocabularies.data.Object)) { - return this.objectNode(/** @type ObjectNode */(object), context); + return this.objectNode((object as ObjectNode), context); } if (types.includes(ns.aml.vocabularies.data.Array)) { - return this.arrayNode(/** @type ArrayNode */(object), context); + return this.arrayNode((object as ArrayNode), context); } return undefined; } - /** - * @param {DataNode} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiDataNode} - */ - dataNode(object, context) { - const result = /** @type ApiDataNode */ ({ + + dataNode(object: DataNode, context?: Record): ApiDataNode { + const result: ApiDataNode = ({ id: object['@id'], types: this.readTypes(object['@type'], context), customDomainProperties: this.customDomainProperties(object, context), @@ -1269,14 +1056,10 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ScalarNode} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiScalarNode} - */ - scalarNode(object, context) { + + scalarNode(object: ScalarNode, context?: Record): ApiScalarNode { const objectContext = context || object['@context']; - const result = /** @type ApiScalarNode */ (this.dataNode(object, context)); + const result = (this.dataNode(object, context)) as ApiScalarNode; const { ns } = this; const value = this._getValue(object, ns.aml.vocabularies.data.value, objectContext); if (value && typeof value === 'string') { @@ -1289,60 +1072,56 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ObjectNode} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiObjectNode} - */ - objectNode(object, context) { + objectNode(object: ObjectNode, context?: Record): ApiObjectNode { const objectContext = context || object['@context']; - const result = /** @type ApiObjectNode */ (this.dataNode(object, context)); + const result = (this.dataNode(object, context)) as ApiObjectNode; result.properties = {}; const prefix = this.ns.aml.vocabularies.data.toString(); const prefixCompact = `${this._getAmfKey(prefix, objectContext)}:`; Object.keys(object).forEach((key) => { if (key.startsWith(prefix) || key.startsWith(prefixCompact)) { - let value = object[key]; + let value = (object as any)[key] as DataNode; if (Array.isArray(value)) { [value] = value; } const name = key.replace(prefix, '').replace(prefixCompact, ''); - result.properties[name] = this.unknownDataNode(value, context); + result.properties[name] = this.unknownDataNode(value, context) as ApiDataNodeUnion; } }); return result; } - /** - * @param {ArrayNode} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiArrayNode} - */ - arrayNode(object, context) { + + arrayNode(object: ArrayNode, context?: Record): ApiArrayNode { const objectContext = context || object['@context']; - const result = /** @type ApiArrayNode */ (this.dataNode(object, objectContext)); + const result = (this.dataNode(object, objectContext)) as ApiArrayNode; result.members = []; - const members = /** @type DataNode[] */ (this._computePropertyArray(object, this.ns.w3.rdfSchema.member)); + const members = (this._computePropertyArray(object, this.ns.w3.rdfSchema.member)) as DataNode[]; if (Array.isArray(members) && members.length) { - result.members = members.map((item) => this.unknownDataNode(item)); + members.forEach(item => { + const node = this.unknownDataNode(item); + if (node) { + result.members.push(node); + } + }); } return result; } /** * Adds the custom domain properties to the currently processed property, a.k.a annotations. - * @param {DomainElement} object - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiCustomDomainProperty[]} The list of custom domain properties. + * @param object + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns The list of custom domain properties. */ - customDomainProperties(object, context) { - const result = /** @type ApiCustomDomainProperty[] */ ([]); + customDomainProperties(object: DomainElement, context?: Record): ApiCustomDomainProperty[] { + const result: ApiCustomDomainProperty[] = []; const objectContext = context || object['@context']; const ids = this._getLinkValues(object, this.ns.aml.vocabularies.document.customDomainProperties, objectContext); if (Array.isArray(ids) && ids.length) { ids.forEach((id) => { const key = `amf://id${id}`; - let value = /** @type DomainElement */ (object[id] || object[key]); + let value = ((object as any)[id] || (object as any)[key]) as DomainElement; if (!value) { return; } @@ -1350,11 +1129,11 @@ export class AmfSerializer extends AmfHelperMixin(Object) { [value] = value; } const extension = this.unknownDataNode(value, objectContext); - const name = this._getValue(value, this.ns.aml.vocabularies.core.extensionName, objectContext); + const name = this._getValue(value, this.ns.aml.vocabularies.core.extensionName, objectContext) as string; if (!name || !extension) { return; } - const cdp = /** @type ApiCustomDomainProperty */ ({ + const cdp: ApiCustomDomainProperty = ({ id: key, name, extension, @@ -1366,13 +1145,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {EndPoint} object The EndPoint to serialize. - * @param {Record=} context - * @returns {ApiEndPoint} Serialized EndPoint + * @param object The EndPoint to serialize. + * @returns Serialized EndPoint */ - endPoint(object, context) { + endPoint(object: EndPoint, context?: Record): ApiEndPoint { const objectContext = context || object['@context']; - const result = /** @type ApiEndPoint */ ({ + const result: ApiEndPoint = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1404,7 +1182,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, objectContext); if (Array.isArray(operations) && operations.length) { - result.operations = operations.map(i => this.operation(/** @type Operation */ (i), objectContext)); + result.operations = operations.map(i => this.operation((i as Operation), objectContext)); } const parameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext); if (Array.isArray(parameters) && parameters.length) { @@ -1412,7 +1190,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(i => this.payload(/** @type Payload */(i), objectContext)); + result.payloads = payloads.map(i => this.payload(/** @type */(i as Payload), objectContext)); } const servers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.server, objectContext); if (Array.isArray(servers) && servers.length) { @@ -1441,13 +1219,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Operation} object The Operation to serialize. - * @param {Record=} context - * @returns {ApiOperation} Serialized Operation + * @param object The Operation to serialize. + * @returns Serialized Operation */ - operation(object, context) { + operation(object: Operation, context?: Record): ApiOperation { const objectContext = context || object['@context']; - const result = /** @type ApiOperation */ ({ + const result: ApiOperation = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1489,54 +1266,54 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (operationId && typeof operationId === 'string') { result.operationId = operationId; } - const accepts = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, objectContext)); + const accepts = (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, objectContext)) as string[]; if (Array.isArray(accepts)) { result.accepts = accepts; } - const schemes = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, objectContext)); + const schemes = (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, objectContext)) as string[]; if (Array.isArray(schemes)) { result.schemes = schemes; } - const contentType = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, objectContext)); + const contentType = (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, objectContext)) as string[]; if (Array.isArray(contentType)) { result.contentType = contentType; } - let expects = object[this._getAmfKey(ns.aml.vocabularies.apiContract.expects, objectContext)]; + let expects = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.expects, objectContext) as string]; if (expects) { if (Array.isArray(expects)) { [expects] = expects; } result.request = this.request(expects, objectContext); } - let documentation = object[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext)]; + let documentation = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as string]; if (documentation) { if (Array.isArray(documentation)) { [documentation] = documentation; } result.documentation = this.documentation(documentation, objectContext); } - const responses = object[this._getAmfKey(ns.aml.vocabularies.apiContract.returns, objectContext)]; + const responses = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.returns, objectContext) as string]; if (Array.isArray(responses)) { result.responses = responses.map(r => this.response(r, objectContext)); } - const callbacks = object[this._getAmfKey(ns.aml.vocabularies.apiContract.callback, objectContext)]; + const callbacks = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.callback, objectContext) as string]; if (Array.isArray(callbacks)) { result.callbacks = callbacks.map(c => this.callback(c, objectContext)); } - const servers = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)]; + const servers = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string]; if (Array.isArray(servers)) { result.servers = servers.map(s => this.server(s)); } - const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext)]; + const security = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]; if (Array.isArray(security)) { result.security = security.map(s => this.securityRequirement(s, objectContext)); } - const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, objectContext)]; + const tags = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, objectContext) as string]; if (Array.isArray(tags) && tags.length) { result.tags = tags.map(s => this.tag(s, objectContext)); } - const traits = object[this._getAmfKey(ns.aml.vocabularies.document.extends, objectContext)]; + const traits = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.extends, objectContext) as string]; if (Array.isArray(traits) && traits.length) { result.extends = traits.map(t => this.parametrizedTrait(t, objectContext)); } @@ -1544,13 +1321,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Tag} object + * @param object * @param {Record=} context - * @returns {ApiTag} + * @returns {} */ - tag(object, context) { + tag(object: Tag, context?: Record): ApiTag { const objectContext = context || object['@context']; - const result = /** @type ApiTag */ ({ + const result: ApiTag = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1565,14 +1342,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {Callback} object - * @param {Record=} context - * @returns {ApiCallback} - */ - callback(object, context) { + callback(object: Callback, context?: Record): ApiCallback { const objectContext = context || object['@context']; - const result = /** @type ApiCallback */ ({ + const result: ApiCallback = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1587,7 +1359,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (expression && typeof expression === 'string') { result.expression = expression; } - let endpoint = object[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext)]; + let endpoint = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as string]; if (endpoint) { if (Array.isArray(endpoint)) { [endpoint] = endpoint; @@ -1598,13 +1370,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Request} object The API request to serialize. - * @param {Record=} context - * @returns {ApiRequest} Serialized API request + * @param object The API request to serialize. + * @returns Serialized API request */ - request(object, context) { + request(object: Request, context?: Record): ApiRequest { const objectContext = context || object['@context']; - const result = /** @type ApiRequest */ ({ + const result: ApiRequest = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1625,7 +1396,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (required && typeof required === 'boolean') { result.required = required; } - let queryString = object[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext)]; + let queryString = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as string]; if (queryString) { if (Array.isArray(queryString)) { [queryString] = queryString; @@ -1650,19 +1421,19 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(p => this.payload(/** @type Payload */ (p), objectContext)); + result.payloads = payloads.map(p => this.payload((p as Payload), objectContext)); } return result; } /** - * @param {Response} object The Response to serialize. + * @param object The Response to serialize. * @param {Record=} context - * @returns {ApiResponse} Serialized Response + * @returns Serialized Response */ - response(object, context) { + response(object: Response, context?: Record): ApiResponse { const objectContext = context || object['@context']; - const result = /** @type ApiResponse */ ({ + const result: ApiResponse = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1691,13 +1462,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(p => this.payload(/** @type Payload */(p), objectContext)); + result.payloads = payloads.map(p => this.payload((p as Payload), objectContext)); } - const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)]; + const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; if (Array.isArray(examples) && examples.length) { result.examples = examples.map(e => this.example(e, objectContext)); } - const links = object[this._getAmfKey(ns.aml.vocabularies.apiContract.link, objectContext)]; + const links = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.link, objectContext) as string]; if (Array.isArray(links) && links.length) { result.links = links.map(p => this.templatedLink(p, objectContext)); } @@ -1705,13 +1476,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Payload} object The Payload to serialize. + * @param object The Payload to serialize. * @param {Record=} context - * @returns {ApiPayload} Serialized Payload + * @returns Serialized Payload */ - payload(object, context) { + payload(object: Payload, context?: Record): ApiPayload { const objectContext = context || object['@context']; - const result = /** @type ApiPayload */ ({ + const result: ApiPayload = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1728,7 +1499,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (mediaType && typeof mediaType === 'string') { result.mediaType = mediaType; } - let schema = object[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext)]; + let schema = (object as any)[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as string]; if (schema) { if (Array.isArray(schema)) { [schema] = schema; @@ -1737,7 +1508,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { trackedId: result.id, }, objectContext); } - const examples = object[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext)]; + const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; if (Array.isArray(examples) && examples.length) { result.examples = examples.map(e => this.example(e, objectContext)); } @@ -1748,13 +1519,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {TemplatedLink} object The TemplatedLink to serialize. + * @param object The TemplatedLink to serialize. * @param {Record=} context - * @returns {ApiTemplatedLink} Serialized TemplatedLink + * @returns Serialized TemplatedLink */ - templatedLink(object, context) { + templatedLink(object: TemplatedLink, context?: Record): ApiTemplatedLink { const objectContext = context || object['@context']; - const result = /** @type ApiTemplatedLink */ ({ + const result: ApiTemplatedLink = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1774,14 +1545,14 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (operationId && typeof operationId === 'string') { result.operationId = operationId; } - let server = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext)]; + let server = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string] as Server | undefined; if (server) { if (Array.isArray(server)) { [server] = server; } - result.server = this.server(server, objectContext); + result.server = this.server(server as Server, objectContext); } - let mapping = /** @type IriTemplateMapping[] */ (object[this._getAmfKey(ns.aml.vocabularies.apiContract.mapping, objectContext)]); + let mapping = ((object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.mapping, objectContext) as string]) as IriTemplateMapping[] | undefined; if (mapping) { if (mapping && !Array.isArray(mapping)) { mapping = [mapping]; @@ -1800,13 +1571,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {IriTemplateMapping} object + * @param object * @param {Record=} context - * @returns {ApiIriTemplateMapping} + * @returns {} */ - iriTemplateMapping(object, context) { + iriTemplateMapping(object: IriTemplateMapping, context?: Record): ApiIriTemplateMapping { const objectContext = context || object['@context']; - const result = /** @type ApiIriTemplateMapping */ ({ + const result: ApiIriTemplateMapping = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1825,13 +1596,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {ParametrizedSecurityScheme} object The ParametrizedSecurityScheme to serialize. + * @param object The ParametrizedSecurityScheme to serialize. * @param {Record=} context - * @returns {ApiParametrizedSecurityScheme} Serialized ParametrizedSecurityScheme + * @returns Serialized ParametrizedSecurityScheme */ - parametrizedSecurityScheme(object, context) { + parametrizedSecurityScheme(object: ParametrizedSecurityScheme, context?: Record): ApiParametrizedSecurityScheme { const objectContext = context || object['@context']; - const result = /** @type ApiParametrizedSecurityScheme */ ({ + const result: ApiParametrizedSecurityScheme = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1842,32 +1613,30 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (name && typeof name === 'string') { result.name = name; } - let scheme = object[this._getAmfKey(ns.aml.vocabularies.security.scheme, objectContext)]; + let scheme = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.scheme, objectContext) as string] as SecurityScheme | undefined; if (scheme) { if (Array.isArray(scheme)) { [scheme] = scheme; } - result.scheme = this.securityScheme(scheme, objectContext); + result.scheme = this.securityScheme(scheme as SecurityScheme, objectContext); } - let settings = object[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext)]; + let settings = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as string] as Settings | undefined; if (settings) { if (Array.isArray(settings)) { [settings] = settings; } - result.settings = this.securitySettings(settings, objectContext); + result.settings = this.securitySettings(settings as Settings, objectContext); } return result; } /** - * @param {SecurityScheme} object The SecurityScheme to serialize as a list item. - * @param {Record=} context - * @returns {ApiSecuritySchemeListItem} Serialized SecurityScheme + * @param object The SecurityScheme to serialize as a list item. + * @returns Serialized SecurityScheme */ - securitySchemeListItem(object, context) { + securitySchemeListItem(object: SecurityScheme, context?: Record): ApiSecuritySchemeListItem { const objectContext = context || object['@context']; - - const result = /** @type ApiSecuritySchemeListItem */ ({ + const result: ApiSecuritySchemeListItem = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), type: '', @@ -1889,13 +1658,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {SecurityScheme} object The SecurityScheme to serialize. + * @param object The SecurityScheme to serialize. * @param {Record=} context - * @returns {ApiSecurityScheme} Serialized SecurityScheme + * @returns Serialized SecurityScheme */ - securityScheme(object, context) { + securityScheme(object: SecurityScheme, context?: Record): ApiSecurityScheme { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityScheme */ ({ + const result: ApiSecurityScheme = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1921,19 +1690,19 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (type && typeof type === 'string') { result.type = type; } - let settings = object[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext)]; + let settings = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as string] as Settings | undefined; if (settings) { if (Array.isArray(settings)) { [settings] = settings; } - result.settings = this.securitySettings(settings, objectContext); + result.settings = this.securitySettings(settings as Settings, objectContext); } - let queryString = object[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext)]; + let queryString = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as string] as Shape | undefined; if (queryString) { if (Array.isArray(queryString)) { [queryString] = queryString; } - result.queryString = this.unknownShape(queryString, undefined, objectContext); + result.queryString = this.unknownShape(queryString as Shape, undefined, objectContext); } const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext); if (Array.isArray(headers) && headers.length) { @@ -1945,19 +1714,18 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } const responses = this[getArrayItems](object, ns.aml.vocabularies.apiContract.response, objectContext); if (Array.isArray(responses) && responses.length) { - result.responses = responses.map(p => this.response(/** @type Response */ (p), objectContext)); + result.responses = responses.map(p => this.response(/** @type */ (p as Response), objectContext)); } return result; } /** - * @param {SecurityRequirement} object The SecurityRequirement to serialize. - * @param {Record=} context - * @returns {ApiSecurityRequirement} Serialized SecurityRequirement + * @param object The SecurityRequirement to serialize. + * @returns Serialized SecurityRequirement */ - securityRequirement(object, context) { + securityRequirement(object: SecurityRequirement, context?: Record): ApiSecurityRequirement { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityRequirement */ ({ + const result: ApiSecurityRequirement = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -1969,48 +1737,39 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (name && typeof name === 'string') { result.name = name; } - const schemes = /** @type ParametrizedSecurityScheme[] */ (object[this._getAmfKey(ns.aml.vocabularies.security.schemes, objectContext)]); + const schemes = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.schemes, objectContext) as string]) as ParametrizedSecurityScheme[] | undefined; if (Array.isArray(schemes) && schemes.length) { result.schemes = schemes.map(p => this.parametrizedSecurityScheme(p, objectContext)); } return result; } - /** - * @param {Settings} object - * @param {Record=} context - * @returns {ApiSecuritySettingsUnion} - */ - securitySettings(object, context) { + securitySettings(object: Settings, context?: Record): ApiSecuritySettingsUnion { const objectContext = context || object['@context']; const { ns } = this; const types = this.readTypes(object['@type'], objectContext); if (types.includes(ns.aml.vocabularies.security.OAuth1Settings)) { - return this.oAuth1Settings(/** @type OAuth1Settings */ (object), objectContext); + return this.oAuth1Settings((object as OAuth1Settings), objectContext); } if (types.includes(ns.aml.vocabularies.security.OAuth2Settings)) { - return this.oAuth2Settings(/** @type OAuth2Settings */ (object), objectContext); + return this.oAuth2Settings((object as OAuth2Settings), objectContext); } if (types.includes(ns.aml.vocabularies.security.ApiKeySettings)) { - return this.apiKeySettings(/** @type ApiKeySettings */ (object), objectContext); + return this.apiKeySettings((object as ApiKeySettings), objectContext); } if (types.includes(ns.aml.vocabularies.security.HttpSettings)) { - return this.httpSettings(/** @type HttpSettings */ (object), objectContext); + return this.httpSettings((object as HttpSettings), objectContext); } if (types.includes(ns.aml.vocabularies.security.OpenIdConnectSettings)) { - return this.openIdConnectSettings(/** @type OpenIdConnectSettings */ (object), objectContext); + return this.openIdConnectSettings((object as OpenIdConnectSettings), objectContext); } return this.settings(object, objectContext); } - /** - * @param {Settings} object - * @param {Record=} context - * @returns {ApiSecuritySettings} - */ - settings(object, context) { + + settings(object: Settings, context?: Record): ApiSecuritySettings { const objectContext = context || object['@context']; - const result = /** @type ApiSecuritySettings */ ({ + const result: ApiSecuritySettings = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -2022,14 +1781,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {OAuth1Settings} object - * @param {Record=} context - * @returns {ApiSecurityOAuth1Settings} - */ - oAuth1Settings(object, context) { + oAuth1Settings(object: OAuth1Settings, context?: Record): ApiSecurityOAuth1Settings { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityOAuth1Settings */ (this.settings(object, objectContext)); + const result = (this.settings(object, objectContext)) as ApiSecurityOAuth1Settings; const { ns } = this; const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext); if (authorizationUri && typeof authorizationUri === 'string') { @@ -2043,7 +1797,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (tokenCredentialsUri && typeof tokenCredentialsUri === 'string') { result.tokenCredentialsUri = tokenCredentialsUri; } - const signatures = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.security.signature, objectContext)); + const signatures = (this._getValueArray(object, ns.aml.vocabularies.security.signature, objectContext)) as string[] | undefined; if (Array.isArray(signatures) && signatures.length) { result.signatures = signatures; } else { @@ -2052,22 +1806,18 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {OAuth2Settings} object - * @param {Record=} context - * @returns {ApiSecurityOAuth2Settings} - */ - oAuth2Settings(object, context) { + + oAuth2Settings(object: OAuth2Settings, context?: Record): ApiSecurityOAuth2Settings { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityOAuth2Settings */ (this.settings(object, objectContext)); + const result = (this.settings(object, objectContext)) as ApiSecurityOAuth2Settings; const { ns } = this; - const grants = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.security.authorizationGrant, objectContext)); + const grants = (this._getValueArray(object, ns.aml.vocabularies.security.authorizationGrant, objectContext)) as string[] | undefined; if (Array.isArray(grants) && grants.length) { result.authorizationGrants = grants; } else { result.authorizationGrants = []; } - const flows = /** @type OAuth2Flow[] */ (object[this._getAmfKey(ns.aml.vocabularies.security.flows, objectContext)]); + const flows = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.flows, objectContext) as string]) as OAuth2Flow[] | undefined; if (Array.isArray(flows) && flows.length) { result.flows = flows.map((p) => this.oAuth2Flow(p, objectContext)); } else { @@ -2076,14 +1826,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {OAuth2Flow} object - * @param {Record=} context - * @returns {ApiSecurityOAuth2Flow} - */ - oAuth2Flow(object, context) { + oAuth2Flow(object: OAuth2Flow, context?: Record): ApiSecurityOAuth2Flow { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityOAuth2Flow */ ({ + const result: ApiSecurityOAuth2Flow = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -2107,21 +1852,17 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (refreshUri && typeof refreshUri === 'string') { result.refreshUri = refreshUri; } - const scopes = object[this._getAmfKey(ns.aml.vocabularies.security.scope, objectContext)]; + const scopes = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.scope, objectContext) as string] as Scope[] | undefined; if (Array.isArray(scopes) && scopes.length) { result.scopes = scopes.map((p) => this.scope(p, objectContext)); } return result; } - /** - * @param {Scope} object - * @param {Record=} context - * @returns {ApiSecurityScope} - */ - scope(object, context) { + + scope(object: Scope, context?: Record): ApiSecurityScope { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityScope */ ({ + const result: ApiSecurityScope = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -2139,14 +1880,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ApiKeySettings} object - * @param {Record=} context - * @returns {ApiSecurityApiKeySettings} - */ - apiKeySettings(object, context) { + apiKeySettings(object: ApiKeySettings, context?: Record): ApiSecurityApiKeySettings { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityApiKeySettings */ (this.settings(object, objectContext)); + const result = (this.settings(object, objectContext)) as ApiSecurityApiKeySettings; const { ns } = this; const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); if (name && typeof name === 'string') { @@ -2159,14 +1895,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {HttpSettings} object - * @param {Record=} context - * @returns {ApiSecurityHttpSettings} - */ - httpSettings(object, context) { + httpSettings(object: HttpSettings, context?: Record): ApiSecurityHttpSettings { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityHttpSettings */ (this.settings(object, objectContext)); + const result = (this.settings(object, objectContext)) as ApiSecurityHttpSettings; const { ns } = this; const scheme = this._getValue(object, ns.aml.vocabularies.security.scheme, objectContext); if (scheme && typeof scheme === 'string') { @@ -2179,14 +1910,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {OpenIdConnectSettings} object - * @param {Record=} context - * @returns {ApiSecurityOpenIdConnectSettings} - */ - openIdConnectSettings(object, context) { + openIdConnectSettings(object: OpenIdConnectSettings, context?: Record): ApiSecurityOpenIdConnectSettings { const objectContext = context || object['@context']; - const result = /** @type ApiSecurityOpenIdConnectSettings */ (this.settings(object, objectContext)); + const result = (this.settings(object, objectContext)) as ApiSecurityOpenIdConnectSettings; const { ns } = this; const url = this._getValue(object, ns.aml.vocabularies.security.openIdConnectUrl, objectContext); if (url && typeof url === 'string') { @@ -2197,74 +1923,65 @@ export class AmfSerializer extends AmfHelperMixin(Object) { /** * Serializes source maps, when available. - * @param {DocumentSourceMaps} object - * @param {Record=} context - * @returns {ApiDocumentSourceMaps|undefined} */ - sourceMap(object, context) { + sourceMap(object: DocumentSourceMaps, context?: Record): ApiDocumentSourceMaps|undefined { const objectContext = context || object['@context']; const { ns } = this; - let sm = object[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, objectContext)]; + let sm = (object as any)[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, objectContext) as string]; if (!sm) { return undefined; } if (Array.isArray(sm)) { [sm] = sm; } - const result = /** @type ApiDocumentSourceMaps */ ({ + const result: ApiDocumentSourceMaps = ({ id: sm['@id'], types: this.readTypes(sm['@type']), }); - const synthesizedField = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.synthesizedField, objectContext)]; + const synthesizedField = (sm as any)[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.synthesizedField, objectContext) as string]; if (Array.isArray(synthesizedField) && synthesizedField.length) { result.synthesizedField = synthesizedField.map(i => this.synthesizedField(i, objectContext)); } - const lexical = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.lexical, objectContext)]; + const lexical = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.lexical, objectContext) as string]; if (Array.isArray(lexical) && lexical.length) { result.lexical = lexical.map(i => this.synthesizedField(i, objectContext)) } - const trackedElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.trackedElement, objectContext)]; + const trackedElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.trackedElement, objectContext) as string]; if (Array.isArray(trackedElement) && trackedElement.length) { result.trackedElement = this.synthesizedField(trackedElement[0], objectContext); } - const autoName = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.autoGeneratedName, objectContext)]; + const autoName = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.autoGeneratedName, objectContext) as string]; if (Array.isArray(autoName) && autoName.length) { result.autoGeneratedName = autoName.map(i => this.synthesizedField(i, objectContext)) } - const jsonSchema = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.parsedJsonSchema, objectContext)]; + const jsonSchema = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.parsedJsonSchema, objectContext) as string]; if (Array.isArray(jsonSchema) && jsonSchema.length) { result.parsedJsonSchema = this.synthesizedField(jsonSchema[0], objectContext); } - const declaredElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.declaredElement, objectContext)]; + const declaredElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.declaredElement, objectContext) as string]; if (Array.isArray(declaredElement) && declaredElement.length) { result.declaredElement = this.synthesizedField(declaredElement[0], objectContext); } return result; } - /** - * @param {SynthesizedField} object - * @param {Record=} context - * @returns {ApiSynthesizedField} - */ - synthesizedField(object, context) { + synthesizedField(object: SynthesizedField, context?: Record): ApiSynthesizedField { const objectContext = context || object['@context']; // compact model if (typeof object === 'string') { - return /** @type ApiSynthesizedField */ ({ + return ({ id: 'synthesizedField/generated', value: object, - }); + }) as ApiSynthesizedField; } - const result = /** @type ApiSynthesizedField */ ({ + const result: ApiSynthesizedField = { id: object['@id'], - }); - // @ts-ignore + value: '', + }; const element = this._getValue(object, this.ns.aml.vocabularies.docSourceMaps.element, objectContext); if (typeof element === 'string') { result.element = element; } - // @ts-ignore const value = this._getValue(object, this.ns.aml.vocabularies.docSourceMaps.value, objectContext); if (typeof value === 'string') { result.value = value @@ -2272,14 +1989,9 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ParametrizedDeclaration} object - * @param {Record=} context - * @returns {ApiParametrizedDeclaration} - */ - parametrizedDeclaration(object, context) { + parametrizedDeclaration(object: ParametrizedDeclaration, context?: Record): ApiParametrizedDeclaration { const objectContext = context || object['@context']; - const result = /** @type ApiParametrizedDeclaration */ ({ + const result: ApiParametrizedDeclaration = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), variables: [], @@ -2291,13 +2003,13 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (name && typeof name === 'string') { result.name = name; } - const variables = object[this._getAmfKey(ns.aml.vocabularies.document.variable, objectContext)]; + const variables = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.variable, objectContext) as string]; if (Array.isArray(variables)) { variables.forEach((item) => { result.variables.push(this.variableValue(item, objectContext)); }); } - const targets = object[this._getAmfKey(ns.aml.vocabularies.document.target, objectContext)]; + const targets = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.target, objectContext) as string]; if (Array.isArray(targets) && targets.length) { const [target] = targets; result.target = this.abstractDeclaration(target, objectContext); @@ -2305,45 +2017,31 @@ export class AmfSerializer extends AmfHelperMixin(Object) { return result; } - /** - * @param {ParametrizedTrait} object - * @param {Record=} context - * @returns {ApiParametrizedTrait} - */ - parametrizedTrait(object, context) { + parametrizedTrait(object: ParametrizedTrait, context?: Record): ApiParametrizedTrait { const objectContext = context || object['@context']; - const result = /** @type ApiParametrizedTrait */ (this.parametrizedDeclaration(object, objectContext)); + const result = (this.parametrizedDeclaration(object, objectContext)) as ApiParametrizedTrait; return result; } - /** - * @param {ParametrizedResourceType} object - * @param {Record=} context - * @returns {ApiParametrizedResourceType} - */ - parametrizedResourceType(object, context) { + + parametrizedResourceType(object: ParametrizedResourceType, context?: Record): ApiParametrizedResourceType { const objectContext = context || object['@context']; - const result = /** @type ApiParametrizedResourceType */ (this.parametrizedDeclaration(object, objectContext)); + const result = (this.parametrizedDeclaration(object, objectContext)) as ApiParametrizedResourceType; return result; } - /** - * @param {VariableValue} object - * @param {Record=} context - * @returns {ApiVariableValue} - */ - variableValue(object, context) { + variableValue(object: VariableValue, context?: Record): ApiVariableValue { const objectContext = context || object['@context']; const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - const result = /** @type ApiVariableValue */ ({ + const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string; + const result: ApiVariableValue = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), sourceMaps: this.sourceMap(object, objectContext), name, }); - const values = object[this._getAmfKey(ns.aml.vocabularies.document.value, objectContext)]; + const values = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.value, objectContext) as string]; if (Array.isArray(values)) { const [item] = values; result.value = this.unknownDataNode(item, objectContext); @@ -2352,15 +2050,15 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {AbstractDeclaration} object + * @param object * @param {Record=} context - * @returns {ApiAbstractDeclaration} + * @returns {} */ - abstractDeclaration(object, context) { + abstractDeclaration(object: AbstractDeclaration, context?: Record): ApiAbstractDeclaration { const objectContext = context || object['@context']; const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - const result = /** @type ApiAbstractDeclaration */ ({ + const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string; + const result: ApiAbstractDeclaration = ({ id: object['@id'], types: this.readTypes(object['@type'], objectContext), customDomainProperties: this.customDomainProperties(object, objectContext), @@ -2368,7 +2066,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { name, variables: [], }); - const variables = /** @type string[] */ (this._getValueArray(object, ns.aml.vocabularies.document.variable, objectContext)); + const variables = (this._getValueArray(object, ns.aml.vocabularies.document.variable, objectContext)) as string[]; if (Array.isArray(variables)) { result.variables = variables; } @@ -2376,7 +2074,7 @@ export class AmfSerializer extends AmfHelperMixin(Object) { if (description && typeof description === 'string') { result.description = description; } - const dataNode = object[this._getAmfKey(ns.aml.vocabularies.document.dataNode, objectContext)]; + const dataNode = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.dataNode, objectContext) as string]; if (Array.isArray(dataNode)) { const [item] = dataNode; result.dataNode = this.unknownDataNode(item, objectContext); @@ -2385,22 +2083,22 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {EndPoint} object The EndPoint to serialize as a list item. - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiEndPointWithOperationsListItem} Serialized EndPoint as a list item. + * @param object The EndPoint to serialize as a list item. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Serialized EndPoint as a list item. */ - endPointWithOperationsListItem(object, context) { + endPointWithOperationsListItem(object: EndPoint, context?: Record): ApiEndPointWithOperationsListItem { const { ns } = this; - const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, context); + const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, context) as string; - const result = /** @type ApiEndPointWithOperationsListItem */ ({ + const result: ApiEndPointWithOperationsListItem = ({ id: object['@id'], path, operations: [], }); const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, context); if (Array.isArray(operations) && operations.length) { - result.operations = operations.map(i => this.operationListItem(/** @type Operation */ (i), context)); + result.operations = operations.map(i => this.operationListItem((i as Operation), context)); } const name = this._getValue(object, ns.aml.vocabularies.core.name, context); if (name && typeof name === 'string') { @@ -2410,12 +2108,12 @@ export class AmfSerializer extends AmfHelperMixin(Object) { } /** - * @param {Operation} object The Operation to serialize as a list item. - * @param {Record=} context A context to use. If not set, it looks for the context of the passed model - * @returns {ApiOperationListItem} Serialized Operation as a list item. + * @param object The Operation to serialize as a list item. + * @param context A context to use. If not set, it looks for the context of the passed model + * @returns Serialized Operation as a list item. */ - operationListItem(object, context) { - const result = /** @type ApiOperationListItem */ ({ + operationListItem(object: Operation, context?: Record): ApiOperationListItem { + const result: ApiOperationListItem = ({ id: object['@id'], method: '', }); diff --git a/src/helpers/Namespace.d.ts b/src/helpers/Namespace.d.ts deleted file mode 100644 index b53f1df..0000000 --- a/src/helpers/Namespace.d.ts +++ /dev/null @@ -1,373 +0,0 @@ -interface Document { - toString(): string; - key: string; - Module: string; - Document: string; - SecuritySchemeFragment: string; - UserDocumentation: string; - DataType: string; - NamedExamples: string; - DomainElement: string; - ParametrizedDeclaration: string; - ExternalDomainElement: string; - customDomainProperties: string; - encodes: string; - declares: string; - references: string; - examples: string; - linkTarget: string; - linkLabel: string; - referenceId: string; - structuredValue: string; - raw: string; - extends: string; - value: string; - name: string; - strict: string; - deprecated: string; - location: string; - variable: string; - target: string; - dataNode: string; - root: string; - usage: string; - version: string; -} - -interface Core { - toString(): string; - key: string; - CreativeWork: string; - version: string; - urlTemplate: string; - displayName: string; - title: string; - name: string; - description: string; - summary: string; - documentation: string; - provider: string; - email: string; - url: string; - termsOfService: string; - license: string; - mediaType: string; - extensionName: string; - deprecated: string; -} - -interface Security { - toString(): string; - key: string; - ParametrizedSecurityScheme: string; - SecuritySchemeFragment: string; - SecurityScheme: string; - OAuth1Settings: string; - OAuth2Settings: string; - OAuth2Flow: string; - Scope: string; - Settings: string; - HttpSettings: string; - ApiKeySettings: string; - OpenIdConnectSettings: string; - security: string; - scheme: string; - schemes: string; - settings: string; - name: string; - type: string; - scope: string; - accessTokenUri: string; - authorizationUri: string; - authorizationGrant: string; - flows: string; - flow: string; - signature: string; - tokenCredentialsUri: string; - requestTokenUri: string; - refreshUri: string; - securityRequirement: string; - openIdConnectUrl: string; - bearerFormat: string; - in: string; -} - -interface ApiContract { - toString(): string; - key: string; - Payload: string; - Request: string; - Response: string; - EndPoint: string; - Parameter: string; - Operation: string; - WebAPI: string; - AsyncAPI: string; - API: string; - UserDocumentationFragment: string; - Example: string; - Server: string; - ParametrizedResourceType: string; - ParametrizedTrait: string; - Callback: string; - TemplatedLink: string; - IriTemplateMapping: string; - Tag: string; - header: string; - parameter: string; - paramName: string; - uriParameter: string; - cookieParameter: string; - variable: string; - payload: string; - server: string; - path: string; - url: string; - scheme: string; - endpoint: string; - queryString: string; - accepts: string; - guiSummary: string; - binding: string; - response: string; - returns: string; - expects: string; - examples: string; - supportedOperation: string; - statusCode: string; - method: string; - required: string; - callback: string; - expression: string; - link: string; - linkExpression: string; - templateVariable: string; - mapping: string; - operationId: string; - protocol: string; - protocolVersion: string; - Message: string; - headerSchema: string; - contentType: string; - allowEmptyValue: string; - style: string; - explode: string; - allowReserved: string; - tag: string; -} - -interface Shapes { - toString(): string; - key: string; - Shape: string; - ScalarShape: string; - ArrayShape: string; - UnionShape: string; - NilShape: string; - FileShape: string; - AnyShape: string; - SchemaShape: string; - MatrixShape: string; - TupleShape: string; - DataTypeFragment: string; - RecursiveShape: string; - XMLSerializer: string; - range: string; - items: string; - anyOf: string; - fileType: string; - number: string; - integer: string; - long: string; - double: string; - boolean: string; - float: string; - nil: string; - dateTimeOnly: string; - password: string; - schema: string; - xmlSerialization: string; - xmlName: string; - xmlAttribute: string; - xmlWrapped: string; - xmlNamespace: string; - xmlPrefix: string; - readOnly: string; - writeOnly: string; - deprecated: string; - fixPoint: string; - discriminator: string; - discriminatorValue: string; - format: string; - multipleOf: string; - uniqueItems: string; -} - -interface Data { - toString(): string; - key: string; - Scalar: string; - Object: string; - Array: string; - value: string; - type: string; - description: string; - required: string; - displayName: string; - minLength: string; - maxLength: string; - default: string; - multipleOf: string; - minimum: string; - maximum: string; - enum: string; - pattern: string; - items: string; - format: string; - example: string; - examples: string; -} - -interface DocSourceMaps { - toString(): string; - key: string; - SourceMap: string; - sources: string; - element: string; - value: string; - declaredElement: string; - trackedElement: string; - parsedJsonSchema: string; - autoGeneratedName: string; - lexical: string; - synthesizedField: string; -} - -interface Vocabularies { - toString(): string; - key: string; - document: Readonly; - core: Readonly; - security: Readonly; - apiContract: Readonly; - shapes: Readonly; - data: Readonly; - docSourceMaps: Readonly; -} - -interface Aml { - toString(): string; - key: string; - vocabularies: Readonly; -} - -interface RdfSyntax { - toString(): string; - key: string; - member: string; - Seq: string; -} - -interface RdfSchema { - toString(): string; - key: string; - member: string; - Seq: string; -} - -interface Hydra { - toString(): string; - key: string; - core: ApiContract; -} - -interface XmlSchema { - toString(): string; - key: string; - boolean: string; - string: string; - number: string; - integer: string; - long: string; - double: string; - float: string; - nil: string; - dateTime: string; - time: string; - date: string; - base64Binary: string; -} - -interface Shacl { - toString(): string; - key: string; - Shape: string; - NodeShape: string; - SchemaShape: string; - PropertyShape: string; - in: string; - defaultValue: string; - defaultValueStr: string; - pattern: string; - minInclusive: string; - maxInclusive: string; - multipleOf: string; - minLength: string; - maxLength: string; - fileType: string; - and: string; - property: string; - name: string; - raw: string; - datatype: string; - minCount: string; - maxCount: string; - xone: string; - not: string; - or: string; - closed: string; - path: string; -} - -interface W3 { - toString(): string; - key: string; - rdfSyntax: Readonly; - rdfSchema: Readonly; - hydra: Readonly; - xmlSchema: Readonly; - shacl: Readonly; -} - -interface Schema { - toString(): string; - key: string; - name: string; - desc: string; - doc: string; - webApi: string; - creativeWork: string; - displayName: string; - title: string; -} - -export interface Namespace { - name: string; - /** - * AMF namespace - */ - aml: Readonly; - /** - * AMF namespace (compatibility) - */ - raml: Readonly; - /** - * W3 namespace - */ - w3: Readonly; - /** - * Schema namespace. The same as aml.vocabularies - */ - schema: Readonly; -} -export const ns: Namespace; diff --git a/src/helpers/Namespace.js b/src/helpers/Namespace.js deleted file mode 100644 index bcbf33c..0000000 --- a/src/helpers/Namespace.js +++ /dev/null @@ -1,347 +0,0 @@ - -/** - * A namespace for AMF properties. - * @type {Object} - */ -export const ns = {}; - -// RAML namespace -ns.aml = {}; -ns.raml = ns.aml; -ns.aml.key = 'http://a.ml/'; -ns.aml.vocabularies = {}; -ns.aml.vocabularies.key = `${ns.aml.key}vocabularies/`; -ns.aml.vocabularies.document = {}; -ns.aml.vocabularies.document.key = `${ns.aml.vocabularies.key}document#`; -const docKey = ns.aml.vocabularies.document.key; -ns.aml.vocabularies.document.toString = () => docKey; -ns.aml.vocabularies.document.Module = `${docKey}Module`; -ns.aml.vocabularies.document.Document = `${docKey}Document`; -ns.aml.vocabularies.document.SecuritySchemeFragment = `${docKey}SecuritySchemeFragment`; -ns.aml.vocabularies.document.UserDocumentation = `${docKey}UserDocumentation`; -ns.aml.vocabularies.document.DataType = `${docKey}DataType`; -ns.aml.vocabularies.document.NamedExamples = `${docKey}NamedExamples`; -ns.aml.vocabularies.document.DomainElement = `${docKey}DomainElement`; -ns.aml.vocabularies.document.ParametrizedDeclaration = `${docKey}ParametrizedDeclaration`; -ns.aml.vocabularies.document.ExternalDomainElement = `${docKey}ExternalDomainElement`; -ns.aml.vocabularies.document.customDomainProperties = `${docKey}customDomainProperties`; -ns.aml.vocabularies.document.encodes = `${docKey}encodes`; -ns.aml.vocabularies.document.declares = `${docKey}declares`; -ns.aml.vocabularies.document.references = `${docKey}references`; -ns.aml.vocabularies.document.examples = `${docKey}examples`; -ns.aml.vocabularies.document.linkTarget = `${docKey}link-target`; -ns.aml.vocabularies.document.linkLabel = `${docKey}link-label`; -ns.aml.vocabularies.document.referenceId = `${docKey}reference-id`; -ns.aml.vocabularies.document.structuredValue = `${docKey}structuredValue`; -ns.aml.vocabularies.document.raw = `${docKey}raw`; -ns.aml.vocabularies.document.extends = `${docKey}extends`; -ns.aml.vocabularies.document.value = `${docKey}value`; -ns.aml.vocabularies.document.name = `${docKey}name`; -ns.aml.vocabularies.document.strict = `${docKey}strict`; -ns.aml.vocabularies.document.deprecated = `${docKey}deprecated`; -ns.aml.vocabularies.document.location = `${docKey}location`; -ns.aml.vocabularies.document.variable = `${docKey}variable`; -ns.aml.vocabularies.document.target = `${docKey}target`; -ns.aml.vocabularies.document.dataNode = `${docKey}dataNode`; -ns.aml.vocabularies.document.root = `${docKey}root`; -ns.aml.vocabularies.document.usage = `${docKey}usage`; -ns.aml.vocabularies.document.version = `${docKey}version`; -ns.aml.vocabularies.core = {}; -ns.aml.vocabularies.core.key = `${ns.aml.vocabularies.key}core#`; -const coreKey = ns.aml.vocabularies.core.key; -ns.aml.vocabularies.core.toString = () => coreKey; -ns.aml.vocabularies.core.CreativeWork = `${coreKey}CreativeWork`; -ns.aml.vocabularies.core.version = `${coreKey}version`; -ns.aml.vocabularies.core.urlTemplate = `${coreKey}urlTemplate`; -ns.aml.vocabularies.core.displayName = `${coreKey}displayName`; -ns.aml.vocabularies.core.title = `${coreKey}title`; -ns.aml.vocabularies.core.name = `${coreKey}name`; -ns.aml.vocabularies.core.description = `${coreKey}description`; -ns.aml.vocabularies.core.documentation = `${coreKey}documentation`; -ns.aml.vocabularies.core.summary = `${coreKey}summary`; -ns.aml.vocabularies.core.provider = `${coreKey}provider`; -ns.aml.vocabularies.core.email = `${coreKey}email`; -ns.aml.vocabularies.core.url = `${coreKey}url`; -ns.aml.vocabularies.core.termsOfService = `${coreKey}termsOfService`; -ns.aml.vocabularies.core.license = `${coreKey}license`; -ns.aml.vocabularies.core.mediaType = `${coreKey}mediaType`; -ns.aml.vocabularies.core.extensionName = `${coreKey}extensionName`; -ns.aml.vocabularies.core.deprecated = `${coreKey}deprecated`; -ns.aml.vocabularies.security = {}; -ns.aml.vocabularies.security.key = `${ns.aml.vocabularies.key}security#`; -const secKey = ns.aml.vocabularies.security.key; -ns.aml.vocabularies.security.toString = () => secKey; -ns.aml.vocabularies.security.ParametrizedSecurityScheme = `${secKey}ParametrizedSecurityScheme`; -ns.aml.vocabularies.security.SecuritySchemeFragment = `${secKey}SecuritySchemeFragment`; -ns.aml.vocabularies.security.SecurityScheme = `${secKey}SecurityScheme`; -ns.aml.vocabularies.security.OAuth1Settings = `${secKey}OAuth1Settings`; -ns.aml.vocabularies.security.OAuth2Settings = `${secKey}OAuth2Settings`; -ns.aml.vocabularies.security.OAuth2Flow = `${secKey}OAuth2Flow`; -ns.aml.vocabularies.security.Scope = `${secKey}Scope`; -ns.aml.vocabularies.security.Settings = `${secKey}Settings`; -ns.aml.vocabularies.security.HttpSettings = `${secKey}HttpSettings`; -ns.aml.vocabularies.security.ApiKeySettings = `${secKey}ApiKeySettings`; -ns.aml.vocabularies.security.OpenIdConnectSettings = `${secKey}OpenIdConnectSettings`; -ns.aml.vocabularies.security.security = `${secKey}security`; -ns.aml.vocabularies.security.scheme = `${secKey}scheme`; -ns.aml.vocabularies.security.schemes = `${secKey}schemes`; -ns.aml.vocabularies.security.settings = `${secKey}settings`; -ns.aml.vocabularies.security.name = `${secKey}name`; -ns.aml.vocabularies.security.type = `${secKey}type`; -ns.aml.vocabularies.security.scope = `${secKey}scope`; -ns.aml.vocabularies.security.accessTokenUri = `${secKey}accessTokenUri`; -ns.aml.vocabularies.security.authorizationUri = `${secKey}authorizationUri`; -ns.aml.vocabularies.security.authorizationGrant = `${secKey}authorizationGrant`; -ns.aml.vocabularies.security.flows = `${secKey}flows`; -ns.aml.vocabularies.security.flow = `${secKey}flow`; -ns.aml.vocabularies.security.signature = `${secKey}signature`; -ns.aml.vocabularies.security.tokenCredentialsUri = `${secKey}tokenCredentialsUri`; -ns.aml.vocabularies.security.requestTokenUri = `${secKey}requestTokenUri`; -ns.aml.vocabularies.security.refreshUri = `${secKey}refreshUri`; -ns.aml.vocabularies.security.securityRequirement = `${secKey}SecurityRequirement`; -ns.aml.vocabularies.security.openIdConnectUrl = `${secKey}openIdConnectUrl`; -ns.aml.vocabularies.security.bearerFormat = `${secKey}bearerFormat`; -ns.aml.vocabularies.security.in = `${secKey}in`; -ns.aml.vocabularies.apiContract = {}; -ns.aml.vocabularies.http = ns.aml.vocabularies.apiContract; -ns.aml.vocabularies.apiContract.key = `${ns.aml.vocabularies.key}apiContract#`; -const contractKey = ns.aml.vocabularies.apiContract.key; -ns.aml.vocabularies.apiContract.toString = () => contractKey; -ns.aml.vocabularies.apiContract.Payload = `${contractKey}Payload`; -ns.aml.vocabularies.apiContract.Request = `${contractKey}Request`; -ns.aml.vocabularies.apiContract.Response = `${contractKey}Response`; -ns.aml.vocabularies.apiContract.EndPoint = `${contractKey}EndPoint`; -ns.aml.vocabularies.apiContract.Parameter = `${contractKey}Parameter`; -ns.aml.vocabularies.apiContract.Operation = `${contractKey}Operation`; -ns.aml.vocabularies.apiContract.WebAPI = `${contractKey}WebAPI`; -ns.aml.vocabularies.apiContract.API = `${contractKey}API`; -ns.aml.vocabularies.apiContract.AsyncAPI = `${contractKey}AsyncAPI`; -ns.aml.vocabularies.apiContract.UserDocumentationFragment = `${contractKey}UserDocumentationFragment`; -ns.aml.vocabularies.apiContract.Example = `${contractKey}Example`; -ns.aml.vocabularies.apiContract.Server = `${contractKey}Server`; -ns.aml.vocabularies.apiContract.ParametrizedResourceType = `${contractKey}ParametrizedResourceType`; -ns.aml.vocabularies.apiContract.ParametrizedTrait = `${contractKey}ParametrizedTrait`; -ns.aml.vocabularies.apiContract.Callback = `${contractKey}Callback`; -ns.aml.vocabularies.apiContract.TemplatedLink = `${contractKey}TemplatedLink`; -ns.aml.vocabularies.apiContract.IriTemplateMapping = `${contractKey}IriTemplateMapping`; -ns.aml.vocabularies.apiContract.Tag = `${contractKey}Tag`; -ns.aml.vocabularies.apiContract.Message = `${contractKey}Message`; -ns.aml.vocabularies.apiContract.header = `${contractKey}header`; -ns.aml.vocabularies.apiContract.parameter = `${contractKey}parameter`; -ns.aml.vocabularies.apiContract.paramName = `${contractKey}paramName`; -ns.aml.vocabularies.apiContract.uriParameter = `${contractKey}uriParameter`; -ns.aml.vocabularies.apiContract.cookieParameter = `${contractKey}cookieParameter`; -ns.aml.vocabularies.apiContract.variable = `${contractKey}variable`; -ns.aml.vocabularies.apiContract.payload = `${contractKey}payload`; -ns.aml.vocabularies.apiContract.server = `${contractKey}server`; -ns.aml.vocabularies.apiContract.path = `${contractKey}path`; -ns.aml.vocabularies.apiContract.url = `${contractKey}url`; -ns.aml.vocabularies.apiContract.scheme = `${contractKey}scheme`; -ns.aml.vocabularies.apiContract.endpoint = `${contractKey}endpoint`; -ns.aml.vocabularies.apiContract.queryString = `${contractKey}queryString`; -ns.aml.vocabularies.apiContract.accepts = `${contractKey}accepts`; -ns.aml.vocabularies.apiContract.guiSummary = `${contractKey}guiSummary`; -ns.aml.vocabularies.apiContract.binding = `${contractKey}binding`; -ns.aml.vocabularies.apiContract.response = `${contractKey}response`; -ns.aml.vocabularies.apiContract.returns = `${contractKey}returns`; -ns.aml.vocabularies.apiContract.expects = `${contractKey}expects`; -ns.aml.vocabularies.apiContract.examples = `${contractKey}examples`; -ns.aml.vocabularies.apiContract.supportedOperation = `${contractKey}supportedOperation`; -ns.aml.vocabularies.apiContract.statusCode = `${contractKey}statusCode`; -ns.aml.vocabularies.apiContract.method = `${contractKey}method`; -ns.aml.vocabularies.apiContract.required = `${contractKey}required`; -ns.aml.vocabularies.apiContract.callback = `${contractKey}callback`; -ns.aml.vocabularies.apiContract.expression = `${contractKey}expression`; -ns.aml.vocabularies.apiContract.link = `${contractKey}link`; -ns.aml.vocabularies.apiContract.linkExpression = `${contractKey}linkExpression`; -ns.aml.vocabularies.apiContract.templateVariable = `${contractKey}templateVariable`; -ns.aml.vocabularies.apiContract.mapping = `${contractKey}mapping`; -ns.aml.vocabularies.apiContract.operationId = `${contractKey}operationId`; -ns.aml.vocabularies.apiContract.protocol = `${contractKey}protocol`; -ns.aml.vocabularies.apiContract.protocolVersion = `${contractKey}protocolVersion`; -ns.aml.vocabularies.apiContract.headerSchema = `${contractKey}headerSchema`; -ns.aml.vocabularies.apiContract.contentType = `${contractKey}contentType`; -ns.aml.vocabularies.apiContract.allowEmptyValue = `${contractKey}allowEmptyValue`; -ns.aml.vocabularies.apiContract.style = `${contractKey}style`; -ns.aml.vocabularies.apiContract.explode = `${contractKey}explode`; -ns.aml.vocabularies.apiContract.allowReserved = `${contractKey}allowReserved`; -ns.aml.vocabularies.apiContract.tag = `${contractKey}tag`; -ns.aml.vocabularies.shapes = {}; -ns.aml.vocabularies.shapes.key = `${ns.aml.vocabularies.key}shapes#`; -const shapesKey = ns.aml.vocabularies.shapes.key; -ns.aml.vocabularies.shapes.toString = () => shapesKey; -ns.aml.vocabularies.shapes.Shape = `${shapesKey}Shape`; -ns.aml.vocabularies.shapes.ScalarShape = `${shapesKey}ScalarShape`; -ns.aml.vocabularies.shapes.ArrayShape = `${shapesKey}ArrayShape`; -ns.aml.vocabularies.shapes.UnionShape = `${shapesKey}UnionShape`; -ns.aml.vocabularies.shapes.NilShape = `${shapesKey}NilShape`; -ns.aml.vocabularies.shapes.FileShape = `${shapesKey}FileShape`; -ns.aml.vocabularies.shapes.AnyShape = `${shapesKey}AnyShape`; -ns.aml.vocabularies.shapes.SchemaShape = `${shapesKey}SchemaShape`; -ns.aml.vocabularies.shapes.MatrixShape = `${shapesKey}MatrixShape`; -ns.aml.vocabularies.shapes.TupleShape = `${shapesKey}TupleShape`; -ns.aml.vocabularies.shapes.DataTypeFragment = `${shapesKey}DataTypeFragment`; -ns.aml.vocabularies.shapes.RecursiveShape = `${shapesKey}RecursiveShape`; -ns.aml.vocabularies.shapes.XMLSerializer = `${shapesKey}XMLSerializer`; -ns.aml.vocabularies.shapes.range = `${shapesKey}range`; -ns.aml.vocabularies.shapes.items = `${shapesKey}items`; -ns.aml.vocabularies.shapes.anyOf = `${shapesKey}anyOf`; -ns.aml.vocabularies.shapes.fileType = `${shapesKey}fileType`; -ns.aml.vocabularies.shapes.number = `${shapesKey}number`; -ns.aml.vocabularies.shapes.integer = `${shapesKey}integer`; -ns.aml.vocabularies.shapes.long = `${shapesKey}long`; -ns.aml.vocabularies.shapes.double = `${shapesKey}double`; -ns.aml.vocabularies.shapes.boolean = `${shapesKey}boolean`; -ns.aml.vocabularies.shapes.float = `${shapesKey}float`; -ns.aml.vocabularies.shapes.nil = `${shapesKey}nil`; -ns.aml.vocabularies.shapes.dateTimeOnly = `${shapesKey}dateTimeOnly`; -ns.aml.vocabularies.shapes.password = `${shapesKey}password`; -ns.aml.vocabularies.shapes.schema = `${shapesKey}schema`; -ns.aml.vocabularies.shapes.xmlSerialization = `${shapesKey}xmlSerialization`; -ns.aml.vocabularies.shapes.xmlName = `${shapesKey}xmlName`; -ns.aml.vocabularies.shapes.xmlAttribute = `${shapesKey}xmlAttribute`; -ns.aml.vocabularies.shapes.xmlWrapped = `${shapesKey}xmlWrapped`; -ns.aml.vocabularies.shapes.xmlNamespace = `${shapesKey}xmlNamespace`; -ns.aml.vocabularies.shapes.xmlPrefix = `${shapesKey}xmlPrefix`; -ns.aml.vocabularies.shapes.readOnly = `${shapesKey}readOnly`; -ns.aml.vocabularies.shapes.writeOnly = `${shapesKey}writeOnly`; -ns.aml.vocabularies.shapes.deprecated = `${shapesKey}deprecated`; -ns.aml.vocabularies.shapes.fixPoint = `${shapesKey}fixPoint`; -ns.aml.vocabularies.shapes.discriminator = `${shapesKey}discriminator`; -ns.aml.vocabularies.shapes.discriminatorValue = `${shapesKey}discriminatorValue`; -ns.aml.vocabularies.shapes.format = `${shapesKey}format`; -ns.aml.vocabularies.shapes.multipleOf = `${shapesKey}multipleOf`; -ns.aml.vocabularies.shapes.uniqueItems = `${shapesKey}uniqueItems`; -ns.aml.vocabularies.data = {}; -ns.aml.vocabularies.data.key = `${ns.aml.vocabularies.key}data#`; -const dataKey = ns.aml.vocabularies.data.key; -ns.aml.vocabularies.data.toString = () => dataKey; -ns.aml.vocabularies.data.Scalar = `${dataKey}Scalar`; -ns.aml.vocabularies.data.Object = `${dataKey}Object`; -ns.aml.vocabularies.data.Array = `${dataKey}Array`; -ns.aml.vocabularies.data.value = `${dataKey}value`; -ns.aml.vocabularies.data.type = `${dataKey}type`; -ns.aml.vocabularies.data.description = `${dataKey}description`; -ns.aml.vocabularies.data.required = `${dataKey}required`; -ns.aml.vocabularies.data.displayName = `${dataKey}displayName`; -ns.aml.vocabularies.data.minLength = `${dataKey}minLength`; -ns.aml.vocabularies.data.maxLength = `${dataKey}maxLength`; -ns.aml.vocabularies.data.default = `${dataKey}default`; -ns.aml.vocabularies.data.multipleOf = `${dataKey}multipleOf`; -ns.aml.vocabularies.data.minimum = `${dataKey}minimum`; -ns.aml.vocabularies.data.maximum = `${dataKey}maximum`; -ns.aml.vocabularies.data.enum = `${dataKey}enum`; -ns.aml.vocabularies.data.pattern = `${dataKey}pattern`; -ns.aml.vocabularies.data.items = `${dataKey}items`; -ns.aml.vocabularies.data.format = `${dataKey}format`; -ns.aml.vocabularies.data.example = `${dataKey}example`; -ns.aml.vocabularies.data.examples = `${dataKey}examples`; - -ns.aml.vocabularies.docSourceMaps = {}; -ns.aml.vocabularies.docSourceMaps.key = `${ns.aml.vocabularies.key}document-source-maps#`; -const dsmKey = ns.aml.vocabularies.docSourceMaps.key; -ns.aml.vocabularies.docSourceMaps.toString = () => dsmKey; -ns.aml.vocabularies.docSourceMaps.SourceMap = `${dsmKey}SourceMap`; -ns.aml.vocabularies.docSourceMaps.sources = `${dsmKey}sources`; -ns.aml.vocabularies.docSourceMaps.element = `${dsmKey}element`; -ns.aml.vocabularies.docSourceMaps.value = `${dsmKey}value`; -ns.aml.vocabularies.docSourceMaps.declaredElement = `${dsmKey}declared-element`; -ns.aml.vocabularies.docSourceMaps.trackedElement = `${dsmKey}tracked-element`; -ns.aml.vocabularies.docSourceMaps.parsedJsonSchema = `${dsmKey}parsed-json-schema`; -ns.aml.vocabularies.docSourceMaps.autoGeneratedName = `${dsmKey}auto-generated-name`; -ns.aml.vocabularies.docSourceMaps.lexical = `${dsmKey}lexical`; -ns.aml.vocabularies.docSourceMaps.synthesizedField = `${dsmKey}synthesized-field`; - -// W3 namespace -ns.w3 = {}; -ns.w3.key = 'http://www.w3.org/'; -ns.w3.rdfSyntax = {}; -ns.w3.rdfSyntax.key = `${ns.w3.key}1999/02/22-rdf-syntax-ns#`; -ns.w3.rdfSyntax.toString = () => ns.w3.rdfSyntax.key; -// TODO: is this unnecessary? -ns.w3.rdfSyntax.member = `${ns.w3.rdfSyntax.key}member`; -ns.w3.rdfSyntax.Seq = `${ns.w3.rdfSyntax.key}Seq`; -ns.w3.rdfSchema = {}; -ns.w3.rdfSchema.key = `${ns.w3.key}2000/01/rdf-schema#`; -ns.w3.rdfSchema.toString = () => ns.w3.rdfSchema.key; -ns.w3.rdfSchema.member = `${ns.w3.rdfSchema.key}member`; -ns.w3.rdfSchema.Seq = `${ns.w3.rdfSchema.key}Seq`; -ns.w3.hydra = {}; -ns.w3.hydra.key = `${ns.w3.key}ns/hydra/`; -ns.w3.hydra.toString = () => ns.w3.hydra.key; -ns.w3.hydra.core = ns.aml.vocabularies.apiContract; -ns.w3.xmlSchema = {}; -ns.w3.xmlSchema.key = `${ns.w3.key}2001/XMLSchema#`; -ns.w3.xmlSchema.toString = () => ns.w3.xmlSchema.key; -ns.w3.xmlSchema.boolean = `${ns.w3.xmlSchema.key}boolean`; -ns.w3.xmlSchema.string = `${ns.w3.xmlSchema.key}string`; -ns.w3.xmlSchema.number = `${ns.w3.xmlSchema.key}number`; -ns.w3.xmlSchema.integer = `${ns.w3.xmlSchema.key}integer`; -ns.w3.xmlSchema.long = `${ns.w3.xmlSchema.key}long`; -ns.w3.xmlSchema.double = `${ns.w3.xmlSchema.key}double`; -ns.w3.xmlSchema.float = `${ns.w3.xmlSchema.key}float`; -ns.w3.xmlSchema.nil = `${ns.w3.xmlSchema.key}nil`; -ns.w3.xmlSchema.dateTime = `${ns.w3.xmlSchema.key}dateTime`; -ns.w3.xmlSchema.time = `${ns.w3.xmlSchema.key}time`; -ns.w3.xmlSchema.date = `${ns.w3.xmlSchema.key}date`; -ns.w3.xmlSchema.base64Binary = `${ns.w3.xmlSchema.key}base64Binary`; -// w3 types -ns.w3.shacl = {}; -ns.w3.shacl.key = `${ns.w3.key}ns/shacl#`; -const n2shaclName = ns.w3.shacl.key; -ns.w3.shacl.toString = () => n2shaclName; -ns.w3.shacl.Shape = `${n2shaclName}Shape`; -ns.w3.shacl.NodeShape = `${n2shaclName}NodeShape`; -ns.w3.shacl.SchemaShape = `${n2shaclName}SchemaShape`; -ns.w3.shacl.PropertyShape = `${n2shaclName}PropertyShape`; -ns.w3.shacl.in = `${n2shaclName}in`; -ns.w3.shacl.defaultValue = `${n2shaclName}defaultValue`; -ns.w3.shacl.defaultValueStr = `${n2shaclName}defaultValueStr`; -ns.w3.shacl.pattern = `${n2shaclName}pattern`; -ns.w3.shacl.minInclusive = `${n2shaclName}minInclusive`; -ns.w3.shacl.maxInclusive = `${n2shaclName}maxInclusive`; -ns.w3.shacl.multipleOf = `${n2shaclName}multipleOf`; -ns.w3.shacl.minLength = `${n2shaclName}minLength`; -ns.w3.shacl.maxLength = `${n2shaclName}maxLength`; -ns.w3.shacl.fileType = `${n2shaclName}fileType`; -ns.w3.shacl.and = `${n2shaclName}and`; -ns.w3.shacl.property = `${n2shaclName}property`; -ns.w3.shacl.name = `${n2shaclName}name`; -ns.w3.shacl.raw = `${n2shaclName}raw`; -ns.w3.shacl.datatype = `${n2shaclName}datatype`; -ns.w3.shacl.minCount = `${n2shaclName}minCount`; -ns.w3.shacl.maxCount = `${n2shaclName}maxCount`; -ns.w3.shacl.xone = `${n2shaclName}xone`; -ns.w3.shacl.not = `${n2shaclName}not`; -ns.w3.shacl.or = `${n2shaclName}or`; -ns.w3.shacl.closed = `${n2shaclName}closed`; -ns.w3.shacl.path = `${n2shaclName}path`; -// Hydra shortcuts -ns.w3.hydra.supportedOperation = `${contractKey}supportedOperation`; -// Schema org namespace -ns.schema = {}; -ns.schema.key = coreKey; -ns.schema.toString = () => coreKey; -ns.schema.name = `${ns.schema.key}name`; -ns.schema.desc = `${ns.schema.key}description`; -ns.schema.doc = `${ns.schema.key}documentation`; -ns.schema.webApi = `${contractKey}WebAPI`; -ns.schema.creativeWork = `${coreKey}CreativeWork`; -ns.schema.displayName = `${coreKey}displayName`; -ns.schema.title = `${coreKey}title`; - -Object.freeze(ns.raml); -Object.freeze(ns.aml); -Object.freeze(ns.aml.vocabularies); -Object.freeze(ns.aml.vocabularies.shapes); -Object.freeze(ns.aml.vocabularies.data); -Object.freeze(ns.aml.vocabularies.apiContract); -Object.freeze(ns.aml.vocabularies.security); -Object.freeze(ns.aml.vocabularies.core); -Object.freeze(ns.aml.vocabularies.document); -Object.freeze(ns.w3); -Object.freeze(ns.w3.rdfSyntax); -Object.freeze(ns.w3.hydra); -Object.freeze(ns.w3.shacl); -Object.freeze(ns.schema); -Object.freeze(ns); diff --git a/src/helpers/Namespace.ts b/src/helpers/Namespace.ts new file mode 100644 index 0000000..17b5615 --- /dev/null +++ b/src/helpers/Namespace.ts @@ -0,0 +1,329 @@ +const amlKey = 'http://a.ml/'; +const vocKey = `${amlKey}vocabularies/`; +const docKey = `${vocKey}document#`; +const coreKey = `${vocKey}core#`; +const secKey = `${vocKey}security#`; +const contractKey = `${vocKey}apiContract#`; +const shapesKey = `${vocKey}shapes#`; +const dataKey = `${vocKey}data#`; +const dsmKey = `${vocKey}document-source-maps#`; +const w3Key = 'http://www.w3.org/'; +const shaclKey = `${w3Key}ns/shacl#`; +const xmlSchemaKey = `${w3Key}2001/XMLSchema#`; +const rdfSyntaxKey = `${w3Key}1999/02/22-rdf-syntax-ns#`; +const rdfSchemaKey = `${w3Key}2000/01/rdf-schema#`; + +/** + * A namespace for AMF properties. + */ +export const ns = { + aml: { + key: 'http://a.ml/', + vocabularies: { + key: vocKey, + document: { + key: docKey, + Module: `${docKey}Module`, + Document: `${docKey}Document`, + SecuritySchemeFragment: `${docKey}SecuritySchemeFragment`, + UserDocumentation: `${docKey}UserDocumentation`, + DataType: `${docKey}DataType`, + NamedExamples: `${docKey}NamedExamples`, + DomainElement: `${docKey}DomainElement`, + ParametrizedDeclaration: `${docKey}ParametrizedDeclaration`, + ExternalDomainElement: `${docKey}ExternalDomainElement`, + + customDomainProperties: `${docKey}customDomainProperties`, + encodes: `${docKey}encodes`, + declares: `${docKey}declares`, + references: `${docKey}references`, + examples: `${docKey}examples`, + linkTarget: `${docKey}link-target`, + linkLabel: `${docKey}link-label`, + referenceId: `${docKey}reference-id`, + structuredValue: `${docKey}structuredValue`, + raw: `${docKey}raw`, + extends: `${docKey}extends`, + value: `${docKey}value`, + name: `${docKey}name`, + strict: `${docKey}strict`, + deprecated: `${docKey}deprecated`, + location: `${docKey}location`, + variable: `${docKey}variable`, + target: `${docKey}target`, + dataNode: `${docKey}dataNode`, + root: `${docKey}root`, + usage: `${docKey}usage`, + version: `${docKey}version`, + }, + core: { + key: coreKey, + CreativeWork: `${coreKey}CreativeWork`, + + version: `${coreKey}version`, + urlTemplate: `${coreKey}urlTemplate`, + displayName: `${coreKey}displayName`, + title: `${coreKey}title`, + name: `${coreKey}name`, + description: `${coreKey}description`, + documentation: `${coreKey}documentation`, + summary: `${coreKey}summary`, + provider: `${coreKey}provider`, + email: `${coreKey}email`, + url: `${coreKey}url`, + termsOfService: `${coreKey}termsOfService`, + license: `${coreKey}license`, + mediaType: `${coreKey}mediaType`, + extensionName: `${coreKey}extensionName`, + deprecated: `${coreKey}deprecated`, + }, + security: { + key: secKey, + ParametrizedSecurityScheme: `${secKey}ParametrizedSecurityScheme`, + SecuritySchemeFragment: `${secKey}SecuritySchemeFragment`, + SecurityScheme: `${secKey}SecurityScheme`, + OAuth1Settings: `${secKey}OAuth1Settings`, + OAuth2Settings: `${secKey}OAuth2Settings`, + OAuth2Flow: `${secKey}OAuth2Flow`, + Scope: `${secKey}Scope`, + Settings: `${secKey}Settings`, + HttpSettings: `${secKey}HttpSettings`, + ApiKeySettings: `${secKey}ApiKeySettings`, + OpenIdConnectSettings: `${secKey}OpenIdConnectSettings`, + security: `${secKey}security`, + scheme: `${secKey}scheme`, + schemes: `${secKey}schemes`, + settings: `${secKey}settings`, + name: `${secKey}name`, + type: `${secKey}type`, + scope: `${secKey}scope`, + accessTokenUri: `${secKey}accessTokenUri`, + authorizationUri: `${secKey}authorizationUri`, + authorizationGrant: `${secKey}authorizationGrant`, + flows: `${secKey}flows`, + flow: `${secKey}flow`, + signature: `${secKey}signature`, + tokenCredentialsUri: `${secKey}tokenCredentialsUri`, + requestTokenUri: `${secKey}requestTokenUri`, + refreshUri: `${secKey}refreshUri`, + securityRequirement: `${secKey}SecurityRequirement`, + openIdConnectUrl: `${secKey}openIdConnectUrl`, + bearerFormat: `${secKey}bearerFormat`, + in: `${secKey}in`, + }, + apiContract: { + key: contractKey, + Payload: `${contractKey}Payload`, + Request: `${contractKey}Request`, + Response: `${contractKey}Response`, + EndPoint: `${contractKey}EndPoint`, + Parameter: `${contractKey}Parameter`, + Operation: `${contractKey}Operation`, + WebAPI: `${contractKey}WebAPI`, + API: `${contractKey}API`, + AsyncAPI: `${contractKey}AsyncAPI`, + UserDocumentationFragment: `${contractKey}UserDocumentationFragment`, + Example: `${contractKey}Example`, + Server: `${contractKey}Server`, + ParametrizedResourceType: `${contractKey}ParametrizedResourceType`, + ParametrizedTrait: `${contractKey}ParametrizedTrait`, + Callback: `${contractKey}Callback`, + TemplatedLink: `${contractKey}TemplatedLink`, + IriTemplateMapping: `${contractKey}IriTemplateMapping`, + Tag: `${contractKey}Tag`, + Message: `${contractKey}Message`, + + header: `${contractKey}header`, + parameter: `${contractKey}parameter`, + paramName: `${contractKey}paramName`, + uriParameter: `${contractKey}uriParameter`, + cookieParameter: `${contractKey}cookieParameter`, + variable: `${contractKey}variable`, + payload: `${contractKey}payload`, + server: `${contractKey}server`, + path: `${contractKey}path`, + url: `${contractKey}url`, + scheme: `${contractKey}scheme`, + endpoint: `${contractKey}endpoint`, + queryString: `${contractKey}queryString`, + accepts: `${contractKey}accepts`, + guiSummary: `${contractKey}guiSummary`, + binding: `${contractKey}binding`, + response: `${contractKey}response`, + returns: `${contractKey}returns`, + expects: `${contractKey}expects`, + examples: `${contractKey}examples`, + supportedOperation: `${contractKey}supportedOperation`, + statusCode: `${contractKey}statusCode`, + method: `${contractKey}method`, + required: `${contractKey}required`, + callback: `${contractKey}callback`, + expression: `${contractKey}expression`, + link: `${contractKey}link`, + linkExpression: `${contractKey}linkExpression`, + templateVariable: `${contractKey}templateVariable`, + mapping: `${contractKey}mapping`, + operationId: `${contractKey}operationId`, + protocol: `${contractKey}protocol`, + protocolVersion: `${contractKey}protocolVersion`, + headerSchema: `${contractKey}headerSchema`, + contentType: `${contractKey}contentType`, + allowEmptyValue: `${contractKey}allowEmptyValue`, + style: `${contractKey}style`, + explode: `${contractKey}explode`, + allowReserved: `${contractKey}allowReserved`, + tag: `${contractKey}tag`, + }, + shapes: { + key: shapesKey, + Shape: `${shapesKey}Shape`, + ScalarShape: `${shapesKey}ScalarShape`, + ArrayShape: `${shapesKey}ArrayShape`, + UnionShape: `${shapesKey}UnionShape`, + NilShape: `${shapesKey}NilShape`, + FileShape: `${shapesKey}FileShape`, + AnyShape: `${shapesKey}AnyShape`, + SchemaShape: `${shapesKey}SchemaShape`, + MatrixShape: `${shapesKey}MatrixShape`, + TupleShape: `${shapesKey}TupleShape`, + RecursiveShape: `${shapesKey}RecursiveShape`, + DataTypeFragment: `${shapesKey}DataTypeFragment`, + XMLSerializer: `${shapesKey}XMLSerializer`, + + // data types + number: `${shapesKey}number`, + integer: `${shapesKey}integer`, + long: `${shapesKey}long`, + double: `${shapesKey}double`, + boolean: `${shapesKey}boolean`, + float: `${shapesKey}float`, + nil: `${shapesKey}nil`, + password: `${shapesKey}password`, + + // API shapes + dateTimeOnly: `${shapesKey}dateTimeOnly`, + + range: `${shapesKey}range`, + items: `${shapesKey}items`, + anyOf: `${shapesKey}anyOf`, + fileType: `${shapesKey}fileType`, + schema: `${shapesKey}schema`, + xmlSerialization: `${shapesKey}xmlSerialization`, + xmlName: `${shapesKey}xmlName`, + xmlAttribute: `${shapesKey}xmlAttribute`, + xmlWrapped: `${shapesKey}xmlWrapped`, + xmlNamespace: `${shapesKey}xmlNamespace`, + xmlPrefix: `${shapesKey}xmlPrefix`, + readOnly: `${shapesKey}readOnly`, + writeOnly: `${shapesKey}writeOnly`, + deprecated: `${shapesKey}deprecated`, + fixPoint: `${shapesKey}fixPoint`, + discriminator: `${shapesKey}discriminator`, + discriminatorValue: `${shapesKey}discriminatorValue`, + format: `${shapesKey}format`, + multipleOf: `${shapesKey}multipleOf`, + uniqueItems: `${shapesKey}uniqueItems`, + }, + data: { + key: dataKey, + Scalar: `${dataKey}Scalar`, + Object: `${dataKey}Object`, + Array: `${dataKey}Array`, + Node: `${dataKey}Node`, + + value: `${dataKey}value`, + type: `${dataKey}type`, + description: `${dataKey}description`, + required: `${dataKey}required`, + displayName: `${dataKey}displayName`, + minLength: `${dataKey}minLength`, + maxLength: `${dataKey}maxLength`, + default: `${dataKey}default`, + multipleOf: `${dataKey}multipleOf`, + minimum: `${dataKey}minimum`, + maximum: `${dataKey}maximum`, + enum: `${dataKey}enum`, + pattern: `${dataKey}pattern`, + items: `${dataKey}items`, + format: `${dataKey}format`, + example: `${dataKey}example`, + examples: `${dataKey}examples`, + }, + docSourceMaps: { + key: dsmKey, + SourceMap: `${dsmKey}SourceMap`, + sources: `${dsmKey}sources`, + element: `${dsmKey}element`, + value: `${dsmKey}value`, + declaredElement: `${dsmKey}declared-element`, + trackedElement: `${dsmKey}tracked-element`, + parsedJsonSchema: `${dsmKey}parsed-json-schema`, + autoGeneratedName: `${dsmKey}auto-generated-name`, + lexical: `${dsmKey}lexical`, + synthesizedField: `${dsmKey}synthesized-field`, + }, + }, + }, + w3: { + key: w3Key, + shacl: { + key: shaclKey, + Shape: `${shaclKey}Shape`, + NodeShape: `${shaclKey}NodeShape`, + SchemaShape: `${shaclKey}SchemaShape`, + PropertyShape: `${shaclKey}PropertyShape`, + in: `${shaclKey}in`, + defaultValue: `${shaclKey}defaultValue`, + defaultValueStr: `${shaclKey}defaultValueStr`, + pattern: `${shaclKey}pattern`, + minInclusive: `${shaclKey}minInclusive`, + maxInclusive: `${shaclKey}maxInclusive`, + multipleOf: `${shaclKey}multipleOf`, + minLength: `${shaclKey}minLength`, + maxLength: `${shaclKey}maxLength`, + fileType: `${shaclKey}fileType`, + and: `${shaclKey}and`, + property: `${shaclKey}property`, + name: `${shaclKey}name`, + raw: `${shaclKey}raw`, + datatype: `${shaclKey}datatype`, + minCount: `${shaclKey}minCount`, + maxCount: `${shaclKey}maxCount`, + xone: `${shaclKey}xone`, + not: `${shaclKey}not`, + or: `${shaclKey}or`, + closed: `${shaclKey}closed`, + path: `${shaclKey}path`, + }, + // XML schema data types + xmlSchema: { + key: xmlSchemaKey, + boolean: `${xmlSchemaKey}boolean`, + string: `${xmlSchemaKey}string`, + number: `${xmlSchemaKey}number`, + integer: `${xmlSchemaKey}integer`, + long: `${xmlSchemaKey}long`, + double: `${xmlSchemaKey}double`, + float: `${xmlSchemaKey}float`, + nil: `${xmlSchemaKey}nil`, + dateTime: `${xmlSchemaKey}dateTime`, + time: `${xmlSchemaKey}time`, + date: `${xmlSchemaKey}date`, + base64Binary: `${xmlSchemaKey}base64Binary`, + byte: `${xmlSchemaKey}byte`, + }, + rdfSyntax: { + key: rdfSyntaxKey, + + Seq: `${rdfSyntaxKey}Seq`, + member: `${rdfSyntaxKey}member`, + }, + + rdfSchema: { + key: rdfSchemaKey, + + Seq: `${rdfSchemaKey}Seq`, + member: `${rdfSchemaKey}member`, + } + }, +}; diff --git a/src/helpers/amf.d.ts b/src/helpers/amf.ts similarity index 99% rename from src/helpers/amf.d.ts rename to src/helpers/amf.ts index dd5ead3..eecaeac 100644 --- a/src/helpers/amf.d.ts +++ b/src/helpers/amf.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-empty-interface */ export declare interface DomainElement { '@id': string; '@type': string[]; @@ -415,8 +416,9 @@ export interface DocumentSourceMaps extends DomainElement { 'http://a.ml/vocabularies/document-source-maps#tracked-element'?: SynthesizedField[]; } -export interface SynthesizedField { +export interface SynthesizedField extends DomainElement { '@id': string; + // '@context'?: Record; 'http://a.ml/vocabularies/document-source-maps#element'?: LdValueString[]; 'http://a.ml/vocabularies/document-source-maps#value'?: LdValueString[]; } diff --git a/src/helpers/api.d.ts b/src/helpers/api.ts similarity index 96% rename from src/helpers/api.d.ts rename to src/helpers/api.ts index cf38cd2..7c1c5ab 100644 --- a/src/helpers/api.d.ts +++ b/src/helpers/api.ts @@ -1,6 +1,7 @@ -import { Server } from "./amf"; +/* eslint-disable @typescript-eslint/no-empty-interface */ +import { Server } from "./amf.js"; -interface ServersQueryOptions { +export interface ServersQueryOptions { /** * An EndPoint to look for the servers in */ @@ -11,7 +12,7 @@ interface ServersQueryOptions { methodId?: string } -interface ServerQueryOptions { +export interface ServerQueryOptions { /** * An EndPoint to look for the servers in. Required if Operation is provided */ @@ -26,7 +27,7 @@ interface ServerQueryOptions { id?: string; } -interface ComputeUriOptions { +export interface ComputeUriOptions { /** * Model for the current server, if available. */ @@ -95,11 +96,13 @@ export interface ApiOrganization extends ApiDomainProperty { url?: string; name?: string; email?: string; + sourceMaps?: ApiDocumentSourceMaps; } export interface ApiLicense extends ApiDomainProperty { url?: string; name?: string; + sourceMaps?: ApiDocumentSourceMaps; } export interface ApiEndPoint extends ApiDomainProperty { @@ -490,6 +493,8 @@ export interface ApiEncoding { } export interface ApiDocumentSourceMaps { + id?: string; + types?: string[]; synthesizedField?: ApiSynthesizedField[]; lexical?: ApiSynthesizedField[]; trackedElement?: ApiSynthesizedField; @@ -508,11 +513,13 @@ export interface ApiParametrizedDeclaration extends ApiDomainProperty { name?: string; target?: ApiAbstractDeclaration; variables: ApiVariableValue[]; + sourceMaps?: ApiDocumentSourceMaps; } export interface ApiVariableValue extends ApiDomainProperty { name: string; value?: ApiDataNode; + sourceMaps?: ApiDocumentSourceMaps; } export interface ApiAbstractDeclaration extends ApiDomainProperty { @@ -520,6 +527,7 @@ export interface ApiAbstractDeclaration extends ApiDomainProperty { description?: string; dataNode?: ApiDataNode; variables: string[]; + sourceMaps?: ApiDocumentSourceMaps; } export interface ApiParametrizedTrait extends ApiParametrizedDeclaration {} diff --git a/src/plugins/NavigationCommands.d.ts b/src/plugins/NavigationCommands.d.ts deleted file mode 100644 index 33ce94f..0000000 --- a/src/plugins/NavigationCommands.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ContextMenuCommand } from '@api-client/context-menu'; - -declare const commands: ContextMenuCommand[]; -export default commands; diff --git a/src/plugins/NavigationCommands.js b/src/plugins/NavigationCommands.ts similarity index 50% rename from src/plugins/NavigationCommands.js rename to src/plugins/NavigationCommands.ts index 4ba3fa0..f9c88b6 100644 --- a/src/plugins/NavigationCommands.js +++ b/src/plugins/NavigationCommands.ts @@ -1,13 +1,13 @@ -/** @typedef {import('@api-client/context-menu').ContextMenuCommand} ContextMenuCommand */ -/** @typedef {import('../elements/ApiNavigationElement').default} ApiNavigationElement */ +import { ContextMenuCommand } from '@api-client/context-menu'; +import ApiNavigationElement from '../elements/ApiNavigationElement.js'; -const commands = /** @type ContextMenuCommand[] */ ([ +const commands: ContextMenuCommand[] = [ { target: 'all', label: 'Expand all', execute: (ctx) => { - const menu = /** @type ApiNavigationElement */ (ctx.root); + const menu = ctx.root as ApiNavigationElement; menu.expandAll(); }, }, @@ -15,7 +15,7 @@ const commands = /** @type ContextMenuCommand[] */ ([ target: 'all', label: 'Collapse all', execute: (ctx) => { - const menu = /** @type ApiNavigationElement */ (ctx.root); + const menu = ctx.root as ApiNavigationElement; menu.collapseAll(); }, }, @@ -23,7 +23,7 @@ const commands = /** @type ContextMenuCommand[] */ ([ target: 'endpoints', label: 'Expand all endpoints', execute: (ctx) => { - const menu = /** @type ApiNavigationElement */ (ctx.root); + const menu = ctx.root as ApiNavigationElement; menu.expandAllEndpoints(); }, }, @@ -31,9 +31,9 @@ const commands = /** @type ContextMenuCommand[] */ ([ target: 'endpoints', label: 'Collapse all endpoints', execute: (ctx) => { - const menu = /** @type ApiNavigationElement */ (ctx.root); + const menu = ctx.root as ApiNavigationElement; menu.collapseAllEndpoints(); }, }, -]); +]; export default commands; diff --git a/src/plugins/NavigationContextMenu.d.ts b/src/plugins/NavigationContextMenu.d.ts deleted file mode 100644 index 4e71b92..0000000 --- a/src/plugins/NavigationContextMenu.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ContextMenu } from '@api-client/context-menu'; - -export declare class NavigationContextMenu extends ContextMenu { - /** - * Finds the click target which - */ - findTarget(e: MouseEvent): HTMLElement|SVGElement|undefined; - - /** - * Maps an element to an internal target name. - * - * @param element The context click target - * @returns The internal target name. - */ - elementToTarget(element: HTMLElement): string|undefined; -} diff --git a/src/plugins/NavigationContextMenu.js b/src/plugins/NavigationContextMenu.ts similarity index 70% rename from src/plugins/NavigationContextMenu.js rename to src/plugins/NavigationContextMenu.ts index 1764718..41bcf1d 100644 --- a/src/plugins/NavigationContextMenu.js +++ b/src/plugins/NavigationContextMenu.ts @@ -4,17 +4,14 @@ export class NavigationContextMenu extends ContextMenu { /** * Finds the click target which can be one of the model objects * or SVG elements. - * - * @param {MouseEvent} e - * @return {HTMLElement|SVGElement|undefined} */ - findTarget(e) { + findTarget(e: MouseEvent): HTMLElement|SVGElement|undefined { let target; const path = e.composedPath(); while(path.length > 0) { - const candidate = /** @type Element */ (path.shift()); + const candidate = path.shift() as Element; if (candidate === this.workspace || (candidate.nodeType === Node.ELEMENT_NODE && (candidate.classList.contains('list-item') || candidate.classList.contains('section-title')))) { - target = /** @type HTMLElement */ (candidate); + target = candidate as HTMLElement; break; } } @@ -24,10 +21,10 @@ export class NavigationContextMenu extends ContextMenu { /** * Maps an element to an internal target name. * - * @param {HTMLElement} element The context click target - * @return {string|undefined} The internal target name. + * @param element The context click target + * @returns The internal target name. */ - elementToTarget(element) { + elementToTarget(element: HTMLElement): string|undefined { if (element === this.workspace) { return 'root'; } diff --git a/src/store/AmfGraphStore.js b/src/store/AmfGraphStore.js deleted file mode 100644 index efacda7..0000000 --- a/src/store/AmfGraphStore.js +++ /dev/null @@ -1,68 +0,0 @@ -import { v4 } from '@advanced-rest-client/uuid'; -import { AmfStore } from './AmfStore.js'; - -/** @typedef {import('../helpers/amf').DomainElement} DomainElement */ - -/** - * The AMF graph store that hosts multiple instances of the AMF graph model. - * - * Note, all methods are asynchronous so this class can be extended to support async communication - * with the store (like HTTP or WS). - */ -export class AmfGraphStore { - /** - * @param {EventTarget=} target The event target to dispatch the events on. - */ - constructor(target=window) { - /** @type {Map} */ - this.apis = new Map(); - this.target = target; - } - - /** - * Creates a new store object. - * @param {DomainElement} graph The graph model to use to initialize the store. - * @returns {Promise} The store id to be used to reference when querying the store. - */ - async add(graph) { - const id = v4(); - const instance = new AmfStore(this.target, graph); - this.apis.set(id, instance); - return id; - } - - /** - * Removes all APIs from the store. - * @returns {Promise} - */ - async clear() { - this.apis.clear(); - } - - /** - * Removes a specific API from the store. - * @param {string} id The graph store identifier generated when calling `add()`. - * @returns {Promise} - */ - async delete(id) { - this.apis.delete(id); - } - - /** - * Proxies a read command to the store. - * @param {string} id The graph store identifier generated when calling `add()`. - * @param {string} command The command (method name) to call on the store. - * @param {...any} args The list of command arguments. - * @returns {Promise} - */ - async read(id, command, ...args) { - if (!this.apis.has(id)) { - throw new Error(`No graph defined for ${id}`); - } - const instance = this.apis.get(id); - if (typeof instance[command] !== 'function') { - throw new Error(`The command ${command} is not callable on the graph store.`); - } - return instance[command](...args); - } -} diff --git a/src/store/AmfGraphStore.d.ts b/src/store/AmfGraphStore.ts similarity index 50% rename from src/store/AmfGraphStore.d.ts rename to src/store/AmfGraphStore.ts index 8a49e40..6ec13f2 100644 --- a/src/store/AmfGraphStore.d.ts +++ b/src/store/AmfGraphStore.ts @@ -1,4 +1,5 @@ -import { DomainElement } from '../helpers/amf'; +import { v4 } from '@advanced-rest-client/uuid'; +import { DomainElement } from '../helpers/amf.js'; import { AmfStore } from './AmfStore.js'; /** @@ -9,29 +10,43 @@ import { AmfStore } from './AmfStore.js'; */ export class AmfGraphStore { apis: Map; + target: EventTarget; + /** * @param target The event target to dispatch the events on. */ - constructor(target?: EventTarget); + constructor(target: EventTarget = window) { + this.apis = new Map(); + this.target = target; + } /** * Creates a new store object. * @param graph The graph model to use to initialize the store. * @returns The store id to be used to reference when querying the store. */ - add(graph: DomainElement): Promise; + async add(graph: DomainElement): Promise { + const id = v4(); + const instance = new AmfStore(this.target, graph); + this.apis.set(id, instance); + return id; + } /** * Removes all APIs from the store. */ - clear(): Promise; + async clear(): Promise { + this.apis.clear(); + } /** * Removes a specific API from the store. * @param id The graph store identifier generated when calling `add()`. */ - delete(id: string): Promise; + async delete(id: string): Promise { + this.apis.delete(id); + } /** * Proxies a read command to the store. @@ -39,5 +54,15 @@ export class AmfGraphStore { * @param command The command (method name) to call on the store. * @param args The list of command arguments. */ - read(id: string, command: string, ...args: any): Promise; + async read(id: string, command: string, ...args: any[]): Promise { + if (!this.apis.has(id)) { + throw new Error(`No graph defined for ${id}`); + } + const instance = this.apis.get(id) as AmfStore; + const typedCmd = command as keyof AmfStore; + if (typeof instance[typedCmd] !== 'function') { + throw new Error(`The command ${command} is not callable on the graph store.`); + } + return (instance[typedCmd] as (...opts: any[]) => Promise)(...args); + } } diff --git a/src/store/AmfStore.d.ts b/src/store/AmfStore.d.ts deleted file mode 100644 index 1bc586c..0000000 --- a/src/store/AmfStore.d.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api'; -import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types'; - -/** - * The store that provides an API to read data from the AMF graph model. - */ -export class AmfStore { - /** - * For future use. - * Indicates that this store is read only. - */ - readonly?: boolean; - - /** - * @returns The list of domain types for the currently loaded document. - */ - getDocumentTypes(): string[]; - - /** - * Gathers information about the loaded document. - * This is mainly used by the `api-documentation` element to decide which documentation to render. - */ - documentMeta(): Promise; - - /** - * @returns API summary for the summary view. - */ - apiSummary(): Promise; - - /** - * @returns Currently loaded API's protocols - */ - apiProtocols(): Promise; - - /** - * @returns Currently loaded API's version - */ - apiVersion(): Promise; - - /** - * Reads an endpoint by its id. - * @param id The domain id of the endpoint. - */ - getEndpoint(id: string): Promise; - - /** - * Reads an endpoint by its path. - * @param path The path value of the endpoint or channel name. - */ - getEndpointByPath(path: string): Promise; - - /** - * Lists all endpoints with operations included into the result. - */ - listEndpointsWithOperations(): Promise; - - /** - * Queries for the list of servers for method, if defined, or endpoint, if defined, or root level - * @param query Server query options - * @returns The list of servers for given query. - */ - queryServers(query?: ServersQueryOptions): Promise; - - /** - * Reads the operation model. - * @param operationId The domain id of the operation to read. - * @param endpointId Optional endpoint id. When not set it searches through all endpoints. - */ - getOperation(operationId: string, endpointId?: string): Promise; - - /** - * Finds an endpoint that has the operation. - * @param id Method name or the domain id of the operation to find - */ - getOperationParent(id: string): Promise; - - /** - * Lists the documentation definitions for the API. - */ - listDocumentations(): Promise; - - /** - * Reads the documentation object from the store. - * @param id The domain id of the documentation object - * @returns The read documentation. - */ - getDocumentation(id: string): Promise; - - /** - * Reads the SecurityScheme object from the graph. - * @param id The domain id of the SecurityScheme - */ - getSecurityScheme(id: string): Promise; - - /** - * Reads the SecurityRequirement object from the graph. - * @param id The domain id of the SecurityRequirement - */ - getSecurityRequirement(id: string): Promise; - - /** - * Lists the security definitions for the API. - */ - listSecurity(): Promise; - - /** - * Reads the Request object from the graph. - * @param id The domain id of the Request - */ - getRequest(id: string): Promise; - - /** - * Reads the response data from the graph. - * @param id The domain id of the response. - */ - getResponse(id: string): Promise; - - /** - * Reads Payload data from the graph - * @param id The domain id of the payload - */ - getPayload(id: string): Promise; - - /** - * Lists the type (schema) definitions for the API. - */ - listTypes(): Promise; - - /** - * @param id The domain id of the API type (schema). - */ - getType(id: string): Promise; -} diff --git a/src/store/AmfStore.js b/src/store/AmfStore.ts similarity index 51% rename from src/store/AmfStore.js rename to src/store/AmfStore.ts index 0d2f17f..8895562 100644 --- a/src/store/AmfStore.js +++ b/src/store/AmfStore.ts @@ -1,5 +1,11 @@ +/* eslint-disable default-param-last */ +/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable no-unused-vars */ /* eslint-disable class-methods-use-this */ +import { AmfDocument } from '../helpers/amf.js'; +import { AmfSerializer } from '../helpers/AmfSerializer.js'; +import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api.js'; +import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types.js'; /** @typedef {import('../helpers/amf').AmfDocument} AmfDocument */ /** @typedef {import('../helpers/amf').DomainElement} DomainElement */ @@ -24,189 +30,191 @@ * An abstract base class for the store implementation that works with API Components. */ export class AmfStore { - constructor() { + /** + * For future use. + * Indicates that the store is read only. + */ + readonly: boolean; + + target: EventTarget; + + serializer: AmfSerializer; + + /** + * @param target The event target to dispatch the events on. + */ + constructor(target: EventTarget = window, graph?: AmfDocument) { + this.readonly = true; + this.target = target; + let amf = graph; + if (Array.isArray(graph)) { + [amf] = graph; + } /** - * For future use. - * Indicates that the store is read only. + * The API serializer */ - this.readonly = true; + this.serializer = new AmfSerializer(amf); } /** - * @returns {string[]} The list of domain types for the currently loaded document. + * @returns The list of domain types for the currently loaded document. */ - getDocumentTypes() { + getDocumentTypes(): string[] { throw new Error('Not implemented'); } /** * Gathers information about the loaded document. * This is mainly used by the `api-documentation` element to decide which documentation to render. - * - * @returns {Promise} */ - async documentMeta() { + async documentMeta(): Promise { throw new Error('Not implemented'); } /** - * @returns {Promise} API summary for the summary view. + * @returns API summary for the summary view. */ - async apiSummary() { + async apiSummary(): Promise { throw new Error('Not implemented'); } /** - * @returns {Promise} Currently loaded API's protocols + * @returns Currently loaded API's protocols */ - async apiProtocols() { + async apiProtocols(): Promise { throw new Error('Not implemented'); } /** - * @returns {Promise} Currently loaded API's version + * @returns Currently loaded API's version */ - async apiVersion() { + async apiVersion(): Promise { throw new Error('Not implemented'); } - + /** * Reads an endpoint by its id. - * @param {string} id The domain id of the endpoint. - * @returns {Promise} + * @param id The domain id of the endpoint. */ - async getEndpoint(id) { + async getEndpoint(id: string): Promise { throw new Error('Not implemented'); } /** * Reads an endpoint by its path. - * @param {string} path The path value of the endpoint or channel name. - * @returns {Promise} + * @param path The path value of the endpoint or channel name. */ - async getEndpointByPath(path) { + async getEndpointByPath(path: string): Promise { throw new Error('Not implemented'); } /** * Lists all endpoints with operations included into the result. - * @returns {Promise} */ - async listEndpointsWithOperations() { + async listEndpointsWithOperations(): Promise { throw new Error('Not implemented'); } /** * Queries for the list of servers for method, if defined, or endpoint, if defined, or root level - * @param {ServersQueryOptions=} query Server query options - * @returns {Promise} The list of servers for given query. + * @param query Server query options + * @returns The list of servers for given query. */ - async queryServers(query) { + async queryServers(query?: ServersQueryOptions): Promise { throw new Error('Not implemented'); } /** * Reads the operation model. - * @param {string} operationId The domain id of the operation to read. - * @param {string=} endpointId Optional endpoint id. When not set it searches through all endpoints. - * @returns {Promise} + * @param operationId The domain id of the operation to read. + * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - async getOperation(operationId, endpointId) { + async getOperation(operationId: string, endpointId?: string): Promise { throw new Error('Not implemented'); } /** * Finds an endpoint that has the operation. - * @param {string} id Method name or the domain id of the operation to find - * @returns {Promise} + * @param id Method name or the domain id of the operation to find */ - async getOperationParent(id) { + async getOperationParent(id: string): Promise { throw new Error('Not implemented'); } /** * Lists the documentation definitions for the API. - * @returns {Promise} */ - async listDocumentations() { + async listDocumentations(): Promise { throw new Error('Not implemented'); } /** * Reads the documentation object from the store. - * @param {string} id The domain id of the documentation object - * @returns {Promise} The read documentation. + * @param id The domain id of the documentation object + * @returns The read documentation. */ - async getDocumentation(id) { + async getDocumentation(id: string): Promise { throw new Error('Not implemented'); } /** * Reads the SecurityScheme object from the graph. - * @param {string} id The domain id of the SecurityScheme - * @returns {Promise} + * @param id The domain id of the SecurityScheme */ - async getSecurityScheme(id) { + async getSecurityScheme(id: string): Promise { throw new Error('Not implemented'); } /** * Reads the SecurityRequirement object from the graph. - * @param {string} id The domain id of the SecurityRequirement - * @returns {Promise} + * @param id The domain id of the SecurityRequirement */ - async getSecurityRequirement(id) { + async getSecurityRequirement(id: string): Promise { throw new Error('Not implemented'); } /** * Lists the security definitions for the API. - * @returns {Promise} */ - async listSecurity() { + async listSecurity(): Promise { throw new Error('Not implemented'); } /** * Reads the Request object from the graph. - * @param {string} id The domain id of the Request - * @returns {Promise} + * @param id The domain id of the Request */ - async getRequest(id) { + async getRequest(id: string): Promise { throw new Error('Not implemented'); } /** * Reads the response data from the graph. - * @param {string} id The domain id of the response. - * @returns {Promise} + * @param id The domain id of the response. */ - async getResponse(id) { + async getResponse(id: string): Promise { throw new Error('Not implemented'); } /** * Reads Payload data from the graph - * @param {string} id The domain id of the payload - * @returns {Promise} + * @param id The domain id of the payload */ - async getPayload(id) { + async getPayload(id: string): Promise { throw new Error('Not implemented'); } /** * Lists the type (schema) definitions for the API. - * @returns {Promise} */ - async listTypes() { + async listTypes(): Promise { throw new Error(`Not implemented`); } /** - * @param {string} id The domain id of the API type (schema). - * @returns {Promise} + * @param id The domain id of the API type (schema). */ - async getType(id) { + async getType(id: string): Promise { throw new Error('Not implemented'); } } diff --git a/src/store/DomEventsAmfStore.d.ts b/src/store/DomEventsAmfStore.d.ts deleted file mode 100644 index e77f11f..0000000 --- a/src/store/DomEventsAmfStore.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { InMemAmfGraphStore } from './InMemAmfGraphStore'; -import { AmfStoreDomEventsMixin } from './mixins/AmfStoreDomEventsMixin'; - -export class DomEventsAmfStore extends AmfStoreDomEventsMixin(InMemAmfGraphStore) { - -} diff --git a/src/store/DomEventsAmfStore.js b/src/store/DomEventsAmfStore.ts similarity index 100% rename from src/store/DomEventsAmfStore.js rename to src/store/DomEventsAmfStore.ts diff --git a/src/store/InMemAmfGraphStore.d.ts b/src/store/InMemAmfGraphStore.d.ts deleted file mode 100644 index aecc981..0000000 --- a/src/store/InMemAmfGraphStore.d.ts +++ /dev/null @@ -1,176 +0,0 @@ -import { AmfHelperMixin } from '../helpers/AmfHelperMixin'; -import { AmfSerializer } from '../helpers/AmfSerializer'; -import { AmfDocument, DomainElement } from '../helpers/amf'; -import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api'; -import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types'; -import { AmfStore } from './AmfStore.js'; - -/** - * The store that provides an API to read data from the AMF graph model. - * The graph model is kept in memory in a form of a Raw ld+json graph representation of the - * AMF's domain model. - */ -export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { - /** - * The event target to dispatch the events on. - */ - target: EventTarget; - /** - * The full API model. - */ - amf: AmfDocument; - /** - * The API serializer - */ - serializer: AmfSerializer; - /** - * For future use. - * Indicates that this store is read only. - */ - readonly?: boolean; - /** - * @param eventsTarget The event target to dispatch the events on. - * @param graph The full API model. - */ - constructor(eventsTarget?: EventTarget, graph?: AmfDocument); - - __amfChanged(amf: AmfDocument): void; - - /** - * @returns The list of domain types for the currently loaded document. - */ - getDocumentTypes(): string[]; - - /** - * Gathers information about the loaded document. - * This is mainly used by the `api-documentation` element to decide which documentation to render. - */ - documentMeta(): Promise; - - /** - * @returns API summary for the summary view. - */ - apiSummary(): Promise; - - /** - * @returns Currently loaded API's protocols - */ - apiProtocols(): Promise; - - /** - * @returns Currently loaded API's version - */ - apiVersion(): Promise; - - /** - * Finds an endpoint in the graph. - * @param id The domain id of the endpoint. - */ - private findEndpoint(id: string): ApiEndPoint|null; - - /** - * Reads an endpoint by its id. - * @param id The domain id of the endpoint. - */ - getEndpoint(id: string): Promise; - - /** - * Reads an endpoint by its path. - * @param path The path value of the endpoint or channel name. - */ - getEndpointByPath(path: string): Promise; - - /** - * Lists all endpoints with operations included into the result. - */ - listEndpointsWithOperations(): Promise; - - /** - * Queries for the list of servers for method, if defined, or endpoint, if defined, or root level - * @param query Server query options - * @returns The list of servers for given query. - */ - queryServers(query?: ServersQueryOptions): Promise; - - /** - * Searches for an operation in the API. - * @param operationId The domain id of the operation to read. - * @param endpointId Optional endpoint id. When not set it searches through all endpoints. - */ - private findOperation(operationId: string, endpointId?: string): ApiOperation|undefined; - - /** - * Reads the operation model. - * @param operationId The domain id of the operation to read. - * @param endpointId Optional endpoint id. When not set it searches through all endpoints. - */ - getOperation(operationId: string, endpointId?: string): Promise; - - /** - * Finds an endpoint that has the operation. - * @param id Method name or the domain id of the operation to find - */ - getOperationParent(id: string): Promise; - - /** - * Lists the documentation definitions for the API. - */ - listDocumentations(): Promise; - - /** - * Reads the documentation object from the store. - * @param id The domain id of the documentation object - * @returns The read documentation. - */ - getDocumentation(id: string): Promise; - - /** - * Reads the SecurityScheme object from the graph. - * @param id The domain id of the SecurityScheme - */ - getSecurityScheme(id: string): Promise; - - /** - * Reads the SecurityRequirement object from the graph. - * @param id The domain id of the SecurityRequirement - */ - getSecurityRequirement(id: string): Promise; - - /** - * Lists the security definitions for the API. - */ - listSecurity(): Promise; - - /** - * Reads the Request object from the graph. - * @param id The domain id of the Request - */ - getRequest(id: string): Promise; - - /** - * Reads the response data from the graph. - * @param id The domain id of the response. - */ - getResponse(id: string): Promise; - - /** - * Finds a payload in a request or a response object. - */ - private findPayload(object: DomainElement, domainId: string): ApiPayload|undefined; - - /** - * Reads Payload data from the graph - * @param id The domain id of the payload - */ - getPayload(id: string): Promise; - - /** - * Lists the type (schema) definitions for the API. - */ - listTypes(): Promise; - - /** - * @param id The domain id of the API type (schema). - */ - getType(id: string): Promise; -} diff --git a/src/store/InMemAmfGraphStore.js b/src/store/InMemAmfGraphStore.ts similarity index 67% rename from src/store/InMemAmfGraphStore.js rename to src/store/InMemAmfGraphStore.ts index adc4e37..6ef30e4 100644 --- a/src/store/InMemAmfGraphStore.js +++ b/src/store/InMemAmfGraphStore.ts @@ -1,29 +1,12 @@ -/* eslint-disable no-unused-vars */ -/* eslint-disable class-methods-use-this */ -/* eslint-disable no-continue */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable default-param-last */ import { AmfHelperMixin } from '../helpers/AmfHelperMixin.js'; -import { AmfSerializer } from '../helpers/AmfSerializer.js'; import { StoreEvents } from '../events/StoreEvents.js'; import { AmfStore } from './AmfStore.js'; +import { AmfDocument, Api, CreativeWork, DomainElement } from '../helpers/amf.js'; +import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api.js'; +import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types.js'; -/** @typedef {import('../helpers/amf').AmfDocument} AmfDocument */ -/** @typedef {import('../helpers/amf').DomainElement} DomainElement */ -/** @typedef {import('../helpers/api').ApiSummary} ApiSummary */ -/** @typedef {import('../helpers/api').ApiEndPoint} ApiEndPoint */ -/** @typedef {import('../helpers/api').ApiOperation} ApiOperation */ -/** @typedef {import('../helpers/api').ServersQueryOptions} ServersQueryOptions */ -/** @typedef {import('../helpers/api').ApiServer} ApiServer */ -/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ -/** @typedef {import('../helpers/api').ApiSecurityScheme} ApiSecurityScheme */ -/** @typedef {import('../helpers/api').ApiSecurityRequirement} ApiSecurityRequirement */ -/** @typedef {import('../helpers/api').ApiRequest} ApiRequest */ -/** @typedef {import('../helpers/api').ApiResponse} ApiResponse */ -/** @typedef {import('../helpers/api').ApiPayload} ApiPayload */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../types').ApiEndPointWithOperationsListItem} ApiEndPointWithOperationsListItem */ -/** @typedef {import('../types').ApiSecuritySchemeListItem} ApiSecuritySchemeListItem */ -/** @typedef {import('../types').ApiNodeShapeListItem} ApiNodeShapeListItem */ -/** @typedef {import('../types').DocumentMeta} DocumentMeta */ /** * The store that provides an API to read data from the AMF graph model. @@ -32,30 +15,22 @@ import { AmfStore } from './AmfStore.js'; */ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** - * @param {EventTarget=} eventsTarget The event target to dispatch the events on. - * @param {AmfDocument=} graph The full API model. + * @param target The event target to dispatch the events on. + * @param graph The full API model. */ - constructor(eventsTarget=window, graph) { - super(); - this.target = eventsTarget; + constructor(target: EventTarget = window, graph?: AmfDocument) { + super(target, graph); let amf = graph; if (Array.isArray(graph)) { [amf] = graph; } - /** - * The API serializer - */ - this.serializer = new AmfSerializer(amf); /** * The graph model. */ this.amf = amf; } - /** - * @param {AmfDocument} amf - */ - __amfChanged(amf) { + __amfChanged(amf: AmfDocument): void { this.serializer.amf = amf; if (this.target) { StoreEvents.graphChange(this.target); @@ -63,9 +38,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } /** - * @returns {string[]} The list of domain types for the currently loaded document. + * @returns The list of domain types for the currently loaded document. */ - getDocumentTypes() { + getDocumentTypes(): string[] { let { amf } = this; if (Array.isArray(amf)) { [amf] = amf; @@ -79,11 +54,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Gathers information about the loaded document. * This is mainly used by the `api-documentation` element to decide which documentation to render. - * - * @returns {Promise} */ - async documentMeta() { - const result = /** @type DocumentMeta */ ({ + async documentMeta(): Promise { + const result: DocumentMeta = ({ isApi: false, isAsync: false, isFragment: false, @@ -120,9 +93,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } /** - * @returns {Promise} API summary for the summary view. + * @returns API summary for the summary view. */ - async apiSummary() { + async apiSummary(): Promise { const { amf } = this; if (!amf) { return null; @@ -136,37 +109,36 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } /** - * @returns {Promise} Currently loaded API's protocols + * @returns Currently loaded API's protocols */ - async apiProtocols() { + async apiProtocols(): Promise { const { amf } = this; if (!amf) { return null; } - const wa = this._computeApi(this.amf); - const protocols = /** @type string[] */ (this._getValueArray(wa, this.ns.aml.vocabularies.apiContract.scheme)); + const wa = this._computeApi(amf); + const protocols = this._getValueArray(wa, this.ns.aml.vocabularies.apiContract.scheme) as string[]; return protocols; } /** - * @returns {Promise} Currently loaded API's version + * @returns Currently loaded API's version */ - async apiVersion() { + async apiVersion(): Promise { const { amf } = this; if (!amf) { return null; } - const version = this._computeApiVersion(amf); + const version = this._computeApiVersion(amf) || null; return version; } /** * Finds an endpoint in the graph. - * @param {string} id The domain id of the endpoint. - * @returns {ApiEndPoint|null} + * @param id The domain id of the endpoint. * @private */ - findEndpoint(id) { + findEndpoint(id: string): ApiEndPoint|null { const { amf } = this; if (!amf) { return null; @@ -185,26 +157,24 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads an endpoint by its id. - * @param {string} id The domain id of the endpoint. - * @returns {Promise} + * @param id The domain id of the endpoint. */ - async getEndpoint(id) { + async getEndpoint(id: string): Promise { return this.findEndpoint(id); } /** * Reads an endpoint by its path. - * @param {string} path The path value of the endpoint or channel name. - * @returns {Promise} + * @param path The path value of the endpoint or channel name. */ - async getEndpointByPath(path) { + async getEndpointByPath(path: string): Promise { const { amf } = this; if (!amf) { - return undefined; + return null; } const api = this._computeApi(amf); if (!api) { - return undefined; + return null; } const endpoints = this._computeEndpoints(api); if (!Array.isArray(endpoints) || !endpoints.length) { @@ -220,9 +190,8 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Lists all endpoints with operations included into the result. - * @returns {Promise} */ - async listEndpointsWithOperations() { + async listEndpointsWithOperations(): Promise { const { amf } = this; if (!amf) { return []; @@ -240,13 +209,13 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Queries for the list of servers for method, if defined, or endpoint, if defined, or root level - * @param {ServersQueryOptions=} query Server query options - * @returns {Promise} The list of servers for given query. + * @param query Server query options + * @returns The list of servers for given query. */ - async queryServers(query) { + async queryServers(query?: ServersQueryOptions): Promise { const { amf } = this; if (!amf) { - return undefined; + return []; } const servers = this._getServers(query); if (!Array.isArray(servers)) { @@ -257,11 +226,10 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Searches for an operation in the API. - * @param {string} operationId The domain id of the operation to read. - * @param {string=} endpointId Optional endpoint id. When not set it searches through all endpoints. - * @returns {ApiOperation|undefined} + * @param operationId The domain id of the operation to read. + * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - findOperation(operationId, endpointId) { + findOperation(operationId: string, endpointId?: string): ApiOperation|undefined { if (endpointId) { const ep = this.findEndpoint(endpointId); if (!ep) { @@ -282,9 +250,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { return undefined; } const { apiContract } = this.ns.aml.vocabularies; - const opKey = this._getAmfKey(apiContract.supportedOperation); + const opKey = this._getAmfKey(apiContract.supportedOperation) as string; for (const endpoint of endpoints) { - let operations = endpoint[opKey]; + let operations = (endpoint as any)[opKey]; if (!operations) { continue; } @@ -302,11 +270,10 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the operation model. - * @param {string} operationId The domain id of the operation to read. - * @param {string=} endpointId Optional endpoint id. When not set it searches through all endpoints. - * @returns {Promise} + * @param operationId The domain id of the operation to read. + * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - async getOperation(operationId, endpointId) { + async getOperation(operationId: string, endpointId?: string): Promise { const op = this.findOperation(operationId, endpointId); if (!op) { throw new Error(`No operation ${operationId} in the graph`); @@ -316,10 +283,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Finds an endpoint that has the operation. - * @param {string} id Method name or the domain id of the operation to find - * @returns {Promise} + * @param id Method name or the domain id of the operation to find */ - async getOperationParent(id) { + async getOperationParent(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -338,9 +304,8 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Lists the documentation definitions for the API. - * @returns {Promise} */ - async listDocumentations() { + async listDocumentations(): Promise { const { amf } = this; if (!amf) { return undefined; @@ -356,8 +321,8 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!api) { return undefined; } - const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation); - const docs = this._ensureArray(api[key]); + const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation) as string; + const docs = this._ensureArray((api as any)[key]) as CreativeWork[]; if (docs) { return docs.map((doc) => this.serializer.documentation(doc)); } @@ -366,10 +331,10 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the documentation object from the store. - * @param {string} id The domain id of the documentation object - * @returns {Promise} The read documentation. + * @param id The domain id of the documentation object + * @returns The read documentation. */ - async getDocumentation(id) { + async getDocumentation(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -378,11 +343,11 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { // when we have loaded Documentation fragment then the id doesn't matter. if (types.includes(this.ns.aml.vocabularies.apiContract.UserDocumentationFragment)) { const encodes = this._computeEncodes(amf); - return this.serializer.documentation(encodes); + return this.serializer.documentation(encodes as Api); } const api = this._computeApi(amf); if (!api) { - return null; + return undefined; } const creative = this._computeDocument(api, id); if (!creative) { @@ -394,10 +359,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the SecurityScheme object from the graph. - * @param {string} id The domain id of the SecurityScheme - * @returns {Promise} + * @param id The domain id of the SecurityScheme */ - async getSecurityScheme(id) { + async getSecurityScheme(id: string): Promise { const types = this.getDocumentTypes(); // when we have loaded Security fragment then the id doesn't matter. if (types.includes(this.ns.aml.vocabularies.security.SecuritySchemeFragment)) { @@ -406,7 +370,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { return undefined; } const encodes = this._computeEncodes(amf); - return this.serializer.securityScheme(encodes); + return this.serializer.securityScheme(encodes as Api); } const object = this.findSecurityScheme(id); if (!object) { @@ -417,10 +381,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the SecurityRequirement object from the graph. - * @param {string} id The domain id of the SecurityRequirement - * @returns {Promise} + * @param id The domain id of the SecurityRequirement */ - async getSecurityRequirement(id) { + async getSecurityRequirement(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -429,15 +392,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = wa[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint)]; + const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation)]; + const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const securityList = operation[this._getAmfKey(this.ns.aml.vocabularies.security.security)]; + const securityList = operation[this._getAmfKey(this.ns.aml.vocabularies.security.security) as string]; if (Array.isArray(securityList)) { for (const security of securityList) { if (security['@id'] === id) { @@ -453,17 +416,16 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Lists the security definitions for the API. - * @returns {Promise} */ - async listSecurity() { + async listSecurity(): Promise { const { amf } = this; if (!amf) { - return undefined; + return []; } if (this._hasType(amf, this.ns.aml.vocabularies.security.SecuritySchemeFragment)) { const model = this._computeEncodes(amf); if (!model) { - return undefined; + return []; } return [this.serializer.securitySchemeListItem(model)]; } @@ -473,10 +435,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the Request object from the graph. - * @param {string} id The domain id of the Request - * @returns {Promise} + * @param id The domain id of the Request */ - async getRequest(id) { + async getRequest(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -485,15 +446,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = wa[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint)]; + const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation)]; + const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects)]; + const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects) as string]; if (Array.isArray(expectsList)) { for (const expects of expectsList) { if (expects['@id'] === id) { @@ -509,10 +470,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads the response data from the graph. - * @param {string} id The domain id of the response. - * @returns {Promise} + * @param id The domain id of the response. */ - async getResponse(id) { + async getResponse(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -521,15 +481,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = wa[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint)]; + const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation)]; + const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns)]; + const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns) as string]; if (Array.isArray(returnsList)) { for (const returns of returnsList) { if (returns['@id'] === id) { @@ -545,12 +505,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Finds a payload in a request or a response object. - * @param {DomainElement} object - * @param {string} domainId - * @returns {ApiPayload|undefined} */ - findPayload(object, domainId) { - const list = object[this._getAmfKey(this.ns.aml.vocabularies.apiContract.payload)]; + findPayload(object: DomainElement, domainId: string): ApiPayload|undefined { + const list = (object as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.payload) as string]; if (!Array.isArray(list) || !list.length) { return undefined; } @@ -563,10 +520,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Reads Payload data from the graph - * @param {string} id The domain id of the payload - * @returns {Promise} + * @param id The domain id of the payload */ - async getPayload(id) { + async getPayload(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -575,15 +531,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = wa[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint)]; + const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation)]; + const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects)]; + const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects) as string]; if (Array.isArray(expectsList)) { for (const expects of expectsList) { const payload = this.findPayload(expects, id); @@ -592,7 +548,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } } } - const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns)]; + const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns) as string]; if (Array.isArray(returnsList)) { for (const returns of returnsList) { const payload = this.findPayload(returns, id); @@ -609,17 +565,16 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Lists the type (schema) definitions for the API. - * @returns {Promise} */ - async listTypes() { + async listTypes(): Promise { const { amf } = this; if (!amf) { - return undefined; + return []; } if (this._hasType(amf, this.ns.aml.vocabularies.shapes.DataTypeFragment)) { const model = this._computeEncodes(amf); if (!model) { - return undefined; + return []; } return [this.serializer.unknownShape(model)]; } @@ -628,10 +583,9 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } /** - * @param {string} id The domain id of the API type (schema). - * @returns {Promise} + * @param id The domain id of the API type (schema). */ - async getType(id) { + async getType(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -640,11 +594,11 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { // when we have loaded Type fragment then the id doesn't matter. if (types.includes(this.ns.aml.vocabularies.shapes.DataTypeFragment)) { const encodes = this._computeEncodes(amf); - return this.serializer.unknownShape(encodes); + return this.serializer.unknownShape(encodes as Api); } const declares = this._computeDeclares(amf); const references = this._computeReferences(amf); - const type = this._computeType(declares, references, id); + const type = this._computeType(declares as DomainElement[], references as DomainElement[], id); if (!type) { return undefined; } diff --git a/src/types.ts b/src/types.ts index c07618a..765713d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,7 +37,7 @@ export declare interface ApiConsoleResponse { export declare interface ApiConsoleHTTPResponse { status: number; statusText?: string; - payload?: any; + payload?: unknown; headers?: string; } @@ -117,7 +117,7 @@ export interface ShapeTemplateOptions extends ParameterRenderOptions { nillable?: boolean; arrayItem?: boolean; index?: number; - value?: any; + value?: unknown; } export interface ComputeBaseUriOptions { @@ -257,6 +257,7 @@ export interface ApiEndpointsTreeItem extends ApiEndPointWithOperationsListItem export interface ApiSecuritySchemeListItem { id: string; + types: string[]; type: string; name?: string; displayName?: string; From d00e01835518ca99c24c3505755c056fc6fda740 Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Thu, 22 Sep 2022 17:48:12 -0700 Subject: [PATCH 4/6] chore: adding @api-client-core Signed-off-by: Pawel Psztyc --- demo/api-operation.js | 2 +- demo/lib/AmfDemoBase.js | 12 +- demo/lib/ApplicationPage.js | 4 +- demo/oauth-authorize.js | 12 +- demo/oauth-popup.html | 29 + package-lock.json | 149 ++ package.json | 3 +- src/elements/ApiRequestEditorElement.js | 32 +- src/elements/ApiRequestElement.d.ts | 285 --- src/elements/ApiRequestElement.js | 544 ----- src/elements/ApiRequestElement.ts | 513 ++++ .../XhrSimpleRequestTransportElement.d.ts | 267 --- ...js => XhrSimpleRequestTransportElement.ts} | 346 ++- src/events/ApiEvents.d.ts | 27 - src/events/ApiEvents.js | 52 - src/events/ApiEvents.ts | 47 + src/events/BaseEvents.js | 68 - src/events/{BaseEvents.d.ts => BaseEvents.ts} | 99 +- src/events/DocumentationEvents.d.ts | 18 - src/events/DocumentationEvents.js | 29 - src/events/DocumentationEvents.ts | 29 + src/events/EndpointEvents.d.ts | 24 - .../{EndpointEvents.js => EndpointEvents.ts} | 26 +- src/events/EventTypes.d.ts | 100 - src/events/{EventTypes.js => EventTypes.ts} | 0 src/events/Events.d.ts | 40 - src/events/{Events.js => Events.ts} | 0 src/events/NavigationEvents.js | 61 - ...igationEvents.d.ts => NavigationEvents.ts} | 44 +- src/helpers/AmfHelperMixin.ts | 1700 ------------- src/helpers/AmfSerializer.ts | 2131 ----------------- src/helpers/Namespace.ts | 329 --- src/helpers/amf.ts | 445 ---- src/helpers/api.ts | 547 ----- src/index.ts | 9 - src/lib/AmfInputParser.ts | 36 +- src/lib/AmfParameterMixin.ts | 102 +- src/lib/Oauth2RamlCustomData.ts | 109 +- src/lib/PayloadUtils.ts | 19 +- src/lib/QueryParameterProcessor.ts | 56 +- src/lib/SecurityProcessor.ts | 16 +- src/lib/Utils.ts | 73 +- src/lib/auth-ui/ApiKeyAuth.ts | 11 +- src/lib/auth-ui/ApiUiBase.ts | 22 +- src/lib/auth-ui/CustomAuth.ts | 21 +- src/lib/auth-ui/OAuth2Auth.ts | 89 +- src/lib/auth-ui/PassThroughAuth.ts | 15 +- .../{NaturalTree.js => NaturalTree.ts} | 35 +- src/schema/ApiExampleGenerator.d.ts | 40 - src/schema/ApiExampleGenerator.js | 120 - src/schema/ApiMonacoSchemaGenerator.d.ts | 32 - src/schema/ApiMonacoSchemaGenerator.js | 285 --- src/schema/ApiSchemaGenerator.d.ts | 52 - src/schema/ApiSchemaGenerator.js | 115 - src/schema/ApiSchemaValues.d.ts | 96 - src/schema/ApiSchemaValues.js | 377 --- src/schema/Utils.js | 203 -- src/schema/data-node/DataNodeBase.js | 87 - src/schema/data-node/JsonDataNodeGenerator.js | 26 - src/schema/data-node/README.md | 3 - .../data-node/UrlEncodedDataNodeGenerator.js | 47 - src/schema/data-node/XmlDataNodeGenerator.js | 31 - src/schema/shape/README.md | 4 - src/schema/shape/ShapeBase.d.ts | 70 - src/schema/shape/ShapeBase.js | 278 --- .../shape/ShapeJsonSchemaGenerator.d.ts | 58 - src/schema/shape/ShapeJsonSchemaGenerator.js | 395 --- src/schema/shape/ShapeXmlSchemaGenerator.d.ts | 95 - src/schema/shape/ShapeXmlSchemaGenerator.js | 531 ---- src/store/AmfGraphStore.ts | 8 +- src/store/AmfStore.ts | 54 +- src/store/InMemAmfGraphStore.ts | 125 +- src/store/mixins/AmfStoreDomEventsMixin.d.ts | 31 - ...entsMixin.js => AmfStoreDomEventsMixin.ts} | 95 +- src/types.ts | 32 +- 75 files changed, 1507 insertions(+), 10410 deletions(-) create mode 100644 demo/oauth-popup.html delete mode 100644 src/elements/ApiRequestElement.d.ts delete mode 100644 src/elements/ApiRequestElement.js create mode 100644 src/elements/ApiRequestElement.ts delete mode 100644 src/elements/XhrSimpleRequestTransportElement.d.ts rename src/elements/{XhrSimpleRequestTransportElement.js => XhrSimpleRequestTransportElement.ts} (57%) delete mode 100644 src/events/ApiEvents.d.ts delete mode 100644 src/events/ApiEvents.js create mode 100644 src/events/ApiEvents.ts delete mode 100644 src/events/BaseEvents.js rename src/events/{BaseEvents.d.ts => BaseEvents.ts} (61%) delete mode 100644 src/events/DocumentationEvents.d.ts delete mode 100644 src/events/DocumentationEvents.js create mode 100644 src/events/DocumentationEvents.ts delete mode 100644 src/events/EndpointEvents.d.ts rename src/events/{EndpointEvents.js => EndpointEvents.ts} (50%) delete mode 100644 src/events/EventTypes.d.ts rename src/events/{EventTypes.js => EventTypes.ts} (100%) delete mode 100644 src/events/Events.d.ts rename src/events/{Events.js => Events.ts} (100%) delete mode 100644 src/events/NavigationEvents.js rename src/events/{NavigationEvents.d.ts => NavigationEvents.ts} (59%) delete mode 100644 src/helpers/AmfHelperMixin.ts delete mode 100644 src/helpers/AmfSerializer.ts delete mode 100644 src/helpers/Namespace.ts delete mode 100644 src/helpers/amf.ts delete mode 100644 src/helpers/api.ts rename src/lib/navigation-layout/{NaturalTree.js => NaturalTree.ts} (73%) delete mode 100644 src/schema/ApiExampleGenerator.d.ts delete mode 100644 src/schema/ApiExampleGenerator.js delete mode 100644 src/schema/ApiMonacoSchemaGenerator.d.ts delete mode 100644 src/schema/ApiMonacoSchemaGenerator.js delete mode 100644 src/schema/ApiSchemaGenerator.d.ts delete mode 100644 src/schema/ApiSchemaGenerator.js delete mode 100644 src/schema/ApiSchemaValues.d.ts delete mode 100644 src/schema/ApiSchemaValues.js delete mode 100644 src/schema/Utils.js delete mode 100644 src/schema/data-node/DataNodeBase.js delete mode 100644 src/schema/data-node/JsonDataNodeGenerator.js delete mode 100644 src/schema/data-node/README.md delete mode 100644 src/schema/data-node/UrlEncodedDataNodeGenerator.js delete mode 100644 src/schema/data-node/XmlDataNodeGenerator.js delete mode 100644 src/schema/shape/README.md delete mode 100644 src/schema/shape/ShapeBase.d.ts delete mode 100644 src/schema/shape/ShapeBase.js delete mode 100644 src/schema/shape/ShapeJsonSchemaGenerator.d.ts delete mode 100644 src/schema/shape/ShapeJsonSchemaGenerator.js delete mode 100644 src/schema/shape/ShapeXmlSchemaGenerator.d.ts delete mode 100644 src/schema/shape/ShapeXmlSchemaGenerator.js delete mode 100644 src/store/mixins/AmfStoreDomEventsMixin.d.ts rename src/store/mixins/{AmfStoreDomEventsMixin.js => AmfStoreDomEventsMixin.ts} (64%) diff --git a/demo/api-operation.js b/demo/api-operation.js index 42cec01..0f86707 100644 --- a/demo/api-operation.js +++ b/demo/api-operation.js @@ -32,7 +32,7 @@ class ComponentPage extends AmfDemoBase { this.renderSecurity = true; this.renderCodeSnippets = true; this.componentName = 'api-operation-document'; - this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth/oauth-popup.html`; + this.redirectUri = `${window.location.origin}/demo/oauth-popup.html`; } get baseUri() { diff --git a/demo/lib/AmfDemoBase.js b/demo/lib/AmfDemoBase.js index 9300c5f..6b5bd1c 100644 --- a/demo/lib/AmfDemoBase.js +++ b/demo/lib/AmfDemoBase.js @@ -1,11 +1,11 @@ -import { html } from 'lit-html'; +import { html } from 'lit'; import { DemoPage } from "@advanced-rest-client/arc-demo-helper"; import { MonacoLoader } from "@advanced-rest-client/monaco-support"; -import '@anypoint-web-components/awc/anypoint-dropdown-menu.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dropdown-menu.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; import { EventTypes as ArcEventTypes } from '@advanced-rest-client/events'; -import { OAuth2Authorization, OidcAuthorization } from '@advanced-rest-client/oauth'; +import { OAuth2Authorization, OidcAuthorization } from '@api-client/core/build/browser.js'; import { DomEventsAmfStore } from "../../src/store/DomEventsAmfStore.js"; import { AmfHelperMixin } from "../../src/helpers/AmfHelperMixin.js"; import { EventTypes } from '../../src/events/EventTypes.js'; @@ -103,7 +103,7 @@ export class AmfDemoBase extends AmfHelperMixin(DemoPage) { * @type {string} */ this.selectedFile = undefined; - this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth/oauth-popup.html`; + this.redirectUri = `${window.location.origin}/demo/oauth-popup.html`; window.addEventListener(ArcEventTypes.Authorization.OAuth2.authorize, this.oauth2authorizeHandler.bind(this)); window.addEventListener(ArcEventTypes.Authorization.Oidc.authorize, this.oidcAuthorizeHandler.bind(this)); diff --git a/demo/lib/ApplicationPage.js b/demo/lib/ApplicationPage.js index 39e0642..fca01d1 100644 --- a/demo/lib/ApplicationPage.js +++ b/demo/lib/ApplicationPage.js @@ -1,6 +1,6 @@ /* eslint-disable class-methods-use-this */ import { EventTypes as ArcEventTypes } from '@advanced-rest-client/events'; -import { OAuth2Authorization, OidcAuthorization } from '@advanced-rest-client/oauth'; +import { OAuth2Authorization, OidcAuthorization } from '@api-client/core/build/browser.js'; import { ReactiveMixin } from './mixins/ReactiveMixin.js'; import { RenderableMixin } from './mixins/RenderableMixin.js'; @@ -34,7 +34,7 @@ export class ApplicationPage extends RenderableMixin(ReactiveMixin(EventTarget)) * True when the app should render mobile friendly view. */ this.isMobile = false; - this.redirectUri = `${window.location.origin}/node_modules/@advanced-rest-client/oauth/oauth-popup.html`; + this.redirectUri = `${window.location.origin}/demo/oauth-popup.html`; window.addEventListener(ArcEventTypes.Authorization.OAuth2.authorize, this.oauth2authorizeHandler.bind(this)); window.addEventListener(ArcEventTypes.Authorization.Oidc.authorize, this.oidcAuthorizeHandler.bind(this)); this.initMediaQueries(); diff --git a/demo/oauth-authorize.js b/demo/oauth-authorize.js index 3bf0d93..7feecd5 100644 --- a/demo/oauth-authorize.js +++ b/demo/oauth-authorize.js @@ -1,7 +1,7 @@ -import '@anypoint-web-components/awc/anypoint-input.js'; -import '@anypoint-web-components/awc/anypoint-button.js'; -import '@anypoint-web-components/awc/anypoint-masked-input.js'; -import { v4 } from '@advanced-rest-client/uuid'; +import { uuidV4 } from '@api-client/core/build/browser.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-input.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-masked-input.js'; function setupFormAction() { const u = new URL(window.location.href) @@ -10,13 +10,13 @@ function setupFormAction() { const type = u.searchParams.get('response_type'); const codeParam = type === 'code' ? 'code' : 'access_token'; const params = new URLSearchParams(); - params.set(codeParam, v4()); + params.set(codeParam, uuidV4()); params.set('state', state); params.set('expires_in', '3600'); params.set('scope', 'dummy'); if (type !== 'code') { params.set('token_type', 'bearer'); - params.set('refresh_token', v4()); + params.set('refresh_token', uuidV4()); } const formUrl = `${redirectUri}#${params.toString()}`; const form = document.querySelector('form'); diff --git a/demo/oauth-popup.html b/demo/oauth-popup.html new file mode 100644 index 0000000..b8391f1 --- /dev/null +++ b/demo/oauth-popup.html @@ -0,0 +1,29 @@ + + + + + Oauth2 callback window + + + +

Sending the authorization data to the application

+ + + + diff --git a/package-lock.json b/package-lock.json index 65aa877..b30468f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@advanced-rest-client/uuid": "^4.0.0", "@anypoint-web-components/awc": "^3.0.12", "@api-client/context-menu": "^0.4.1", + "@api-client/core": "^0.8.0", "@open-wc/dedupe-mixin": "^1.3.1", "@pawel-up/data-mock": "^0.3.2", "amf-json-ld-lib": "0.0.14", @@ -235,6 +236,50 @@ "lit": "^2.2.2" } }, + "node_modules/@api-client/core": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@api-client/core/-/core-0.8.0.tgz", + "integrity": "sha512-NExKuzc62Jt5Roi8P2wnOJSajZmzth66+IqS7nE91Mr+h6Mh/Z1ah+RGaDAFmlylSgsP1ZQ5rRHpYHlegC/EAg==", + "dependencies": { + "@api-client/json": "^0.1.3", + "@metrichor/jmespath": "^0.3.1", + "@pawel-up/data-mock": "^0.3.0", + "@pawel-up/jexl": "^3.0.0", + "@xmldom/xmldom": "^0.8.2", + "amf-json-ld-lib": "^0.0.14", + "console-table-printer": "^2.11.0", + "ws": "^8.6.0", + "xpath": "^0.0.32" + }, + "engines": { + "node": ">=15" + } + }, + "node_modules/@api-client/core/node_modules/ws": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz", + "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@api-client/json": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@api-client/json/-/json-0.1.4.tgz", + "integrity": "sha512-CFyzxmQ70bNvYQWp8OyhX10ox85pZQhS93TXLNo/djtTf4qncYXkmf2OBV0AAONigAcpLYTRpAI/PUPRKOQMkw==" + }, "node_modules/@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -1147,6 +1192,14 @@ "tslib": "^2.1.0" } }, + "node_modules/@metrichor/jmespath": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@metrichor/jmespath/-/jmespath-0.3.1.tgz", + "integrity": "sha512-X/S90FG+VlEWGNEptEpZ15QN7h9aRhdOZm3yjE4lHItig8lSpJbmYDqAPo3iKc4CjUGfUSv4z+VhKrFw6iHBMg==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1302,6 +1355,11 @@ "resolved": "https://registry.npmjs.org/@pawel-up/html.md/-/html.md-0.1.0.tgz", "integrity": "sha512-xJjiWGJUOaTZd9W5KgFfrwnjQTDT46lHs3i4zFkBi+nCGk5M/WRDX1RGEfjRAIE5BKvGn/kXeKXbjefNnT6msQ==" }, + "node_modules/@pawel-up/jexl": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@pawel-up/jexl/-/jexl-3.0.0.tgz", + "integrity": "sha512-rGg9CQtLzzGCU3KNKRfHfHtaDdvPbcvZiRqNI0rKc8hvgrZzwpNOX60leK3qarXG7dDQ98E9UQHp4yh8pUEJvQ==" + }, "node_modules/@rollup/plugin-node-resolve": { "version": "13.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz", @@ -2225,6 +2283,14 @@ "node": ">=12.0.0" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.2.tgz", + "integrity": "sha512-+R0juSseERyoPvnBQ/cZih6bpF7IpCXlWbHRoCRzYzqpz6gWHOgf8o4MOEf6KBVuOyqU+gCNLkCWVIJAro8XyQ==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -3120,6 +3186,14 @@ "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", "dev": true }, + "node_modules/console-table-printer": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/console-table-printer/-/console-table-printer-2.11.1.tgz", + "integrity": "sha512-8LfFpbF/BczoxPwo2oltto5bph8bJkGOATXsg3E9ddMJOGnWJciKHldx2zDj5XIBflaKzPfVCjOTl6tMh7lErg==", + "dependencies": { + "simple-wcswidth": "^1.0.1" + } + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -7792,6 +7866,11 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/simple-wcswidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz", + "integrity": "sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg==" + }, "node_modules/sinon": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz", @@ -8807,6 +8886,14 @@ } } }, + "node_modules/xpath": { + "version": "0.0.32", + "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.32.tgz", + "integrity": "sha512-rxMJhSIoiO8vXcWvSifKqhvV96GjiD5wYb8/QHdoRyQvraTpp4IEv944nhGausZZ3u7dhQXteZuZbaqfpB7uYw==", + "engines": { + "node": ">=0.6.0" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -9125,6 +9212,35 @@ "lit": "^2.2.2" } }, + "@api-client/core": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@api-client/core/-/core-0.8.0.tgz", + "integrity": "sha512-NExKuzc62Jt5Roi8P2wnOJSajZmzth66+IqS7nE91Mr+h6Mh/Z1ah+RGaDAFmlylSgsP1ZQ5rRHpYHlegC/EAg==", + "requires": { + "@api-client/json": "^0.1.3", + "@metrichor/jmespath": "^0.3.1", + "@pawel-up/data-mock": "^0.3.0", + "@pawel-up/jexl": "^3.0.0", + "@xmldom/xmldom": "^0.8.2", + "amf-json-ld-lib": "^0.0.14", + "console-table-printer": "^2.11.0", + "ws": "^8.6.0", + "xpath": "^0.0.32" + }, + "dependencies": { + "ws": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz", + "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==", + "requires": {} + } + } + }, + "@api-client/json": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@api-client/json/-/json-0.1.4.tgz", + "integrity": "sha512-CFyzxmQ70bNvYQWp8OyhX10ox85pZQhS93TXLNo/djtTf4qncYXkmf2OBV0AAONigAcpLYTRpAI/PUPRKOQMkw==" + }, "@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -9869,6 +9985,11 @@ "tslib": "^2.1.0" } }, + "@metrichor/jmespath": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@metrichor/jmespath/-/jmespath-0.3.1.tgz", + "integrity": "sha512-X/S90FG+VlEWGNEptEpZ15QN7h9aRhdOZm3yjE4lHItig8lSpJbmYDqAPo3iKc4CjUGfUSv4z+VhKrFw6iHBMg==" + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -10012,6 +10133,11 @@ "resolved": "https://registry.npmjs.org/@pawel-up/html.md/-/html.md-0.1.0.tgz", "integrity": "sha512-xJjiWGJUOaTZd9W5KgFfrwnjQTDT46lHs3i4zFkBi+nCGk5M/WRDX1RGEfjRAIE5BKvGn/kXeKXbjefNnT6msQ==" }, + "@pawel-up/jexl": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@pawel-up/jexl/-/jexl-3.0.0.tgz", + "integrity": "sha512-rGg9CQtLzzGCU3KNKRfHfHtaDdvPbcvZiRqNI0rKc8hvgrZzwpNOX60leK3qarXG7dDQ98E9UQHp4yh8pUEJvQ==" + }, "@rollup/plugin-node-resolve": { "version": "13.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz", @@ -10774,6 +10900,11 @@ "playwright": "^1.22.2" } }, + "@xmldom/xmldom": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.2.tgz", + "integrity": "sha512-+R0juSseERyoPvnBQ/cZih6bpF7IpCXlWbHRoCRzYzqpz6gWHOgf8o4MOEf6KBVuOyqU+gCNLkCWVIJAro8XyQ==" + }, "accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -11429,6 +11560,14 @@ "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", "dev": true }, + "console-table-printer": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/console-table-printer/-/console-table-printer-2.11.1.tgz", + "integrity": "sha512-8LfFpbF/BczoxPwo2oltto5bph8bJkGOATXsg3E9ddMJOGnWJciKHldx2zDj5XIBflaKzPfVCjOTl6tMh7lErg==", + "requires": { + "simple-wcswidth": "^1.0.1" + } + }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -14891,6 +15030,11 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "simple-wcswidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz", + "integrity": "sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg==" + }, "sinon": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz", @@ -15658,6 +15802,11 @@ "dev": true, "requires": {} }, + "xpath": { + "version": "0.0.32", + "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.32.tgz", + "integrity": "sha512-rxMJhSIoiO8vXcWvSifKqhvV96GjiD5wYb8/QHdoRyQvraTpp4IEv944nhGausZZ3u7dhQXteZuZbaqfpB7uYw==" + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index ebb1b51..578e997 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,9 @@ "@advanced-rest-client/highlight": "^2.0.2", "@advanced-rest-client/http-code-snippets": "^4.0.1", "@advanced-rest-client/icons": "^4.0.0", - "@advanced-rest-client/oauth": "^0.2.1", - "@advanced-rest-client/uuid": "^4.0.0", "@anypoint-web-components/awc": "^3.0.12", "@api-client/context-menu": "^0.4.1", + "@api-client/core": "^0.8.0", "@open-wc/dedupe-mixin": "^1.3.1", "@pawel-up/data-mock": "^0.3.2", "amf-json-ld-lib": "0.0.14", diff --git a/src/elements/ApiRequestEditorElement.js b/src/elements/ApiRequestEditorElement.js index b166994..908f09f 100644 --- a/src/elements/ApiRequestEditorElement.js +++ b/src/elements/ApiRequestEditorElement.js @@ -14,20 +14,20 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { html, LitElement } from 'lit-element'; -import { classMap } from 'lit-html/directives/class-map.js'; +import { html, LitElement } from 'lit'; +import { classMap } from 'lit/directives/class-map.js'; +import { uuidV4, Headers } from '@api-client/core/build/browser.js'; import { EventsTargetMixin } from '@anypoint-web-components/awc'; import { RequestEventTypes } from '@advanced-rest-client/events'; -import { v4 } from '@advanced-rest-client/uuid'; -import { HeadersParser, ifProperty } from '@advanced-rest-client/base'; -import '@anypoint-web-components/awc/anypoint-dropdown-menu.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; -import '@anypoint-web-components/awc/anypoint-item-body.js'; -import '@anypoint-web-components/awc/anypoint-radio-button.js'; -import '@anypoint-web-components/awc/anypoint-radio-group.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; -import '@anypoint-web-components/awc/anypoint-switch.js'; +import { ifProperty } from '@advanced-rest-client/base'; +import '@anypoint-web-components/awc/dist/define/anypoint-dropdown-menu.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item-body.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-group.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-switch.js'; import '@advanced-rest-client/base/define/body-formdata-editor.js'; import '@advanced-rest-client/base/define/body-multipart-editor.js'; import '@advanced-rest-client/base/define/body-raw-editor.js'; @@ -1063,7 +1063,7 @@ export default class ApiRequestEditorElement extends AmfParameterMixin(EventsTar */ execute() { const request = this.serialize(); - const uuid = v4(); + const uuid = uuidV4(); this[requestIdValue] = uuid; request.id = uuid; this[loadingRequestValue] = true; @@ -1152,7 +1152,9 @@ export default class ApiRequestEditorElement extends AmfParameterMixin(EventsTar } } if (body instanceof FormData) { - request.headers = /** @type string */ (HeadersParser.replace(request.headers, 'content-type', null)); + const parser = new Headers(request.headers); + parser.delete('content-type'); + request.headers = parser.toString(); } else if (payload) { request.headers = ensureContentType(request.headers, payload.mediaType); } @@ -1332,7 +1334,7 @@ export default class ApiRequestEditorElement extends AmfParameterMixin(EventsTar if (!['query', 'header'].includes(type)) { return; } - const id = v4(); + const id = uuidV4(); const param = /** @type OperationParameter */ ({ binding: type, source: 'custom', diff --git a/src/elements/ApiRequestElement.d.ts b/src/elements/ApiRequestElement.d.ts deleted file mode 100644 index 68d5a59..0000000 --- a/src/elements/ApiRequestElement.d.ts +++ /dev/null @@ -1,285 +0,0 @@ -/** -@license -Copyright 2021 The Advanced REST client authors -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at -http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -import { TemplateResult, LitElement } from 'lit-element'; -import { EventsTargetMixin } from '@anypoint-web-components/awc'; -import { ArcResponse, ArcRequest, ApiTypes } from '@advanced-rest-client/events'; -import { Oauth2Credentials } from '@advanced-rest-client/base'; -import { ServerType, ApiConsoleResponse, ApiConsoleRequest } from '../types'; -import { ApiRequestEvent, ApiResponseEvent } from '../events/RequestEvents'; - -export const domainIdValue: unique symbol; -export const domainIdChanged: unique symbol; -export const appendProxy: unique symbol; -export const propagateResponse: unique symbol; -export const responseHandler: unique symbol; -export const requestHandler: unique symbol; -export const appendConsoleHeaders: unique symbol; -export const navigationHandler: unique symbol; -export const requestTemplate: unique symbol; -export const responseTemplate: unique symbol; -export const changeHandler: unique symbol; - -export default class ApiRequestElement extends EventsTargetMixin(LitElement) { - /** - * True when the panel render the response. - */ - get hasResponse(): boolean; - /** - * The domain id (AMF's id) of an API operation. - * @attribute - */ - domainId: string; - [domainIdValue]: string; - /** - * By default application hosting the element must set `domainId` - * property. When using `api-navigation` element - * by setting this property the element listens for navigation events - * and updates the state - * @attribute - */ - handleNavigationEvents: boolean; - /** - * When set it renders the URL input above the URL parameters. - * @attribute - */ - urlEditor: boolean; - /** - * When set it renders a label with the computed URL. - * @attribute - */ - urlLabel: boolean; - /** - * A base URI for the API. To be set if RAML spec is missing `baseUri` - * declaration and this produces invalid URL input. This information - * is passed to the URL editor that prefixes the URL with `baseUri` value - * if passed URL is a relative URL. - * @attribute - */ - baseUri: string; - /** - * OAuth2 redirect URI. - * This value **must** be set in order for OAuth 1/2 to work properly. - * @attribute - */ - redirectUri: string; - /** - * Enables Anypoint platform styles. - * @attribute - */ - anypoint: boolean; - /** - * Enables Material Design outlined style - * @attribute - */ - outlined: boolean; - /** - * Created by the transport ARC `request` object - */ - request: ArcRequest.TransportRequest; - /** - * Created by the transport ARC `response` object. - */ - response: ArcResponse.Response | ArcResponse.ErrorResponse; - /** - * Forces the console to send headers defined in this string overriding any used defined - * header. - * This should be an array of headers with `name` and `value` keys, e.g.: - * ``` - * [{ - * name: "x-token", - * value: "value" - * }] - * ``` - */ - appendHeaders: ApiTypes.ApiType[]; - /** - * If set every request made from the console will be proxied by the service provided in this - * value. - * It will prefix entered URL with the proxy value. so the call to - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/path/http://domain.com/path/?query=some+value` - * - * If the proxy require a to pass the URL as a query parameter define value as follows: - * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` - * attribute. - * @attribute - */ - proxy: string; - /** - * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` - * @attribute - */ - proxyEncodeUrl: boolean; - /** - * ID of latest request. - * It is received from the `api-request-editor` when `api-request` - * event is dispatched. When `api-response` event is handled - * the id is compared and if match it renders the result. - * - * This system allows to use different request panels on single app - * and don't mix the results. - */ - lastRequestId: string; - /** - * If set it computes `hasOptional` property and shows checkbox in the - * form to show / hide optional properties. - * @attribute - */ - allowHideOptional: boolean; - /** - * When set, renders "add custom" item button. - * If the element is to be used without AMF model this should always - * be enabled. Otherwise users won't be able to add a parameter. - * @attribute - */ - allowCustom: boolean; - /** - * Holds the value of the currently selected server - * Data type: URI - * @attribute - */ - serverValue: string; - /** - * Holds the type of the currently selected server - * Values: `server` | `slot` | `custom` - * @attribute - */ - serverType: ServerType; - /** - * Optional property to set - * If true, the server selector is not rendered - * @attribute - */ - noServerSelector: boolean; - /** - * Optional property to set - * If true, the server selector custom base URI option is rendered - * @attribute - */ - allowCustomBaseUri: boolean; - /** - * List of credentials source - */ - credentialsSource: Oauth2Credentials[]; - /** - * When set it applies the authorization values to the request dispatched - * with the API request event. - * If possible, it applies the authorization values to query parameter or headers - * depending on the configuration. - * - * When the values arr applied to the request the authorization config is kept in the - * request object, but its `enabled` state is always `false`, meaning other potential - * processors should ignore this values. - * - * If this property is not set then the application hosting this component should - * process the authorization data and apply them to the request. - * @attribute - */ - applyAuthorization: boolean; - /** - * By default the element stores user input in a map that is associated with the specific - * instance of this element. This way the element can be used multiple times in the same document. - * However, this way parameter values generated by the generators or entered by the user won't - * get populated in different operations. - * - * By setting this value the element prefers a global cache for values. Once the user enter - * a value it is registered in the global cache and restored when the same parameter is used again. - * - * Do not use this option when the element is embedded multiple times in the page. It will result - * in generating request data from the cache and not what's in the form inputs and these may not be in sync. - * - * These values are stored in memory only. Listen to the `change` event to learn that something changed. - * @attribute - */ - globalCache: boolean; - _attachListeners(node: EventTarget): void; - _detachListeners(node: EventTarget): void; - - /** - * Serializes the state of the request editor into the `ApiConsoleRequest` object. - */ - serialize(): ApiConsoleRequest; - - /** - * A handler for the API call. - * This handler will only check if there is authorization required - * and if the user is authorized. - */ - [requestHandler](e: ApiRequestEvent): void; - - /** - * Appends headers defined in the `appendHeaders` array. - */ - [appendConsoleHeaders](e: ApiRequestEvent): void; - - /** - * Sets the proxy URL if the `proxy` property is set. - */ - [appendProxy](e: ApiRequestEvent): void; - - /** - * Handler for the `api-response` custom event. Sets values on the response - * panel when response is ready. - */ - [responseHandler](e: ApiResponseEvent): void; - - /** - * Propagate `api-response` detail object. - * - * Until API Console v 6.x it was using a different response view. The current version - * uses new response view based on ARC response view which uses different data structure. - * This function transforms the response to the one of the corresponding data types used in ARC. - * However, this keeps compatibility with previous versions of the transport library so it is - * safe to upgrade the console without changing the HTTP request process. - * - * @param data Event's detail object - */ - [propagateResponse](data: ApiConsoleResponse): void; - - /** - * Clears response panel when the `domainId` change. - */ - [domainIdChanged](id: string): void; - - /** - * Clears response panel. - */ - clearResponse(): void; - - /** - * Handles navigation events and computes available servers. - * - * When `handleNavigationEvents` is set then it also manages the selection. - */ - [navigationHandler](e: CustomEvent): void; - - /** - * Retargets the change event from the editor. - */ - [changeHandler](): void; - - render(): TemplateResult; - - /** - * @returns A template for the request panel - */ - [requestTemplate](): TemplateResult; - - /** - * @returns A template for the response view - */ - [responseTemplate](): TemplateResult | string; -} diff --git a/src/elements/ApiRequestElement.js b/src/elements/ApiRequestElement.js deleted file mode 100644 index 79d9ec8..0000000 --- a/src/elements/ApiRequestElement.js +++ /dev/null @@ -1,544 +0,0 @@ -/** -@license -Copyright 2021 The Advanced REST client authors -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at -http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -import { html, LitElement } from 'lit-element'; -import { ArcHeaders } from '@advanced-rest-client/base/api.js'; -import { EventsTargetMixin } from '@anypoint-web-components/awc'; -import elementStyles from './styles/Panel.styles.js'; -import { EventTypes } from '../events/EventTypes.js'; -import '../../define/api-request-editor.js'; -import '../../define/api-response-view.js'; - -/* eslint-disable no-plusplus */ -/* eslint-disable class-methods-use-this */ - -/** @typedef {import('lit-html').TemplateResult} TemplateResult */ -/** @typedef {import('@advanced-rest-client/events').ArcResponse.Response} ArcResponse */ -/** @typedef {import('@advanced-rest-client/events').ArcResponse.ErrorResponse} ErrorResponse */ -/** @typedef {import('@advanced-rest-client/events').ArcRequest.ArcBaseRequest} ArcBaseRequest */ -/** @typedef {import('@advanced-rest-client/events').ArcRequest.TransportRequest} TransportRequest */ -/** @typedef {import('@advanced-rest-client/events').ApiTypes.ApiType} ApiType */ -/** @typedef {import('@advanced-rest-client/base').Oauth2Credentials} Oauth2Credentials */ -/** @typedef {import('../types').ServerType} ServerType */ -/** @typedef {import('../types').ApiConsoleRequest} ApiConsoleRequest */ -/** @typedef {import('../types').ApiConsoleResponse} ApiConsoleResponse */ -/** @typedef {import('../events/RequestEvents').ApiRequestEvent} ApiRequestEvent */ -/** @typedef {import('../events/RequestEvents').ApiResponseEvent} ApiResponseEvent */ -/** @typedef {import('../events/NavigationEvents').ApiNavigationEvent} ApiNavigationEvent */ - -export const domainIdValue = Symbol('domainIdValue'); -export const domainIdChanged = Symbol('domainIdChanged'); -export const appendProxy = Symbol('appendProxy'); -export const propagateResponse = Symbol('propagateResponse'); -export const responseHandler = Symbol('responseHandler'); -export const requestHandler = Symbol('requestHandler'); -export const appendConsoleHeaders = Symbol('appendConsoleHeaders'); -export const navigationHandler = Symbol('navigationHandler'); -export const requestTemplate = Symbol('requestTemplate'); -export const responseTemplate = Symbol('requestTemplate'); -export const changeHandler = Symbol('changeHandler'); - -export default class ApiRequestElement extends EventsTargetMixin(LitElement) { - get styles() { - return elementStyles; - } - - /** - * True when the panel render the response. - * @returns {boolean} - */ - get hasResponse() { - return !!this.response; - } - - static get properties() { - return { - /** - * The domain id (AMF's id) of an API operation. - */ - domainId: { type: String }, - /** - * By default application hosting the element must set `domainId` - * property. When using `api-navigation` element - * by setting this property the element listens for navigation events - * and updates the state - */ - handleNavigationEvents: { type: Boolean }, - /** - * When set it renders the URL input above the URL parameters. - */ - urlEditor: { type: Boolean }, - /** - * When set it renders a label with the computed URL. - */ - urlLabel: { type: Boolean }, - /** - * A base URI for the API. To be set if RAML spec is missing `baseUri` - * declaration and this produces invalid URL input. This information - * is passed to the URL editor that prefixes the URL with `baseUri` value - * if passed URL is a relative URL. - */ - baseUri: { type: String }, - /** - * OAuth2 redirect URI. - * This value **must** be set in order for OAuth 1/2 to work properly. - */ - redirectUri: { type: String }, - /** - * Enables Anypoint platform styles. - */ - anypoint: { type: Boolean, reflect: true }, - /** - * Enables Material Design outlined style - */ - outlined: { type: Boolean }, - /** - * Created by the transport ARC `request` object - */ - request: { type: Object }, - /** - * Created by the transport ARC `response` object. - */ - response: { type: Object }, - /** - * Forces the console to send headers defined in this string overriding any used defined - * header. - * This should be an array of headers with `name` and `value` keys, e.g.: - * ``` - * [{ - * name: "x-token", - * value: "value" - * }] - * ``` - */ - appendHeaders: { type: Array }, - /** - * If set every request made from the console will be proxied by the service provided in this - * value. - * It will prefix entered URL with the proxy value. so the call to - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/path/http://domain.com/path/?query=some+value` - * - * If the proxy require a to pass the URL as a query parameter define value as follows: - * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` - * attribute. - */ - proxy: { type: String }, - /** - * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` - */ - proxyEncodeUrl: { type: Boolean }, - - /** - * ID of latest request. - * It is received from the `api-request-editor` when `api-request` - * event is dispatched. When `api-response` event is handled - * the id is compared and if match it renders the result. - * - * This system allows to use different request panels on single app - * and don't mix the results. - */ - lastRequestId: { type: String }, - /** - * If set it computes `hasOptional` property and shows checkbox in the - * form to show / hide optional properties. - */ - allowHideOptional: { type: Boolean }, - /** - * When set, renders "add custom" item button. - * If the element is to be used without AMF model this should always - * be enabled. Otherwise users won't be able to add a parameter. - */ - allowCustom: { type: Boolean }, - /** - * Holds the value of the currently selected server - * Data type: URI - */ - serverValue: { type: String }, - /** - * Holds the type of the currently selected server - * Values: `server` | `slot` | `custom` - */ - serverType: { type: String }, - /** - * Optional property to set - * If true, the server selector is not rendered - */ - noServerSelector: { type: Boolean }, - /** - * Optional property to set - * If true, the server selector custom base URI option is rendered - */ - allowCustomBaseUri: { type: Boolean }, - /** - * List of credentials source - */ - credentialsSource: { type: Array }, - /** - * When set it applies the authorization values to the request dispatched - * with the API request event. - * If possible, it applies the authorization values to query parameter or headers - * depending on the configuration. - * - * When the values arr applied to the request the authorization config is kept in the - * request object, but its `enabled` state is always `false`, meaning other potential - * processors should ignore this values. - * - * If this property is not set then the application hosting this component should - * process the authorization data and apply them to the request. - */ - applyAuthorization: { type: Boolean }, - /** - * By default the element stores user input in a map that is associated with the specific - * instance of this element. This way the element can be used multiple times in the same document. - * However, this way parameter values generated by the generators or entered by the user won't - * get populated in different operations. - * - * By setting this value the element prefers a global cache for values. Once the user enter - * a value it is registered in the global cache and restored when the same parameter is used again. - * - * Do not use this option when the element is embedded multiple times in the page. It will result - * in generating request data from the cache and not what's in the form inputs and these may not be in sync. - * - * These values are stored in memory only. Listen to the `change` event to learn that something changed. - */ - globalCache: { type: Boolean, reflect: true }, - }; - } - - get domainId() { - return this[domainIdValue]; - } - - set domainId(value) { - const old = this[domainIdValue]; - /* istanbul ignore if */ - if (old === value) { - return; - } - this[domainIdValue] = value; - this.requestUpdate('domainId', old); - this[domainIdChanged](value); - } - - constructor() { - super(); - this[responseHandler] = this[responseHandler].bind(this); - this[requestHandler] = this[requestHandler].bind(this); - this[navigationHandler] = this[navigationHandler].bind(this); - /** @type ApiType[] */ - this.appendHeaders = null; - /** @type string */ - this.proxy = undefined; - /** @type boolean */ - this.proxyEncodeUrl = false; - /** @type boolean */ - this.handleNavigationEvents = false; - /** @type boolean */ - this.urlEditor = undefined; - /** @type boolean */ - this.urlLabel = undefined; - /** @type string */ - this.baseUri = undefined; - /** @type boolean */ - this.allowHideOptional = false; - /** @type boolean */ - this.allowCustom = false; - /** @type boolean */ - this.anypoint = false; - /** @type boolean */ - this.outlined = false; - /** @type string */ - this.serverValue = undefined; - /** @type ServerType */ - this.serverType = undefined; - /** @type string */ - this.redirectUri = undefined; - /** @type boolean */ - this.noServerSelector = false; - this.allowCustomBaseUri = false; - /** @type boolean */ - this.globalCache = undefined; - /** @type boolean */ - this.applyAuthorization = undefined; - /** @type Oauth2Credentials[] */ - this.credentialsSource = undefined; - /** @type {ArcBaseRequest} */ - this.request = undefined; - /** @type {ArcResponse|ErrorResponse} */ - this.response = undefined; - } - - /** - * @param {EventTarget} node - */ - _attachListeners(node) { - this.addEventListener(EventTypes.Request.apiRequest, this[requestHandler]); - node.addEventListener(EventTypes.Request.apiResponse, this[responseHandler]); - node.addEventListener(EventTypes.Request.apiResponseLegacy, this[responseHandler]); - node.addEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler]); - } - - /** - * @param {EventTarget} node - */ - _detachListeners(node) { - this.removeEventListener(EventTypes.Request.apiRequest, this[requestHandler]); - node.removeEventListener(EventTypes.Request.apiResponse, this[responseHandler]); - node.removeEventListener(EventTypes.Request.apiResponseLegacy, this[responseHandler]); - node.removeEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler]); - } - - /** - * Serializes the state of the request editor into the `ApiConsoleRequest` object. - * - * Note this is the same object as the one passed to the detail of the api request event. - * - * @return {ApiConsoleRequest} - */ - serialize() { - const editor = this.shadowRoot.querySelector('api-request-editor'); - return editor.serialize(); - } - - /** - * A handler for the API call. - * This handler will only check if there is authorization required - * and if the user is authorized. - * - * @param {ApiRequestEvent} e `api-request` event - */ - [requestHandler](e) { - this.lastRequestId = e.detail.id; - this[appendConsoleHeaders](e); - this[appendProxy](e); - } - - /** - * Appends headers defined in the `appendHeaders` array. - * @param {ApiRequestEvent} e The `api-request` event. - */ - [appendConsoleHeaders](e) { - const headersToAdd = this.appendHeaders; - if (!headersToAdd) { - return; - } - const parser = new ArcHeaders(e.detail.headers || ''); - headersToAdd.forEach((header) => { - const { name, value } = header; - parser.set(name, value); - }); - e.detail.headers = parser.toString(); - } - - /** - * Sets the proxy URL if the `proxy` property is set. - * @param {ApiRequestEvent} e The `api-request` event. - */ - [appendProxy](e) { - const { proxy } = this; - if (!proxy) { - return; - } - let { url } = e.detail; - if (this.proxyEncodeUrl) { - url = encodeURIComponent(url); - } - e.detail.url = `${proxy}${url}`; - } - - /** - * Handler for the `api-response` custom event. Sets values on the response - * panel when response is ready. - * - * @param {ApiResponseEvent} e - */ - [responseHandler](e) { - const response = /** @type ApiConsoleResponse */ (e.detail); - if (this.lastRequestId !== response.id) { - return; - } - this[propagateResponse](response); - } - - /** - * Propagate `api-response` detail object. - * - * Until API Console v 6.x it was using a different response view. The current version - * uses new response view based on ARC response view which uses different data structure. - * This function transforms the response to the one of the corresponding data types used in ARC. - * However, this keeps compatibility with previous versions of the transport library so it is - * safe to upgrade the console without changing the HTTP request process. - * - * @param {ApiConsoleResponse} data Event's detail object - */ - async [propagateResponse](data) { - if (data.isError) { - this.response = /** @type ErrorResponse */ ({ - error: data.error, - statusText: data.response.statusText, - status: data.response.status, - headers: data.response.headers, - id: data.id, - payload: data.response.payload, - }); - } else { - this.response = /** @type ArcResponse */ ({ - loadingTime: data.loadingTime, - statusText: data.response.statusText, - status: data.response.status, - headers: data.response.headers, - id: data.id, - payload: data.response.payload, - }); - } - - const transportRequest = /** @type TransportRequest */({ - httpMessage: '', - method: data.request.method, - endTime: 0, - startTime: 0, - url: data.request.url, - headers: data.request.headers, - payload: data.request.payload, - }); - - const arcRequest = /** @type ArcBaseRequest */ ({ - method: data.request.method, - url: data.request.url, - payload: data.request.payload, - headers: data.request.headers, - kind: 'ARC#HttpRequest', - transportRequest, - response: this.response, - }); - - this.request = arcRequest; - await this.updateComplete; - this.dispatchEvent(new Event('resize', { bubbles: true, composed: true })); - } - - /** - * Clears response panel when the `domainId` change. - * @param {string} id - */ - [domainIdChanged](id) { - if (!id) { - return; - } - this.clearResponse(); - } - - /** - * Clears response panel. - */ - clearResponse() { - if (this.request) { - this.request = undefined; - } - if (this.response) { - this.response = undefined; - } - } - - /** - * Handles navigation events and computes available servers. - * - * When `handleNavigationEvents` is set then it also manages the selection. - * - * @param {ApiNavigationEvent} e - */ - [navigationHandler](e) { - if (this.handleNavigationEvents) { - const { domainId, domainType } = e.detail; - this.domainId = domainType === 'operation' ? domainId : undefined; - } - } - - /** - * Retargets the change event from the editor. - */ - [changeHandler]() { - this.dispatchEvent(new Event('change')); - } - - render() { - return html`${this[requestTemplate]()}${this[responseTemplate]()}`; - } - - /** - * @return {TemplateResult} A template for the request panel - */ - [requestTemplate]() { - const { - redirectUri, - domainId, - urlEditor, - urlLabel, - baseUri, - eventsTarget, - allowHideOptional, - allowCustom, - anypoint, - outlined, - serverValue, - serverType, - noServerSelector, - allowCustomBaseUri, - credentialsSource, - globalCache, - applyAuthorization, - } = this; - - return html` - - - `; - } - - /** - * @return {TemplateResult|string} A template for the response view - */ - [responseTemplate]() { - const { hasResponse } = this; - if (!hasResponse) { - return ''; - } - return html``; - } -} diff --git a/src/elements/ApiRequestElement.ts b/src/elements/ApiRequestElement.ts new file mode 100644 index 0000000..f375339 --- /dev/null +++ b/src/elements/ApiRequestElement.ts @@ -0,0 +1,513 @@ +/** +@license +Copyright 2021 The Advanced REST client authors +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +*/ +import { html, LitElement, CSSResult, TemplateResult } from 'lit'; +import { property, state } from 'lit/decorators.js'; +import { ErrorResponse, TransportRequest, Response, ApiType, ArcBaseRequest } from '@api-client/core/build/legacy.js'; +import { ArcHeaders, Oauth2Credentials } from '@advanced-rest-client/base/api.js'; +import { EventsTargetMixin } from '@anypoint-web-components/awc/dist/index.js'; +import elementStyles from './styles/Panel.styles.js'; +import { EventTypes } from '../events/EventTypes.js'; +import '../../define/api-request-editor.js'; +import '../../define/api-response-view.js'; +import { ApiConsoleRequest, ApiConsoleResponse } from '../types.js'; +import { ApiRequestEvent, ApiResponseEvent } from '../events/RequestEvents.js'; +import { ApiNavigationEvent } from '../events/NavigationEvents.js'; + +/* eslint-disable no-plusplus */ +/* eslint-disable class-methods-use-this */ + +export const domainIdValue = Symbol('domainIdValue'); +export const domainIdChanged = Symbol('domainIdChanged'); +export const appendProxy = Symbol('appendProxy'); +export const propagateResponse = Symbol('propagateResponse'); +export const responseHandler = Symbol('responseHandler'); +export const requestHandler = Symbol('requestHandler'); +export const appendConsoleHeaders = Symbol('appendConsoleHeaders'); +export const navigationHandler = Symbol('navigationHandler'); +export const requestTemplate = Symbol('requestTemplate'); +export const responseTemplate = Symbol('requestTemplate'); +export const changeHandler = Symbol('changeHandler'); + +export default class ApiRequestElement extends EventsTargetMixin(LitElement) { + static get styles(): CSSResult[] { + return [elementStyles]; + } + + /** + * True when the panel render the response. + */ + get hasResponse(): boolean { + return !!this.response; + } + + /** + * By default application hosting the element must set `domainId` + * property. When using `api-navigation` element + * by setting this property the element listens for navigation events + * and updates the state + */ + @property({ type: Boolean, reflect: true }) handleNavigationEvents?: boolean; + + /** + * When set it renders the URL input above the URL parameters. + */ + @property({ type: Boolean, reflect: true }) urlEditor?: boolean; + + /** + * When set it renders a label with the computed URL. + */ + @property({ type: Boolean, reflect: true }) urlLabel?: boolean; + + /** + * A base URI for the API. To be set if RAML spec is missing `baseUri` + * declaration and this produces invalid URL input. This information + * is passed to the URL editor that prefixes the URL with `baseUri` value + * if passed URL is a relative URL. + */ + @property({ type: String }) baseUri?: string; + + /** + * OAuth2 redirect URI. + * This value **must** be set in order for OAuth 1/2 to work properly. + */ + @property({ type: String }) redirectUri?: string; + + /** + * Enables Anypoint platform styles. + */ + @property({ type: Boolean, reflect: true }) anypoint?: boolean; + + /** + * Enables Material Design outlined style + */ + @property({ type: Boolean, reflect: true }) outlined?: boolean; + + /** + * Created by the transport `request` object + */ + @state() request?: TransportRequest; + + /** + * Created by the transport ARC `response` object. + */ + @state() response?: ErrorResponse | Response; + + /** + * Forces the console to send headers defined in this string overriding any used defined + * header. + * This should be an array of headers with `name` and `value` keys, e.g.: + * ``` + * [{ + * name: "x-token", + * value: "value" + * }] + * ``` + */ + @property({ type: Array }) appendHeaders?: ApiType[]; + + /** + * If set every request made from the console will be proxied by the service provided in this + * value. + * It will prefix entered URL with the proxy value. so the call to + * `http://domain.com/path/?query=some+value` will become + * `https://proxy.com/path/http://domain.com/path/?query=some+value` + * + * If the proxy require a to pass the URL as a query parameter define value as follows: + * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` + * attribute. + */ + @property({ type: String }) proxy?: string; + + /** + * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. + * `http://domain.com/path/?query=some+value` will become + * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` + */ + @property({ type: Boolean, reflect: true }) proxyEncodeUrl?: boolean; + + /** + * ID of latest request. + * It is received from the `api-request-editor` when `api-request` + * event is dispatched. When `api-response` event is handled + * the id is compared and if match it renders the result. + * + * This system allows to use different request panels on single app + * and don't mix the results. + */ + @state() lastRequestId?: string; + + /** + * If set it computes `hasOptional` property and shows checkbox in the + * form to show / hide optional properties. + */ + @property({ type: Boolean, reflect: true }) allowHideOptional?: boolean; + + /** + * When set, renders "add custom" item button. + * If the element is to be used without AMF model this should always + * be enabled. Otherwise users won't be able to add a parameter. + */ + @property({ type: Boolean, reflect: true }) allowCustom?: boolean; + + /** + * Holds the value of the currently selected server + * Data type: URI + */ + @property({ type: String }) serverValue?: string; + + /** + * Holds the type of the currently selected server + * Values: `server` | `slot` | `custom` + */ + @property({ type: String }) serverType?: string; + + /** + * Optional property to set + * If true, the server selector is not rendered + */ + @property({ type: Boolean, reflect: true }) noServerSelector?: boolean; + + /** + * Optional property to set + * If true, the server selector custom base URI option is rendered + */ + @property({ type: Boolean, reflect: true }) allowCustomBaseUri?: boolean; + + /** + * List of credentials source + */ + @property({ type: Array }) credentialsSource?: Oauth2Credentials[]; + + /** + * When set it applies the authorization values to the request dispatched + * with the API request event. + * If possible, it applies the authorization values to query parameter or headers + * depending on the configuration. + * + * When the values arr applied to the request the authorization config is kept in the + * request object, but its `enabled` state is always `false`, meaning other potential + * processors should ignore this values. + * + * If this property is not set then the application hosting this component should + * process the authorization data and apply them to the request. + */ + @property({ type: Boolean, reflect: true }) applyAuthorization?: boolean; + + /** + * By default the element stores user input in a map that is associated with the specific + * instance of this element. This way the element can be used multiple times in the same document. + * However, this way parameter values generated by the generators or entered by the user won't + * get populated in different operations. + * + * By setting this value the element prefers a global cache for values. Once the user enter + * a value it is registered in the global cache and restored when the same parameter is used again. + * + * Do not use this option when the element is embedded multiple times in the page. It will result + * in generating request data from the cache and not what's in the form inputs and these may not be in sync. + * + * These values are stored in memory only. Listen to the `change` event to learn that something changed. + */ + @property({ type: Boolean, reflect: true }) globalCache?: boolean; + + [domainIdValue]?: string; + + /** + * The domain id (AMF's id) of an API operation. + */ + @property({ type: String }) + get domainId(): string | undefined { + return this[domainIdValue]; + } + + set domainId(value: string | undefined) { + const old = this[domainIdValue]; + /* istanbul ignore if */ + if (old === value) { + return; + } + this[domainIdValue] = value; + this.requestUpdate('domainId', old); + this[domainIdChanged](value); + } + + constructor() { + super(); + this[responseHandler] = this[responseHandler].bind(this); + this[requestHandler] = this[requestHandler].bind(this); + this[navigationHandler] = this[navigationHandler].bind(this); + this.proxyEncodeUrl = false; + this.handleNavigationEvents = false; + this.allowHideOptional = false; + this.allowCustom = false; + this.anypoint = false; + this.outlined = false; + this.noServerSelector = false; + this.allowCustomBaseUri = false; + } + + _attachListeners(node: EventTarget): void { + this.addEventListener(EventTypes.Request.apiRequest, this[requestHandler] as EventListener); + node.addEventListener(EventTypes.Request.apiResponse, this[responseHandler] as EventListener); + node.addEventListener(EventTypes.Request.apiResponseLegacy, this[responseHandler] as EventListener); + node.addEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler] as EventListener); + } + + _detachListeners(node: EventTarget): void { + this.removeEventListener(EventTypes.Request.apiRequest, this[requestHandler] as EventListener); + node.removeEventListener(EventTypes.Request.apiResponse, this[responseHandler] as EventListener); + node.removeEventListener(EventTypes.Request.apiResponseLegacy, this[responseHandler] as EventListener); + node.removeEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler] as EventListener); + } + + /** + * Serializes the state of the request editor into the `ApiConsoleRequest` object. + * + * Note this is the same object as the one passed to the detail of the api request event. + */ + serialize(): ApiConsoleRequest { + const { shadowRoot } = this; + if (!shadowRoot) { + throw new Error(`The component is not yet initialized.`); + } + const editor = shadowRoot.querySelector('api-request-editor'); + if (!editor) { + throw new Error(`The request editor has been manually removed from the DOM.`); + } + return editor.serialize(); + } + + /** + * A handler for the API call. + * This handler will only check if there is authorization required + * and if the user is authorized. + * + * @param e `api-request` event + */ + [requestHandler](e: ApiRequestEvent): void { + this.lastRequestId = e.detail.id; + this[appendConsoleHeaders](e); + this[appendProxy](e); + } + + /** + * Appends headers defined in the `appendHeaders` array. + * @param e The `api-request` event. + */ + [appendConsoleHeaders](e: ApiRequestEvent): void { + const headersToAdd = this.appendHeaders; + if (!headersToAdd) { + return; + } + const parser = new ArcHeaders(e.detail.headers || ''); + headersToAdd.forEach((header) => { + const { name, value } = header; + parser.set(name, value); + }); + e.detail.headers = parser.toString(); + } + + /** + * Sets the proxy URL if the `proxy` property is set. + * @param e The `api-request` event. + */ + [appendProxy](e: ApiRequestEvent): void { + const { proxy } = this; + if (!proxy) { + return; + } + let { url } = e.detail; + if (this.proxyEncodeUrl) { + url = encodeURIComponent(url); + } + e.detail.url = `${proxy}${url}`; + } + + /** + * Handler for the `api-response` custom event. Sets values on the response + * panel when response is ready. + */ + [responseHandler](e: ApiResponseEvent): void { + const response = e.detail as ApiConsoleResponse; + if (this.lastRequestId !== response.id) { + return; + } + this[propagateResponse](response); + } + + /** + * Propagate `api-response` detail object. + * + * Until API Console v 6.x it was using a different response view. The current version + * uses new response view based on ARC response view which uses different data structure. + * This function transforms the response to the one of the corresponding data types used in ARC. + * However, this keeps compatibility with previous versions of the transport library so it is + * safe to upgrade the console without changing the HTTP request process. + * + * @param {ApiConsoleResponse} data Event's detail object + */ + async [propagateResponse](data: ApiConsoleResponse): Promise { + if (data.isError) { + this.response = { + error: data.error, + statusText: data.response.statusText, + status: data.response.status, + headers: data.response.headers, + id: data.id, + payload: data.response.payload, + } as ErrorResponse; + } else { + this.response = { + loadingTime: data.loadingTime, + statusText: data.response.statusText, + status: data.response.status, + headers: data.response.headers, + id: data.id, + payload: data.response.payload, + } as Response; + } + + const transportRequest: TransportRequest = { + httpMessage: '', + method: data.request.method, + endTime: 0, + startTime: 0, + url: data.request.url, + headers: data.request.headers, + payload: data.request.payload, + }; + + const arcRequest: ArcBaseRequest = { + method: data.request.method, + url: data.request.url, + payload: data.request.payload, + headers: data.request.headers, + kind: 'ARC#HttpRequest', + transportRequest, + response: this.response, + }; + + this.request = arcRequest; + await this.updateComplete; + this.dispatchEvent(new Event('resize', { bubbles: true, composed: true })); + } + + /** + * Clears response panel when the `domainId` change. + */ + [domainIdChanged](id: string): void { + if (!id) { + return; + } + this.clearResponse(); + } + + /** + * Clears response panel. + */ + clearResponse() { + if (this.request) { + this.request = undefined; + } + if (this.response) { + this.response = undefined; + } + } + + /** + * Handles navigation events and computes available servers. + * + * When `handleNavigationEvents` is set then it also manages the selection. + */ + [navigationHandler](e: ApiNavigationEvent): void { + if (this.handleNavigationEvents) { + const { domainId, domainType } = e.detail; + this.domainId = domainType === 'operation' ? domainId : undefined; + } + } + + /** + * Retargets the change event from the editor. + */ + [changeHandler]() { + this.dispatchEvent(new Event('change')); + } + + render(): TemplateResult { + return html`${this[requestTemplate]()}${this[responseTemplate]()}`; + } + + /** + * @returns A template for the request panel + */ + [requestTemplate](): TemplateResult { + const { + redirectUri, + domainId, + urlEditor, + urlLabel, + baseUri, + eventsTarget, + allowHideOptional, + allowCustom, + anypoint, + outlined, + serverValue, + serverType, + noServerSelector, + allowCustomBaseUri, + credentialsSource, + globalCache, + applyAuthorization, + } = this; + + return html` + + + `; + } + + /** + * @returns A template for the response view + */ + [responseTemplate](): TemplateResult | string { + const { hasResponse } = this; + if (!hasResponse) { + return ''; + } + return html``; + } +} diff --git a/src/elements/XhrSimpleRequestTransportElement.d.ts b/src/elements/XhrSimpleRequestTransportElement.d.ts deleted file mode 100644 index 0d89d38..0000000 --- a/src/elements/XhrSimpleRequestTransportElement.d.ts +++ /dev/null @@ -1,267 +0,0 @@ -/* eslint-disable no-param-reassign */ -/* eslint-disable class-methods-use-this */ -/** -@license -Copyright 2018 The Advanced REST client authors -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at -http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -import { LitElement } from 'lit-element'; -import { FormItem } from '@advanced-rest-client/events/src/forms/FormTypes'; -import { ApiConsoleRequest } from '../types'; - -/** - * `xhr-simple-request` - * A XHR request that works with API components. - * - * This is a copy of `iron-request` element from PolymerElements library but - * adjusted to work with `API request` object (or ARC request object). - * - * It also handles custom events related to request flow. - */ -export default class XhrSimpleRequestTransportElement extends LitElement { - /** - * A reference to the XMLHttpRequest instance used to generate the - * network request. - */ - _xhr: XMLHttpRequest; - - /** - * A reference to the parsed response body, if the `xhr` has completely - * resolved. - */ - _response: any; - - /** - * A reference to response headers, if the `xhr` has completely - * resolved. - */ - _headers: string - - /** - * A reference to the status code, if the `xhr` has completely resolved. - */ - _status: number; - - /** - * A reference to the status text, if the `xhr` has completely resolved. - */ - _statusText: string; - /** - * A promise that resolves when the `xhr` response comes back, or rejects - * if there is an error before the `xhr` completes. - * The resolve callback is called with the original request as an argument. - * By default, the reject callback is called with an `Error` as an argument. - * If `rejectWithRequest` is true, the reject callback is called with an - * object with two keys: `request`, the original request, and `error`, the - * error object. - */ - _completes: Promise; - - /** - * Aborted will be true if an abort of the request is attempted. - */ - _aborted: boolean; - - /** - * It is true when the browser fired an error event from the - * XHR object (mainly network errors). - */ - _error: boolean; - - /** - * TimedOut will be true if the XHR threw a timeout event. - */ - _timedOut: boolean; - /** - * Appends headers to each request handled by this component. - * - * Example - * - * ```html - * - * ``` - * @attribute - */ - appendHeaders: string; - /** - * If set every request made from the console will be proxied by the service provided in this - * value. - * It will prefix entered URL with the proxy value. so the call to - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/path/http://domain.com/path/?query=some+value` - * - * If the proxy require a to pass the URL as a query parameter define value as follows: - * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` - * attribute. - * @attribute - */ - proxy: string; - /** - * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` - * @attribute - */ - proxyEncodeUrl: boolean; - - /** - * A reference to the parsed response body, if the `xhr` has completely - * resolved. - */ - get response(): any; - - /** - * A reference to response headers, if the `xhr` has completely - * resolved. - */ - get headers(): string; - - /** - * A reference to the status code, if the `xhr` has completely resolved. - */ - get status(): number; - - get statusText(): string; - - /** - * A promise that resolves when the `xhr` response comes back, or rejects - * if there is an error before the `xhr` completes. - * The resolve callback is called with the original request as an argument. - * By default, the reject callback is called with an `Error` as an argument. - * If `rejectWithRequest` is true, the reject callback is called with an - * object with two keys: `request`, the original request, and `error`, the - * error object. - */ - get completes(): Promise; - - - /** - * Aborted will be true if an abort of the request is attempted. - */ - get aborted(): boolean; - - /** - * Error will be true if the browser fired an error event from the - * XHR object (mainly network errors). - */ - get error(): boolean; - - /** - * Aborted will be true if an abort of the request is attempted. - */ - get timedOut(): boolean; - - resolveCompletes: Function; - rejectCompletes: Function; - - constructor(); - - connectedCallback(): void; - - /** - * Succeeded is true if the request succeeded. The request succeeded if it - * loaded without error, wasn't aborted, and the status code is ≥ 200, and - * < 300, or if the status code is 0. - * - * The status code 0 is accepted as a success because some schemes - e.g. - * file:// - don't provide status codes. - */ - get succeeded(): boolean; - - /** - * Sends a request. - * - * @param {ApiConsoleRequest} options API request object - * @return {Promise} - */ - send(options: ApiConsoleRequest): Promise; - - /** - * Applies headers to the XHR object. - * - * @param {XMLHttpRequest} xhr - * @param {string=} headers HTTP headers string - * @param {boolean=} isFormData Prevents setting content-type header for - * Multipart requests. - */ - _applyHeaders(xhr: XMLHttpRequest, headers?: string, isFormData?: boolean): void; - - /** - * Handler for XHR `error` event. - * - * @param {ProgressEvent} error https://xhr.spec.whatwg.org/#event-xhr-error - */ - _errorHandler(error): void; - - /** - * Handler for XHR `timeout` event. - * - * @param {ProgressEvent} error https://xhr.spec.whatwg.org/#event-xhr-timeout - */ - _timeoutHandler(error): void; - - /** - * Handler for XHR `abort` event. - */ - _abortHandler(): void; - - /** - * Handler for XHR `loadend` event. - */ - _loadEndHandler(): void; - - /** - * Aborts the request. - */ - abort(): void; - - /** - * Updates the status code and status text. - */ - _updateStatus(): void; - - /** - * Attempts to parse the response body of the XHR. If parsing succeeds, - * the value returned will be deserialized based on the `responseType` - * set on the XHR. - * - * TODO: The `responseType` will always be empty string because - * send function does not sets the response type. - * API request object does not support this property. However in the future - * it may actually send this information extracted from the AMF model. - * This function will be ready to handle this case. - * - * @return The parsed response, or undefined if there was an empty response or parsing failed. - */ - parseResponse(): any; - - /** - * Collects response headers string from the XHR object. - * - * @return {string|undefined} - */ - collectHeaders(): string|undefined; - - /** - * Computes value for `_addHeaders` property. - * A list of headers to add to each request. - * @param headers Headers string - */ - _computeAddHeaders(headers: string): FormItem[]|undefined; - - /** - * Sets the proxy URL if the `proxy` property is set. - * @param {string} url Request URL to alter if needed. - * @return {string} The URL to use with request. - */ - _appendProxy(url: string): string; -} diff --git a/src/elements/XhrSimpleRequestTransportElement.js b/src/elements/XhrSimpleRequestTransportElement.ts similarity index 57% rename from src/elements/XhrSimpleRequestTransportElement.js rename to src/elements/XhrSimpleRequestTransportElement.ts index 6ee93d1..e0ebda6 100644 --- a/src/elements/XhrSimpleRequestTransportElement.js +++ b/src/elements/XhrSimpleRequestTransportElement.ts @@ -13,11 +13,10 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { LitElement } from 'lit-element'; -import { HeadersParser } from '@advanced-rest-client/base/api.js'; - -/** @typedef {import('@advanced-rest-client/events').FormTypes.FormItem} FormItem */ -/** @typedef {import('../types').ApiConsoleRequest} ApiConsoleRequest */ +import { LitElement } from 'lit'; +import { property, state } from 'lit/decorators.js'; +import { Headers } from '@api-client/core/build/browser.js'; +import { ApiConsoleRequest } from '../types.js'; /** * `xhr-simple-request` @@ -29,99 +28,97 @@ import { HeadersParser } from '@advanced-rest-client/base/api.js'; * It also handles custom events related to request flow. */ export default class XhrSimpleRequestTransportElement extends LitElement { - static get properties() { - return { - /** - * A reference to the XMLHttpRequest instance used to generate the - * network request. - */ - _xhr: { type: Object }, - - /** - * A reference to the parsed response body, if the `xhr` has completely - * resolved. - */ - _response: { type: Object }, - - /** - * A reference to response headers, if the `xhr` has completely - * resolved. - * @default undefined - */ - _headers: { type: Object }, - - /** - * A reference to the status code, if the `xhr` has completely resolved. - */ - _status: { type: Number }, - - /** - * A reference to the status text, if the `xhr` has completely resolved. - */ - _statusText: { type: String }, - /** - * A promise that resolves when the `xhr` response comes back, or rejects - * if there is an error before the `xhr` completes. - * The resolve callback is called with the original request as an argument. - * By default, the reject callback is called with an `Error` as an argument. - * If `rejectWithRequest` is true, the reject callback is called with an - * object with two keys: `request`, the original request, and `error`, the - * error object. - */ - _completes: { type: Object }, - - /** - * Aborted will be true if an abort of the request is attempted. - */ - _aborted: { type: Boolean }, - - /** - * It is true when the browser fired an error event from the - * XHR object (mainly network errors). - */ - _error: { type: Boolean }, - - /** - * TimedOut will be true if the XHR threw a timeout event. - */ - _timedOut: { type: Boolean }, - /** - * Appends headers to each request handled by this component. - * - * Example - * - * ```html - * - * ``` - */ - appendHeaders: { type: String }, - /** - * If set every request made from the console will be proxied by the service provided in this - * value. - * It will prefix entered URL with the proxy value. so the call to - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/path/http://domain.com/path/?query=some+value` - * - * If the proxy require a to pass the URL as a query parameter define value as follows: - * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` - * attribute. - */ - proxy: { type: String }, - /** - * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. - * `http://domain.com/path/?query=some+value` will become - * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` - */ - proxyEncodeUrl: { type: Boolean } - }; - } + /** + * A reference to the XMLHttpRequest instance used to generate the + * network request. + */ + @state() _xhr: XMLHttpRequest; + + /** + * A reference to the parsed response body, if the `xhr` has completely + * resolved. + */ + @state() _response?: string | null | undefined; + + /** + * A reference to response headers, if the `xhr` has completely resolved. + */ + @state() _headers?: string; + + /** + * A reference to the status code, if the `xhr` has completely resolved. + */ + @state() _status?: number; + + /** + * A reference to the status text, if the `xhr` has completely resolved. + */ + @state() _statusText?: string; + + /** + * A promise that resolves when the `xhr` response comes back, or rejects + * if there is an error before the `xhr` completes. + * The resolve callback is called with the original request as an argument. + * By default, the reject callback is called with an `Error` as an argument. + * If `rejectWithRequest` is true, the reject callback is called with an + * object with two keys: `request`, the original request, and `error`, the + * error object. + */ + @state() _completes: Promise<{ response: string | null | undefined, headers: string | undefined }>; + + /** + * Aborted will be true if an abort of the request is attempted. + */ + @state() _aborted?: boolean; + + /** + * It is true when the browser fired an error event from the + * XHR object (mainly network errors). + */ + @state() _error?: boolean; + + /** + * TimedOut will be true if the XHR threw a timeout event. + */ + @state() _timedOut?: boolean; + + /** + * Appends headers to each request handled by this component. + * + * Example + * + * ```html + * + * ``` + */ + @property({ type: String }) appendHeaders?: string; + /** + * If set every request made from the console will be proxied by the service provided in this + * value. + * It will prefix entered URL with the proxy value. so the call to + * `http://domain.com/path/?query=some+value` will become + * `https://proxy.com/path/http://domain.com/path/?query=some+value` + * + * If the proxy require a to pass the URL as a query parameter define value as follows: + * `https://proxy.com/path/?url=`. In this case be sure to set `proxy-encode-url` + * attribute. + */ + @property({ type: String }) proxy?: string; + + /** + * If `proxy` is set, it will URL encode the request URL before appending it to the proxy URL. + * `http://domain.com/path/?query=some+value` will become + * `https://proxy.com/?url=http%3A%2F%2Fdomain.com%2Fpath%2F%3Fquery%3Dsome%2Bvalue` + */ + @property({ type: Boolean }) proxyEncodeUrl?: boolean; + /** * A reference to the parsed response body, if the `xhr` has completely * resolved. */ - get response() { + get response(): string | null | undefined { return this._response; } @@ -129,20 +126,18 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * A reference to response headers, if the `xhr` has completely * resolved. */ - get headers() { + get headers(): string | undefined { return this._headers; } /** * A reference to the status code, if the `xhr` has completely resolved. - * - * @returns {number} */ - get status() { + get status(): number | undefined { return this._status; } - get statusText() { + get statusText(): string | undefined { return this._statusText; } @@ -154,10 +149,8 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * If `rejectWithRequest` is true, the reject callback is called with an * object with two keys: `request`, the original request, and `error`, the * error object. - * - * @return {Promise} */ - get completes() { + get completes(): Promise<{ response: string | null | undefined, headers: string | undefined }> { return this._completes; } @@ -165,9 +158,8 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * Aborted will be true if an abort of the request is attempted. * * @default false - * @return {boolean} */ - get aborted() { + get aborted(): boolean | undefined { return this._aborted; } @@ -175,17 +167,21 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * Error will be true if the browser fired an error event from the * XHR object (mainly network errors). */ - get error() { + get error(): boolean | undefined { return this._error; } /** * Aborted will be true if an abort of the request is attempted. */ - get timedOut() { + get timedOut(): boolean | undefined { return this._timedOut; } + resolveCompletes?: (value: { response: string | null | undefined, headers: string | undefined }) => void; + + rejectCompletes?: (err: { request: XMLHttpRequest, headers?: string | undefined, error: Error | ProgressEvent }) => void; + constructor() { super(); this._xhr = new XMLHttpRequest(); @@ -193,7 +189,7 @@ export default class XhrSimpleRequestTransportElement extends LitElement { this._status = 0; this._statusText = ''; this.appendHeaders = undefined; - this._completes = new Promise((resolve, reject) => { + this._completes = new Promise<{ response: string | null | undefined, headers: string | undefined }>((resolve, reject) => { this.resolveCompletes = resolve; this.rejectCompletes = reject; }); @@ -204,7 +200,7 @@ export default class XhrSimpleRequestTransportElement extends LitElement { this.proxyEncodeUrl = false; } - connectedCallback() { + connectedCallback(): void { super.connectedCallback(); this.setAttribute('aria-hidden', 'true'); } @@ -216,14 +212,12 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * * The status code 0 is accepted as a success because some schemes - e.g. * file:// - don't provide status codes. - * - * @return {boolean} */ - get succeeded() { + get succeeded(): boolean { if (this.error || this.aborted || this.timedOut) { return false; } - const status = this._xhr.status || 0; + const status = this._xhr?.status || 0; // Note: if we are using the file:// protocol, the status code will be 0 // for all outcomes (successful or otherwise). @@ -233,10 +227,9 @@ export default class XhrSimpleRequestTransportElement extends LitElement { /** * Sends a request. * - * @param {ApiConsoleRequest} options API request object - * @return {Promise} + * @param options API request object */ - send(options) { + send(options: ApiConsoleRequest): Promise<{ response: string | null | undefined, headers: string | undefined }> | null { const xhr = this._xhr; if (xhr.readyState > 0) { return null; @@ -249,12 +242,14 @@ export default class XhrSimpleRequestTransportElement extends LitElement { const url = this._appendProxy(options.url); xhr.open(options.method || 'GET', url, true); this._applyHeaders(xhr, options.headers, options.payload instanceof FormData); - xhr.timeout = options.timeout; + if (typeof options.timeout === 'number') { + xhr.timeout = options.timeout; + } xhr.withCredentials = !!options.withCredentials; try { xhr.send(options.payload); } catch (e) { - this._errorHandler(e); + this._errorHandler(e as Error); } return this.completes; } @@ -262,35 +257,34 @@ export default class XhrSimpleRequestTransportElement extends LitElement { /** * Applies headers to the XHR object. * - * @param {XMLHttpRequest} xhr - * @param {string|Headers} headers HTTP headers - * @param {boolean=} isFormData Prevents setting content-type header for - * Multipart requests. + * @param xhr + * @param headers HTTP headers + * @param isFormData Prevents setting content-type header for Multipart requests. */ - _applyHeaders(xhr, headers, isFormData) { + _applyHeaders(xhr: XMLHttpRequest, headers?: string | Headers, isFormData?: boolean): void { const fixed = this._computeAddHeaders(this.appendHeaders); - const fixedNames = []; - if (fixed && fixed.length) { - fixed.forEach((item) => { - fixedNames[fixedNames.length] = item.name; + const fixedNames: string[] = []; + if (fixed) { + fixed.forEach((value, name) => { + fixedNames[fixedNames.length] = name; try { - xhr.setRequestHeader(item.name, item.value); + xhr.setRequestHeader(name, value); } catch (e) { // .. } }); } if (headers) { - const data = HeadersParser.toJSON(headers); - data.forEach((item) => { - if (fixedNames.indexOf(item.name) !== -1) { + const parsed = new Headers(headers); + parsed.forEach((value, name) => { + if (fixedNames.indexOf(name) !== -1) { return; } - if (isFormData && item.name.toLowerCase() === 'content-type') { + if (isFormData && name.toLowerCase() === 'content-type') { return; } try { - xhr.setRequestHeader(item.name, item.value); + xhr.setRequestHeader(name, value); } catch (e) { // .. } @@ -298,12 +292,20 @@ export default class XhrSimpleRequestTransportElement extends LitElement { } } + _computeAddHeaders(headers?: string): Headers | undefined { + if (!headers) { + return undefined; + } + headers = String(headers).replace('\\n', '\n'); + return new Headers(headers); + } + /** * Handler for XHR `error` event. * - * @param {ProgressEvent} error https://xhr.spec.whatwg.org/#event-xhr-error + * @param error https://xhr.spec.whatwg.org/#event-xhr-error */ - _errorHandler(error) { + _errorHandler(error: ProgressEvent | Error): void { if (this.aborted) { return; } @@ -315,28 +317,32 @@ export default class XhrSimpleRequestTransportElement extends LitElement { request: this._xhr, headers: this.headers }; - this.rejectCompletes(response); + if (this.rejectCompletes) { + this.rejectCompletes(response); + } } /** * Handler for XHR `timeout` event. * - * @param {ProgressEvent} error https://xhr.spec.whatwg.org/#event-xhr-timeout + * @param error https://xhr.spec.whatwg.org/#event-xhr-timeout */ - _timeoutHandler(error) { + _timeoutHandler(error: ProgressEvent): void { this._timedOut = true; this._updateStatus(); const response = { error, request: this._xhr }; - this.rejectCompletes(response); + if (this.rejectCompletes) { + this.rejectCompletes(response); + } } /** * Handler for XHR `abort` event. */ - _abortHandler() { + _abortHandler(): void { this._aborted = true; this._updateStatus(); const error = new Error('Request aborted'); @@ -344,13 +350,15 @@ export default class XhrSimpleRequestTransportElement extends LitElement { error, request: this._xhr }; - this.rejectCompletes(response); + if (this.rejectCompletes) { + this.rejectCompletes(response); + } } /** * Handler for XHR `loadend` event. */ - _loadEndHandler() { + _loadEndHandler(): void { if (this.aborted || this.timedOut) { return; } @@ -364,8 +372,10 @@ export default class XhrSimpleRequestTransportElement extends LitElement { request: this._xhr, headers: this.headers }; - this.rejectCompletes(response); - } else { + if (this.rejectCompletes) { + this.rejectCompletes(response); + } + } else if (this.resolveCompletes) { this.resolveCompletes({ response: this.response, headers: this.headers @@ -376,17 +386,17 @@ export default class XhrSimpleRequestTransportElement extends LitElement { /** * Aborts the request. */ - abort() { + abort(): void { this._aborted = true; - this._xhr.abort(); + this._xhr?.abort(); } /** * Updates the status code and status text. */ - _updateStatus() { - this._status = this._xhr.status; - this._statusText = (this._xhr.statusText === undefined ? '' : this._xhr.statusText); + _updateStatus(): void { + this._status = this._xhr?.status; + this._statusText = (this._xhr?.statusText === undefined ? '' : this._xhr.statusText); } /** @@ -400,11 +410,10 @@ export default class XhrSimpleRequestTransportElement extends LitElement { * it may actually send this information extracted from the AMF model. * This function will be ready to handle this case. * - * @return {*} The parsed response, - * or undefined if there was an empty response or parsing failed. + * @returns The parsed response, or undefined if there was an empty response or parsing failed. */ - parseResponse() { - const xhr = this._xhr; + parseResponse(): string | null | undefined { + const xhr = this._xhr as XMLHttpRequest; const { responseType } = xhr; const preferResponseText = !xhr.responseType; try { @@ -439,46 +448,35 @@ export default class XhrSimpleRequestTransportElement extends LitElement { } } } catch (e) { - this.rejectCompletes(new Error(`Could not parse response. ${ e.message}`)); + if (this.rejectCompletes) { + this.rejectCompletes({ + error: new Error(`Could not parse response. ${(e as Error).message}`), + request: this._xhr, + }); + } } return undefined; } /** * Collects response headers string from the XHR object. - * - * @return {string|undefined} */ - collectHeaders() { - let data; + collectHeaders(): string|undefined { + let data: string | undefined; try { - data = this._xhr.getAllResponseHeaders(); + data = this._xhr?.getAllResponseHeaders(); } catch (_) { // ... } return data; } - /** - * Computes value for `_addHeaders` property. - * A list of headers to add to each request. - * @param {string} headers Headers string - * @return {FormItem[]|undefined} - */ - _computeAddHeaders(headers) { - if (!headers) { - return undefined; - } - headers = String(headers).replace('\\n', '\n'); - return HeadersParser.toJSON(headers); - } - /** * Sets the proxy URL if the `proxy` property is set. - * @param {string} url Request URL to alter if needed. - * @return {string} The URL to use with request. + * @param url Request URL to alter if needed. + * @returns The URL to use with request. */ - _appendProxy(url) { + _appendProxy(url: string): string { const { proxy } = this; if (!proxy) { return url; diff --git a/src/events/ApiEvents.d.ts b/src/events/ApiEvents.d.ts deleted file mode 100644 index 0c0f67e..0000000 --- a/src/events/ApiEvents.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { ApiSummary } from '../helpers/api'; -import { DocumentMeta } from '../types'; - -export declare interface IApiEvents { - /** - * Reads basic info about the API. - * @param target The node on which to dispatch the event - */ - summary(target: EventTarget): Promise; - /** - * Reads the current API's protocols. - * @param target The node on which to dispatch the event - */ - protocols(target: EventTarget): Promise; - /** - * Reads the current API's version. - * @param target The node on which to dispatch the event - */ - version(target: EventTarget): Promise; - /** - * Reads the meta information about the currently loaded document from the store. - * @param target The node on which to dispatch the event - */ - documentMeta(target: EventTarget): Promise; -} - -export declare const ApiEvents: Readonly; diff --git a/src/events/ApiEvents.js b/src/events/ApiEvents.js deleted file mode 100644 index c225e24..0000000 --- a/src/events/ApiEvents.js +++ /dev/null @@ -1,52 +0,0 @@ -import { EventTypes } from './EventTypes.js'; -import { ApiStoreContextEvent } from './BaseEvents.js'; - -/** @typedef {import('../helpers/api').ApiSummary} ApiSummary */ -/** @typedef {import('../types').DocumentMeta} DocumentMeta */ - -export const ApiEvents = { - /** - * Reads basic info about the API. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} - */ - summary: async (target) => { - const e = new ApiStoreContextEvent(EventTypes.Api.summary); - target.dispatchEvent(e); - return e.detail.result; - }, - - /** - * Reads the current API's protocols. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} - */ - protocols: async (target) => { - const e = new ApiStoreContextEvent(EventTypes.Api.protocols); - target.dispatchEvent(e); - return e.detail.result; - }, - - /** - * Reads the current API's version. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} - */ - version: async (target) => { - const e = new ApiStoreContextEvent(EventTypes.Api.version); - target.dispatchEvent(e); - return e.detail.result; - }, - - /** - * Reads the meta information about the currently loaded document from the store. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} - */ - documentMeta: async (target) => { - const e = new ApiStoreContextEvent(EventTypes.Api.documentMeta); - target.dispatchEvent(e); - return e.detail.result; - }, -} -Object.freeze(ApiEvents); diff --git a/src/events/ApiEvents.ts b/src/events/ApiEvents.ts new file mode 100644 index 0000000..accbf1d --- /dev/null +++ b/src/events/ApiEvents.ts @@ -0,0 +1,47 @@ +import { ApiDefinitions } from '@api-client/core/build/browser.js'; +import { EventTypes } from './EventTypes.js'; +import { ApiStoreContextEvent } from './BaseEvents.js'; +import { DocumentMeta } from '../types.js'; + +export const ApiEvents = { + /** + * Reads basic info about the API. + * @param target The node on which to dispatch the event + */ + summary: async (target: EventTarget): Promise => { + const e = new ApiStoreContextEvent(EventTypes.Api.summary); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, + + /** + * Reads the current API's protocols. + * @param target The node on which to dispatch the event + */ + protocols: async (target: EventTarget): Promise => { + const e = new ApiStoreContextEvent(EventTypes.Api.protocols); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, + + /** + * Reads the current API's version. + * @param target The node on which to dispatch the event + */ + version: async (target: EventTarget): Promise => { + const e = new ApiStoreContextEvent(EventTypes.Api.version); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, + + /** + * Reads the meta information about the currently loaded document from the store. + * @param target The node on which to dispatch the event + */ + documentMeta: async (target: EventTarget): Promise => { + const e = new ApiStoreContextEvent(EventTypes.Api.documentMeta); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, +} +Object.freeze(ApiEvents); diff --git a/src/events/BaseEvents.js b/src/events/BaseEvents.js deleted file mode 100644 index 37bb446..0000000 --- a/src/events/BaseEvents.js +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable max-classes-per-file */ - -/** - * A base class to use with store events that do not expect a result. - */ -export class ApiStoreContextVoidEvent extends CustomEvent { - /** - * @param {string} type The event type - * @param {any=} detail The optional detail object. It adds object's properties to the `detail` with the `result` property. - */ - constructor(type, detail={}) { - super(type, { - bubbles: true, - composed: true, - cancelable: true, - detail, - }); - } -} - - -/** - * A base class to use with store events. - */ -export class ApiStoreContextEvent extends CustomEvent { - /** - * @param {string} type The event type - * @param {any=} detail The optional detail object. It adds object's properties to the `detail` with the `result` property. - */ - constructor(type, detail={}) { - super(type, { - bubbles: true, - composed: true, - cancelable: true, - detail: { - result: undefined, - ...detail, - } - }); - } -} - -/** - * An event to be used to read an object from the API store. - */ -export class ApiStoreReadEvent extends ApiStoreContextEvent { - /** - * @param {string} type The type of the event - * @param {string} id The domain id of the object to read - * @param {string=} parent The domain id of the parent object (like endpoint for an operation). - */ - constructor(type, id, parent) { - super(type, { id, parent }); - } -} - -/** - * An event to be used to read a list of object from the API store. - */ -export class ApiStoreReadBulkEvent extends ApiStoreContextEvent { - /** - * @param {string} type The type of the event - * @param {string[]} ids The list of domain ids to read. These must be of the same domain type. - */ - constructor(type, ids) { - super(type, { ids }); - } -} diff --git a/src/events/BaseEvents.d.ts b/src/events/BaseEvents.ts similarity index 61% rename from src/events/BaseEvents.d.ts rename to src/events/BaseEvents.ts index 620c653..1368d2b 100644 --- a/src/events/BaseEvents.d.ts +++ b/src/events/BaseEvents.ts @@ -1,53 +1,28 @@ -/** - * A base class to use with store events that do not expect a result. - */ -export declare class ApiStoreContextVoidEvent extends CustomEvent { - /** - * @param type The event type - * @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property. - */ - constructor(type: string, detail?: any); -} +/* eslint-disable max-classes-per-file */ /** - * A base class to use with store events. + * A base class to use with store events that do not expect a result. */ -export declare class ApiStoreContextEvent extends CustomEvent> { +export class ApiStoreContextVoidEvent extends CustomEvent { /** * @param type The event type * @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property. */ - constructor(type: string, detail?: any); -} - -/** - * An event to be used to read an object from the API store. - */ -export class ApiStoreReadEvent extends CustomEvent> { - /** - * @param type The type of the event - * @param id The domain id of the object to read - * @param parent The domain id of the parent object (like endpoint for an operation). - */ - constructor(type: string, id: string, parent?: string); -} - -/** - * An event to be used to read a list of object from the API store. - */ -export class ApiStoreReadBulkEvent extends CustomEvent> { - /** - * @param type The type of the event - * @param ids The list of domain ids to read. These must be of the same domain type. - */ - constructor(type: string, ids: string[]); + constructor(type: string, detail?: T) { + super(type, { + bubbles: true, + composed: true, + cancelable: true, + detail, + }); + } } /** * Base event detail definition for the events that returns a `result` * property on the `detail` object */ -export declare interface StoreEventDetailWithResult { +export interface StoreEventDetailWithResult { /** * This property is set by the store, a promise resolved when the operation finish * with the corresponding result. @@ -55,10 +30,27 @@ export declare interface StoreEventDetailWithResult { result?: Promise | null; } + /** - * A detail for an event that returns a void result. + * A base class to use with store events. */ -export declare interface StoreEventDetailVoid extends StoreEventDetailWithResult { +export class ApiStoreContextEvent extends CustomEvent> { + /** + * @param type The event type + * @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property. + */ + constructor(type: string, detail?: T) { + const d = detail || {}; + super(type, { + bubbles: true, + composed: true, + cancelable: true, + detail: { + result: undefined, + ...d, + } + }); + } } export declare interface ApiStoreReadEventDetail extends StoreEventDetailWithResult { @@ -72,9 +64,36 @@ export declare interface ApiStoreReadEventDetail extends StoreEventDetailWith parent?: string; } +/** + * An event to be used to read an object from the API store. + */ +export class ApiStoreReadEvent extends ApiStoreContextEvent> { + /** + * @param type The type of the event + * @param id The domain id of the object to read + * @param parent The domain id of the parent object (like endpoint for an operation). + */ + constructor(type: string, id: string, parent?: string) { + super(type, { id, parent }); + } +} + export declare interface ApiStoreReadBulkEventDetail extends StoreEventDetailWithResult { /** * The list of domain ids to read. */ - ids: string; + ids: string[]; +} + +/** + * An event to be used to read a list of object from the API store. + */ +export class ApiStoreReadBulkEvent extends ApiStoreContextEvent> { + /** + * @param type The type of the event + * @param ids The list of domain ids to read. These must be of the same domain type. + */ + constructor(type: string, ids: string[]) { + super(type, { ids }); + } } diff --git a/src/events/DocumentationEvents.d.ts b/src/events/DocumentationEvents.d.ts deleted file mode 100644 index f19eef3..0000000 --- a/src/events/DocumentationEvents.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ApiDocumentation } from '../helpers/api'; - -declare interface IDocumentationEvents { - /** - * Lists the documentation definitions for the API. - * @param target The node on which to dispatch the event - * @returns The list of documentations. - */ - list(target: EventTarget): Promise; - /** - * Reads RAML's/OAS's documentation page. - * @param target The node on which to dispatch the event - * @param id The domain id of the documentation. - */ - get(target: EventTarget, id: string): Promise; -} - -export declare const DocumentationEvents: Readonly; diff --git a/src/events/DocumentationEvents.js b/src/events/DocumentationEvents.js deleted file mode 100644 index ac5fac6..0000000 --- a/src/events/DocumentationEvents.js +++ /dev/null @@ -1,29 +0,0 @@ -import { EventTypes } from './EventTypes.js'; -import { ApiStoreReadEvent, ApiStoreContextEvent } from './BaseEvents.js'; - -/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ - -export const DocumentationEvents = { - /** - * Reads RAML's/OAS's documentation page. - * @param {EventTarget} target The node on which to dispatch the event - * @param {string} id The domain id of the documentation. - * @returns {Promise} - */ - get: async (target, id) => { - const e = new ApiStoreReadEvent(EventTypes.Documentation.get, id); - target.dispatchEvent(e); - return e.detail.result; - }, - /** - * Lists the documentation definitions for the API. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} The list of documentations. - */ - list: async (target) => { - const e = new ApiStoreContextEvent(EventTypes.Documentation.list); - target.dispatchEvent(e); - return e.detail.result; - }, -} -Object.freeze(DocumentationEvents); diff --git a/src/events/DocumentationEvents.ts b/src/events/DocumentationEvents.ts new file mode 100644 index 0000000..9a580c7 --- /dev/null +++ b/src/events/DocumentationEvents.ts @@ -0,0 +1,29 @@ +import { ApiDefinitions } from '@api-client/core/build/browser.js'; +import { EventTypes } from './EventTypes.js'; +import { ApiStoreReadEvent, ApiStoreContextEvent } from './BaseEvents.js'; + +/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ + +export const DocumentationEvents = { + /** + * Reads RAML's/OAS's documentation page. + * @param target The node on which to dispatch the event + * @param id The domain id of the documentation. + */ + get: async (target: EventTarget, id: string): Promise => { + const e = new ApiStoreReadEvent(EventTypes.Documentation.get, id); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, + /** + * Lists the documentation definitions for the API. + * @param target The node on which to dispatch the event + * @returns The list of documentations. + */ + list: async (target: EventTarget): Promise => { + const e = new ApiStoreContextEvent(EventTypes.Documentation.list); + target.dispatchEvent(e); + return e.detail.result as Promise; + }, +} +Object.freeze(DocumentationEvents); diff --git a/src/events/EndpointEvents.d.ts b/src/events/EndpointEvents.d.ts deleted file mode 100644 index ae0466d..0000000 --- a/src/events/EndpointEvents.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ApiEndPointWithOperationsListItem } from '../types'; -import { ApiEndPoint } from '../helpers/api'; - -declare interface IEndpointEvents { - /** - * Reads the endpoint model from the store. - * @param target The node on which to dispatch the event - * @param id The domain id of the endpoint. - */ - get(target: EventTarget, id: string): Promise; - /** - * Reads the endpoint model from the store by the path value. - * @param target The node on which to dispatch the event - * @param path The path of the endpoint. - */ - byPath(target: EventTarget, path: string): Promise; - /** - * List all endpoints in the API. - * @param target The node on which to dispatch the event - */ - list(target: EventTarget): Promise; -} - -export declare const EndpointEvents: Readonly; diff --git a/src/events/EndpointEvents.js b/src/events/EndpointEvents.ts similarity index 50% rename from src/events/EndpointEvents.js rename to src/events/EndpointEvents.ts index 65ed75a..5fa1e94 100644 --- a/src/events/EndpointEvents.js +++ b/src/events/EndpointEvents.ts @@ -1,3 +1,4 @@ +import { ApiDefinitions } from '@api-client/core/build/browser.js'; import { EventTypes } from './EventTypes.js'; import { ApiStoreContextEvent, ApiStoreReadEvent } from './BaseEvents.js'; @@ -7,35 +8,32 @@ import { ApiStoreContextEvent, ApiStoreReadEvent } from './BaseEvents.js'; export const EndpointEvents = { /** * Reads the endpoint model from the store. - * @param {EventTarget} target The node on which to dispatch the event - * @param {string} id The domain id of the endpoint. - * @returns {Promise} + * @param target The node on which to dispatch the event + * @param id The domain id of the endpoint. */ - get: async (target, id) => { + get: async (target: EventTarget, id: string): Promise => { const e = new ApiStoreReadEvent(EventTypes.Endpoint.get, id); target.dispatchEvent(e); - return e.detail.result; + return e.detail.result as Promise; }, /** * Reads the endpoint model from the store by the path value. - * @param {EventTarget} target The node on which to dispatch the event - * @param {string} path The path of the endpoint. - * @returns {Promise} + * @param target The node on which to dispatch the event + * @param path The path of the endpoint. */ - byPath: async (target, path) => { + byPath: async (target: EventTarget, path: string): Promise => { const e = new ApiStoreReadEvent(EventTypes.Endpoint.byPath, path); target.dispatchEvent(e); - return e.detail.result; + return e.detail.result as Promise; }, /** * Lists all endpoints with operations included into the result. - * @param {EventTarget} target The node on which to dispatch the event - * @returns {Promise} + * @param target The node on which to dispatch the event */ - list: async (target) => { + list: async (target: EventTarget): Promise => { const e = new ApiStoreContextEvent(EventTypes.Endpoint.list); target.dispatchEvent(e); - return e.detail.result; + return e.detail.result as Promise; }, }; diff --git a/src/events/EventTypes.d.ts b/src/events/EventTypes.d.ts deleted file mode 100644 index ffbcc68..0000000 --- a/src/events/EventTypes.d.ts +++ /dev/null @@ -1,100 +0,0 @@ -interface Security { - settingsChanged: string; - get: string; - getRequirement: string; - list: string; -} -interface Request { - apiRequest: string; - apiRequestLegacy: string; - abortApiRequest: string; - abortApiRequestLegacy: string; - apiResponse: string; - apiResponseLegacy: string; - redirectUriChange: string; - redirectUriChangeLegacy: string; - populateAnnotatedFields: string; - populateAnnotatedFieldsLegacy: string; - get: string; -} - -interface Response { - get: string; -} - -interface Server { - serverChange: string; - serverCountChange: string; - query: string; -} - -declare interface ApiEvents { - summary: string; - protocols: string; - version: string; - documentMeta: string; -} -declare interface Navigation { - apiNavigate: string; - navigateExternal: string; -} - -declare interface EndpointEvents { - get: string; - byPath: string; - list: string; -} - -declare interface OperationEvents { - get: string; - getParent: string; -} - -declare interface ReportingEvents { - error: string; -} - -declare interface TelemetryEvents { - view: string; - event: string; - exception: string; - social: string; - timing: string; -} - -declare interface StoreEvents { - graphChange: string; -} - -declare interface DocumentationEvents { - get: string; - list: string; -} - -declare interface PayloadEvents { - get: string; -} - -declare interface TypeEvents { - get: string; - list: string; -} - -interface IEventTypes { - Security: Readonly; - Request: Readonly; - Response: Readonly; - Payload: Readonly; - Server: Readonly; - Api: Readonly; - Navigation: Readonly; - Endpoint: Readonly; - Operation: Readonly; - Reporting: Readonly; - Telemetry: Readonly; - Store: Readonly; - Documentation: Readonly; - Type: Readonly; -} - -export const EventTypes: Readonly; diff --git a/src/events/EventTypes.js b/src/events/EventTypes.ts similarity index 100% rename from src/events/EventTypes.js rename to src/events/EventTypes.ts diff --git a/src/events/Events.d.ts b/src/events/Events.d.ts deleted file mode 100644 index d3c61b4..0000000 --- a/src/events/Events.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { IStoreEvents } from './StoreEvents'; -import { IEndpointEvents } from './EndpointEvents'; -import { IOperationEvents } from './OperationEvents'; -import { IApiEvents } from './ApiEvents'; -import { IServerEvents } from './ServerEvents'; -import { INavigationEvents } from './NavigationEvents'; -import { IDocumentationEvents } from './DocumentationEvents'; -import { ISecurityEvents } from './SecurityEvents'; -import { ITypeEvents } from './TypeEvents'; -import { IResponseEvents } from './ResponseEvents'; -import { IRequestEvents } from './RequestEvents'; -import { IReportingEvents } from './ReportingEvents'; -import { ITelemetryEvents } from './TelemetryEvents'; -import { IPayloadEvents } from './PayloadEvents'; -// import { IParameterEvents } from './ParameterEvents'; -// import { IExampleEvents } from './ExampleEvents'; -// import { ICustomPropertyEvents } from './CustomPropertyEvents'; - -declare interface IEvents { - Store: IStoreEvents; - Api: IApiEvents; - Endpoint: IEndpointEvents; - Operation: IOperationEvents; - Server: IServerEvents; - // Documentation: IDocumentationEvents; - Security: ISecurityEvents; - Type: ITypeEvents; - Response: IResponseEvents; - Request: IRequestEvents; - Payload: IPayloadEvents; - // Parameter: IParameterEvents; - // Example: IExampleEvents; - // CustomProperty: ICustomPropertyEvents; - Navigation: INavigationEvents; - Reporting: IReportingEvents; - Telemetry: ITelemetryEvents; - Documentation: IDocumentationEvents; -} - -export const Events: Readonly; diff --git a/src/events/Events.js b/src/events/Events.ts similarity index 100% rename from src/events/Events.js rename to src/events/Events.ts diff --git a/src/events/NavigationEvents.js b/src/events/NavigationEvents.js deleted file mode 100644 index aa43415..0000000 --- a/src/events/NavigationEvents.js +++ /dev/null @@ -1,61 +0,0 @@ -/* eslint-disable max-classes-per-file */ -import { EventTypes } from './EventTypes.js'; - -/** @typedef {import('../helpers/api').ApiSummary} ApiSummary */ -/** @typedef {import('../types').SelectionType} SelectionType */ - -export class ApiNavigationEvent extends CustomEvent { - /** - * @param {string} domainId The domain id (graph id) of the selected object - * @param {SelectionType} domainType The type of the selected domain object. - * @param {string=} parentId Optional, the parent object domain id (for an operation it is an endpoint) - * @param {boolean=} passive Whether the selection came from the system processing rather than user interaction. - */ - constructor(domainId, domainType, parentId, passive) { - super(EventTypes.Navigation.apiNavigate, { - bubbles: true, - composed: true, - cancelable: false, - detail: { - domainId, domainType, parentId, passive, - } - }); - } -} - -export const NavigationEvents = { - /** - * Performs a navigation action in AMF components. - * @param {EventTarget} target The node on which to dispatch the event - * @param {string} domainId The domain id (graph id) of the selected object - * @param {SelectionType} domainType The type of the selected domain object. - * @param {string=} parentId Optional, the parent object domain id (for an operation it is an endpoint) - * @param {boolean=} passive Whether the selection came from the system processing rather than user interaction. - */ - apiNavigate: (target, domainId, domainType, parentId, passive) => { - const e = new ApiNavigationEvent(domainId, domainType, parentId, passive); - target.dispatchEvent(e); - }, - /** - * Dispatches an event to inform the application to open a browser window. - * This is a general purpose action. It has the `detail` object with optional - * `purpose` property which can be used to support different kind of external navigation. - * - * @param {EventTarget} target A node on which to dispatch the event. - * @param {string} url The URL to open - * @returns {boolean} True when the event was cancelled meaning the navigation was handled. - */ - navigateExternal: (target, url) => { - const e = new CustomEvent(EventTypes.Navigation.navigateExternal, { - bubbles: true, - composed: true, - cancelable: true, - detail: { - url, - }, - }); - target.dispatchEvent(e); - return e.defaultPrevented; - }, -} -Object.freeze(NavigationEvents); diff --git a/src/events/NavigationEvents.d.ts b/src/events/NavigationEvents.ts similarity index 59% rename from src/events/NavigationEvents.d.ts rename to src/events/NavigationEvents.ts index 3934c03..cab6b39 100644 --- a/src/events/NavigationEvents.d.ts +++ b/src/events/NavigationEvents.ts @@ -1,4 +1,6 @@ -import { SelectionType } from '../types'; +/* eslint-disable max-classes-per-file */ +import { EventTypes } from './EventTypes.js'; +import { SelectionType } from '../types.js'; export interface ApiNavigationEventDetail { /** @@ -19,26 +21,38 @@ export interface ApiNavigationEventDetail { passive?: boolean; } -export declare class ApiNavigationEvent extends CustomEvent { +export class ApiNavigationEvent extends CustomEvent { /** * @param domainId The domain id (graph id) of the selected object * @param domainType The type of the selected domain object. * @param parentId Optional, the parent object domain id (for an operation it is an endpoint) * @param passive Whether the selection came from the system processing rather than user interaction. */ - constructor(domainId: string, domainType: SelectionType, parentId?: string, passive?: boolean); + constructor(domainId: string, domainType: SelectionType, parentId?: string, passive?: boolean) { + super(EventTypes.Navigation.apiNavigate, { + bubbles: true, + composed: true, + cancelable: false, + detail: { + domainId, domainType, parentId, passive, + } + }); + } } -export declare interface INavigationEvents { +export const NavigationEvents = { /** - * Reads basic info about the API. + * Performs a navigation action in AMF components. * @param target The node on which to dispatch the event * @param domainId The domain id (graph id) of the selected object * @param domainType The type of the selected domain object. * @param parentId Optional, the parent object domain id (for an operation it is an endpoint) * @param passive Whether the selection came from the system processing rather than user interaction. */ - apiNavigate(target: EventTarget, domainId: string, domainType: SelectionType, parentId?: string, passive?: boolean): void; + apiNavigate: (target: EventTarget, domainId: string, domainType: SelectionType, parentId?: string, passive?: boolean): void => { + const e = new ApiNavigationEvent(domainId, domainType, parentId, passive); + target.dispatchEvent(e); + }, /** * Dispatches an event to inform the application to open a browser window. * This is a general purpose action. It has the `detail` object with optional @@ -46,9 +60,19 @@ export declare interface INavigationEvents { * * @param target A node on which to dispatch the event. * @param url The URL to open - * @returns True when the event was cancelled meaning the navigation handled. + * @returns True when the event was cancelled meaning the navigation was handled. */ - navigateExternal(target: EventTarget, url: string): boolean; + navigateExternal: (target: EventTarget, url: string): boolean => { + const e = new CustomEvent(EventTypes.Navigation.navigateExternal, { + bubbles: true, + composed: true, + cancelable: true, + detail: { + url, + }, + }); + target.dispatchEvent(e); + return e.defaultPrevented; + }, } - -export declare const NavigationEvents: Readonly; +Object.freeze(NavigationEvents); diff --git a/src/helpers/AmfHelperMixin.ts b/src/helpers/AmfHelperMixin.ts deleted file mode 100644 index 1653329..0000000 --- a/src/helpers/AmfHelperMixin.ts +++ /dev/null @@ -1,1700 +0,0 @@ -/* eslint-disable default-param-last */ -/* eslint-disable @typescript-eslint/no-unused-vars */ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -/* eslint-disable @typescript-eslint/ban-types */ -/* eslint-disable class-methods-use-this */ -/* eslint-disable no-plusplus */ -/* eslint-disable no-continue */ - -/** -@license -Copyright 2018 The Advanced REST client authors -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at -http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -// @ts-ignore -import { AmfModelExpander, JsonLdOptions, JsonLd } from 'amf-json-ld-lib'; -import { dedupeMixin } from '@open-wc/dedupe-mixin'; -import { ns as Namespace } from './Namespace.js'; -import { - AmfDocument, AsyncApi, DomainElement, EndPoint, Operation, Parameter, Payload, Request, Response, - SecurityScheme, Server, Shape, WebApi, Api -} from './amf.js'; -import { ServersQueryOptions } from './api.js'; - -/** @typedef {import('./Namespace').ns} Namespace */ -/** @typedef {import('./amf').DomainElement} DomainElement */ -/** @typedef {import('./amf').AmfDocument} AmfDocument */ -/** @typedef {import('./amf').WebApi} WebApi */ -/** @typedef {import('./amf').AsyncApi} AsyncApi */ -/** @typedef {import('./amf').Server} Server */ -/** @typedef {import('./amf').EndPoint} EndPoint */ -/** @typedef {import('./amf').Operation} Operation */ -/** @typedef {import('./amf').Shape} Shape */ -/** @typedef {import('./amf').Parameter} Parameter */ -/** @typedef {import('./amf').Request} Request */ -/** @typedef {import('./amf').Response} Response */ -/** @typedef {import('./amf').Payload} Payload */ -/** @typedef {import('./amf').SecurityScheme} SecurityScheme */ -/** @typedef {import('./api').ServersQueryOptions} ServersQueryOptions */ -/** @typedef {import('./api').ServerQueryOptions} ServerQueryOptions */ -/** @typedef {import('./api').ComputeUriOptions} ComputeUriOptions */ - -export const expandKey = Symbol('expandKey'); -export const findAmfType = Symbol('findAmfType'); -export const findReferenceObject = Symbol('findReferenceObject'); -export const getArrayItems = Symbol('getArrayItems'); -export const computeReferenceSecurity = Symbol('computeReferenceSecurity'); - -type Constructor = new (...args: any[]) => T; - -/** - * Common functions used by AMF components to compute AMF values. - */ -export interface AmfHelperMixinInterface { - /** - * A namespace for AMF model. - */ - readonly ns: typeof Namespace; - - /** - * Generated AMF json/ld model form the API spec. - * The element assumes the object of the first array item to be a - * type of `"http://raml.org/vocabularies/document#Document` - * on AMF vocabulary. - * - * It is only useful for the element to resolve references. - */ - amf: AmfDocument | undefined; - _amf: AmfDocument | undefined; - - /** - * This is an abstract method to be implemented by the components. - * If, instead, the component uses `amf` setter you must use `super.amf` to - * set the value. - * @param amf Current AMF model. Can be undefined. - */ - __amfChanged(amf: AmfDocument): void - /** - * Expands flattened AMF model - */ - _expand(amf: any): AmfDocument; - - /** - * Returns compact model key for given value. - * - * @param property AMF original property - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Compact model property name or the same value if - * value not found in the context. - */ - _getAmfKey(property: string | undefined, context?: Record): string | undefined; - - /** - * Ensures that the model is AMF object. - * - * @param amf AMF json/ld model - * @returns API spec - */ - _ensureAmfModel(amf: any): AmfDocument | undefined; - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param value An item to test - */ - _ensureArray(value: T): T[] | undefined; - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param value An item to test - */ - _ensureArray(value: T[]): T[] | undefined; - - /** - * Gets a single scalar value from a model. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for key - */ - _getValue(model: DomainElement, key: string, context?: Record): string | number | boolean | undefined | null; - - /** - * Gets values from a model as an array of `@value` properties. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for key - */ - _getValueArray(model: DomainElement, key: string, context?: Record): Array | undefined; - - /** - * Reads an array from the model. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Value for the key - */ - [getArrayItems](model: DomainElement, key: string, context?: Record): DomainElement[] | undefined; - - /** - * Reads the value of the `@id` property. - * @param model Amf model to extract the value from. - * @param key Model key to search for the @id - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValue(model: DomainElement, key: string, context?: Record): string | undefined; - - /** - * Reads the list of value for the `@id` property. - * @param model Amf model to extract the value from. - * @param key Model key to search for the `@id` - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValues(model: DomainElement, key: string, context?: Record): string[] | undefined; - - /** - * Checks if a model has a type. - * - * @param model Model to test - * @param type Type name - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns True if model has a type. - */ - _hasType(model: DomainElement, type: string, context?: Record): boolean | null; - - /** - * Checks if a shape has a property. - * - * @param shape The shape to test - * @param key Property name to test - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _hasProperty(shape: DomainElement, key: string, context?: Record): boolean | null; - - /** - * Computes array value of a property in a model (shape). - * - * @param shape AMF shape object - * @param key Property name - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computePropertyArray(shape: DomainElement, key: string, context?: Record): Array | undefined; - - /** - * Computes API version from the AMF model. - */ - _computeApiVersion(amf: AmfDocument, context?: Record): string | undefined; - - /** - * Computes model's `encodes` property. - * - * @param model AMF data model - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of encodes - */ - _computeEncodes(model: AmfDocument, context?: Record): Api | undefined; - - /** - * Computes list of declarations in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeDeclares(model: AmfDocument, context?: Record): DomainElement[] | undefined; - - /** - * Computes list of references in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeReferences(model: AmfDocument, context?: Record): DomainElement[] | undefined; - - /** - * Computes AMF's `http://schema.org/WebAPI` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Web API declaration. - */ - _computeWebApi(model: AmfDocument, context?: Record): WebApi | undefined; - - /** - * Computes AMF's `http://schema.org/API` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @return The API declaration. - */ - _computeApi(model: AmfDocument, context?: Record): AsyncApi | WebApi; - - /** - * Returns whether an AMF node is a WebAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isWebAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Returns whether an AMF node is an AsyncAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAsyncAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Returns whether an AMF node is an API node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAPI(model: AmfDocument, context?: Record): boolean; - - /** - * Determines whether a partial model is valid for reading servers from - * Current valid values: - * - Operation - * - Endpoint - * @param model The partial model to evaluate - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Whether the model's type is part of the array of valid node types from which to read servers - */ - _isValidServerPartial(model: any, context?: Record): boolean; - - /** - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of servers for method, if defined, or endpoint, if defined, or root level - */ - _getServers(opts?: ServersQueryOptions, context?: Record): Server[] | undefined; - - /** - * Computes value for the `expects` property. - * - * @param method AMF `supportedOperation` model - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computeExpects(method: Operation, context?: Record): Request | undefined; - - /** - * Computes list of endpoints from a WebApi model. - * - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Always returns an array of endpoints. - */ - _computeEndpoints(webApi: WebApi, context?: Record): EndPoint[] | undefined; - - /** - * Computes model for an endpoint documentation. - * - * @param webApi Current value of `webApi` property - * @param id Selected shape ID - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint definition - */ - _computeEndpointModel(webApi: WebApi, id: string, context?: Record): EndPoint | undefined; - - /** - * Computes method for the method documentation. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A method definition - */ - _computeMethodModel(webApi: WebApi, selected: string, context?: Record): Operation | undefined; - - /** - * Computes an endpoint for a method. - * - * @param webApi The WebApi AMF model - * @param methodId Method id - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint model of undefined. - */ - _computeMethodEndpoint(webApi: WebApi, methodId: string, context?: Record): EndPoint | undefined; - - /** - * Computes a list of methods for an endpoint that contains a method with - * given id. - * - * @param webApi WebApi model - * @param methodId Method id. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A list of sibling methods or undefined. - */ - __computeMethodsListForMethod(webApi: WebApi, methodId: string, context?: Record): Operation[] | undefined; - - /** - * Computes a type documentation model. - * - * @param declares Current value of `declares` property - * @param references Current value of `references` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A type definition - */ - _computeType(declares: DomainElement[], references: DomainElement[], selected: string, context?: Record): Shape | undefined; - - /** - * Finds a type in the model declares and references. - * @param domainId The domain id of the type (AMF's shape). - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The AMF shape or undefined when not found. - */ - [findAmfType](domainId?: string, context?: Record): Shape | undefined; - - /** - * Searches for an object in model's references list. - * It does not resolve the object (useful for handling links correctly). - * - * @param domainId The domain of the object to find in the references. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The domain object or undefined. - */ - [findReferenceObject](domainId?: string, context?: Record): DomainElement | undefined; - - /** - * Computes a type model from a reference (library for example). - * - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - _computeReferenceType(reference: DomainElement, selected: string, context?: Record): Shape | undefined; - - /** - * Computes a documentation model. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A method definition - */ - _computeDocument(webApi: WebApi, selected: string, context?: Record): DomainElement | undefined; - - /** - * Resolves a reference to an external fragment. - * - * @param shape A shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape. - */ - _resolve(shape: T, context?: Record): T; - _getLinkTarget(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined; - - /** - * Resolves the shape of a given reference. - * - * @param references References object to search in - * @param id Id of the shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape for given reference, undefined otherwise - */ - _obtainShapeFromReferences(references: DomainElement[], id: string, context?: Record): DomainElement | undefined; - - /** - * Searches a node with a given ID in an array - * - * @param array Array to search for a given ID - * @param id Id to search for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Node with the given ID when found, undefined otherwise - */ - _findById(array: DomainElement[], id: string): DomainElement | undefined; - _getReferenceId(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined; - _resolveRecursive(shape: T, context?: Record): T; - - /** - * Merge two shapes together. If the resulting shape has one of the "special merge" keys, - * then the special merge function for that key will be used to match that property - * @param shapeA AMF node - * @param shapeB AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Merged AMF node - */ - _mergeShapes(shapeA: any, shapeB: any, context?: Record): any; - - /** - * Obtains source map sources value from two shapes and returns the merged result - * If neither shape has a sources node, then an empty object will be returned. - * Result is wrapped in an array as per AMF model standard - * @param AMF node - * @param AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Empty object or resulting merge, wrapped in an array - */ - _mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record): any[]; - - /** - * Expands the key property from compacted mode to full mode. - * @param value The value to process - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The expanded value. - */ - [expandKey](value: string, context?: Record): string; - /** - * Computes a security model from a reference (library for example). - * @param domainId Domain id of the security requirement to find. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - findSecurityScheme(domainId: string, context?: Record): SecurityScheme | undefined; - - /** - * Computes a security model from a reference (library for example). - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - [computeReferenceSecurity](reference: DomainElement, selected: string, context?: Record): SecurityScheme | undefined; - /** - * Collects domain objects by a domain type. - * @param source The element to search for declare/encoded objects. - * @param type The domain type - * @param context A context to use. If not set, it looks for the context of the passed model - */ - getByType(source: DomainElement, type: string, context?: Record): DomainElement[]; -} - -export const AmfHelperMixin = dedupeMixin(>(superClass: T): Constructor & T => { - class AmfHelperMixinClass extends superClass { - static get properties() { - return { - /** - * Generated AMF json/ld model form the API spec. - * The element assumes the object of the first array item to be a - * type of `"http://raml.org/vocabularies/document#Document` - * on AMF vocabulary. - * - * It is only useful for the element to resolve references. - */ - amf: { type: Object } - }; - } - - /** - * A namespace for AMF model. - */ - get ns(): typeof Namespace { - return Namespace; - } - - get amf() { - return this._amf; - } - - set amf(value) { - const old = this._amf; - if (old === value) { - return; - } - let expanded; - if (!value || AmfModelExpander.isInExpandedForm(value)) { - this._flattenedAmf = undefined; - expanded = value; - } else { - const oldFlattened = this._flattenedAmf; - if (oldFlattened === value) { - return; - } - this._flattenedAmf = value; - expanded = this._expand(value); - } - // Cached keys cannot be static as this element can be using in the sane - // document with different AMF models - this.__cachedKeys = {}; - this._amf = expanded; - this.__amfChanged(expanded); - if (this.requestUpdate) { - this.requestUpdate('amf', old); - } - } - - /** - * This is an abstract method to be implemented by the components. - * If, instead, the component uses `amf` setter you must use `super.amf` to - * set the value. - * @param amf Current AMF model. Can be undefined. - */ - __amfChanged(amf: any) { - // ... - } - - /** - * Expands flattened AMF model - */ - _expand(amf: any) { - AmfModelExpander.preprocessLegacyRootNodeId(amf) - const linkEmbeddingFilter = (key: string) => !key.endsWith("fixPoint") - const rootNode = amf['@context'] ? '' : "amf://id"; - const options = JsonLdOptions.apply() - .withEmbeddedLinks(linkEmbeddingFilter) - .withCompactedIris() - .withExpandedStructure() - .withRootNode(rootNode) - return JsonLd.process(amf, options) - } - - /** - * Returns compact model key for given value. - * @param property AMF original property - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Compact model property name or the same value if - * value not found in the context. - */ - _getAmfKey(property: string, context?: Record): string | undefined { - if (!property) { - return undefined; - } - let { amf } = this; - if (!amf && !context) { - return property; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - if (!this.__cachedKeys) { - this.__cachedKeys = {}; - } - const ctx = (context || amf['@context']) as Record; - if (!ctx || !property) { - return property; - } - const cache = this.__cachedKeys; - if (property in cache) { - return cache[property]; - } - /* eslint-disable-next-line no-param-reassign */ - property = String(property); - const hashIndex = property.indexOf('#'); - const hashProperty = property.substr(0, hashIndex + 1); - const keys = Object.keys(ctx); - for (let i = 0, len = keys.length; i < len; i++) { - const k = keys[i]; - if (ctx[k] === property) { - cache[property] = k; - return k; - } if (hashIndex === -1 && property.indexOf(ctx[k]) === 0) { - const result = property.replace(ctx[k], `${k}:`); - cache[property] = result; - return result; - } if (ctx[k] === hashProperty) { - const result = `${k}:${property.substr(hashIndex + 1)}`; - cache[property] = result; - return result; - } - } - return property; - } - - /** - * Ensures that the model is AMF object. - * - * @param amf AMF json/ld model - * @returns API spec - */ - _ensureAmfModel(amf: any): AmfDocument | undefined { - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - /* eslint-disable-next-line no-param-reassign */ - [amf] = amf; - } - if (this._hasType(amf, Namespace.aml.vocabularies.document.Document)) { - return amf; - } - return undefined; - } - - /** - * Ensures that the value is an array. - * It returns undefined when there's no value. - * It returns the same array if the value is already an array. - * It returns new array of the item is not an array. - * - * @param value An item to test - */ - _ensureArray(value: any): unknown { - if (!value) { - return undefined; - } - if (value instanceof Array) { - return value; - } - return [value]; - } - - /** - * Gets a single scalar value from a model. - * @param model Amf model to extract the value from. - * @param inKey Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The value for key - */ - _getValue(model: DomainElement, inKey: string, context?: Record): string | number | boolean | undefined | null { - /* eslint-disable-next-line no-param-reassign */ - const key = this._getAmfKey(inKey, context); - if (!key) { - return undefined; - } - let data = model && (model as any)[key] as any; - if (!data) { - // This includes "undefined", "false", "null" and "0" - return data; - } - if (Array.isArray(data)) { - /* eslint-disable-next-line no-param-reassign */ - [data] = data; - } - if (!data) { - return undefined; - } - const type = typeof data; - if (['string', 'number', 'boolean', 'undefined'].indexOf(type) !== -1) { - return data; - } - return data['@value']; - } - - /** - * Gets values from a model as an array of `@value` properties. - * @param model Amf model to extract the value from. - * @param inKey Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The value for key - */ - _getValueArray(model: DomainElement, inKey: string, context?: Record): Array | undefined { - const key = this._getAmfKey(inKey, context); - if (!key) { - return undefined; - } - const data = model && this._ensureArray((model as any)[key]); - if (!Array.isArray(data)) { - return undefined; - } - return data.map((item) => item['@value'] || item); - } - - /** - * Reads an array from the model. - * - * @param model Amf model to extract the value from. - * @param key Model key to search for the value - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The value for the key - */ - [getArrayItems](model: DomainElement, key: string, context?: Record): DomainElement[] | undefined { - const k = this._getAmfKey(key, context); - if (!k) { - return undefined; - } - const data = model && this._ensureArray((model as any)[k]); - if (!Array.isArray(data)) { - return undefined; - } - return data; - } - - /** - * Reads the value of the `@id` property. - * @param model Amf model to extract the value from. - * @param key Model key to search for the @id - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValue(model: DomainElement, key: string, context?: Record): string | undefined { - const k = this._getAmfKey(key, context); - if (!k) { - return undefined; - } - let data = model && (model as any)[k]; - if (!data) { - return undefined; - } - if (Array.isArray(data)) { - [data] = data; - } - if (!data) { - return undefined; - } - return data['@id']; - } - - /** - * Reads the list of value for the `@id` property. - * @param model Amf model to extract the value from. - * @param inKey Model key to search for the @id - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _getLinkValues(model: DomainElement, inKey: string, context?: Record): string[] | undefined { - const k = this._getAmfKey(inKey, context); - if (!k) { - return undefined; - } - let data = (model && (model as any)[k]) as DomainElement[] | undefined; - if (!data) { - return undefined; - } - if (!Array.isArray(data)) { - data = [data]; - } - return data.map(i => i['@id']); - } - - /** - * Checks if a model has a type. - * @param model Model to test - * @param type Type name - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns True if model has a type. - */ - _hasType(model: DomainElement, type: string, context?: Record): boolean { - const types = this._ensureArray(model && model['@type']) as string[]; - if (!types || !types.length) { - return false; - } - const key = this._getAmfKey(type, context); - for (let i = 0; i < types.length; i++) { - if (types[i] === key) { - return true; - } - } - return false; - } - - /** - * Checks if a shape has a property. - * @param shape The shape to test - * @param inKey Property name to test - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _hasProperty(shape: DomainElement, inKey: string, context?: Record): boolean { - const k = this._getAmfKey(inKey, context); - if (!k) { - return false; - } - return !!(shape && k && k in shape); - } - - /** - * Computes array value of a property in a model (shape). - * - * @param shape AMF shape object - * @param inKey Property name - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computePropertyArray(shape: DomainElement, inKey: string, context?: Record): Array | undefined { - if (!shape) { - return undefined; - } - const k = this._getAmfKey(inKey, context); - if (!k) { - return undefined; - } - const data = this._ensureArray(shape && (shape as any)[k]); - if (!data || !Array.isArray(data)) { - return undefined; - } - return data; - } - - /** - * Computes API version from the AMF model. - * - * @param amf - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns {string} - */ - _computeApiVersion(amf: AmfDocument, context?: Record) { - const api = this._computeApi(amf); - if (!api) { - return undefined; - } - return /** @type string */ (this._getValue(api, this.ns.aml.vocabularies.core.version, context)); - } - - /** - * Computes model's `encodes` property. - * - * @param model AMF data model - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of encodes - */ - _computeEncodes(model: AmfDocument, context?: Record): DomainElement | undefined { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.encodes, context); - if (!key) { - return undefined; - } - const data = (model as any)[key]; - if (data) { - return Array.isArray(data) ? data[0] : data; - } - return undefined; - } - - /** - * Computes list of declarations in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeDeclares(model: AmfDocument, context?: Record): DomainElement[] | undefined { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.declares, context); - if (!key) { - return undefined; - } - const data = this._ensureArray((model as any)[key]); - return Array.isArray(data) ? data : undefined; - } - - /** - * Computes list of references in the AMF api model. - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of declarations - */ - _computeReferences(model: AmfDocument, context?: Record): DomainElement[] | undefined { - if (!model) { - return undefined; - } - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.document.references, context); - if (!key) { - return undefined; - } - const data = this._ensureArray((model as any)[key]) as DomainElement[] | undefined; - return data instanceof Array ? data : undefined; - } - - /** - * Computes AMF's `http://schema.org/WebAPI` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Web API declaration. - */ - _computeWebApi(model: AmfDocument, context?: Record): WebApi | undefined { - const enc = this._computeEncodes(model, context); - if (!enc) { - return undefined; - } - if (this._hasType(enc, this.ns.aml.vocabularies.apiContract.WebAPI, context)) { - return enc; - } - return undefined; - } - - /** - * Computes AMF's `http://schema.org/API` model - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns API declaration. - */ - _computeApi(model: AmfDocument, context?: Record): AsyncApi | WebApi | undefined { - const enc = this._computeEncodes(model, context); - if (!enc) { - return undefined; - } - if (this._isAPI(model, context) || this._isWebAPI(model, context) || this._isAsyncAPI(model, context)) { - return enc; - } - return undefined; - } - - /** - * Returns whether an AMF node is a WebAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isWebAPI(model: AmfDocument, context?: Record): boolean { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.WebAPI, context); - } - - /** - * Returns whether an AMF node is an AsyncAPI node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAsyncAPI(model: AmfDocument, context?: Record): boolean { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.AsyncAPI, context); - } - - /** - * Returns whether an AMF node is an API node - * - * @param model AMF json/ld model for an API - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _isAPI(model: AmfDocument, context?: Record): boolean { - const enc = this._computeEncodes(model, context); - if (!enc) { - return false; - } - return this._hasType(enc, this.ns.aml.vocabularies.apiContract.API, context); - } - - /** - * Determines whether a partial model is valid for reading servers from - * Current valid values: - * - Operation - * - Endpoint - * @param model The partial model to evaluate - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Whether the model's type is part of the array of valid node types from which - * to read servers - */ - _isValidServerPartial(model: DomainElement, context?: Record): boolean { - if (Array.isArray(model)) { - /* eslint-disable-next-line no-param-reassign */ - [model] = model; - } - if (!model) { - return false; - } - const oKey = this.ns.aml.vocabularies.apiContract.Operation; - const eKey = this.ns.aml.vocabularies.apiContract.EndPoint; - const allowedPartialModelTypes = [this._getAmfKey(oKey, context), this._getAmfKey(eKey, context)]; - const types = model['@type']; - for (const type of types) { - if (allowedPartialModelTypes.indexOf(type) !== -1) { - return true; - } - } - return false; - } - - /** - * @param options Server query options - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns List of servers for method, if defined, or endpoint, if defined, or root level - */ - _getServers(options: ServersQueryOptions = {}, context?: Record): Server[] | undefined { - const { endpointId, methodId } = options; - const { amf } = this; - if (!amf) { - return undefined; - } - let api = this._computeApi(amf, context); - if (Array.isArray(api)) { - [api] = api; - } - if (!api) { - if (this._isValidServerPartial(amf, context)) { - api = amf; - } else { - return undefined; - } - } - - const serverKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.server, context) as string; - const getRootServers = () => (this[getArrayItems](api as DomainElement, serverKey, context)) as Server[]; - const getEndpointServers = () => { - const endpoint = this._computeEndpointModel(api as WebApi, endpointId, context); - const servers = (this[getArrayItems](endpoint as EndPoint, serverKey, context)) as Server[]; - if (servers) { - return servers; - } - return getRootServers(); - }; - const getMethodServers = () => { - const method = this._computeMethodModel(api as WebApi, methodId as string, context); - const servers = (this[getArrayItems](method as Operation, serverKey, context)) as Server[]; - if (servers) { - return servers; - } - return getEndpointServers(); - }; - - if (methodId) { - return getMethodServers(); - } if (endpointId) { - return getEndpointServers(); - } - return getRootServers(); - } - - /** - * Computes value for the `expects` property. - * - * @param method AMF `supportedOperation` model - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computeExpects(method: Operation, context?: Record): Request | undefined { - const operationKey = this.ns.aml.vocabularies.apiContract.Operation; - const expectsKey = this.ns.aml.vocabularies.apiContract.expects; - if (this._hasType(method, operationKey, context)) { - const key = this._getAmfKey(expectsKey, context); - if (!key) { - return undefined; - } - const expects = this._ensureArray((method as any)[key]); - if (expects) { - return Array.isArray(expects) ? expects[0] : expects; - } - } - return undefined; - } - - /** - * Computes list of endpoints from a WebApi model. - * @param webApi - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An array of endpoints. - */ - _computeEndpoints(webApi: WebApi, context?: Record): EndPoint[] | undefined { - if (!webApi) { - return []; - } - const endpointKey = this.ns.aml.vocabularies.apiContract.endpoint; - const key = this._getAmfKey(endpointKey, context); - if (!key) { - return undefined; - } - return this._ensureArray((webApi as any)[key]) as EndPoint[]; - } - - /** - * Computes model for an endpoint documentation. - * - * @param webApi Current value of `webApi` property - * @param id Selected shape ID - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint definition - */ - _computeEndpointModel(webApi: WebApi, id?: string, context?: Record): EndPoint | undefined { - if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { - return webApi; - } - const endpoints = this._computeEndpoints(webApi, context); - if (!endpoints) { - return undefined; - } - return endpoints.find((item) => item['@id'] === id); - } - - /** - * Computes method for the method documentation. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A method definition - */ - _computeMethodModel(webApi: WebApi, selected: string, context?: Record): Operation | undefined { - const methods = this.__computeMethodsListForMethod(webApi, selected, context); - if (!methods) { - return undefined; - } - return methods.find((item) => item['@id'] === selected); - } - - /** - * Computes an endpoint for a method. - * @param webApi The WebApi AMF model - * @param methodId Method id - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns An endpoint model of undefined. - */ - _computeMethodEndpoint(webApi: WebApi, methodId: string, context?: Record): EndPoint | undefined { - if (!webApi || !methodId) { - return undefined; - } - if (this._hasType(webApi, this.ns.aml.vocabularies.apiContract.EndPoint, context)) { - return webApi; - } - const endpoints = this._computeEndpoints(webApi, context); - if (!endpoints) { - return undefined; - } - const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context) as string; - for (let i = 0, len = endpoints.length; i < len; i++) { - const endpoint = endpoints[i]; - let methods = (endpoint as any)[opKey] as Operation[] | undefined; - if (!methods) { - continue; - } - if (!Array.isArray(methods)) { - methods = [methods]; - } - for (let j = 0, jLen = methods.length; j < jLen; j++) { - if (methods[j]['@id'] === methodId) { - return endpoint; - } - } - } - return undefined; - } - - /** - * Computes a list of methods for an endpoint that contains a method with - * given id. - * - * @param webApi WebApi model - * @param methodId Method id. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A list of sibling methods or undefined. - */ - __computeMethodsListForMethod(webApi: WebApi, methodId: string, context?: Record): Operation[] | undefined { - const endpoint = this._computeMethodEndpoint(webApi, methodId, context); - if (!endpoint) { - return undefined; - } - const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation, context); - if (!opKey) { - return undefined; - } - return this._ensureArray((endpoint as any)[opKey]) as Operation[]; - } - - /** - * Computes a type documentation model. - * - * @param declares Current value of `declares` property - * @param references Current value of `references` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns A type definition - */ - _computeType(declares: DomainElement[], references: DomainElement[], selected: string, context?: Record): Shape | undefined { - if ((!declares && !references) || !selected) { - return undefined; - } - // In compact model some IDs are presented in long version (in source maps for examples) - // This must test for this case as well. - const compactId = selected.replace('amf://id', ''); - let type = declares && declares.find((item) => item['@id'] === selected || item['@id'] === compactId); - if (!type && references && references.length) { - for (let i = 0, len = references.length; i < len; i++) { - if (!this._hasType(references[i], this.ns.aml.vocabularies.document.Module)) { - continue; - } - type = this._computeReferenceType(references[i], selected, context); - if (type) { - break; - } - } - } - return type; - } - - /** - * Finds a type in the model declares and references. - * @param domainId The domain id of the type (AMF's shape). - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The AMF shape or undefined when not found. - */ - [findAmfType](domainId: string, context?: Record): Shape | undefined { - let { amf } = this; - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const declares = this._computeDeclares(amf, context); - const compactId = domainId.replace('amf://id', ''); - if (Array.isArray(declares)) { - const result = declares.find((item) => item['@id'] === domainId || item['@id'] === compactId); - if (result) { - return result; - } - } - return this[findReferenceObject](domainId); - } - - /** - * Searches for an object in model's references list. - * It does not resolve the object (useful for handling links correctly). - * - * @param domainId The domain of the object to find in the references. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The domain object or undefined. - */ - [findReferenceObject](domainId: string, context?: Record): DomainElement | undefined { - let { amf } = this; - if (!amf) { - return undefined; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const references = this._computeReferences(amf, context); - if (!Array.isArray(references) || !references.length) { - return undefined; - } - const compactId = domainId.replace('amf://id', ''); - for (let i = 0, len = references.length; i < len; i++) { - const ref = /** @type AmfDocument */ (references[i]); - const declares = this._computeDeclares(ref, context); - if (!Array.isArray(declares)) { - continue; - } - for (let j = 0, lenDecl = declares.length; j < lenDecl; j++) { - let declared = declares[j]; - if (Array.isArray(declared)) { - [declared] = declared; - } - if (declared['@id'] === domainId || declared['@id'] === compactId) { - return declared; - } - } - } - return undefined; - } - - /** - * Computes a type model from a reference (library for example). - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - _computeReferenceType(reference: DomainElement, selected: string, context?: Record): Shape | undefined { - const declare = this._computeDeclares(reference, context); - if (!declare) { - return undefined; - } - // In compact model some IDs are presented in long version (in source maps for examples) - // This must test for this case as well. - const compactId = selected.replace('amf://id', ''); - let result = declare.find((item) => { - if (Array.isArray(item)) { - /* eslint-disable-next-line no-param-reassign */ - [item] = item; - } - return item['@id'] === selected || item['@id'] === compactId; - }); - if (Array.isArray(result)) { - [result] = result; - } - return this._resolve(result as Shape); - } - - /** - * Computes a documentation model. - * - * @param webApi Current value of `webApi` property - * @param selected Selected shape - * @param context A context to use. If not set, it looks for the context of the passed model - */ - _computeDocument(webApi: WebApi, selected: string, context?: Record): DomainElement | undefined { - if (!webApi || !selected) { - return undefined; - } - const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation, context) as string; - const docs = this._ensureArray((webApi as any)[key]) as DomainElement[]; - return docs && docs.find((item) => item['@id'] === selected); - } - - /** - * Resolves a reference to an external fragment. - * - * @param shape A shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape. - */ - _resolve

(shape: P & { __apicResolved?: boolean }, context?: Record): P { - const { amf } = this; - if (!shape || typeof shape !== 'object' || Array.isArray(shape) || !amf || shape.__apicResolved) { - return shape; - } - let refKey = this._getAmfKey(this.ns.aml.vocabularies.document.linkTarget, context) as string; - let refValue = this._ensureArray((shape as any)[refKey]) as any[]; - let refData; - if (refValue) { - const rk = refValue[0]['@id']; - if (rk === (shape as any)['@id']) { - // recursive shape. - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - refData = this._getLinkTarget(amf, rk, context); - } else { - refKey = this._getAmfKey(this.ns.aml.vocabularies.document.referenceId, context) as string; - refValue = this._ensureArray((shape as any)[refKey]) as any[]; - if (refValue) { - const rk = refValue[0]['@id']; - if (rk === (shape as any)['@id']) { - // recursive shape. - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - refData = this._getReferenceId(amf, rk, context); - } - } - if (!refData) { - this._resolveRecursive(shape); - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - return shape; - } - const copy = { ...refData }; - delete (copy as any)['@id']; - const types = copy['@type']; - if (types) { - if ((shape as any)['@type']) { - /* eslint-disable-next-line no-param-reassign */ - (shape as any)['@type'] = (shape as any)['@type'].concat(types); - } else { - /* eslint-disable-next-line no-param-reassign */ - (shape as any)['@type'] = types; - } - delete (copy as any)['@type']; - } - this._mergeShapes(shape, copy, context); - /* eslint-disable-next-line no-param-reassign */ - shape.__apicResolved = true; - this._resolveRecursive(shape); - return shape; - } - - /** - * @param amf References object to search in - * @param id Id of the shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape for given reference, undefined otherwise - */ - _getLinkTarget(amf: AmfDocument, id: string, context?: Record): DomainElement | undefined { - if (!amf || !id) { - return undefined; - } - let target; - const declares = this._computeDeclares(amf, context); - if (declares) { - target = this._findById(declares, id); - } - if (!target) { - const references = this._computeReferences(amf, context); - target = this._obtainShapeFromReferences(references as DomainElement[], id, context); - } - if (!target) { - return undefined; - } - // Declaration may contain references - target = this._resolve(target); - return target; - } - - /** - * Resolves the shape of a given reference. - * - * @param references References object to search in - * @param id Id of the shape to resolve - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Resolved shape for given reference, undefined otherwise - */ - _obtainShapeFromReferences(references: DomainElement[], id: string, context?: Record): DomainElement | undefined { - if (!Array.isArray(references) || !references.length) { - return undefined; - } - let target; - for (let i = 0; i < references.length; i++) { - const _ref = references[i]; - // case of fragment that encodes the shape - const encoded = this._computeEncodes(_ref, context); - if (encoded && encoded['@id'] === id) { - target = encoded; - break; - } - // case of a library which declares types - if (!encoded) { - const decl = this._computeDeclares(_ref, context) as DomainElement[]; - target = this._findById(decl, id); - if (target) break; - } - } - return target; - } - - /** - * Searches a node with a given ID in an array - * - * @param array Array to search for a given ID - * @param id Id to search for - * @returns Node with the given ID when found, undefined otherwise - */ - _findById(array: DomainElement[], id: string): DomainElement | undefined { - if (!array) return undefined; - let target; - for (let i = 0; i < array.length; i++) { - const _current = array[i]; - if (_current && _current['@id'] === id) { - target = _current; - break; - } - } - return target; - } - - _getReferenceId(amf: AmfDocument, id: string, context?: Record) { - if (!amf || !id) { - return undefined; - } - const refs = this._computeReferences(amf, context); - if (!refs) { - return undefined; - } - for (let i = 0; i < refs.length; i++) { - const _ref = refs[i]; - const enc = this._computeEncodes(_ref, context); - if (enc) { - if (enc['@id'] === id) { - return enc; - } - } - } - return undefined; - } - - _resolveRecursive(shape: any, context?: Record): void { - Object.keys(shape).forEach((key) => { - const currentShape = shape[key]; - if (Array.isArray(currentShape)) { - for (let i = 0, len = currentShape.length; i < len; i++) { - currentShape[i] = this._resolve(currentShape[i]); - } - } else if (typeof currentShape === 'object') { - /* eslint-disable-next-line no-param-reassign */ - shape[key] = this._resolve(currentShape, context); - } - }); - } - - /** - * Merge two shapes together. If the resulting shape has one of the "special merge" keys, - * then the special merge function for that key will be used to match that property - * @param shapeA AMF node - * @param shapeB AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Merged AMF node - */ - _mergeShapes(shapeA: any, shapeB: any, context?: Record): any { - const merged = { ...shapeA, ...shapeB }; - const specialMerges = [ - { - key: this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context) as string, - merger: this._mergeSourceMapsSources.bind(this) - }, - ]; - specialMerges.forEach(({ key, merger }) => { - if (this._hasProperty(merged, key, context)) { - merged[key] = merger(shapeA, shapeB, context); - } - }); - return Object.assign(shapeA, merged); - } - - /** - * Obtains source map sources value from two shapes and returns the merged result - * If neither shape has a sources node, then an empty object will be returned. - * Result is wrapped in an array as per AMF model standard - * @param shapeA AMF node - * @param shapeB AMF node - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Empty object or resulting merge, wrapped in an array - */ - _mergeSourceMapsSources(shapeA: any, shapeB: any, context?: Record): (any | {})[] { - const sourcesKey = this._getAmfKey(this.ns.aml.vocabularies.docSourceMaps.sources, context) as string; - let aSources = shapeA[sourcesKey] || {}; - if (Array.isArray(aSources)) { - /* eslint-disable prefer-destructuring */ - aSources = aSources[0]; - } - let bSources = shapeB[sourcesKey] || {}; - if (Array.isArray(bSources)) { - /* eslint-disable prefer-destructuring */ - bSources = bSources[0]; - } - return [Object.assign(aSources, bSources)]; - } - - /** - * Expands the key property from compacted mode to full mode. - * @param value The value to process - * @param context - * @returns The expanded value. - */ - [expandKey](value: string, context?: Record): string { - let { amf } = this; - if (!value || typeof value !== 'string' || (!amf && !context)) { - return value; - } - if (Array.isArray(amf)) { - [amf] = amf; - } - const ctx = context || amf['@context']; - if (!ctx) { - return value; - } - const [root, key] = value.split(':'); - if (!root || !key) { - return value; - } - const prefix = ctx[root]; - if (!prefix) { - return value; - } - return `${prefix}${key}`; - } - - /** - * Computes a security model from a reference (library for example). - * @param domainId Domain id of the security requirement to find. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - findSecurityScheme(domainId: string, context?: Record): SecurityScheme | undefined { - const { amf } = this; - const declares = this._computeDeclares(amf, context); - let result; - if (declares) { - result = declares.find((item) => item['@id'] === domainId); - } - if (result) { - result = this._resolve(result); - return result; - } - const references = this._computeReferences(amf, context); - if (Array.isArray(references) && references.length) { - for (const ref of references) { - if (this._hasType(ref, this.ns.aml.vocabularies.document.Module, context)) { - result = this[computeReferenceSecurity](ref, domainId, context); - if (result) { - result = this._resolve(result); - return result; - } - } - } - } - return undefined; - } - - /** - * Computes a security model from a reference (library for example). - * @param reference AMF model for a reference to extract the data from - * @param selected Node ID to look for - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Type definition or undefined if not found. - */ - [computeReferenceSecurity](reference: DomainElement, selected: string, context?: Record): SecurityScheme | undefined { - const declare = this._computeDeclares(reference, context); - if (!declare) { - return undefined; - } - let result = declare.find((item) => { - let declared = item; - if (Array.isArray(declared)) { - [declared] = declared; - } - return declared['@id'] === selected; - }); - if (Array.isArray(result)) { - [result] = result; - } - return this._resolve(result as DomainElement) as SecurityScheme; - } - - /** - * Collects domain objects by a domain type. - * @param source The element to search for declare/encoded objects. - * @param type The domain type - * @param context A context to use. If not set, it looks for the context of the passed model - */ - getByType(source: DomainElement, type: string, context?: Record): DomainElement[] { - if (!source) { - return []; - } - let result: DomainElement[] = []; - const declares = this._computeDeclares(source); - const key = this._getAmfKey(type, context); - if (!key) { - return []; - } - if (declares && declares.length) { - declares.forEach((declared) => { - if (this._hasType(declared, key)) { - result.push(declared); - } - }); - } - const references = this._computeReferences(source); - if (Array.isArray(references) && references.length) { - for (const ref of references) { - if (this._hasType(ref, this.ns.aml.vocabularies.document.Module)) { - const items = this.getByType(ref, type, context); - if (items.length) { - result = result.concat(items); - } - } - } - } - return result; - } - } - return AmfHelperMixinClass as Constructor & T; -}); diff --git a/src/helpers/AmfSerializer.ts b/src/helpers/AmfSerializer.ts deleted file mode 100644 index 8afc5ca..0000000 --- a/src/helpers/AmfSerializer.ts +++ /dev/null @@ -1,2131 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable default-param-last */ -/* eslint-disable class-methods-use-this */ -import { AmfHelperMixin, expandKey, findAmfType, getArrayItems } from "./AmfHelperMixin.js"; - -import { - AnyShape, ApiKeySettings, ArrayNode, ArrayShape, Callback, CreativeWork, DataArrangeShape, - DataNode, DocumentSourceMaps, DomainElement, EndPoint, Example, FileShape, HttpSettings, - IriTemplateMapping, NodeShape, OAuth1Settings, OAuth2Flow, OAuth2Settings, ObjectNode, - OpenIdConnectSettings, Operation, Parameter, ParametrizedSecurityScheme, Payload, - PropertyShape, RecursiveShape, Request, Response, ScalarNode, ScalarShape, SchemaShape, - Scope, SecurityRequirement, SecurityScheme, Server, Settings, Shape, SynthesizedField, - Tag, TemplatedLink, TupleShape, UnionShape, Api, WebApi, AsyncApi, Organization, License, - ParametrizedDeclaration, ParametrizedTrait, ParametrizedResourceType, VariableValue, AbstractDeclaration, - XMLSerializer, -} from "./amf.js"; -import { - ApiAnyShape, ApiArrayNode, ApiArrayShape, ApiCallback, ApiCustomDomainProperty, ApiDataArrangeShape, - ApiDataNode, ApiDataNodeUnion, ApiDocumentation, ApiDocumentSourceMaps, ApiEndPoint, ApiExample, - ApiFileShape, ApiIriTemplateMapping, ApiNodeShape, ApiObjectNode, ApiOperation, ApiParameter, - ApiParametrizedSecurityScheme, ApiPayload, ApiPropertyShape, ApiRecursiveShape, ApiRequest, ApiResponse, - ApiScalarNode, ApiScalarShape, ApiSchemaShape, ApiSecurityApiKeySettings, ApiSecurityHttpSettings, - ApiSecurityOAuth1Settings, ApiSecurityOAuth2Flow, ApiSecurityOAuth2Settings, - ApiSecurityOpenIdConnectSettings, ApiSecurityRequirement, ApiSecurityScheme, ApiSecurityScope, - ApiSecuritySettings, ApiSecuritySettingsUnion, ApiServer, ApiShape, ApiShapeUnion, ApiSynthesizedField, - ApiTag, ApiTupleShape, ApiUnionShape, ApiXMLSerializer, ApiOrganization, ApiSummary, ApiBase, - ApiWeb, ApiAsync, ApiLicense, ApiParametrizedDeclaration, ApiParametrizedTrait, ApiParametrizedResourceType, - ApiVariableValue, ApiAbstractDeclaration, ShapeProcessingOptions, ApiTemplatedLink, -} from "./api.js"; -import { - ApiEndPointWithOperationsListItem, - ApiOperationListItem, - ApiSecuritySchemeListItem, -} from '../types.js' - -/** - * A class that takes AMF's ld+json model and outputs JavaScript interface of it. - */ -export class AmfSerializer extends AmfHelperMixin(Object) { - /** - * @param graph Optional AMF generated graph model. - */ - constructor(graph?: DomainElement) { - super(); - if (graph) { - this.amf = graph; - } - } - - /** - * @param types The list of graph object types. When not defined it returns an empty array. - * @returns The expanded types. - */ - readTypes(types: string[], context?: Record): string[] { - let target = types; - if (typeof target === 'string') { - target = [target]; - } - if (!Array.isArray(target)) { - return []; - } - return target.map((type) => this[expandKey](type, context)); - } - - /** - * @param object The API to serialize. - * @returns API summary, without complex objects. - */ - apiSummary(object: Api): ApiSummary { - const context = object['@context']; - const result: ApiSummary = ({ - id: object['@id'], - types: this.readTypes(object['@type'], context), - customDomainProperties: this.customDomainProperties(object, context), - sourceMaps: this.sourceMap(object), - schemes: [], - accepts: [], - contentType: [], - documentations: [], - tags: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, context); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, context); - if (description && typeof description === 'string') { - result.description = description; - } - const version = this._getValue(object, ns.aml.vocabularies.core.version, context); - if (version && typeof version === 'string') { - result.version = version; - } - const termsOfService = this._getValue(object, ns.aml.vocabularies.core.termsOfService, context); - if (termsOfService && typeof termsOfService === 'string') { - result.termsOfService = termsOfService; - } - const accepts = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.accepts, context) as string]; - if (Array.isArray(accepts) && accepts.length) { - result.accepts = (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, context)) as string[]; - } - const contentType = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.contentType, context) as string]; - if (Array.isArray(contentType) && contentType.length) { - result.contentType = (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, context)) as string[]; - } - const schemes = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.scheme, context) as string]; - if (Array.isArray(schemes) && schemes.length) { - result.schemes = (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, context)) as string[]; - } - let provider = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.provider, context) as string]; - if (Array.isArray(provider)) { - [provider] = provider; - } - if (provider) { - result.provider = this.provider(provider); - } - let license = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.license, context) as string]; - if (Array.isArray(license)) { - [license] = license; - } - if (license) { - result.license = this.license(license); - } - const tags = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, context) as string]; - if (Array.isArray(tags) && tags.length) { - result.tags = tags.map(t => this.tag(t)); - } - const docs = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, context) as string]; - if (Array.isArray(docs) && docs.length) { - result.documentations = docs.map(d => this.documentation(d)); - } - return result; - } - - api(object: Api, context?: Record): ApiBase { - const objectContext = context || object['@context']; - const result = this.apiSummary(object) as ApiBase; - result.endPoints = []; - result.servers = []; - result.security = []; - const { ns } = this; - const endPoints = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as string]; - if (Array.isArray(endPoints) && endPoints.length) { - result.endPoints = endPoints.map(e => this.endPoint(e, objectContext)); - } - const servers = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string]; - if (Array.isArray(servers) && servers.length) { - result.servers = servers.map(s => this.server(s, objectContext)); - } - const security = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]; - if (Array.isArray(security) && security.length) { - result.security = security.map(s => this.securityRequirement(s, objectContext)); - } - return result; - } - - - webApi(object: WebApi, context?: Record): ApiWeb { - return this.api(object, context) as ApiWeb; - } - - - asyncApi(object: AsyncApi, context?: Record): ApiAsync { - return this.api(object, context) as ApiAsync; - } - - provider(object: Organization, context?: Record): ApiOrganization { - const objectContext = context || object['@context']; - const result: ApiOrganization = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext); - if (url && typeof url === 'string') { - result.url = url; - } - const email = this._getValue(object, ns.aml.vocabularies.core.email, objectContext); - if (email && typeof email === 'string') { - result.email = email; - } - return result; - } - - license(object: License, context?: Record): ApiLicense { - const objectContext = context || object['@context']; - const result: ApiLicense = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext); - if (url && typeof url === 'string') { - result.url = url; - } - return result; - } - - /** - * @param object The AMF Server to serialize. - * @returns Serialized Server - */ - server(object: Server, context?: Record): ApiServer { - const objectContext = context || object['@context']; - const { ns } = this; - const url = this._getValue(object, ns.aml.vocabularies.core.urlTemplate, objectContext) as string || ''; - const result: ApiServer = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - url, - variables: [], - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const variables = ((object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.variable, objectContext) as string]) as Parameter[]; - if (Array.isArray(variables) && variables.length) { - result.variables = variables.map((p) => this.parameter(p, objectContext)); - } - const protocol = (this._getValue(object, ns.aml.vocabularies.apiContract.protocol, objectContext)) as string | undefined; - const protocolVersion = (this._getValue(object, ns.aml.vocabularies.apiContract.protocolVersion, objectContext)) as string | undefined; - if (protocol) { - result.protocol = protocol; - } - if (protocolVersion) { - result.protocolVersion = protocolVersion; - } - const security = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]) as SecurityRequirement[]; - if (Array.isArray(security) && security.length) { - result.security = security.map((p) => this.securityRequirement(p, objectContext)); - } - return result; - } - - /** - * @param object The Parameter to serialize. - * @returns Serialized Parameter - */ - parameter(object: Parameter, context?: Record): ApiParameter { - const objectContext = context || object['@context']; - const result: ApiParameter = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - payloads: [], - examples: [], - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const paramName = this._getValue(object, ns.aml.vocabularies.apiContract.paramName, objectContext); - if (paramName && typeof paramName === 'string') { - result.paramName = paramName; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext); - if (typeof required === 'boolean') { - result.required = required; - } - const allowEmptyValue = this._getValue(object, ns.aml.vocabularies.apiContract.allowEmptyValue, objectContext); - if (typeof allowEmptyValue === 'boolean') { - result.allowEmptyValue = allowEmptyValue; - } - const deprecated = this._getValue(object, ns.aml.vocabularies.document.deprecated, objectContext); - if (typeof deprecated === 'boolean') { - result.deprecated = deprecated; - } - const explode = this._getValue(object, ns.aml.vocabularies.apiContract.explode, objectContext); - if (typeof explode === 'boolean') { - result.explode = explode; - } - const allowReserved = this._getValue(object, ns.aml.vocabularies.apiContract.allowReserved, objectContext); - if (typeof allowReserved === 'boolean') { - result.allowReserved = allowReserved; - } - const style = this._getValue(object, ns.aml.vocabularies.apiContract.style, objectContext); - if (style && typeof style === 'string') { - result.style = style; - } - const binding = this._getValue(object, ns.aml.vocabularies.apiContract.binding, objectContext); - if (binding && typeof binding === 'string') { - result.binding = binding; - } - const schemas = (object as any)[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as string]; - if (Array.isArray(schemas) && schemas.length) { - const [schema] = schemas; - result.schema = this.unknownShape(schema, { - trackedId: object['@id'], - }, objectContext); - } - const payloads = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.payload, objectContext) as string]; - if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(p => this.payload(p, objectContext)); - } - const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; - if (Array.isArray(examples) && examples.length) { - result.examples = examples.map(e => this.example(e, objectContext)); - } - return result; - } - - unknownShape(object: Shape, options?: ShapeProcessingOptions, context?: Record): ApiShapeUnion { - const objectContext = context || object['@context']; - const types = this.readTypes(object['@type'], objectContext); - const { ns } = this; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this.scalarShape((object as ScalarShape), options, objectContext); - } - if (types.includes(ns.w3.shacl.NodeShape)) { - return this.nodeShape((object as NodeShape), options, objectContext); - } - if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this.unionShape((object as UnionShape), options, objectContext); - } - if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { - return this.fileShape((object as FileShape), options, objectContext); - } - if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) { - return this.schemaShape((object as SchemaShape), options, objectContext); - } - // this must be before the ArrayShape - if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this.tupleShape((object as TupleShape), options, objectContext); - } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this.arrayShape((object as ArrayShape), options, objectContext); - } - if (types.includes(ns.aml.vocabularies.shapes.RecursiveShape)) { - return this.recursiveShape((object as RecursiveShape), objectContext); - } - // recursiveShape - return this.anyShape((object as AnyShape), options, objectContext); - } - - isLink(object: DomainElement, context?: Record): boolean { - const objectContext = context || object['@context']; - return !!this._getLinkValue(object, this.ns.aml.vocabularies.document.linkTarget, objectContext); - } - - getLinkTarget(object: DomainElement, context?: Record): DomainElement|undefined { - const objectContext = context || object['@context']; - const id = this._getLinkValue(object, this.ns.aml.vocabularies.document.linkTarget, objectContext); - return this[findAmfType](id, objectContext); - } - - shape(object: Shape, context?: Record): ApiShape { - const objectContext = context || object['@context']; - this._resolve(object); - - let linkLabel: string | undefined; - let target = object; - if (this.isLink(target)) { - linkLabel = (this._getValue(target, this.ns.aml.vocabularies.document.linkLabel, objectContext)) as string; - const id = this._getLinkValue(target, this.ns.aml.vocabularies.document.linkTarget, objectContext); - const value = (this[findAmfType](id, objectContext)) as Shape; - if (value) { - target = value; - } - } - const result: ApiShape = ({ - id: target['@id'], - types: this.readTypes(object['@type'], objectContext), - values: [], - inherits: [], - or: [], - and: [], - xone: [], - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - if (linkLabel) { - result.linkLabel = linkLabel; - } - const { ns } = this; - const name = this._getValue(target, ns.w3.shacl.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const displayName = this._getValue(target, ns.aml.vocabularies.core.displayName, objectContext); - if (displayName && typeof displayName === 'string') { - result.displayName = displayName; - } else { - const coreName = this._getValue(target, ns.aml.vocabularies.core.name, objectContext); - if (coreName && typeof coreName === 'string') { - result.displayName = coreName; - } - } - const description = this._getValue(target, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const defaultValueStr = this._getValue(target, ns.w3.shacl.defaultValueStr, objectContext); - if (defaultValueStr && typeof defaultValueStr === 'string') { - result.defaultValueStr = defaultValueStr; - } - const deprecated = this._getValue(target, ns.aml.vocabularies.shapes.deprecated, objectContext); - if (typeof deprecated === 'boolean') { - result.deprecated = deprecated; - } - const readOnly = this._getValue(target, ns.aml.vocabularies.shapes.readOnly, objectContext); - if (typeof readOnly === 'boolean') { - result.readOnly = readOnly; - } - const writeOnly = this._getValue(target, ns.aml.vocabularies.shapes.writeOnly, objectContext); - if (typeof writeOnly === 'boolean') { - result.writeOnly = writeOnly; - } - const defValue = (target as any)[this._getAmfKey(ns.w3.shacl.defaultValue, objectContext) as string]; - if (Array.isArray(defValue) && defValue.length) { - result.defaultValue = this.unknownDataNode(defValue[0], objectContext); - } - // @TODO: - // if (Array.isArray(inherits) && inherits.length) { - // result.inherits = inherits.map((item) => this.unknownShape(item)); - // } - const orKey = this._getAmfKey(ns.w3.shacl.or, objectContext) as string; - const orGroup = /** @type */ ((target as any)[orKey]) as Shape[]; - if (Array.isArray(orGroup) && orGroup.length) { - result.or = orGroup.map((item) => this.unknownShape(item, undefined, objectContext)); - } - const andKey = this._getAmfKey(ns.w3.shacl.and, objectContext) as string; - const andGroup = /** @type */ ((target as any)[andKey]) as Shape[]; - if (Array.isArray(andGroup) && andGroup.length) { - result.and = andGroup.map((item) => this.unknownShape(item, undefined, objectContext)); - } - const xoneKey = this._getAmfKey(ns.w3.shacl.xone, objectContext) as string; - const xone = ((target as any)[xoneKey]) as Shape[]; - if (Array.isArray(xone) && xone.length) { - result.xone = xone.map((item) => this.unknownShape(item, undefined, objectContext)); - } - const valuesList = (target as any)[this._getAmfKey(ns.w3.shacl.in, objectContext) as string]; - if (Array.isArray(valuesList) && valuesList.length) { - const [values] = valuesList; - const prefix = this.ns.w3.rdfSchema.toString(); - const prefixCompact = this._getAmfKey(prefix, objectContext) as string; - Object.keys(values).forEach((key) => { - if (key.startsWith(prefix) || key.startsWith(prefixCompact)) { - let value = values[key]; - if (Array.isArray(value)) { - [value] = value; - } - const processed = this.unknownDataNode(value, objectContext); - if (processed) { - result.values.push(processed); - } - } - }); - } - const notKey = this._getAmfKey(ns.w3.shacl.not, objectContext) as string; - let not = ((target as any)[notKey]) as Shape | undefined; - if (not) { - if (Array.isArray(not)) { - [not] = not; - } - result.not = this.unknownShape(not as Shape, undefined, objectContext); - } - return result; - } - - anyShape(object: AnyShape, options: ShapeProcessingOptions={}, context?: Record): ApiAnyShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.shape(target, objectContext)) as ApiAnyShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as Shape; - if (value) { - target = value; - } - } - result.examples = []; - - const { ns } = this; - const examples = (target as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; - if (Array.isArray(examples) && examples.length) { - if (options.trackedId) { - const filtered = this.filterTrackedExamples(examples, options.trackedId, objectContext); - result.examples = filtered.map((item) => this.example(item, objectContext)); - } else { - const filtered = this.filterNonTrackedExamples(examples, objectContext); - result.examples = filtered.map((item) => this.example(item, objectContext)); - } - } - const docs = (target as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as string]; - if (Array.isArray(docs) && docs.length) { - const [documentation] = docs; - result.documentation = this.documentation(documentation, objectContext); - } - const xml = (target as any)[this._getAmfKey(ns.aml.vocabularies.shapes.xmlSerialization, objectContext) as string]; - if (Array.isArray(xml) && xml.length) { - result.xmlSerialization = this.xmlSerializer(xml[0], objectContext); - } - return result; - } - - /** - * Filters examples that should be rendered for a payload identified by `trackedId`. - * - * This function is copied from old `api-example-generator/ExampleGenerator`. - */ - filterTrackedExamples(examples: Example[], trackedId: string, context?: Record): Example[] { - const { docSourceMaps } = this.ns.aml.vocabularies; - const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as string; - const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as string; - const longId = trackedId.indexOf('amf') === -1 ? `amf://id${trackedId}` : trackedId; - return examples.filter((item) => { - let example = item; - if (Array.isArray(example)) { - [example] = example; - } - let sm = (example as any)[sourceKey] as DocumentSourceMaps; - if (!sm) { - return true - } - if (Array.isArray(sm)) { - [sm] = sm; - } - let tracked = (sm as any)[trackedKey]; - if (!tracked) { - return true; - } - if (Array.isArray(tracked)) { - [tracked] = tracked; - } - const { value } = this.synthesizedField(tracked, context); - if (!value) { - return true; - } - const ids = value.split(','); - if (ids.indexOf(longId) !== -1 || ids.indexOf(trackedId) !== -1) { - return true; - } - return false; - }); - } - - /** - * Kind of the opposite of the `filterTrackedExamples`. It gathers examples that only have been - * defined for the parent Shape (ed in the type declaration). It filters out all examples - * defined in a payload. - */ - filterNonTrackedExamples(examples: Example[], context?: Record): Example[] { - const { docSourceMaps } = this.ns.aml.vocabularies; - const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as string; - const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as string; - return examples.filter((item) => { - let example = item; - if (Array.isArray(example)) { - [example] = example; - } - let sm = (example as any)[sourceKey] as DocumentSourceMaps; - if (!sm) { - return true - } - if (Array.isArray(sm)) { - [sm] = sm; - } - let tracked = (sm as any)[trackedKey]; - if (!tracked) { - return true; - } - if (Array.isArray(tracked)) { - [tracked] = tracked; - } - const { value } = this.synthesizedField(tracked, context); - if (!value) { - return true; - } - return false; - }); - } - - scalarShape(object: ScalarShape, options={}, context?: Record): ApiScalarShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.anyShape(target, options, objectContext)) as ApiScalarShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as ScalarShape; - if (value) { - target = value; - } - } - const { ns } = this; - const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext); - if (pattern && typeof pattern === 'string') { - result.pattern = pattern; - } - const dataType = this._getLinkValue(target, ns.w3.shacl.datatype, objectContext); - if (dataType && typeof dataType === 'string') { - result.dataType = dataType; - } - const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext); - if (format && typeof format === 'string') { - result.format = format; - } - const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext); - if (typeof multipleOf === 'number') { - result.multipleOf = multipleOf; - } - const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext); - if (typeof minInclusive === 'number') { - result.minimum = minInclusive; - result.exclusiveMinimum = false; - } - const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext); - if (typeof maxInclusive === 'number') { - result.maximum = maxInclusive; - result.exclusiveMaximum = false; - } - const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext); - if (typeof minLength === 'number') { - result.minLength = minLength; - } - const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext); - if (typeof maxLength === 'number') { - result.maxLength = maxLength; - } - return result; - } - - /** - * @param {NodeShape} object The NodeShape to serialize - * @param {ShapeProcessingOptions=} options - * @param {Record=} context - * @returns {ApiNodeShape} - */ - nodeShape(object: NodeShape, options={}, context?: Record): ApiNodeShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.anyShape(target, options, objectContext)) as ApiNodeShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as NodeShape; - if (value) { - target = value; - } - } - const { ns } = this; - const discriminator = this._getValue(target, ns.aml.vocabularies.shapes.discriminator, objectContext); - if (discriminator && typeof discriminator === 'string') { - result.discriminator = discriminator; - } - const discriminatorValue = this._getValue(target, ns.aml.vocabularies.shapes.discriminatorValue, objectContext); - if (discriminatorValue && typeof discriminatorValue === 'string') { - result.discriminatorValue = discriminatorValue; - } - const closed = this._getValue(target, ns.w3.shacl.closed, objectContext); - if (typeof closed === 'boolean') { - result.closed = closed; - } - - result.customShapeProperties = []; - result.customShapePropertyDefinitions = []; - result.dependencies = []; - // todo: not sure what the keys are. - // if (!minProperties.isNull) { - // result.minProperties = minProperties.value(); - // } - // if (!maxProperties.isNull) { - // result.maxProperties = maxProperties.value(); - // } - // if (Array.isArray(customShapeProperties) && customShapeProperties.length) { - // result.customShapeProperties = customShapeProperties.map((item) => item.id); - // } else { - // result.customShapeProperties = []; - // } - // if (Array.isArray(customShapePropertyDefinitions) && customShapePropertyDefinitions.length) { - // result.customShapePropertyDefinitions = customShapePropertyDefinitions.map((item) => item.id); - // } else { - // result.customShapePropertyDefinitions = []; - // } - const properties = ((target as any)[this._getAmfKey(ns.w3.shacl.property, objectContext) as string]) as PropertyShape[]; - if (Array.isArray(properties) && properties.length) { - result.properties = properties.map((item) => this.propertyShape(item, objectContext)); - } else { - result.properties = []; - } - // if (Array.isArray(dependencies) && dependencies.length) { - // result.dependencies = dependencies.map((item) => item.id); - // } else { - // result.dependencies = []; - // } - return result; - } - - propertyShape(object: PropertyShape, context?: Record): ApiPropertyShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.shape(target, objectContext)) as ApiPropertyShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as PropertyShape; - if (value) { - target = value; - } - } - const { ns } = this; - const path = this._getLinkValue(target, ns.w3.shacl.path, objectContext); - if (path && typeof path === 'string') { - result.path = path; - } - const minCount = this._getValue(target, ns.w3.shacl.minCount, objectContext); - if (typeof minCount === 'number') { - result.minCount = minCount; - } - const maxCount = this._getValue(target, ns.w3.shacl.maxCount, objectContext); - if (typeof maxCount === 'number') { - result.maxCount = maxCount; - } - // if (!patternName.isNullOrEmpty) { - // result.patternName = patternName.value(); - // } - - const ranges = ((target as any)[this._getAmfKey(ns.aml.vocabularies.shapes.range, objectContext) as string]) as Shape[]; - if (Array.isArray(ranges) && ranges.length) { - const [range] = ranges; - result.range = this.unknownShape(range, undefined, objectContext); - } - return result; - } - - unionShape(object: UnionShape, options: ShapeProcessingOptions={}, context?: Record): ApiUnionShape { - const objectContext = context || object['@context']; - const anyOf = ((object as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf, objectContext) as string]) as Shape[]; - const result = (this.anyShape(object, options, objectContext)) as ApiUnionShape; - if (Array.isArray(anyOf) && anyOf.length) { - const opt = { ...options, trackedId: undefined }; - result.anyOf = anyOf.map((shape) => this.unknownShape(shape, opt, objectContext)); - } else { - result.anyOf = []; - } - return result; - } - - fileShape(object: FileShape, options: ShapeProcessingOptions={}, context?: Record): ApiFileShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.anyShape(target, options, objectContext)) as ApiFileShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as FileShape; - if (value) { - target = value; - } - } - const { ns } = this; - const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext); - if (pattern && typeof pattern === 'string') { - result.pattern = pattern; - } - const fileTypes = (this._getValueArray(target, ns.aml.vocabularies.shapes.fileType, objectContext)) as string[]; - if (Array.isArray(fileTypes) && fileTypes.length) { - result.fileTypes = fileTypes; - } - const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext); - if (typeof minLength === 'number') { - result.minLength = minLength; - } - const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext); - if (typeof maxLength === 'number') { - result.maxLength = maxLength; - } - const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext); - if (typeof minInclusive === 'number') { - result.minimum = minInclusive; - result.exclusiveMinimum = false; - } - const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext); - if (typeof maxInclusive === 'number') { - result.maximum = maxInclusive; - result.exclusiveMaximum = false; - } - const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext); - if (format && typeof format === 'string') { - result.format = format; - } - const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext); - if (typeof multipleOf === 'number') { - result.multipleOf = multipleOf; - } - return result; - } - - - schemaShape(object: SchemaShape, options: ShapeProcessingOptions={}, context?: Record): ApiSchemaShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.anyShape(target, options, objectContext)) as ApiSchemaShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as SchemaShape; - if (value) { - target = value; - } - } - const { ns } = this; - const mediaType = this._getValue(target, ns.aml.vocabularies.core.mediaType, objectContext); - if (mediaType && typeof mediaType === 'string') { - result.mediaType = mediaType; - } - const raw = this._getValue(target, ns.aml.vocabularies.document.raw, objectContext); - if (raw && typeof raw === 'string') { - result.raw = raw; - } - return result; - } - - recursiveShape(object: RecursiveShape, context?: Record): ApiRecursiveShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.shape(target, objectContext)) as ApiRecursiveShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as RecursiveShape; - if (value) { - target = value; - } - } - const { ns } = this; - const fp = this._getLinkValue(object, ns.aml.vocabularies.shapes.fixPoint, objectContext); - if (fp && typeof fp === 'string') { - result.fixPoint = fp; - } - return result; - } - - dataArrangeShape(object: DataArrangeShape, options={}, context?: Record): ApiDataArrangeShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.anyShape(target, options, objectContext)) as ApiDataArrangeShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as DataArrangeShape; - if (value) { - target = value; - } - } - // const { ns } = this; - // const { minItems, maxItems, uniqueItems } = object; - // if (!minItems.isNull) { - // result.minItems = minItems.value(); - // } - // if (!maxItems.isNull) { - // result.maxItems = maxItems.value(); - // } - // if (!uniqueItems.isNull) { - // result.uniqueItems = uniqueItems.value(); - // } - return result; - } - - arrayShape(object: ArrayShape, options: ShapeProcessingOptions={}, context?: Record): ApiArrayShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.dataArrangeShape(target, options, objectContext)) as ApiArrayShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as ArrayShape; - if (value) { - target = value; - } - } - - const items = (target as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext) as string]; - if (Array.isArray(items) && items.length) { - const [item] = items; - result.items = this.unknownShape(item, undefined, objectContext); - } - return result; - } - - tupleShape(object: TupleShape, options?: ShapeProcessingOptions, context?: Record): ApiTupleShape { - const objectContext = context || object['@context']; - let target = object; - const result = (this.dataArrangeShape(target, options, objectContext)) as ApiTupleShape; - if (this.isLink(target)) { - const value = (this.getLinkTarget(target, objectContext)) as TupleShape; - if (value) { - target = value; - } - } - const items = (target as any)[this._getAmfKey(this.ns.aml.vocabularies.shapes.items, objectContext) as string]; - const prefix = this._getAmfKey(this.ns.w3.rdfSchema.key, objectContext) as string; - if (Array.isArray(items) && items.length) { - result.items = []; - items.forEach((item) => { - if (Array.isArray(item)) { - // eslint-disable-next-line no-param-reassign - [item] = item; - } - Object.keys(item).filter(k => k.startsWith(prefix)).forEach((key) => { - let shape = item[key]; - if (Array.isArray(shape)) { - [shape] = shape; - } - const value = this.unknownShape(shape, undefined, objectContext); - result.items.push(value); - }); - }); - } else { - result.items = []; - } - return result; - } - - /** - * @param object The CreativeWork to serialize. - * @returns Serialized CreativeWork - */ - documentation(object: CreativeWork, context?: Record): ApiDocumentation { - const objectContext = context || object['@context']; - const result: ApiDocumentation = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const url = this._getLinkValue(object, this.ns.aml.vocabularies.core.url, objectContext); - if (url && typeof url === 'string') { - result.url = url; - } - const description = this._getValue(object, this.ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const title = this._getValue(object, this.ns.aml.vocabularies.core.title, objectContext); - if (title && typeof title === 'string') { - result.title = title; - } - return result; - } - - /** - * @param {} object The Example to serialize. - * @returns {} Serialized Example - */ - example(object: Example, context?: Record): ApiExample { - const objectContext = context || object['@context']; - this._resolve(object); - const result: ApiExample = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - strict: false, - }); - const { ns } = this; - const strict = this._getValue(object, ns.aml.vocabularies.document.strict, objectContext); - if (typeof strict === 'boolean') { - result.strict = strict; - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext); - if (displayName && typeof displayName === 'string') { - result.displayName = displayName; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const raw = this._getValue(object, ns.aml.vocabularies.document.raw, objectContext); - if (raw && typeof raw === 'string') { - result.value = raw; - } - const location = this._getValue(object, ns.aml.vocabularies.document.location, objectContext); - if (location && typeof location === 'string') { - result.location = location; - } - // if (!mediaType.isNullOrEmpty) { - // result.mediaType = mediaType.value(); - // } - const structuredValue = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.structuredValue, objectContext) as string]; - if (Array.isArray(structuredValue) && structuredValue.length) { - const [value] = structuredValue; - result.structuredValue = this.unknownDataNode(value, objectContext); - } - return result; - } - - xmlSerializer(object: XMLSerializer, context?: Record): ApiXMLSerializer { - const objectContext = context || object['@context']; - const result: ApiXMLSerializer = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const xmlAttribute = this._getValue(object, ns.aml.vocabularies.shapes.xmlAttribute, objectContext); - if (typeof xmlAttribute === 'boolean') { - result.attribute = xmlAttribute; - } - const wrapped = this._getValue(object, ns.aml.vocabularies.shapes.xmlWrapped, objectContext); - if (typeof wrapped === 'boolean') { - result.wrapped = wrapped; - } - const name = this._getValue(object, ns.aml.vocabularies.shapes.xmlName, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const xmlNs = this._getValue(object, ns.aml.vocabularies.shapes.xmlNamespace, objectContext); - if (xmlNs && typeof xmlNs === 'string') { - result.namespace = xmlNs; - } - const xmlPrefix = this._getValue(object, ns.aml.vocabularies.shapes.xmlPrefix, objectContext); - if (xmlPrefix && typeof xmlPrefix === 'string') { - result.prefix = xmlPrefix; - } - return result; - } - - unknownDataNode(object: DataNode, context?: Record): ApiDataNodeUnion | undefined { - const types = this.readTypes(object['@type'], context); - const { ns } = this; - if (types.includes(ns.aml.vocabularies.data.Scalar)) { - return this.scalarNode((object as ScalarNode), context); - } - if (types.includes(ns.aml.vocabularies.data.Object)) { - return this.objectNode((object as ObjectNode), context); - } - if (types.includes(ns.aml.vocabularies.data.Array)) { - return this.arrayNode((object as ArrayNode), context); - } - return undefined; - } - - - dataNode(object: DataNode, context?: Record): ApiDataNode { - const result: ApiDataNode = ({ - id: object['@id'], - types: this.readTypes(object['@type'], context), - customDomainProperties: this.customDomainProperties(object, context), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, context); - if (name && typeof name === 'string') { - result.name = name; - } - return result; - } - - - scalarNode(object: ScalarNode, context?: Record): ApiScalarNode { - const objectContext = context || object['@context']; - const result = (this.dataNode(object, context)) as ApiScalarNode; - const { ns } = this; - const value = this._getValue(object, ns.aml.vocabularies.data.value, objectContext); - if (value && typeof value === 'string') { - result.value = value; - } - const dataType = this._getLinkValue(object, ns.w3.shacl.datatype, objectContext); - if (dataType && typeof dataType === 'string') { - result.dataType = dataType; - } - return result; - } - - objectNode(object: ObjectNode, context?: Record): ApiObjectNode { - const objectContext = context || object['@context']; - const result = (this.dataNode(object, context)) as ApiObjectNode; - result.properties = {}; - const prefix = this.ns.aml.vocabularies.data.toString(); - const prefixCompact = `${this._getAmfKey(prefix, objectContext)}:`; - Object.keys(object).forEach((key) => { - if (key.startsWith(prefix) || key.startsWith(prefixCompact)) { - let value = (object as any)[key] as DataNode; - if (Array.isArray(value)) { - [value] = value; - } - const name = key.replace(prefix, '').replace(prefixCompact, ''); - result.properties[name] = this.unknownDataNode(value, context) as ApiDataNodeUnion; - } - }); - return result; - } - - - arrayNode(object: ArrayNode, context?: Record): ApiArrayNode { - const objectContext = context || object['@context']; - const result = (this.dataNode(object, objectContext)) as ApiArrayNode; - result.members = []; - const members = (this._computePropertyArray(object, this.ns.w3.rdfSchema.member)) as DataNode[]; - if (Array.isArray(members) && members.length) { - members.forEach(item => { - const node = this.unknownDataNode(item); - if (node) { - result.members.push(node); - } - }); - } - return result; - } - - /** - * Adds the custom domain properties to the currently processed property, a.k.a annotations. - * @param object - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns The list of custom domain properties. - */ - customDomainProperties(object: DomainElement, context?: Record): ApiCustomDomainProperty[] { - const result: ApiCustomDomainProperty[] = []; - const objectContext = context || object['@context']; - const ids = this._getLinkValues(object, this.ns.aml.vocabularies.document.customDomainProperties, objectContext); - if (Array.isArray(ids) && ids.length) { - ids.forEach((id) => { - const key = `amf://id${id}`; - let value = ((object as any)[id] || (object as any)[key]) as DomainElement; - if (!value) { - return; - } - if (Array.isArray(value)) { - [value] = value; - } - const extension = this.unknownDataNode(value, objectContext); - const name = this._getValue(value, this.ns.aml.vocabularies.core.extensionName, objectContext) as string; - if (!name || !extension) { - return; - } - const cdp: ApiCustomDomainProperty = ({ - id: key, - name, - extension, - }); - result.push(cdp); - }); - } - return result; - } - - /** - * @param object The EndPoint to serialize. - * @returns Serialized EndPoint - */ - endPoint(object: EndPoint, context?: Record): ApiEndPoint { - const objectContext = context || object['@context']; - const result: ApiEndPoint = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object), - path: '', - operations: [], - parameters: [], - payloads: [], - servers: [], - security: [], - extends: [], - }); - const { ns } = this; - const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, objectContext); - if (path && typeof path === 'string') { - result.path = path; - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const summary = this._getValue(object, ns.aml.vocabularies.core.summary, objectContext); - if (summary && typeof summary === 'string') { - result.summary = summary; - } - const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, objectContext); - if (Array.isArray(operations) && operations.length) { - result.operations = operations.map(i => this.operation((i as Operation), objectContext)); - } - const parameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext); - if (Array.isArray(parameters) && parameters.length) { - result.parameters = parameters.map(i => this.parameter(i, objectContext)); - } - const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); - if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(i => this.payload(/** @type */(i as Payload), objectContext)); - } - const servers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.server, objectContext); - if (Array.isArray(servers) && servers.length) { - result.servers = servers.map(i => this.server(i, objectContext)); - } - const security = this[getArrayItems](object, ns.aml.vocabularies.security.security, objectContext); - if (Array.isArray(security) && security.length) { - result.security = security.map(i => this.securityRequirement(i, objectContext)); - } - const extensions = this[getArrayItems](object, ns.aml.vocabularies.document.extends, objectContext); - if (Array.isArray(extensions) && extensions.length) { - result.extends = []; - extensions.forEach((ex) => { - let extension = ex; - if (Array.isArray(extension)) { - [extension] = extension; - } - if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedResourceType, objectContext)) { - result.extends.push(this.parametrizedResourceType(extension, objectContext)); - } else if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedTrait, objectContext)) { - result.extends.push(this.parametrizedTrait(extension, objectContext)); - } - }); - } - return result; - } - - /** - * @param object The Operation to serialize. - * @returns Serialized Operation - */ - operation(object: Operation, context?: Record): ApiOperation { - const objectContext = context || object['@context']; - const result: ApiOperation = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object), - method: '', - deprecated: false, - callbacks: [], - responses: [], - servers: [], - security: [], - accepts: [], - schemes: [], - contentType: [], - tags: [], - extends: [], - }); - const { ns } = this; - const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, objectContext); - if (method && typeof method === 'string') { - result.method = method; - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const summary = this._getValue(object, ns.aml.vocabularies.apiContract.guiSummary, objectContext); - if (summary && typeof summary === 'string') { - result.summary = summary; - } - const deprecated = this._getValue(object, ns.aml.vocabularies.core.deprecated, objectContext); - if (typeof deprecated === 'boolean') { - result.deprecated = deprecated; - } - const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext); - if (operationId && typeof operationId === 'string') { - result.operationId = operationId; - } - const accepts = (this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, objectContext)) as string[]; - if (Array.isArray(accepts)) { - result.accepts = accepts; - } - const schemes = (this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, objectContext)) as string[]; - if (Array.isArray(schemes)) { - result.schemes = schemes; - } - const contentType = (this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, objectContext)) as string[]; - if (Array.isArray(contentType)) { - result.contentType = contentType; - } - - let expects = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.expects, objectContext) as string]; - if (expects) { - if (Array.isArray(expects)) { - [expects] = expects; - } - result.request = this.request(expects, objectContext); - } - let documentation = (object as any)[this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as string]; - if (documentation) { - if (Array.isArray(documentation)) { - [documentation] = documentation; - } - result.documentation = this.documentation(documentation, objectContext); - } - const responses = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.returns, objectContext) as string]; - if (Array.isArray(responses)) { - result.responses = responses.map(r => this.response(r, objectContext)); - } - const callbacks = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.callback, objectContext) as string]; - if (Array.isArray(callbacks)) { - result.callbacks = callbacks.map(c => this.callback(c, objectContext)); - } - const servers = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string]; - if (Array.isArray(servers)) { - result.servers = servers.map(s => this.server(s)); - } - const security = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as string]; - if (Array.isArray(security)) { - result.security = security.map(s => this.securityRequirement(s, objectContext)); - } - const tags = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, objectContext) as string]; - if (Array.isArray(tags) && tags.length) { - result.tags = tags.map(s => this.tag(s, objectContext)); - } - const traits = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.extends, objectContext) as string]; - if (Array.isArray(traits) && traits.length) { - result.extends = traits.map(t => this.parametrizedTrait(t, objectContext)); - } - return result; - } - - /** - * @param object - * @param {Record=} context - * @returns {} - */ - tag(object: Tag, context?: Record): ApiTag { - const objectContext = context || object['@context']; - const result: ApiTag = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object), - name: '', - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - return result; - } - - callback(object: Callback, context?: Record): ApiCallback { - const objectContext = context || object['@context']; - const result: ApiCallback = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const expression = this._getValue(object, ns.aml.vocabularies.apiContract.expression, objectContext); - if (expression && typeof expression === 'string') { - result.expression = expression; - } - let endpoint = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as string]; - if (endpoint) { - if (Array.isArray(endpoint)) { - [endpoint] = endpoint; - } - result.endpoint = this.endPoint(endpoint, objectContext); - } - return result; - } - - /** - * @param object The API request to serialize. - * @returns Serialized API request - */ - request(object: Request, context?: Record): ApiRequest { - const objectContext = context || object['@context']; - const result: ApiRequest = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object), - required: false, - headers: [], - queryParameters: [], - payloads: [], - uriParameters: [], - cookieParameters: [], - }); - const { ns } = this; - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext); - if (required && typeof required === 'boolean') { - result.required = required; - } - let queryString = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as string]; - if (queryString) { - if (Array.isArray(queryString)) { - [queryString] = queryString; - } - result.queryString = this.unknownShape(queryString, undefined, objectContext); - } - const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext); - if (Array.isArray(headers) && headers.length) { - result.headers = headers.map(p => this.parameter(p, objectContext)); - } - const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext); - if (Array.isArray(queryParameters) && queryParameters.length) { - result.queryParameters = queryParameters.map(p => this.parameter(p, objectContext)); - } - const uriParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.uriParameter, objectContext); - if (Array.isArray(uriParameters) && uriParameters.length) { - result.uriParameters = uriParameters.map(p => this.parameter(p, objectContext)); - } - const cookieParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.cookieParameter, objectContext); - if (Array.isArray(cookieParameters) && cookieParameters.length) { - result.cookieParameters = cookieParameters.map(p => this.parameter(p, objectContext)); - } - const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); - if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(p => this.payload((p as Payload), objectContext)); - } - return result; - } - - /** - * @param object The Response to serialize. - * @param {Record=} context - * @returns Serialized Response - */ - response(object: Response, context?: Record): ApiResponse { - const objectContext = context || object['@context']; - const result: ApiResponse = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - headers: [], - payloads: [], - examples: [], - links: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const statusCode = this._getValue(object, ns.aml.vocabularies.apiContract.statusCode, objectContext); - if (statusCode && typeof statusCode === 'string') { - result.statusCode = statusCode; - } - const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext); - if (Array.isArray(headers) && headers.length) { - result.headers = headers.map(p => this.parameter(p, objectContext)); - } - const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext); - if (Array.isArray(payloads) && payloads.length) { - result.payloads = payloads.map(p => this.payload((p as Payload), objectContext)); - } - const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; - if (Array.isArray(examples) && examples.length) { - result.examples = examples.map(e => this.example(e, objectContext)); - } - const links = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.link, objectContext) as string]; - if (Array.isArray(links) && links.length) { - result.links = links.map(p => this.templatedLink(p, objectContext)); - } - return result; - } - - /** - * @param object The Payload to serialize. - * @param {Record=} context - * @returns Serialized Payload - */ - payload(object: Payload, context?: Record): ApiPayload { - const objectContext = context || object['@context']; - const result: ApiPayload = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - examples: [], - // encoding: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const mediaType = this._getValue(object, ns.aml.vocabularies.core.mediaType, objectContext); - if (mediaType && typeof mediaType === 'string') { - result.mediaType = mediaType; - } - let schema = (object as any)[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as string]; - if (schema) { - if (Array.isArray(schema)) { - [schema] = schema; - } - result.schema = this.unknownShape(schema, { - trackedId: result.id, - }, objectContext); - } - const examples = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as string]; - if (Array.isArray(examples) && examples.length) { - result.examples = examples.map(e => this.example(e, objectContext)); - } - // if (Array.isArray(encoding) && encoding.length) { - // result.encoding = encoding.map((p) => p.id); - // } - return result; - } - - /** - * @param object The TemplatedLink to serialize. - * @param {Record=} context - * @returns Serialized TemplatedLink - */ - templatedLink(object: TemplatedLink, context?: Record): ApiTemplatedLink { - const objectContext = context || object['@context']; - const result: ApiTemplatedLink = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - mapping: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext); - if (operationId && typeof operationId === 'string') { - result.operationId = operationId; - } - let server = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as string] as Server | undefined; - if (server) { - if (Array.isArray(server)) { - [server] = server; - } - result.server = this.server(server as Server, objectContext); - } - let mapping = ((object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.mapping, objectContext) as string]) as IriTemplateMapping[] | undefined; - if (mapping) { - if (mapping && !Array.isArray(mapping)) { - mapping = [mapping]; - } - if (mapping) { - result.mapping = mapping.map(item => this.iriTemplateMapping(item, objectContext)); - } - } - // if (!template.isNullOrEmpty) { - // result.template = template.value(); - // } - // if (!requestBody.isNullOrEmpty) { - // result.requestBody = requestBody.value(); - // } - return result; - } - - /** - * @param object - * @param {Record=} context - * @returns {} - */ - iriTemplateMapping(object: IriTemplateMapping, context?: Record): ApiIriTemplateMapping { - const objectContext = context || object['@context']; - const result: ApiIriTemplateMapping = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const templateVariable = this._getValue(object, ns.aml.vocabularies.apiContract.templateVariable, objectContext); - if (templateVariable && typeof templateVariable === 'string') { - result.templateVariable = templateVariable; - } - const linkExpression = this._getValue(object, ns.aml.vocabularies.apiContract.linkExpression, objectContext); - if (linkExpression && typeof linkExpression === 'string') { - result.linkExpression = linkExpression; - } - return result; - } - - /** - * @param object The ParametrizedSecurityScheme to serialize. - * @param {Record=} context - * @returns Serialized ParametrizedSecurityScheme - */ - parametrizedSecurityScheme(object: ParametrizedSecurityScheme, context?: Record): ApiParametrizedSecurityScheme { - const objectContext = context || object['@context']; - const result: ApiParametrizedSecurityScheme = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - let scheme = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.scheme, objectContext) as string] as SecurityScheme | undefined; - if (scheme) { - if (Array.isArray(scheme)) { - [scheme] = scheme; - } - result.scheme = this.securityScheme(scheme as SecurityScheme, objectContext); - } - let settings = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as string] as Settings | undefined; - if (settings) { - if (Array.isArray(settings)) { - [settings] = settings; - } - result.settings = this.securitySettings(settings as Settings, objectContext); - } - return result; - } - - /** - * @param object The SecurityScheme to serialize as a list item. - * @returns Serialized SecurityScheme - */ - securitySchemeListItem(object: SecurityScheme, context?: Record): ApiSecuritySchemeListItem { - const objectContext = context || object['@context']; - const result: ApiSecuritySchemeListItem = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - type: '', - }); - const { ns } = this; - const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext); - if (type && typeof type === 'string') { - result.type = type; - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext); - if (displayName && typeof displayName === 'string') { - result.displayName = displayName; - } - return result; - } - - /** - * @param object The SecurityScheme to serialize. - * @param {Record=} context - * @returns Serialized SecurityScheme - */ - securityScheme(object: SecurityScheme, context?: Record): ApiSecurityScheme { - const objectContext = context || object['@context']; - const result: ApiSecurityScheme = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - headers: [], - queryParameters: [], - responses: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext); - if (displayName && typeof displayName === 'string') { - result.displayName = displayName; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext); - if (type && typeof type === 'string') { - result.type = type; - } - let settings = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as string] as Settings | undefined; - if (settings) { - if (Array.isArray(settings)) { - [settings] = settings; - } - result.settings = this.securitySettings(settings as Settings, objectContext); - } - let queryString = (object as any)[this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as string] as Shape | undefined; - if (queryString) { - if (Array.isArray(queryString)) { - [queryString] = queryString; - } - result.queryString = this.unknownShape(queryString as Shape, undefined, objectContext); - } - const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext); - if (Array.isArray(headers) && headers.length) { - result.headers = headers.map(p => this.parameter(p, objectContext)); - } - const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext); - if (Array.isArray(queryParameters) && queryParameters.length) { - result.queryParameters = queryParameters.map(p => this.parameter(p, objectContext)); - } - const responses = this[getArrayItems](object, ns.aml.vocabularies.apiContract.response, objectContext); - if (Array.isArray(responses) && responses.length) { - result.responses = responses.map(p => this.response(/** @type */ (p as Response), objectContext)); - } - return result; - } - - /** - * @param object The SecurityRequirement to serialize. - * @returns Serialized SecurityRequirement - */ - securityRequirement(object: SecurityRequirement, context?: Record): ApiSecurityRequirement { - const objectContext = context || object['@context']; - const result: ApiSecurityRequirement = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - schemes: [], - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const schemes = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.schemes, objectContext) as string]) as ParametrizedSecurityScheme[] | undefined; - if (Array.isArray(schemes) && schemes.length) { - result.schemes = schemes.map(p => this.parametrizedSecurityScheme(p, objectContext)); - } - return result; - } - - securitySettings(object: Settings, context?: Record): ApiSecuritySettingsUnion { - const objectContext = context || object['@context']; - const { ns } = this; - const types = this.readTypes(object['@type'], objectContext); - if (types.includes(ns.aml.vocabularies.security.OAuth1Settings)) { - return this.oAuth1Settings((object as OAuth1Settings), objectContext); - } - if (types.includes(ns.aml.vocabularies.security.OAuth2Settings)) { - return this.oAuth2Settings((object as OAuth2Settings), objectContext); - } - if (types.includes(ns.aml.vocabularies.security.ApiKeySettings)) { - return this.apiKeySettings((object as ApiKeySettings), objectContext); - } - if (types.includes(ns.aml.vocabularies.security.HttpSettings)) { - return this.httpSettings((object as HttpSettings), objectContext); - } - if (types.includes(ns.aml.vocabularies.security.OpenIdConnectSettings)) { - return this.openIdConnectSettings((object as OpenIdConnectSettings), objectContext); - } - return this.settings(object, objectContext); - } - - - settings(object: Settings, context?: Record): ApiSecuritySettings { - const objectContext = context || object['@context']; - const result: ApiSecuritySettings = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - // if (additionalProperties && additionalProperties.id) { - // result.additionalProperties = this.unknownDataNode(additionalProperties); - // } - return result; - } - - oAuth1Settings(object: OAuth1Settings, context?: Record): ApiSecurityOAuth1Settings { - const objectContext = context || object['@context']; - const result = (this.settings(object, objectContext)) as ApiSecurityOAuth1Settings; - const { ns } = this; - const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext); - if (authorizationUri && typeof authorizationUri === 'string') { - result.authorizationUri = authorizationUri; - } - const requestTokenUri = this._getValue(object, ns.aml.vocabularies.security.requestTokenUri, objectContext); - if (requestTokenUri && typeof requestTokenUri === 'string') { - result.requestTokenUri = requestTokenUri; - } - const tokenCredentialsUri = this._getValue(object, ns.aml.vocabularies.security.tokenCredentialsUri, objectContext); - if (tokenCredentialsUri && typeof tokenCredentialsUri === 'string') { - result.tokenCredentialsUri = tokenCredentialsUri; - } - const signatures = (this._getValueArray(object, ns.aml.vocabularies.security.signature, objectContext)) as string[] | undefined; - if (Array.isArray(signatures) && signatures.length) { - result.signatures = signatures; - } else { - result.signatures = []; - } - return result; - } - - - oAuth2Settings(object: OAuth2Settings, context?: Record): ApiSecurityOAuth2Settings { - const objectContext = context || object['@context']; - const result = (this.settings(object, objectContext)) as ApiSecurityOAuth2Settings; - const { ns } = this; - const grants = (this._getValueArray(object, ns.aml.vocabularies.security.authorizationGrant, objectContext)) as string[] | undefined; - if (Array.isArray(grants) && grants.length) { - result.authorizationGrants = grants; - } else { - result.authorizationGrants = []; - } - const flows = ((object as any)[this._getAmfKey(ns.aml.vocabularies.security.flows, objectContext) as string]) as OAuth2Flow[] | undefined; - if (Array.isArray(flows) && flows.length) { - result.flows = flows.map((p) => this.oAuth2Flow(p, objectContext)); - } else { - result.flows = []; - } - return result; - } - - oAuth2Flow(object: OAuth2Flow, context?: Record): ApiSecurityOAuth2Flow { - const objectContext = context || object['@context']; - const result: ApiSecurityOAuth2Flow = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - scopes: [], - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext); - if (authorizationUri && typeof authorizationUri === 'string') { - result.authorizationUri = authorizationUri; - } - const accessTokenUri = this._getValue(object, ns.aml.vocabularies.security.accessTokenUri, objectContext); - if (accessTokenUri && typeof accessTokenUri === 'string') { - result.accessTokenUri = accessTokenUri; - } - const flow = this._getValue(object, ns.aml.vocabularies.security.flow, objectContext); - if (flow && typeof flow === 'string') { - result.flow = flow; - } - const refreshUri = this._getValue(object, ns.aml.vocabularies.security.refreshUri, objectContext); - if (refreshUri && typeof refreshUri === 'string') { - result.refreshUri = refreshUri; - } - const scopes = (object as any)[this._getAmfKey(ns.aml.vocabularies.security.scope, objectContext) as string] as Scope[] | undefined; - if (Array.isArray(scopes) && scopes.length) { - result.scopes = scopes.map((p) => this.scope(p, objectContext)); - } - return result; - } - - - scope(object: Scope, context?: Record): ApiSecurityScope { - const objectContext = context || object['@context']; - const result: ApiSecurityScope = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - return result; - } - - apiKeySettings(object: ApiKeySettings, context?: Record): ApiSecurityApiKeySettings { - const objectContext = context || object['@context']; - const result = (this.settings(object, objectContext)) as ApiSecurityApiKeySettings; - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const inParam = this._getValue(object, ns.aml.vocabularies.security.in, objectContext); - if (inParam && typeof inParam === 'string') { - result.in = inParam; - } - return result; - } - - httpSettings(object: HttpSettings, context?: Record): ApiSecurityHttpSettings { - const objectContext = context || object['@context']; - const result = (this.settings(object, objectContext)) as ApiSecurityHttpSettings; - const { ns } = this; - const scheme = this._getValue(object, ns.aml.vocabularies.security.scheme, objectContext); - if (scheme && typeof scheme === 'string') { - result.scheme = scheme; - } - const bearerFormat = this._getValue(object, ns.aml.vocabularies.security.bearerFormat, objectContext); - if (bearerFormat && typeof bearerFormat === 'string') { - result.bearerFormat = bearerFormat; - } - return result; - } - - openIdConnectSettings(object: OpenIdConnectSettings, context?: Record): ApiSecurityOpenIdConnectSettings { - const objectContext = context || object['@context']; - const result = (this.settings(object, objectContext)) as ApiSecurityOpenIdConnectSettings; - const { ns } = this; - const url = this._getValue(object, ns.aml.vocabularies.security.openIdConnectUrl, objectContext); - if (url && typeof url === 'string') { - result.url = url; - } - return result; - } - - /** - * Serializes source maps, when available. - */ - sourceMap(object: DocumentSourceMaps, context?: Record): ApiDocumentSourceMaps|undefined { - const objectContext = context || object['@context']; - const { ns } = this; - let sm = (object as any)[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, objectContext) as string]; - if (!sm) { - return undefined; - } - if (Array.isArray(sm)) { - [sm] = sm; - } - const result: ApiDocumentSourceMaps = ({ - id: sm['@id'], - types: this.readTypes(sm['@type']), - }); - const synthesizedField = (sm as any)[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.synthesizedField, objectContext) as string]; - if (Array.isArray(synthesizedField) && synthesizedField.length) { - result.synthesizedField = synthesizedField.map(i => this.synthesizedField(i, objectContext)); - } - const lexical = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.lexical, objectContext) as string]; - if (Array.isArray(lexical) && lexical.length) { - result.lexical = lexical.map(i => this.synthesizedField(i, objectContext)) - } - const trackedElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.trackedElement, objectContext) as string]; - if (Array.isArray(trackedElement) && trackedElement.length) { - result.trackedElement = this.synthesizedField(trackedElement[0], objectContext); - } - const autoName = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.autoGeneratedName, objectContext) as string]; - if (Array.isArray(autoName) && autoName.length) { - result.autoGeneratedName = autoName.map(i => this.synthesizedField(i, objectContext)) - } - const jsonSchema = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.parsedJsonSchema, objectContext) as string]; - if (Array.isArray(jsonSchema) && jsonSchema.length) { - result.parsedJsonSchema = this.synthesizedField(jsonSchema[0], objectContext); - } - const declaredElement = sm[this._getAmfKey(ns.aml.vocabularies.docSourceMaps.declaredElement, objectContext) as string]; - if (Array.isArray(declaredElement) && declaredElement.length) { - result.declaredElement = this.synthesizedField(declaredElement[0], objectContext); - } - return result; - } - - synthesizedField(object: SynthesizedField, context?: Record): ApiSynthesizedField { - const objectContext = context || object['@context']; - // compact model - if (typeof object === 'string') { - return ({ - id: 'synthesizedField/generated', - value: object, - }) as ApiSynthesizedField; - } - const result: ApiSynthesizedField = { - id: object['@id'], - value: '', - }; - const element = this._getValue(object, this.ns.aml.vocabularies.docSourceMaps.element, objectContext); - if (typeof element === 'string') { - result.element = element; - } - const value = this._getValue(object, this.ns.aml.vocabularies.docSourceMaps.value, objectContext); - if (typeof value === 'string') { - result.value = value - } - return result; - } - - parametrizedDeclaration(object: ParametrizedDeclaration, context?: Record): ApiParametrizedDeclaration { - const objectContext = context || object['@context']; - const result: ApiParametrizedDeclaration = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - variables: [], - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - }); - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext); - if (name && typeof name === 'string') { - result.name = name; - } - const variables = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.variable, objectContext) as string]; - if (Array.isArray(variables)) { - variables.forEach((item) => { - result.variables.push(this.variableValue(item, objectContext)); - }); - } - const targets = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.target, objectContext) as string]; - if (Array.isArray(targets) && targets.length) { - const [target] = targets; - result.target = this.abstractDeclaration(target, objectContext); - } - return result; - } - - parametrizedTrait(object: ParametrizedTrait, context?: Record): ApiParametrizedTrait { - const objectContext = context || object['@context']; - const result = (this.parametrizedDeclaration(object, objectContext)) as ApiParametrizedTrait; - return result; - } - - - parametrizedResourceType(object: ParametrizedResourceType, context?: Record): ApiParametrizedResourceType { - const objectContext = context || object['@context']; - const result = (this.parametrizedDeclaration(object, objectContext)) as ApiParametrizedResourceType; - return result; - } - - variableValue(object: VariableValue, context?: Record): ApiVariableValue { - const objectContext = context || object['@context']; - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string; - const result: ApiVariableValue = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - name, - }); - const values = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.value, objectContext) as string]; - if (Array.isArray(values)) { - const [item] = values; - result.value = this.unknownDataNode(item, objectContext); - } - return result; - } - - /** - * @param object - * @param {Record=} context - * @returns {} - */ - abstractDeclaration(object: AbstractDeclaration, context?: Record): ApiAbstractDeclaration { - const objectContext = context || object['@context']; - const { ns } = this; - const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string; - const result: ApiAbstractDeclaration = ({ - id: object['@id'], - types: this.readTypes(object['@type'], objectContext), - customDomainProperties: this.customDomainProperties(object, objectContext), - sourceMaps: this.sourceMap(object, objectContext), - name, - variables: [], - }); - const variables = (this._getValueArray(object, ns.aml.vocabularies.document.variable, objectContext)) as string[]; - if (Array.isArray(variables)) { - result.variables = variables; - } - const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext); - if (description && typeof description === 'string') { - result.description = description; - } - const dataNode = (object as any)[this._getAmfKey(ns.aml.vocabularies.document.dataNode, objectContext) as string]; - if (Array.isArray(dataNode)) { - const [item] = dataNode; - result.dataNode = this.unknownDataNode(item, objectContext); - } - return result; - } - - /** - * @param object The EndPoint to serialize as a list item. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Serialized EndPoint as a list item. - */ - endPointWithOperationsListItem(object: EndPoint, context?: Record): ApiEndPointWithOperationsListItem { - const { ns } = this; - const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, context) as string; - - const result: ApiEndPointWithOperationsListItem = ({ - id: object['@id'], - path, - operations: [], - }); - const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, context); - if (Array.isArray(operations) && operations.length) { - result.operations = operations.map(i => this.operationListItem((i as Operation), context)); - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, context); - if (name && typeof name === 'string') { - result.name = name; - } - return result; - } - - /** - * @param object The Operation to serialize as a list item. - * @param context A context to use. If not set, it looks for the context of the passed model - * @returns Serialized Operation as a list item. - */ - operationListItem(object: Operation, context?: Record): ApiOperationListItem { - const result: ApiOperationListItem = ({ - id: object['@id'], - method: '', - }); - const { ns } = this; - const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, context); - if (method && typeof method === 'string') { - result.method = method; - } - const name = this._getValue(object, ns.aml.vocabularies.core.name, context); - if (name && typeof name === 'string') { - result.name = name; - } - return result; - } -} diff --git a/src/helpers/Namespace.ts b/src/helpers/Namespace.ts deleted file mode 100644 index 17b5615..0000000 --- a/src/helpers/Namespace.ts +++ /dev/null @@ -1,329 +0,0 @@ -const amlKey = 'http://a.ml/'; -const vocKey = `${amlKey}vocabularies/`; -const docKey = `${vocKey}document#`; -const coreKey = `${vocKey}core#`; -const secKey = `${vocKey}security#`; -const contractKey = `${vocKey}apiContract#`; -const shapesKey = `${vocKey}shapes#`; -const dataKey = `${vocKey}data#`; -const dsmKey = `${vocKey}document-source-maps#`; -const w3Key = 'http://www.w3.org/'; -const shaclKey = `${w3Key}ns/shacl#`; -const xmlSchemaKey = `${w3Key}2001/XMLSchema#`; -const rdfSyntaxKey = `${w3Key}1999/02/22-rdf-syntax-ns#`; -const rdfSchemaKey = `${w3Key}2000/01/rdf-schema#`; - -/** - * A namespace for AMF properties. - */ -export const ns = { - aml: { - key: 'http://a.ml/', - vocabularies: { - key: vocKey, - document: { - key: docKey, - Module: `${docKey}Module`, - Document: `${docKey}Document`, - SecuritySchemeFragment: `${docKey}SecuritySchemeFragment`, - UserDocumentation: `${docKey}UserDocumentation`, - DataType: `${docKey}DataType`, - NamedExamples: `${docKey}NamedExamples`, - DomainElement: `${docKey}DomainElement`, - ParametrizedDeclaration: `${docKey}ParametrizedDeclaration`, - ExternalDomainElement: `${docKey}ExternalDomainElement`, - - customDomainProperties: `${docKey}customDomainProperties`, - encodes: `${docKey}encodes`, - declares: `${docKey}declares`, - references: `${docKey}references`, - examples: `${docKey}examples`, - linkTarget: `${docKey}link-target`, - linkLabel: `${docKey}link-label`, - referenceId: `${docKey}reference-id`, - structuredValue: `${docKey}structuredValue`, - raw: `${docKey}raw`, - extends: `${docKey}extends`, - value: `${docKey}value`, - name: `${docKey}name`, - strict: `${docKey}strict`, - deprecated: `${docKey}deprecated`, - location: `${docKey}location`, - variable: `${docKey}variable`, - target: `${docKey}target`, - dataNode: `${docKey}dataNode`, - root: `${docKey}root`, - usage: `${docKey}usage`, - version: `${docKey}version`, - }, - core: { - key: coreKey, - CreativeWork: `${coreKey}CreativeWork`, - - version: `${coreKey}version`, - urlTemplate: `${coreKey}urlTemplate`, - displayName: `${coreKey}displayName`, - title: `${coreKey}title`, - name: `${coreKey}name`, - description: `${coreKey}description`, - documentation: `${coreKey}documentation`, - summary: `${coreKey}summary`, - provider: `${coreKey}provider`, - email: `${coreKey}email`, - url: `${coreKey}url`, - termsOfService: `${coreKey}termsOfService`, - license: `${coreKey}license`, - mediaType: `${coreKey}mediaType`, - extensionName: `${coreKey}extensionName`, - deprecated: `${coreKey}deprecated`, - }, - security: { - key: secKey, - ParametrizedSecurityScheme: `${secKey}ParametrizedSecurityScheme`, - SecuritySchemeFragment: `${secKey}SecuritySchemeFragment`, - SecurityScheme: `${secKey}SecurityScheme`, - OAuth1Settings: `${secKey}OAuth1Settings`, - OAuth2Settings: `${secKey}OAuth2Settings`, - OAuth2Flow: `${secKey}OAuth2Flow`, - Scope: `${secKey}Scope`, - Settings: `${secKey}Settings`, - HttpSettings: `${secKey}HttpSettings`, - ApiKeySettings: `${secKey}ApiKeySettings`, - OpenIdConnectSettings: `${secKey}OpenIdConnectSettings`, - security: `${secKey}security`, - scheme: `${secKey}scheme`, - schemes: `${secKey}schemes`, - settings: `${secKey}settings`, - name: `${secKey}name`, - type: `${secKey}type`, - scope: `${secKey}scope`, - accessTokenUri: `${secKey}accessTokenUri`, - authorizationUri: `${secKey}authorizationUri`, - authorizationGrant: `${secKey}authorizationGrant`, - flows: `${secKey}flows`, - flow: `${secKey}flow`, - signature: `${secKey}signature`, - tokenCredentialsUri: `${secKey}tokenCredentialsUri`, - requestTokenUri: `${secKey}requestTokenUri`, - refreshUri: `${secKey}refreshUri`, - securityRequirement: `${secKey}SecurityRequirement`, - openIdConnectUrl: `${secKey}openIdConnectUrl`, - bearerFormat: `${secKey}bearerFormat`, - in: `${secKey}in`, - }, - apiContract: { - key: contractKey, - Payload: `${contractKey}Payload`, - Request: `${contractKey}Request`, - Response: `${contractKey}Response`, - EndPoint: `${contractKey}EndPoint`, - Parameter: `${contractKey}Parameter`, - Operation: `${contractKey}Operation`, - WebAPI: `${contractKey}WebAPI`, - API: `${contractKey}API`, - AsyncAPI: `${contractKey}AsyncAPI`, - UserDocumentationFragment: `${contractKey}UserDocumentationFragment`, - Example: `${contractKey}Example`, - Server: `${contractKey}Server`, - ParametrizedResourceType: `${contractKey}ParametrizedResourceType`, - ParametrizedTrait: `${contractKey}ParametrizedTrait`, - Callback: `${contractKey}Callback`, - TemplatedLink: `${contractKey}TemplatedLink`, - IriTemplateMapping: `${contractKey}IriTemplateMapping`, - Tag: `${contractKey}Tag`, - Message: `${contractKey}Message`, - - header: `${contractKey}header`, - parameter: `${contractKey}parameter`, - paramName: `${contractKey}paramName`, - uriParameter: `${contractKey}uriParameter`, - cookieParameter: `${contractKey}cookieParameter`, - variable: `${contractKey}variable`, - payload: `${contractKey}payload`, - server: `${contractKey}server`, - path: `${contractKey}path`, - url: `${contractKey}url`, - scheme: `${contractKey}scheme`, - endpoint: `${contractKey}endpoint`, - queryString: `${contractKey}queryString`, - accepts: `${contractKey}accepts`, - guiSummary: `${contractKey}guiSummary`, - binding: `${contractKey}binding`, - response: `${contractKey}response`, - returns: `${contractKey}returns`, - expects: `${contractKey}expects`, - examples: `${contractKey}examples`, - supportedOperation: `${contractKey}supportedOperation`, - statusCode: `${contractKey}statusCode`, - method: `${contractKey}method`, - required: `${contractKey}required`, - callback: `${contractKey}callback`, - expression: `${contractKey}expression`, - link: `${contractKey}link`, - linkExpression: `${contractKey}linkExpression`, - templateVariable: `${contractKey}templateVariable`, - mapping: `${contractKey}mapping`, - operationId: `${contractKey}operationId`, - protocol: `${contractKey}protocol`, - protocolVersion: `${contractKey}protocolVersion`, - headerSchema: `${contractKey}headerSchema`, - contentType: `${contractKey}contentType`, - allowEmptyValue: `${contractKey}allowEmptyValue`, - style: `${contractKey}style`, - explode: `${contractKey}explode`, - allowReserved: `${contractKey}allowReserved`, - tag: `${contractKey}tag`, - }, - shapes: { - key: shapesKey, - Shape: `${shapesKey}Shape`, - ScalarShape: `${shapesKey}ScalarShape`, - ArrayShape: `${shapesKey}ArrayShape`, - UnionShape: `${shapesKey}UnionShape`, - NilShape: `${shapesKey}NilShape`, - FileShape: `${shapesKey}FileShape`, - AnyShape: `${shapesKey}AnyShape`, - SchemaShape: `${shapesKey}SchemaShape`, - MatrixShape: `${shapesKey}MatrixShape`, - TupleShape: `${shapesKey}TupleShape`, - RecursiveShape: `${shapesKey}RecursiveShape`, - DataTypeFragment: `${shapesKey}DataTypeFragment`, - XMLSerializer: `${shapesKey}XMLSerializer`, - - // data types - number: `${shapesKey}number`, - integer: `${shapesKey}integer`, - long: `${shapesKey}long`, - double: `${shapesKey}double`, - boolean: `${shapesKey}boolean`, - float: `${shapesKey}float`, - nil: `${shapesKey}nil`, - password: `${shapesKey}password`, - - // API shapes - dateTimeOnly: `${shapesKey}dateTimeOnly`, - - range: `${shapesKey}range`, - items: `${shapesKey}items`, - anyOf: `${shapesKey}anyOf`, - fileType: `${shapesKey}fileType`, - schema: `${shapesKey}schema`, - xmlSerialization: `${shapesKey}xmlSerialization`, - xmlName: `${shapesKey}xmlName`, - xmlAttribute: `${shapesKey}xmlAttribute`, - xmlWrapped: `${shapesKey}xmlWrapped`, - xmlNamespace: `${shapesKey}xmlNamespace`, - xmlPrefix: `${shapesKey}xmlPrefix`, - readOnly: `${shapesKey}readOnly`, - writeOnly: `${shapesKey}writeOnly`, - deprecated: `${shapesKey}deprecated`, - fixPoint: `${shapesKey}fixPoint`, - discriminator: `${shapesKey}discriminator`, - discriminatorValue: `${shapesKey}discriminatorValue`, - format: `${shapesKey}format`, - multipleOf: `${shapesKey}multipleOf`, - uniqueItems: `${shapesKey}uniqueItems`, - }, - data: { - key: dataKey, - Scalar: `${dataKey}Scalar`, - Object: `${dataKey}Object`, - Array: `${dataKey}Array`, - Node: `${dataKey}Node`, - - value: `${dataKey}value`, - type: `${dataKey}type`, - description: `${dataKey}description`, - required: `${dataKey}required`, - displayName: `${dataKey}displayName`, - minLength: `${dataKey}minLength`, - maxLength: `${dataKey}maxLength`, - default: `${dataKey}default`, - multipleOf: `${dataKey}multipleOf`, - minimum: `${dataKey}minimum`, - maximum: `${dataKey}maximum`, - enum: `${dataKey}enum`, - pattern: `${dataKey}pattern`, - items: `${dataKey}items`, - format: `${dataKey}format`, - example: `${dataKey}example`, - examples: `${dataKey}examples`, - }, - docSourceMaps: { - key: dsmKey, - SourceMap: `${dsmKey}SourceMap`, - sources: `${dsmKey}sources`, - element: `${dsmKey}element`, - value: `${dsmKey}value`, - declaredElement: `${dsmKey}declared-element`, - trackedElement: `${dsmKey}tracked-element`, - parsedJsonSchema: `${dsmKey}parsed-json-schema`, - autoGeneratedName: `${dsmKey}auto-generated-name`, - lexical: `${dsmKey}lexical`, - synthesizedField: `${dsmKey}synthesized-field`, - }, - }, - }, - w3: { - key: w3Key, - shacl: { - key: shaclKey, - Shape: `${shaclKey}Shape`, - NodeShape: `${shaclKey}NodeShape`, - SchemaShape: `${shaclKey}SchemaShape`, - PropertyShape: `${shaclKey}PropertyShape`, - in: `${shaclKey}in`, - defaultValue: `${shaclKey}defaultValue`, - defaultValueStr: `${shaclKey}defaultValueStr`, - pattern: `${shaclKey}pattern`, - minInclusive: `${shaclKey}minInclusive`, - maxInclusive: `${shaclKey}maxInclusive`, - multipleOf: `${shaclKey}multipleOf`, - minLength: `${shaclKey}minLength`, - maxLength: `${shaclKey}maxLength`, - fileType: `${shaclKey}fileType`, - and: `${shaclKey}and`, - property: `${shaclKey}property`, - name: `${shaclKey}name`, - raw: `${shaclKey}raw`, - datatype: `${shaclKey}datatype`, - minCount: `${shaclKey}minCount`, - maxCount: `${shaclKey}maxCount`, - xone: `${shaclKey}xone`, - not: `${shaclKey}not`, - or: `${shaclKey}or`, - closed: `${shaclKey}closed`, - path: `${shaclKey}path`, - }, - // XML schema data types - xmlSchema: { - key: xmlSchemaKey, - boolean: `${xmlSchemaKey}boolean`, - string: `${xmlSchemaKey}string`, - number: `${xmlSchemaKey}number`, - integer: `${xmlSchemaKey}integer`, - long: `${xmlSchemaKey}long`, - double: `${xmlSchemaKey}double`, - float: `${xmlSchemaKey}float`, - nil: `${xmlSchemaKey}nil`, - dateTime: `${xmlSchemaKey}dateTime`, - time: `${xmlSchemaKey}time`, - date: `${xmlSchemaKey}date`, - base64Binary: `${xmlSchemaKey}base64Binary`, - byte: `${xmlSchemaKey}byte`, - }, - rdfSyntax: { - key: rdfSyntaxKey, - - Seq: `${rdfSyntaxKey}Seq`, - member: `${rdfSyntaxKey}member`, - }, - - rdfSchema: { - key: rdfSchemaKey, - - Seq: `${rdfSchemaKey}Seq`, - member: `${rdfSchemaKey}member`, - } - }, -}; diff --git a/src/helpers/amf.ts b/src/helpers/amf.ts deleted file mode 100644 index eecaeac..0000000 --- a/src/helpers/amf.ts +++ /dev/null @@ -1,445 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-interface */ -export declare interface DomainElement { - '@id': string; - '@type': string[]; - '@context'?: Record; - 'http://a.ml/vocabularies/document#customDomainProperties'?: []; -} - -export interface ExternalDomainElement extends DomainElement { - 'http://a.ml/vocabularies/document#raw': LdValueString[]; - 'http://a.ml/vocabularies/core#mediaType': LdValueString[]; -} - -export declare interface Linkable { - 'http://a.ml/vocabularies/document#link-target'?: LdIdValue[]; - 'http://a.ml/vocabularies/document#link-label'?: LdValueString[]; -} - -export declare interface LdValue { - '@value': T; -} - -export declare interface LdIdValue { - '@id': string; -} - -export declare interface LdValueString extends LdValue { -} - -export declare interface LdValueBoolean extends LdValue { -} - -export declare interface LdValueNumber extends LdValue { -} - -export declare interface LdValueRange extends LdIdValue { - '@type'?: string[]; -} - -export interface AmfDocument extends DomainElement { - 'http://a.ml/vocabularies/document#version'?: LdValueString[]; - 'http://a.ml/vocabularies/document#root'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/document#encodes'?: DomainElement[]; - 'http://a.ml/vocabularies/document#references'?: DomainElement[]; - 'http://a.ml/vocabularies/document#declares'?: DomainElement[]; -} - -export interface Api extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#server'?: Server[]; - 'http://a.ml/vocabularies/apiContract#accepts'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#contentType'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#scheme'?: LdValueString[]; - 'http://a.ml/vocabularies/core#version'?: LdValueString[]; - 'http://a.ml/vocabularies/core#documentation'?: CreativeWork[]; - 'http://a.ml/vocabularies/apiContract#endpoint'?: EndPoint[]; - 'http://a.ml/vocabularies/apiContract#tag'?: Tag[]; - 'http://a.ml/vocabularies/core#provider'?: Organization[]; - 'http://a.ml/vocabularies/core#license'?: License[]; -} - -export interface WebApi extends Api {} -export interface AsyncApi extends Api {} - -export interface Module extends DomainElement { - 'http://a.ml/vocabularies/document#version'?: LdValueString[]; - 'http://a.ml/vocabularies/document#root'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/document#declares'?: DomainElement[]; - 'http://a.ml/vocabularies/document#usage'?: LdValueString[]; -} - -export interface DataTypeFragment extends DomainElement { - 'http://a.ml/vocabularies/document#version'?: LdValueString[]; - 'http://a.ml/vocabularies/document#root'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/document#encodes'?: Shape[]; - 'http://a.ml/vocabularies/document#references'?: DomainElement[]; -} - -export interface ExternalFragment extends DomainElement { - 'http://a.ml/vocabularies/document#version'?: LdValueString[]; - 'http://a.ml/vocabularies/document#root'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/document#encodes'?: ExternalDomainElement[]; -} - -export interface Organization extends DomainElement { - 'http://a.ml/vocabularies/core#email'?: LdValueString[]; - 'http://a.ml/vocabularies/core#url'?: LdValueString[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; -} - -export interface License extends DomainElement { - 'http://a.ml/vocabularies/core#url'?: LdValueString[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; -} - -export declare interface Server extends DomainElement { - 'http://a.ml/vocabularies/core#urlTemplate'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#variable'?: Parameter[]; -} - -export declare interface EndPoint extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#guiSummary'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#path'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#supportedOperation'?: Operation[]; - 'http://a.ml/vocabularies/apiContract#parameter'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#payload'?: Payload[]; - 'http://a.ml/vocabularies/apiContract#server'?: Server[]; - 'http://a.ml/vocabularies/security#security'?: SecurityRequirement[]; - 'http://a.ml/vocabularies/document#extends'?: ParametrizedDeclaration[]; -} - -export declare interface Operation extends DomainElement { - 'http://a.ml/vocabularies/apiContract#method': LdValueString[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/shapes#deprecated'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#guiSummary'?: LdValueString[]; - 'http://a.ml/vocabularies/core#documentation'?: CreativeWork[]; - 'http://a.ml/vocabularies/apiContract#scheme'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#accepts'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#contentType'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#expects'?: Request[]; - 'http://a.ml/vocabularies/apiContract#returns'?: Response[]; - 'http://a.ml/vocabularies/security#security'?: SecurityRequirement[]; - 'http://a.ml/vocabularies/apiContract#callback'?: Callback[]; - 'http://a.ml/vocabularies/apiContract#server'?: Server[]; - 'http://a.ml/vocabularies/document#extends'?: ParametrizedTrait[]; -} - -export interface Payload extends DomainElement { - 'http://a.ml/vocabularies/core#mediaType': LdValueString[]; - 'http://a.ml/vocabularies/shapes#schema'?: DomainElement[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#examples'?: Example[]; - // encoding: Encoding[] -} - -export interface Request extends DomainElement { - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#payload'?: Payload[]; - 'http://a.ml/vocabularies/apiContract#required'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#parameter'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#uriParameter'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#header'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#cookieParameter'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#queryString'?: Shape; -} - -export interface Response extends DomainElement { - 'http://a.ml/vocabularies/apiContract#statusCode': LdValueString[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#payload'?: Payload[]; - 'http://a.ml/vocabularies/apiContract#header'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#examples'?: Example[]; - 'http://a.ml/vocabularies/apiContract#link'?: TemplatedLink[]; -} - -export declare interface Parameter extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/shapes#schema'?: DomainElement[]; - 'http://a.ml/vocabularies/shapes#deprecated'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#paramName'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#required'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#binding'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#allowEmptyValue'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#style'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#explode'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/apiContract#allowReserved'?: LdValueBoolean[]; - - // payloads: Payload[] - // examples: Example[] -} - -export interface TemplatedLink extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#operationId': LdValueString[]; - 'http://a.ml/vocabularies/apiContract#mapping': IriTemplateMapping[]; - 'http://a.ml/vocabularies/apiContract#server'?: Server[]; - // not sure what this is - // template: StrField - // requestBody: StrField -} - -export interface IriTemplateMapping extends DomainElement { - 'http://a.ml/vocabularies/apiContract#templateVariable'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#linkExpression'?: LdValueString[]; -} - -export declare interface Shape extends DomainElement, Linkable { - 'http://www.w3.org/ns/shacl#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/core#displayName'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#defaultValueStr'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#defaultValue'?: DataNode[]; - 'http://a.ml/vocabularies/shapes#readOnly'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#writeOnly'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#deprecated'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/document#location'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#or'?: Shape[]; - 'http://www.w3.org/ns/shacl#and'?: Shape[]; - 'http://www.w3.org/ns/shacl#xone'?: Shape[]; - 'http://www.w3.org/ns/shacl#not'?: Shape[]; - // values: DataNode[] - // inherits: Shape[] -} - -export declare interface PropertyShape extends Shape { - 'http://www.w3.org/ns/shacl#path'?: LdIdValue[]; - 'http://a.ml/vocabularies/shapes#range'?: Shape[]; - 'http://www.w3.org/ns/shacl#minCount'?: LdValueNumber[]; - 'http://www.w3.org/ns/shacl#maxCount'?: LdValueNumber[]; - // patternName: StrField -} - -export declare interface AnyShape extends Shape { - 'http://a.ml/vocabularies/core#documentation'?: CreativeWork[]; - 'http://a.ml/vocabularies/shapes#xmlSerialization'?: DomainElement[]; - 'http://a.ml/vocabularies/apiContract#examples'?: DomainElement[]; - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; -} - -export declare interface DataArrangeShape extends AnyShape { - // minItems: IntField - // maxItems: IntField - // uniqueItems: BoolField -} - -export declare interface ArrayShape extends DataArrangeShape { - 'http://a.ml/vocabularies/shapes#items'?: Shape[]; -} - -export declare interface UnionShape extends AnyShape { - 'http://a.ml/vocabularies/shapes#anyOf'?: Shape[]; -} - -export declare interface TupleShape extends AnyShape { - 'http://a.ml/vocabularies/shapes#items'?: Shape[]; -} - -export declare interface FileShape extends AnyShape { - 'http://a.ml/vocabularies/shapes#fileType'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#pattern'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#minLength'?: LdValueNumber[]; - 'http://www.w3.org/ns/shacl#maxLength'?: LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#minimum'?: LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#maximum'?: LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#exclusiveMinimum'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#exclusiveMaximum'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#format'?: LdValueString[]; - 'http://a.ml/vocabularies/shapes#multipleOf'?: LdValueNumber[]; -} - -export declare interface NilShape extends AnyShape { -} - -export declare interface RecursiveShape extends Shape { - 'http://a.ml/vocabularies/shapes#fixPoint'?: LdIdValue[]; - 'http://a.ml/vocabularies/document#recursive'?: LdValueBoolean[]; -} - -export declare interface ScalarShape extends Shape { - 'http://www.w3.org/ns/shacl#datatype'?: LdIdValue[]; - 'http://www.w3.org/ns/shacl#pattern'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#minLength'?: LdValueNumber[]; - 'http://www.w3.org/ns/shacl#maxLength'?: LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#minimum': LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#maximum': LdValueNumber[]; - 'http://a.ml/vocabularies/shapes#exclusiveMinimum': LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#exclusiveMaximum': LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#format'?: LdValueString[]; - 'http://a.ml/vocabularies/shapes#multipleOf'?: LdValueNumber[]; -} - -export declare interface SchemaShape extends Shape { - 'http://a.ml/vocabularies/core#mediaType': LdValueString[]; - 'http://a.ml/vocabularies/document#raw'?: LdValueString[]; -} - -export declare interface NodeShape extends AnyShape { - // minProperties: IntField - // maxProperties: IntField - 'http://www.w3.org/ns/shacl#closed'?: LdValueBoolean[]; - // customShapeProperties?: PropertyShape[] - // customShapePropertyDefinitions?: PropertyShape[] - 'http://a.ml/vocabularies/shapes#discriminator'?: LdValueString[]; - 'http://a.ml/vocabularies/shapes#discriminatorValue'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#property'?: PropertyShape[]; - // dependencies: PropertyDependencies[] -} - -export declare interface DataNode extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; -} - -export declare interface ObjectNode extends DataNode { - // [key: string]: DataNode[]; -} - -export declare interface ArrayNode extends DataNode { -} - -export declare interface ScalarNode extends DataNode { - 'http://a.ml/vocabularies/data#value'?: LdValueString[]; - 'http://www.w3.org/ns/shacl#datatype'?: LdIdValue[]; -} - -export declare interface Example extends DomainElement, Linkable { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#displayName'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/data#value'?: LdIdValue[]; - 'http://a.ml/vocabularies/document#structuredValue'?: DataNode[]; - 'http://a.ml/vocabularies/document#strict'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/core#mediaType'?: LdValueString[]; - 'http://a.ml/vocabularies/document#raw'?: LdValueString[]; -} - -export interface CreativeWork extends DomainElement { - 'http://a.ml/vocabularies/core#title'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; -} - -export interface SecurityRequirement extends DomainElement { - 'http://a.ml/vocabularies/security#schemes'?: ParametrizedSecurityScheme[]; - // not sure if this is the right key. Can't generate an example. - 'http://a.ml/vocabularies/security#name'?: LdValueString[]; -} - -export interface ParametrizedSecurityScheme extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/security#scheme'?: SecurityScheme[]; - 'http://a.ml/vocabularies/security#settings': Settings[]; -} - -export interface SecurityScheme extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/security#type'?: LdValueString[]; - 'http://a.ml/vocabularies/core#displayName'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#parameter'?: Parameter[]; - 'http://a.ml/vocabularies/apiContract#header'?: Parameter[]; - 'http://a.ml/vocabularies/security#settings'?: Settings[]; - 'http://a.ml/vocabularies/apiContract#response'?: Response[]; - 'http://a.ml/vocabularies/apiContract#queryString'?: Shape; -} - -export interface Settings extends DomainElement { - // additionalProperties: DataNode; -} - -export interface OAuth1Settings extends Settings { - 'http://a.ml/vocabularies/security#requestTokenUri'?: LdValueString[]; - 'http://a.ml/vocabularies/security#authorizationUri'?: LdValueString[]; - 'http://a.ml/vocabularies/security#tokenCredentialsUri'?: LdValueString[]; - 'http://a.ml/vocabularies/security#signature': LdValueString[]; -} - -export interface OAuth2Settings extends Settings { - 'http://a.ml/vocabularies/security#authorizationGrant': LdValueString[]; - 'http://a.ml/vocabularies/security#flows'?: OAuth2Flow[]; -} - -export interface OAuth2Flow extends Settings { - 'http://a.ml/vocabularies/security#authorizationUri'?: LdValueString[]; - 'http://a.ml/vocabularies/security#accessTokenUri': LdValueString[]; - 'http://a.ml/vocabularies/security#flow'?: LdValueString[]; - 'http://a.ml/vocabularies/security#refreshUri': LdValueString[]; - 'http://a.ml/vocabularies/security#scope'?: Scope[]; -} - -export interface ApiKeySettings extends Settings { - 'http://a.ml/vocabularies/core#name': LdValueString[]; - 'http://a.ml/vocabularies/security#in': LdValueString[]; -} - -export interface HttpSettings extends Settings { - 'http://a.ml/vocabularies/security#scheme'?: LdValueString[]; - 'http://a.ml/vocabularies/security#bearerFormat'?: LdValueString[]; -} - -export interface OpenIdConnectSettings extends Settings { - 'http://a.ml/vocabularies/security#openIdConnectUrl': LdValueString[]; -} - -export interface Scope extends DomainElement { - 'http://a.ml/vocabularies/core#name': LdValueString[]; - 'http://a.ml/vocabularies/core#description': LdValueString[]; -} - -export interface Callback extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#expression'?: LdValueString[]; - 'http://a.ml/vocabularies/apiContract#endpoint'?: EndPoint[]; -} - -export interface XMLSerializer extends DomainElement { - 'http://a.ml/vocabularies/shapes#xmlAttribute'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#xmlWrapped'?: LdValueBoolean[]; - 'http://a.ml/vocabularies/shapes#xmlName'?: LdValueBoolean[]; -} - -export interface Tag extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; -} - -export interface DocumentSourceMaps extends DomainElement { - 'http://a.ml/vocabularies/document-source-maps#synthesized-field'?: SynthesizedField[]; - 'http://a.ml/vocabularies/document-source-maps#lexical'?: SynthesizedField[]; - 'http://a.ml/vocabularies/document-source-maps#tracked-element'?: SynthesizedField[]; -} - -export interface SynthesizedField extends DomainElement { - '@id': string; - // '@context'?: Record; - 'http://a.ml/vocabularies/document-source-maps#element'?: LdValueString[]; - 'http://a.ml/vocabularies/document-source-maps#value'?: LdValueString[]; -} - -export interface ParametrizedDeclaration extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/document#target'?: AbstractDeclaration[]; - 'http://a.ml/vocabularies/document#variable'?: VariableValue[]; -} - -export interface VariableValue extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/document#value'?: DataNode[]; -} - -export interface AbstractDeclaration extends DomainElement { - 'http://a.ml/vocabularies/core#name'?: LdValueString[]; - 'http://a.ml/vocabularies/core#description'?: LdValueString[]; - 'http://a.ml/vocabularies/document#dataNode'?: DataNode[]; - 'http://a.ml/vocabularies/document#variable'?: LdValueString[]; -} - -export interface ParametrizedTrait extends ParametrizedDeclaration {} -export interface ParametrizedResourceType extends ParametrizedDeclaration {} diff --git a/src/helpers/api.ts b/src/helpers/api.ts deleted file mode 100644 index 7c1c5ab..0000000 --- a/src/helpers/api.ts +++ /dev/null @@ -1,547 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-interface */ -import { Server } from "./amf.js"; - -export interface ServersQueryOptions { - /** - * An EndPoint to look for the servers in - */ - endpointId?: string - /** - * An Operation to look for the servers in - */ - methodId?: string -} - -export interface ServerQueryOptions { - /** - * An EndPoint to look for the servers in. Required if Operation is provided - */ - endpointId?: string - /** - * An Operation to look for the servers in - */ - methodId?: string - /** - * Optional selected server id - */ - id?: string; -} - -export interface ComputeUriOptions { - /** - * Model for the current server, if available. - */ - server?: Server; - /** - * Base URI to be used with the endpoint's path. - * Note, base URI is ignored when `ignoreBase` is set - */ - baseUri?: string; - /** - * Current version of the API. It is used to replace - * `{version}` from the URI template. - */ - version?: string; - /** - * List of available protocols of the base URI with path. - */ - protocols?: string[]; - /** - * Whether or not to ignore rendering - */ - ignoreBase?: boolean; - ignorePath?: boolean; -} - -export interface ApiDomainProperty { - id: string; - types: string[]; - customDomainProperties: ApiCustomDomainProperty[]; -} - -export interface ApiCustomDomainProperty { - id: string; - name: string; - extension: ApiDataNodeUnion; -} - -export type ScalarDataTypes = 'string' | 'base64Binary' | 'boolean' | 'date' | 'dateTime' | 'double' | 'float' | 'integer' | 'long' | 'number' | 'time'; - -export interface ApiSummary extends ApiDomainProperty { - name?: string; - description?: string; - // identifier?: string; <- not sure what this is. - schemes: string[]; - accepts: string[]; - contentType: string[]; - version?: string; - termsOfService?: string; - provider?: ApiOrganization; - license?: ApiLicense; - documentations: ApiDocumentation[]; - tags: ApiTag[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiBase extends ApiSummary { - endPoints: ApiEndPoint[]; - servers: ApiServer[]; - security: ApiSecurityRequirement[]; -} - -export interface ApiWeb extends ApiBase {} -export interface ApiAsync extends ApiBase {} - -export interface ApiOrganization extends ApiDomainProperty { - url?: string; - name?: string; - email?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiLicense extends ApiDomainProperty { - url?: string; - name?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiEndPoint extends ApiDomainProperty { - description?: string; - name?: string; - summary?: string; - path: string; - operations: ApiOperation[]; - parameters: ApiParameter[]; - payloads: ApiPayload[]; - servers: ApiServer[]; - security: ApiSecurityRequirement[]; - sourceMaps?: ApiDocumentSourceMaps; - extends: ApiParametrizedDeclaration[]; -} - -export interface ApiOperation extends ApiDomainProperty { - method: string; - name?: string; - description?: string; - summary?: string; - deprecated: boolean; - schemes?: string[]; - accepts?: string[]; - contentType?: string[]; - operationId?: string; - documentation?: ApiDocumentation; - request?: ApiRequest; - responses: ApiResponse[]; - security: ApiSecurityRequirement[]; - callbacks: ApiCallback[]; - servers: ApiServer[]; - tags: ApiTag[]; - sourceMaps?: ApiDocumentSourceMaps; - extends: ApiParametrizedTrait[]; -} - -export interface ApiTag extends ApiDomainProperty { - name: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiServer extends ApiDomainProperty { - url: string; - description?: string; - variables: ApiParameter[]; - sourceMaps?: ApiDocumentSourceMaps; - protocol?: string; - protocolVersion?: string; - security?: ApiSecurityRequirement[]; -} - -export interface ApiParameter extends ApiDomainProperty { - name?: string; - paramName?: string; - description?: string; - required?: boolean; - deprecated?: boolean; - allowEmptyValue?: boolean; - style?: string; - explode?: boolean; - allowReserved?: boolean; - binding?: string; - schema?: ApiShapeUnion; - payloads: ApiPayload[]; - examples: ApiExample[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiExample extends ApiDomainProperty { - name?: string; - displayName?: string; - description?: string; - value?: string; - structuredValue?: ApiDataNodeUnion; - strict: boolean; - mediaType?: string; - location?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiPayload extends ApiDomainProperty { - name?: string; - mediaType?: string; - schema?: ApiShapeUnion; - examples: ApiExample[]; - // encoding: ApiEncoding[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiResponse extends ApiDomainProperty { - name?: string; - description?: string; - statusCode?: string; - headers: ApiParameter[]; - payloads: ApiPayload[]; - examples: ApiExample[]; - links: ApiTemplatedLink[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiTemplatedLink extends ApiDomainProperty { - name?: string; - description?: string; - template?: string; - operationId?: string; - requestBody?: string; - mapping: ApiIriTemplateMapping[]; - server?: ApiServer; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiIriTemplateMapping extends ApiDomainProperty { - templateVariable?: string; - linkExpression?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityRequirement extends ApiDomainProperty { - name?: string; - schemes: ApiParametrizedSecurityScheme[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiParametrizedSecurityScheme extends ApiDomainProperty { - name?: string; - settings?: ApiSecuritySettingsUnion; - scheme?: ApiSecurityScheme; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityScheme extends ApiDomainProperty { - name?: string; - type?: string; - displayName?: string; - description?: string; - settings?: ApiSecuritySettingsUnion; - headers: ApiParameter[]; - queryParameters: ApiParameter[]; - responses: ApiResponse[]; - queryString?: ApiShapeUnion; - sourceMaps?: ApiDocumentSourceMaps; -} - - -export interface ApiSecuritySettings extends ApiDomainProperty { - additionalProperties?: ApiDataNodeUnion; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityOAuth1Settings extends ApiSecuritySettings { - requestTokenUri?: string; - authorizationUri?: string; - tokenCredentialsUri?: string; - signatures: string[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityOAuth2Settings extends ApiSecuritySettings { - authorizationGrants: string[]; - flows: ApiSecurityOAuth2Flow[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityApiKeySettings extends ApiSecuritySettings { - name?: string; - in?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityHttpSettings extends ApiSecuritySettings { - scheme?: string; - bearerFormat?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityOpenIdConnectSettings extends ApiSecuritySettings { - url?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export type ApiSecuritySettingsUnion = ApiSecuritySettings | ApiSecurityOAuth1Settings | ApiSecurityOAuth2Settings | ApiSecurityApiKeySettings | ApiSecurityHttpSettings | ApiSecurityOpenIdConnectSettings; - -export interface ApiSecurityOAuth2Flow extends ApiDomainProperty { - authorizationUri?: string; - accessTokenUri?: string; - flow?: string; - refreshUri?: string; - scopes: ApiSecurityScope[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiSecurityScope extends ApiDomainProperty { - name?: string; - description?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiRequest extends ApiDomainProperty { - description?: string; - required?: boolean; - queryParameters: ApiParameter[]; - headers: ApiParameter[]; - payloads: ApiPayload[]; - queryString?: ApiShapeUnion; - uriParameters: ApiParameter[]; - cookieParameters: ApiParameter[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiCallback extends ApiDomainProperty { - name?: string; - expression?: string; - endpoint?: ApiEndPoint; - sourceMaps?: ApiDocumentSourceMaps; -} - -/** - * The definition of the domain extension - */ -export interface ApiCustomDomainExtension extends ApiDomainProperty { - name?: string; - displayName?: string; - description?: string; - domain: string[]; - schema?: ApiShapeUnion; - sourceMaps?: ApiDocumentSourceMaps; -} - -/** - * Applies to an object domain extension - */ -export interface ApiDomainExtension extends ApiDomainProperty { - name?: string; - definedBy?: ApiCustomDomainExtension; - extension?: ApiDataNodeUnion; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiDocumentation extends ApiDomainProperty { - url?: string; - description?: string; - title?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export type ApiShapeUnion = ApiScalarShape | ApiNodeShape | ApiUnionShape | ApiFileShape | ApiSchemaShape | ApiAnyShape | ApiArrayShape | ApiTupleShape | ApiRecursiveShape; - -export interface ApiShape extends ApiDomainProperty { - values: ApiDataNodeUnion[]; - inherits: ApiShapeUnion[]; - or: ApiShapeUnion[]; - and: ApiShapeUnion[]; - xone: ApiShapeUnion[]; - name?: string; - displayName?: string; - description?: string; - defaultValueStr?: string; - defaultValue?: ApiDataNodeUnion; - deprecated?: boolean; - readOnly?: boolean; - writeOnly?: boolean; - not?: ApiShapeUnion; - /** - * A label that appeared on a link. - */ - linkLabel?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiPropertyShape extends ApiShape { - path?: string; - range?: ApiShapeUnion; - minCount?: number; - maxCount?: number; - patternName?: string; -} - -export interface ApiAnyShape extends ApiShape { - documentation?: ApiDocumentation; - xmlSerialization: ApiXMLSerializer; - examples: ApiExample[]; -} - -export interface ApiNodeShape extends ApiAnyShape { - minProperties?: number; - maxProperties?: number; - closed?: boolean; - customShapeProperties: string[]; - customShapePropertyDefinitions: string[]; - discriminator?: string; - discriminatorValue?: string; - properties: ApiPropertyShape[]; - dependencies: string[]; -} - -export interface ApiXMLSerializer extends ApiDomainProperty { - attribute?: boolean; - wrapped?: boolean; - name?: string; - namespace?: string; - prefix?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiScalarShape extends ApiAnyShape { - dataType?: string; - pattern?: string; - minLength?: number; - maxLength?: number; - minimum?: number; - maximum?: number; - exclusiveMinimum?: boolean; - exclusiveMaximum?: boolean; - format?: string; - multipleOf?: number; -} - -export interface ApiFileShape extends ApiAnyShape { - fileTypes?: string[]; - pattern?: string; - minLength?: number; - maxLength?: number; - minimum?: number; - maximum?: number; - exclusiveMinimum?: boolean; - exclusiveMaximum?: boolean; - format?: string; - multipleOf?: number; -} - -export interface ApiSchemaShape extends ApiAnyShape { - mediaType?: string; - raw?: string; -} - -export interface ApiUnionShape extends ApiAnyShape { - anyOf: ApiShapeUnion[]; -} - -export interface ApiDataArrangeShape extends ApiAnyShape { - minItems?: number; - maxItems?: number; - uniqueItems?: boolean; -} - -export interface ApiArrayShape extends ApiDataArrangeShape { - items?: ApiShapeUnion; -} - -export interface ApiTupleShape extends ApiDataArrangeShape { - items: ApiShapeUnion[]; - additionalItems?: boolean; -} - -export interface ApiRecursiveShape extends ApiShape { - fixPoint: string; -} - -export interface ApiDataNode extends ApiDomainProperty { - name?: string; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiObjectNode extends ApiDataNode { - properties: { [key: string]: ApiDataNodeUnion }; -} - -export interface ApiScalarNode extends ApiDataNode { - value?: string; - dataType?: string; -} - -export interface ApiArrayNode extends ApiDataNode { - members: ApiDataNodeUnion[]; -} - -export type ApiDataNodeUnion = ApiDataNode | ApiObjectNode | ApiScalarNode | ApiArrayNode; - -export interface ApiEncoding { - propertyName?: string; - contentType?: string; - style?: string; - explode?: boolean; - allowReserved?: boolean; - headers: ApiParameter[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiDocumentSourceMaps { - id?: string; - types?: string[]; - synthesizedField?: ApiSynthesizedField[]; - lexical?: ApiSynthesizedField[]; - trackedElement?: ApiSynthesizedField; - autoGeneratedName?: ApiSynthesizedField[]; - parsedJsonSchema?: ApiSynthesizedField; - declaredElement?: ApiSynthesizedField; -} - -export interface ApiSynthesizedField { - id: string; - element?: string; - value: string; -} - -export interface ApiParametrizedDeclaration extends ApiDomainProperty { - name?: string; - target?: ApiAbstractDeclaration; - variables: ApiVariableValue[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiVariableValue extends ApiDomainProperty { - name: string; - value?: ApiDataNode; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiAbstractDeclaration extends ApiDomainProperty { - name: string; - description?: string; - dataNode?: ApiDataNode; - variables: string[]; - sourceMaps?: ApiDocumentSourceMaps; -} - -export interface ApiParametrizedTrait extends ApiParametrizedDeclaration {} -export interface ApiParametrizedResourceType extends ApiParametrizedDeclaration {} - -export interface ShapeProcessingOptions { - /** - * This is set when serializing a shape / parameter. - * It is used to determine which example of the schema to include. - * - * When an example has the `tracked-element` in the source maps then this - * is used to determine the only examples included to the schema. - * - * Note, the value of the tracked-element can be a list of IDs separated by coma. - */ - trackedId?: string; -} diff --git a/src/index.ts b/src/index.ts index 9a82ea8..96301e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,15 +27,6 @@ export * as UrlLib from './lib/UrlUtils.js'; export * as Utils from './lib/Utils.js'; export { SecurityProcessor } from './lib/SecurityProcessor.js'; export * from './types.js' -export { AmfHelperMixin } from './helpers/AmfHelperMixin.js'; -export { AmfSerializer } from './helpers/AmfSerializer.js'; -export { ns } from './helpers/Namespace.js'; -export * as Amf from './helpers/amf.js'; -export * as Api from './helpers/api.js'; -export { ApiExampleGenerator } from './schema/ApiExampleGenerator.js'; -export { ApiMonacoSchemaGenerator } from './schema/ApiMonacoSchemaGenerator.js'; -export { ApiSchemaValues } from './schema/ApiSchemaValues.js'; -export { ApiSchemaGenerator } from './schema/ApiSchemaGenerator.js'; export { EventTypes as ApiEventTypes } from './events/EventTypes.js'; export { Events as ApiEvents } from './events/Events.js'; export { ApiNavigationEventDetail } from './events/NavigationEvents.js'; diff --git a/src/lib/AmfInputParser.ts b/src/lib/AmfInputParser.ts index c183d90..c7b304a 100644 --- a/src/lib/AmfInputParser.ts +++ b/src/lib/AmfInputParser.ts @@ -2,9 +2,7 @@ /* eslint-disable no-continue */ /* eslint-disable no-param-reassign */ /* eslint-disable class-methods-use-this */ -import { ApiSchemaValues } from '../schema/ApiSchemaValues.js'; -import { ns } from '../helpers/Namespace.js'; -import { ApiArrayShape, ApiParameter, ApiScalarShape, ApiShapeUnion, ApiUnionShape } from '../helpers/api.js'; +import { ApiSchemaValues, AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; export interface ParametersSerializationReport { valid: boolean; @@ -35,7 +33,7 @@ export class AmfInputParser { * @param nillable The list of parameter ids that are marked as nil values. * @param defaultNil The nil value to insert when the parameter is in the nillable list. */ - static reportRequestInputs(parameters: ApiParameter[], values: Map, nillable: string[]=[], defaultNil: any=null): ParametersSerializationReport { + static reportRequestInputs(parameters: ApiDefinitions.IApiParameter[], values: Map, nillable: string[]=[], defaultNil: any=null): ParametersSerializationReport { const report: ParametersSerializationReport = { valid: true, invalid: [], @@ -65,8 +63,8 @@ export class AmfInputParser { return; } if (jsType === 'undefined') { - if (schema && schema.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - value = ApiSchemaValues.readInputValue(param, schema as ApiScalarShape); + if (schema && schema.types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)) { + value = ApiSchemaValues.readInputValue(param, schema as AmfShapes.IApiScalarShape); } } if (!schema) { @@ -99,16 +97,16 @@ export class AmfInputParser { * @param required Whether the parameter is required. * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportItem(reportGroup: Record, name: string, schema: ApiShapeUnion, value: any, required?: boolean): boolean { + static addReportItem(reportGroup: Record, name: string, schema: AmfShapes.IShapeUnion, value: any, required?: boolean): boolean { const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return AmfInputParser.addReportScalarItem(reportGroup, name, value, (schema as ApiScalarShape), required); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)) { + return AmfInputParser.addReportScalarItem(reportGroup, name, value, (schema as AmfShapes.IApiScalarShape), required); } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return AmfInputParser.addReportArrayItem(reportGroup, name, value, (schema as ApiArrayShape), required); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.ArrayShape) || types.includes(AmfNamespace.aml.vocabularies.shapes.MatrixShape)) { + return AmfInputParser.addReportArrayItem(reportGroup, name, value, (schema as AmfShapes.IApiArrayShape), required); } - if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return AmfInputParser.addReportUnionItem(reportGroup, name, value, (schema as ApiUnionShape), required); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.UnionShape)) { + return AmfInputParser.addReportUnionItem(reportGroup, name, value, (schema as AmfShapes.IApiUnionShape), required); } // ignored parameters are valid (from the form POV). return true; @@ -118,7 +116,7 @@ export class AmfInputParser { * @param required Whether the parameter is required. * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportScalarItem(reportGroup: Record, name: string, value: any, schema: ApiScalarShape, required?: boolean): boolean { + static addReportScalarItem(reportGroup: Record, name: string, value: any, schema: AmfShapes.IApiScalarShape, required?: boolean): boolean { const type = typeof value; const isScalar = type !== 'undefined' && type !== 'object' && value !== null; reportGroup[name] = isScalar ? ApiSchemaValues.parseScalarInput(value, schema) : value; @@ -133,7 +131,7 @@ export class AmfInputParser { * @param required Whether the parameter is required. * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportArrayItem(reportGroup: Record, name: string, value: any, schema: ApiArrayShape, required?: boolean): boolean { + static addReportArrayItem(reportGroup: Record, name: string, value: any, schema: AmfShapes.IApiArrayShape, required?: boolean): boolean { if (!Array.isArray(reportGroup[name])) { reportGroup[name] = []; } @@ -171,22 +169,22 @@ export class AmfInputParser { * @param required Whether the parameter is required. * @returns `true` when the parameter is valid and `false` otherwise. */ - static addReportUnionItem(reportGroup: Record, name: string, value: any, schema: ApiUnionShape, required?: boolean): boolean { + static addReportUnionItem(reportGroup: Record, name: string, value: any, schema: AmfShapes.IApiUnionShape, required?: boolean): boolean { const { anyOf } = schema; if (!anyOf || !anyOf.length) { return !required; } - const nil = anyOf.find(shape => shape.types.includes(ns.aml.vocabularies.shapes.NilShape)); + const nil = anyOf.find(shape => shape.types.includes(AmfNamespace.aml.vocabularies.shapes.NilShape)); if (nil && anyOf.length === 2) { // this item is not marked as nil (or we wouldn't get to this line) so use the only schema left. const scalar = anyOf.find(shape => shape !== nil); - return AmfInputParser.addReportScalarItem(reportGroup, name, value, scalar as ApiScalarShape); + return AmfInputParser.addReportScalarItem(reportGroup, name, value, scalar as AmfShapes.IApiScalarShape); } // we are iterating over each schema in the union. Ignoring non-scalar schemas it parses user input // for each schema and if the result is set (non-undefined) then this value is used. for (let i = 0, len = anyOf.length; i < len; i += 1) { const option = anyOf[i]; - if (!option.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { + if (!option.types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)) { continue; } const result = ApiSchemaValues.parseUserInput(value, option); diff --git a/src/lib/AmfParameterMixin.ts b/src/lib/AmfParameterMixin.ts index 3e21f1a..3339fed 100644 --- a/src/lib/AmfParameterMixin.ts +++ b/src/lib/AmfParameterMixin.ts @@ -15,16 +15,14 @@ import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import '@anypoint-web-components/awc/dist/define/anypoint-button.js'; import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; import '@anypoint-web-components/awc/dist/define/anypoint-switch.js'; -import { AnypointListboxElement, SupportedInputTypes, AnypointCheckboxElement, AnypointSwitchElement } from '@anypoint-web-components/awc'; +import { AnypointListboxElement, SupportedInputTypes, AnypointCheckboxElement } from '@anypoint-web-components/awc'; +import { ApiSchemaValues, AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; import '@advanced-rest-client/icons/arc-icon.js'; import { ifDefined } from 'lit/directives/if-defined.js' import { classMap } from 'lit/directives/class-map.js'; -import { ApiSchemaValues } from '../schema/ApiSchemaValues.js'; -import { ns } from '../helpers/Namespace.js'; import * as InputCache from './InputCache.js'; import { readLabelValue } from './Utils.js'; import { OperationParameter, ShapeTemplateOptions, ParameterRenderOptions } from '../types.js'; -import { ApiAnyShape, ApiArrayShape, ApiParameter, ApiScalarNode, ApiScalarShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../helpers/api.js'; type Constructor = new (...args: any[]) => T; @@ -83,7 +81,7 @@ export interface AmfParameterMixinInterface { * @param isArray Whether the value should be read for an array. * @returns The value to set on the input. Note, it is not cast to the type. */ - readInputValue(parameter: ApiParameter, schema: ApiScalarShape, isArray?: boolean): any; + readInputValue(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, isArray?: boolean): any; paramChangeHandler(e: Event): void; booleanHandler(e: Event): void; /** @@ -103,20 +101,20 @@ export interface AmfParameterMixinInterface { /** * @returns The template for the request parameter form control. */ - parameterSchemaTemplate(parameter: ApiParameter, schema: ApiShapeUnion, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; + parameterSchemaTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IShapeUnion, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; /** * @returns The template for the schema parameter. */ - scalarShapeTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; + scalarShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult | string; /** * @return A template for an input form item for the given type and schema */ - textInputTemplate(parameter: ApiParameter, schema: ApiScalarShape, type?: SupportedInputTypes, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; + textInputTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, type?: SupportedInputTypes, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; /** - * @param paramId The ApiParameter id. + * @param paramId The ApiDefinitions.IApiParameter id. * @param arrayIndex When this is an array item, the index on the array. * @returns The template for the param remove button. */ @@ -125,17 +123,17 @@ export interface AmfParameterMixinInterface { /** * @returns The template for the enum input. */ - enumTemplate(parameter: ApiParameter, schema: ApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; + enumTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, userOpts?: ParameterRenderOptions, opts?: ShapeTemplateOptions): TemplateResult; /** * @returns The template for the checkbox input. */ - booleanTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts?: ShapeTemplateOptions): TemplateResult; + booleanTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, opts?: ShapeTemplateOptions): TemplateResult; /** * @returns The template for the nil checkbox input. */ - nillInputTemplate(parameter: ApiParameter): TemplateResult; + nillInputTemplate(parameter: ApiDefinitions.IApiParameter): TemplateResult; /** * or now we do not support union shapes. There's no way to learn how to serialize @@ -147,7 +145,7 @@ export interface AmfParameterMixinInterface { /** * @returns The template for the union shape. */ - unionShapeTemplate(parameter: ApiParameter, schema: ApiUnionShape): TemplateResult | string; + unionShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiUnionShape): TemplateResult | string; /** * This situation makes not sense as there's no mechanism to describe how to @@ -166,17 +164,17 @@ export interface AmfParameterMixinInterface { /** * @returns The template for the array shape. */ - arrayShapeTemplate(parameter: ApiParameter, schema: ApiArrayShape): TemplateResult | string; + arrayShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiArrayShape): TemplateResult | string; /** * @returns The template for the tuple shape. */ - tupleShapeTemplate(parameter: ApiParameter, schema: ApiTupleShape): TemplateResult | string; + tupleShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiTupleShape): TemplateResult | string; /** * @returns The template for the Any shape. */ - anyShapeTemplate(parameter: ApiParameter, schema: ApiAnyShape): TemplateResult | string; + anyShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiAnyShape): TemplateResult | string; /** * @param {string} id The id of the parameter to add the value to. @@ -195,8 +193,6 @@ export interface AmfParameterMixinInterface { * @mixin */ export const AmfParameterMixin = dedupeMixin(>(superClass: T): Constructor & T => { - - class AmfParameterMixinClass extends superClass { parametersValue: OperationParameter[]; @@ -259,7 +255,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC * @param isArray Whether the value should be read for an array. * @returns The value to set on the input. Note, it is not cast to the type. */ - readInputValue(parameter: ApiParameter, schema: ApiScalarShape, isArray=false): any { + readInputValue(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, isArray=false): any { const { id } = parameter; if (InputCache.has(this.target, id, this.globalCache)) { return InputCache.get(this.target, id, this.globalCache); @@ -291,7 +287,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC return; } // sets cached value of the input. - const typed = ApiSchemaValues.parseUserInput(value, param.schema as ApiShapeUnion); + const typed = ApiSchemaValues.parseUserInput(value, param.schema as AmfShapes.IShapeUnion); InputCache.set(this.target, domainId, typed, this.globalCache, isArray === 'true', index ? Number(index) : undefined); this.notifyChange(); this.paramChanged(domainId); @@ -351,9 +347,9 @@ export const AmfParameterMixin = dedupeMixin(>(superC if (!param) { return; } - const enumValues = ((param.schema as ApiShapeUnion).values as ApiScalarNode[]); + const enumValues = ((param.schema as AmfShapes.IShapeUnion).values as AmfShapes.IApiScalarNode[]); const { value } = enumValues[list.selected as number]; - const typed = ApiSchemaValues.parseUserInput(value, param.schema as ApiShapeUnion); + const typed = ApiSchemaValues.parseUserInput(value, param.schema as AmfShapes.IShapeUnion); InputCache.set(this.target, domainId, typed, this.globalCache, isArray === 'true', index ? Number(index) : undefined); this.notifyChange(); this.paramChanged(domainId); @@ -405,30 +401,30 @@ export const AmfParameterMixin = dedupeMixin(>(superC * @param opts Internal Process options * @returns The template for the request parameter form control. */ - parameterSchemaTemplate(parameter: ApiParameter, schema: ApiShapeUnion, opts: ShapeTemplateOptions={}): TemplateResult | string { + parameterSchemaTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IShapeUnion, opts: ShapeTemplateOptions={}): TemplateResult | string { const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this.scalarShapeTemplate(parameter, schema as ApiScalarShape, opts); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)) { + return this.scalarShapeTemplate(parameter, schema as AmfShapes.IApiScalarShape, opts); } - if (types.includes(ns.w3.shacl.NodeShape)) { + if (types.includes(AmfNamespace.w3.shacl.NodeShape)) { return this.nodeShapeTemplate(); } - if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this.unionShapeTemplate(parameter, schema as ApiUnionShape); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.UnionShape)) { + return this.unionShapeTemplate(parameter, schema as AmfShapes.IApiUnionShape); } - if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { + if (types.includes(AmfNamespace.aml.vocabularies.shapes.FileShape)) { return this.fileShapeTemplate(); } - if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) { + if (types.includes(AmfNamespace.aml.vocabularies.shapes.SchemaShape)) { return this.schemaShapeTemplate(); } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this.arrayShapeTemplate(parameter, schema as ApiArrayShape); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.ArrayShape) || types.includes(AmfNamespace.aml.vocabularies.shapes.MatrixShape)) { + return this.arrayShapeTemplate(parameter, schema as AmfShapes.IApiArrayShape); } - if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this.tupleShapeTemplate(parameter, schema as ApiTupleShape); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.TupleShape)) { + return this.tupleShapeTemplate(parameter, schema as AmfShapes.IApiTupleShape); } - return this.anyShapeTemplate(parameter, schema as ApiAnyShape); + return this.anyShapeTemplate(parameter, schema as AmfShapes.IApiAnyShape); } /** @@ -437,7 +433,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC * @param opts * @returns The template for the schema parameter. */ - scalarShapeTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { + scalarShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { const { readOnly, values, dataType='text' } = schema; if (readOnly) { return ''; @@ -456,11 +452,11 @@ export const AmfParameterMixin = dedupeMixin(>(superC * Corrects the `http://www.w3.org/2001/XMLSchema#dateTime` schema with the `date-time` or `rfc3339` formats * to remove the last `.ZZZ` part which is not recognizable by the `` element. */ - [correctDateTimeParameter](schema: ApiScalarShape, value: any): any { + [correctDateTimeParameter](schema: AmfShapes.IApiScalarShape, value: any): any { if (!value) { return value; } - if (schema.dataType === ns.w3.xmlSchema.dateTime) { + if (schema.dataType === AmfNamespace.w3.xmlSchema.dateTime) { if (['date-time', 'rfc3339'].includes(schema.format || '')) { return String(value).replace(/(\.\d\d\d)Z/, '$1'); } @@ -475,7 +471,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC * @param opts * @returns A template for an input form item for the given type and schema */ - textInputTemplate(parameter: ApiParameter, schema: ApiScalarShape, type?: SupportedInputTypes, opts: ShapeTemplateOptions={}): TemplateResult { + textInputTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, type?: SupportedInputTypes, opts: ShapeTemplateOptions={}): TemplateResult { const { id, binding, } = parameter; const { pattern, minimum, minLength, maxLength, maximum, multipleOf } = schema; let required = false; @@ -543,7 +539,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC } /** - * @param paramId The ApiParameter id. + * @param paramId The ApiDefinitions.IApiParameter id. * @param arrayIndex When this is an array item, the index on the array. * @returns The template for the param remove button. */ @@ -570,7 +566,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC * @param opts * @returns The template for the enum input. */ - enumTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { + enumTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { const { anypoint } = this; let required = false; if (typeof opts.required === 'boolean') { @@ -579,7 +575,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC required = parameter.required || false; } const label = readLabelValue(parameter, schema); - const enumValues = (schema.values || []) as ApiScalarNode[]; + const enumValues = (schema.values || []) as AmfShapes.IApiScalarNode[]; const selectedValue = this.readInputValue(parameter, schema); const selected = enumValues.findIndex(i => i.value === selectedValue); const { id, binding } = parameter; @@ -625,12 +621,12 @@ export const AmfParameterMixin = dedupeMixin(>(superC /** * @returns The template for the checkbox input. */ - booleanTemplate(parameter: ApiParameter, schema: ApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { + booleanTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiScalarShape, opts: ShapeTemplateOptions={}): TemplateResult | string { const label = readLabelValue(parameter, schema); const { id } = parameter; let value: boolean; if (opts.arrayItem) { - value = opts.value || ''; + value = opts.value as boolean || false; } else { value = this.readInputValue(parameter, schema); } @@ -666,7 +662,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC /** * @returns The template for the nil checkbox input. */ - nillInputTemplate(parameter: ApiParameter): TemplateResult | string { + nillInputTemplate(parameter: ApiDefinitions.IApiParameter): TemplateResult | string { return html` >(superC /** * @returns The template for the union shape. */ - unionShapeTemplate(parameter: ApiParameter, schema: ApiUnionShape): TemplateResult | string { + unionShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiUnionShape): TemplateResult | string { const { anyOf } = schema; if (!anyOf || !anyOf.length) { return ''; } - const nil = anyOf.find(shape => shape.types.includes(ns.aml.vocabularies.shapes.NilShape)); + const nil = anyOf.find(shape => shape.types.includes(AmfNamespace.aml.vocabularies.shapes.NilShape)); if (nil && anyOf.length === 2) { // this is a case where a scalar is marked as nillable instead of not required // (which for some reason is a common practice among RAML developers). - const scalar = anyOf.find(shape => shape !== nil) as ApiShapeUnion; + const scalar = anyOf.find(shape => shape !== nil) as AmfShapes.IShapeUnion; return this.parameterSchemaTemplate(parameter, scalar, { nillable: true, }); } - const hasComplex = anyOf.some(i => !i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)); - const hasScalar = anyOf.some(i => i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)); + const hasComplex = anyOf.some(i => !i.types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)); + const hasScalar = anyOf.some(i => i.types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)); if (hasComplex && !hasScalar) { // We quit here as this is the same problem as with the Node shape - unclear how to serialize the types return ''; @@ -741,7 +737,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC /** * @returns The template for the array shape. */ - arrayShapeTemplate(parameter: ApiParameter, schema: ApiArrayShape): TemplateResult | string { + arrayShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiArrayShape): TemplateResult | string { const { items } = schema; if (!items) { return ''; @@ -768,7 +764,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC /** * @returns The template for the tuple shape. */ - tupleShapeTemplate(parameter: ApiParameter, schema: ApiTupleShape): TemplateResult | string { + tupleShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiTupleShape): TemplateResult | string { const { items } = schema; if (!items) { return ''; @@ -780,7 +776,7 @@ export const AmfParameterMixin = dedupeMixin(>(superC /** * @returns The template for the Any shape. */ - anyShapeTemplate(parameter: ApiParameter, schema: ApiAnyShape): TemplateResult | string { + anyShapeTemplate(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IApiAnyShape): TemplateResult | string { return this.textInputTemplate(parameter, schema, 'text'); } diff --git a/src/lib/Oauth2RamlCustomData.ts b/src/lib/Oauth2RamlCustomData.ts index bd384cf..bfa96f7 100644 --- a/src/lib/Oauth2RamlCustomData.ts +++ b/src/lib/Oauth2RamlCustomData.ts @@ -1,6 +1,5 @@ /* eslint-disable class-methods-use-this */ -import { ApiArrayShape, ApiDataNodeUnion, ApiObjectNode, ApiParameter, ApiScalarNode, ApiScalarShape, ApiShape, ApiShapeUnion } from '../helpers/api.js'; -import { ns } from '../helpers/Namespace.js'; +import { AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; /** * Computes a data model for custom definition for the OAuth 2 scheme @@ -8,15 +7,15 @@ import { ns } from '../helpers/Namespace.js'; * https://github.com/raml-org/raml-annotations/tree/master/annotations/security-schemes */ export class Oauth2RamlCustomData { - readParams(properties: {[key: string]: ApiDataNodeUnion}): ApiParameter[] { - const result: ApiParameter[] = []; + readParams(properties: {[key: string]: AmfShapes.IApiDataNodeUnion}): ApiDefinitions.IApiParameter[] { + const result: ApiDefinitions.IApiParameter[] = []; Object.keys(properties).forEach((key) => { const definition = properties[key]; - if (definition.types.includes(ns.aml.vocabularies.data.Object)) { - const property = this.getProperty((definition as ApiObjectNode)); + if (definition.types.includes(AmfNamespace.aml.vocabularies.data.Object)) { + const property = this.getProperty((definition as AmfShapes.IApiObjectNode)); result.push(property); - } else if (definition.types.includes(ns.aml.vocabularies.data.Scalar)) { - const property = this.getPropertyScalar((definition as ApiScalarNode)); + } else if (definition.types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) { + const property = this.getPropertyScalar((definition as AmfShapes.IApiScalarNode)); result.push(property); } }); @@ -24,17 +23,17 @@ export class Oauth2RamlCustomData { } /** - * Creates an ApiParameter for an annotation that has properties. + * Creates an ApiDefinitions.IApiParameter for an annotation that has properties. * This expects the properties to be defined like RAML's type definition. */ - getProperty(definition: ApiObjectNode): ApiParameter { + getProperty(definition: AmfShapes.IApiObjectNode): ApiDefinitions.IApiParameter { const { properties={}, id, name } = definition; - const result: ApiParameter = { + const result: ApiDefinitions.IApiParameter = { id, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], customDomainProperties: [], }; const schema = this.readSchema(definition); @@ -42,28 +41,28 @@ export class Oauth2RamlCustomData { result.schema = schema; } if (properties.required) { - const req = properties.required as ApiScalarNode; + const req = properties.required as AmfShapes.IApiScalarNode; result.required = req.value === 'true'; } return result; } /** - * Creates an ApiParameter for an annotation that has no properties but rather a simplified + * Creates an ApiDefinitions.IApiParameter for an annotation that has no properties but rather a simplified * notation of `propertyName: dataType`. */ - getPropertyScalar(definition: ApiScalarNode): ApiParameter { + getPropertyScalar(definition: AmfShapes.IApiScalarNode): ApiDefinitions.IApiParameter { const { dataType = '', id, name } = definition; - const result: ApiParameter = { + const result: ApiDefinitions.IApiParameter = { id, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], customDomainProperties: [], }; - const schema = this.createSchema() as ApiScalarShape; - schema.types = [ns.aml.vocabularies.shapes.ScalarShape]; + const schema = this.createSchema() as AmfShapes.IApiScalarShape; + schema.types = [AmfNamespace.aml.vocabularies.shapes.ScalarShape]; schema.id = id; schema.name = name; schema.dataType = this.typeToSchemaType(dataType); @@ -71,15 +70,15 @@ export class Oauth2RamlCustomData { return result; } - readSchema(property: ApiObjectNode): ApiShapeUnion | undefined { + readSchema(property: AmfShapes.IApiObjectNode): AmfShapes.IShapeUnion | undefined { const { properties={}, name, id } = property; // const { example, examples, } = properties; - const isArray = this.readIsSchemaArray((properties.type as ApiScalarNode), (properties.items as ApiScalarNode)); - const type = this.readSchemaType((properties.type as ApiScalarNode), (properties.items as ApiScalarNode)); - let schema: ApiShapeUnion | undefined; + const isArray = this.readIsSchemaArray((properties.type as AmfShapes.IApiScalarNode), (properties.items as AmfShapes.IApiScalarNode)); + const type = this.readSchemaType((properties.type as AmfShapes.IApiScalarNode), (properties.items as AmfShapes.IApiScalarNode)); + let schema: AmfShapes.IShapeUnion | undefined; if (isArray) { - const s = this.createSchema() as ApiArrayShape; - s.types = [ns.aml.vocabularies.shapes.ArrayShape]; + const s = this.createSchema() as AmfShapes.IApiArrayShape; + s.types = [AmfNamespace.aml.vocabularies.shapes.ArrayShape]; s.id = id; s.name = name; s.items = this.createTypedSchema(type, property); @@ -90,7 +89,7 @@ export class Oauth2RamlCustomData { return schema; } - createTypedSchema(type: string, object: ApiObjectNode): ApiShapeUnion | undefined { + createTypedSchema(type: string, object: AmfShapes.IApiObjectNode): AmfShapes.IShapeUnion | undefined { switch (type) { case 'string': case 'number': @@ -108,7 +107,7 @@ export class Oauth2RamlCustomData { } } - createSchema(): ApiShape { + createSchema(): AmfShapes.IApiShape { return { id: '', types: [], @@ -122,64 +121,64 @@ export class Oauth2RamlCustomData { }; } - createScalarSchema(object: ApiObjectNode, type: string): ApiScalarShape { + createScalarSchema(object: AmfShapes.IApiObjectNode, type: string): AmfShapes.IApiScalarShape { const { properties={}, name, id } = object; - const schema = this.createSchema() as ApiScalarShape; - schema.types = [ns.aml.vocabularies.shapes.ScalarShape]; + const schema = this.createSchema() as AmfShapes.IApiScalarShape; + schema.types = [AmfNamespace.aml.vocabularies.shapes.ScalarShape]; schema.id = id; schema.name = name; schema.dataType = this.typeToSchemaType(type); if (properties.format) { - const item = properties.format as ApiScalarNode; + const item = properties.format as AmfShapes.IApiScalarNode; schema.format = item.value; } if (properties.default) { - const item = properties.default as ApiScalarNode; + const item = properties.default as AmfShapes.IApiScalarNode; schema.defaultValueStr = item.value; // schema.defaultValue = item.value; } if (properties.description) { - const item = (properties.description as ApiScalarNode); + const item = (properties.description as AmfShapes.IApiScalarNode); schema.description = item.value; } if (properties.displayName) { - const item = (properties.displayName as ApiScalarNode); + const item = (properties.displayName as AmfShapes.IApiScalarNode); schema.displayName = item.value; } if (properties.pattern) { - const item = (properties.pattern as ApiScalarNode); + const item = (properties.pattern as AmfShapes.IApiScalarNode); schema.pattern = item.value; } if (properties.maximum) { - const item = (properties.maximum as ApiScalarNode); + const item = (properties.maximum as AmfShapes.IApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.maximum = value; } } if (properties.minimum) { - const item = (properties.minimum as ApiScalarNode); + const item = (properties.minimum as AmfShapes.IApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.minimum = value; } } if (properties.multipleOf) { - const item = (properties.multipleOf as ApiScalarNode); + const item = (properties.multipleOf as AmfShapes.IApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.multipleOf = value; } } if (properties.maxLength) { - const item = (properties.maxLength as ApiScalarNode); + const item = (properties.maxLength as AmfShapes.IApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.maxLength = value; } } if (properties.minLength) { - const item = (properties.minLength as ApiScalarNode); + const item = (properties.minLength as AmfShapes.IApiScalarNode); const value = Number(item.value); if (!Number.isNaN(value)) { schema.minLength = value; @@ -192,9 +191,9 @@ export class Oauth2RamlCustomData { * @param object * @param items The definition of the `items` property that corresponds to RAML's items property of an array */ - readSchemaType(object: ApiScalarNode, items?: ApiScalarNode): string { - if (object.dataType !== ns.w3.xmlSchema.string) { - return ns.w3.xmlSchema.string; + readSchemaType(object: AmfShapes.IApiScalarNode, items?: AmfShapes.IApiScalarNode): string { + if (object.dataType !== AmfNamespace.w3.xmlSchema.string) { + return AmfNamespace.w3.xmlSchema.string; } let inputType = object.value || ''; if (inputType.endsWith('[]')) { @@ -209,17 +208,17 @@ export class Oauth2RamlCustomData { typeToSchemaType(type: string): string { switch (type) { - case 'boolean': return ns.w3.xmlSchema.boolean; - case 'number': return ns.w3.xmlSchema.number; - case 'integer': return ns.w3.xmlSchema.integer; - case 'float': return ns.w3.xmlSchema.float; - case 'double': return ns.w3.xmlSchema.double; - case 'long': return ns.w3.xmlSchema.long; - case 'date-only': return ns.w3.xmlSchema.date; - case 'date-time': return ns.w3.xmlSchema.dateTime; - case 'time-only': return ns.w3.xmlSchema.time; - case 'nil': return ns.w3.xmlSchema.nil; - default: return ns.w3.xmlSchema.string; + case 'boolean': return AmfNamespace.w3.xmlSchema.boolean; + case 'number': return AmfNamespace.w3.xmlSchema.number; + case 'integer': return AmfNamespace.w3.xmlSchema.integer; + case 'float': return AmfNamespace.w3.xmlSchema.float; + case 'double': return AmfNamespace.w3.xmlSchema.double; + case 'long': return AmfNamespace.w3.xmlSchema.long; + case 'date-only': return AmfNamespace.w3.xmlSchema.date; + case 'date-time': return AmfNamespace.w3.xmlSchema.dateTime; + case 'time-only': return AmfNamespace.w3.xmlSchema.time; + case 'nil': return AmfNamespace.w3.xmlSchema.nil; + default: return AmfNamespace.w3.xmlSchema.string; } } @@ -229,7 +228,7 @@ export class Oauth2RamlCustomData { * @param items The definition of the `items` property that corresponds to RAML's items property of an array * @returns True when the schema is an array. */ - readIsSchemaArray(type: ApiScalarNode, items: ApiScalarNode): boolean { + readIsSchemaArray(type: AmfShapes.IApiScalarNode, items: AmfShapes.IApiScalarNode): boolean { if (!type && items) { return true; } diff --git a/src/lib/PayloadUtils.ts b/src/lib/PayloadUtils.ts index e8dab72..bfcc750 100644 --- a/src/lib/PayloadUtils.ts +++ b/src/lib/PayloadUtils.ts @@ -1,11 +1,8 @@ -import { ApiType } from '@advanced-rest-client/events/src/models/ApiTypes.js'; -import { ApiAnyShape, ApiPayload } from '../helpers/api.js'; -import { ApiExampleGenerator } from '../schema/ApiExampleGenerator.js'; -import { ApiMonacoSchemaGenerator } from '../schema/ApiMonacoSchemaGenerator.js'; -import { ApiSchemaGenerator } from '../schema/ApiSchemaGenerator.js'; +import { ApiDefinitions, AmfShapes, ApiExampleGenerator, ApiMonacoSchemaGenerator, ApiSchemaGenerator } from '@api-client/core/build/browser.js'; +import { ApiType } from '@api-client/core/build/legacy.js'; export interface PayloadInfo { - value: string|FormData|Blob; + value: string | FormData | Blob; model?: ApiType[]; schemas?: any; } @@ -17,11 +14,11 @@ export interface PayloadInfo { const cache: Map = new Map(); -export function getPayloadValue(payload: ApiPayload): PayloadInfo { +export function getPayloadValue(payload: ApiDefinitions.IApiPayload): PayloadInfo { if (cache.has(payload.id)) { return cache.get(payload.id) as PayloadInfo; } - const { id, mediaType='text/plain', schema } = payload; + const { id, mediaType = 'text/plain', schema } = payload; if (mediaType === 'multipart/form-data') { // schema generators don't support this yet, @@ -34,12 +31,12 @@ export function getPayloadValue(payload: ApiPayload): PayloadInfo { cache.set(id, info); return info; } - + const schemaFactory = new ApiMonacoSchemaGenerator(); const monacoSchemes = schemaFactory.generate(schema, id); let { examples } = payload; if (!Array.isArray(examples) || !examples.length) { - examples = (schema as ApiAnyShape).examples; + examples = (schema as AmfShapes.IApiAnyShape).examples; } if (Array.isArray(examples) && examples.length) { const [example] = examples; @@ -61,7 +58,7 @@ export function getPayloadValue(payload: ApiPayload): PayloadInfo { cache.set(id, info); return info; } - const info = { value: result.renderValue, schemas: monacoSchemes }; + const info = { value: result.renderValue, schemas: monacoSchemes } as PayloadInfo; cache.set(id, info); return info; } diff --git a/src/lib/QueryParameterProcessor.ts b/src/lib/QueryParameterProcessor.ts index 8aaeddc..d87eb07 100644 --- a/src/lib/QueryParameterProcessor.ts +++ b/src/lib/QueryParameterProcessor.ts @@ -1,17 +1,7 @@ /* eslint-disable class-methods-use-this */ -import { ApiArrayShape, ApiNodeShape, ApiParameter, ApiPropertyShape, ApiScalarShape, ApiShapeUnion, ApiUnionShape } from '../helpers/api.js'; -import { ns } from '../helpers/Namespace.js'; +import { AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; import { OperationParameter } from '../types.js'; -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../types').OperationParameter} OperationParameter */ - /** * A library to create a list of ApiParameters from a query string value. */ @@ -21,26 +11,26 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - collectOperationParameters(schema: ApiShapeUnion, binding: string, source?: string): OperationParameter[] { + collectOperationParameters(schema: AmfShapes.IShapeUnion, binding: string, source?: string): OperationParameter[] { let result: OperationParameter[] = []; if (!schema) { return result; } const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - result.push(this.scalarShapeOperationParameter((schema as ApiScalarShape), binding, source)); - } else if (types.includes(ns.w3.shacl.NodeShape)) { - const params = this.nodeShapeOperationParameter((schema as ApiNodeShape), binding, source); + if (types.includes(AmfNamespace.aml.vocabularies.shapes.ScalarShape)) { + result.push(this.scalarShapeOperationParameter((schema as AmfShapes.IApiScalarShape), binding, source)); + } else if (types.includes(AmfNamespace.w3.shacl.NodeShape)) { + const params = this.nodeShapeOperationParameter((schema as AmfShapes.IApiNodeShape), binding, source); result = result.concat(params); - } else if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) { - const arrResult = this.arrayShapeOperationParameter((schema as ApiArrayShape), binding, source); + } else if (types.includes(AmfNamespace.aml.vocabularies.shapes.ArrayShape)) { + const arrResult = this.arrayShapeOperationParameter((schema as AmfShapes.IApiArrayShape), binding, source); if (Array.isArray(arrResult)) { result = result.concat(arrResult); } else if (arrResult) { result.push(arrResult); } - } else if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - const params = this.unionShapeOperationParameter((schema as ApiUnionShape), binding, source); + } else if (types.includes(AmfNamespace.aml.vocabularies.shapes.UnionShape)) { + const params = this.unionShapeOperationParameter((schema as AmfShapes.IApiUnionShape), binding, source); if (params) { result = result.concat(params); } @@ -53,16 +43,16 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - scalarShapeOperationParameter(shape: ApiScalarShape, binding: string, source?: string): OperationParameter { + scalarShapeOperationParameter(shape: AmfShapes.IApiScalarShape, binding: string, source?: string): OperationParameter { const { id, name } = shape; - const constructed: ApiParameter = { + const constructed: ApiDefinitions.IApiParameter = { id, binding, schema: shape, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: false, customDomainProperties: [], }; @@ -81,7 +71,7 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - nodeShapeOperationParameter(shape: ApiNodeShape, binding: string, source?: string): OperationParameter[] { + nodeShapeOperationParameter(shape: AmfShapes.IApiNodeShape, binding: string, source?: string): OperationParameter[] { const result: OperationParameter[] = []; const { properties=[] } = shape; if (!properties.length) { @@ -98,16 +88,16 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - parameterOperationParameter(property: ApiPropertyShape, binding: string, source?: string): OperationParameter { + parameterOperationParameter(property: AmfShapes.IApiPropertyShape, binding: string, source?: string): OperationParameter { const { id, range, name, minCount=0 } = property; - const constructed: ApiParameter = { + const constructed: ApiDefinitions.IApiParameter = { id, binding, schema: range, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: minCount > 0, customDomainProperties: [], }; @@ -126,21 +116,21 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - arrayShapeOperationParameter(shape: ApiArrayShape, binding: string, source?: string): OperationParameter|OperationParameter[] { + arrayShapeOperationParameter(shape: AmfShapes.IApiArrayShape, binding: string, source?: string): OperationParameter|OperationParameter[] { const target = shape.items || shape; - if (target.types.includes(ns.w3.shacl.NodeShape)) { - const typed = (shape.items as ApiNodeShape); + if (target.types.includes(AmfNamespace.w3.shacl.NodeShape)) { + const typed = (shape.items as AmfShapes.IApiNodeShape); return this.collectOperationParameters(typed, binding, source); } const { id, name, } = target; - const constructed: ApiParameter = { + const constructed: ApiDefinitions.IApiParameter = { id, binding, schema: shape, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: false, customDomainProperties: [], }; @@ -159,7 +149,7 @@ export class QueryParameterProcessor { * @param binding The parameter binding. * @param source Optional parameter source. */ - unionShapeOperationParameter(shape: ApiUnionShape, binding: string, source?: string): OperationParameter[]|undefined { + unionShapeOperationParameter(shape: AmfShapes.IApiUnionShape, binding: string, source?: string): OperationParameter[]|undefined { const { anyOf=[], or=[], and=[], xone=[] } = shape; if (and.length) { let result: OperationParameter[] = []; diff --git a/src/lib/SecurityProcessor.ts b/src/lib/SecurityProcessor.ts index d61a972..8e0b19c 100644 --- a/src/lib/SecurityProcessor.ts +++ b/src/lib/SecurityProcessor.ts @@ -1,5 +1,4 @@ -/* eslint-disable no-continue */ -import { ArcHeaders, UrlParser, AuthorizationUtils } from '@advanced-rest-client/base/api.js'; +import { Headers, UrlParser, AuthorizationUtils, ApiDefinitions } from '@api-client/core/build/browser.js'; import { BasicAuthorization, OidcAuthorization, OAuth2Authorization, BearerAuthorization, RamlCustomAuthorization, ApiKeyAuthorization, PassThroughAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; import { RequestAuthorization } from '@advanced-rest-client/events/src/request/ArcRequest.js'; import { @@ -7,7 +6,6 @@ import { METHOD_PASS_THROUGH, METHOD_API_KEY, } from '../elements/ApiAuthorizationMethodElement.js'; -import { ApiSecurityRequirement } from '../helpers/api.js'; import { ApiConsoleRequest, SecuritySelectorListItem } from '../types.js'; /** @@ -50,7 +48,7 @@ function applyHeaders(request: ApiConsoleRequest, headers?: Record { const value = headers[name]; parser.append(name, value); @@ -59,7 +57,7 @@ function applyHeaders(request: ApiConsoleRequest, headers?: Record readPropertyTypeLabel(i)); return items.join(' or '); } - if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { + if (types.includes(AmfNamespace.aml.vocabularies.shapes.FileShape)) { return 'File'; } return schema.name || 'Unknown'; @@ -119,7 +103,7 @@ export function readPropertyTypeLabel(schema: ApiShapeUnion, isArray=false): str * @param shapes * @returns true when all of passed shapes are scalar. */ -function isAllScalar(shapes: ApiShapeUnion[] = []): boolean { +function isAllScalar(shapes: AmfShapes.IShapeUnion[] = []): boolean { return !shapes.some(i => !isScalarType(i.types)); } @@ -127,7 +111,7 @@ function isAllScalar(shapes: ApiShapeUnion[] = []): boolean { * @param shape * @returns true when the passed union type consists of scalar values only. Nil counts as scalar. */ -export function isScalarUnion(shape: ApiUnionShape): boolean { +export function isScalarUnion(shape: AmfShapes.IApiUnionShape): boolean { const { anyOf=[], or=[], and=[], xone=[] } = shape; if (anyOf.length) { return isAllScalar(anyOf); @@ -155,11 +139,12 @@ export function sanitizeHTML(HTML: string): string { return result; } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return result.toString(); } -export function joinTraitNames(traits: ApiParametrizedDeclaration[]): string { +export function joinTraitNames(traits: ApiDefinitions.IApiParametrizedDeclaration[]): string { const names = traits.map(trait => trait.name).filter(i => !!i); let value = ''; if (names.length === 2) { @@ -174,7 +159,7 @@ export function joinTraitNames(traits: ApiParametrizedDeclaration[]): string { return value; } -export function generateHeaders(params: Record): string { +export function generateHeaders(params: Record): string { if (typeof params !== 'object') { return ''; } @@ -188,7 +173,7 @@ export function generateHeaders(params: Record): string { value = String(value); } let result = `${name}: `; - value = value.split('\n').join(' '); + value = (value as string).split('\n').join(' '); result += value; return result; }); @@ -204,12 +189,12 @@ export function ensureContentType(headers: string, mime: string): string { if (!mime) { return headers; } - const list = HeadersParser.toJSON(headers); - const current = HeadersParser.contentType(list); + const parsed = new Headers(headers); + const current = parsed.get('content-type'); if (!current && mime) { - list.push({ name: 'content-type', value: mime, enabled: true }); + parsed.set('content-type', mime); } - return HeadersParser.toString(list); + return parsed.toString(); } /** @@ -217,7 +202,7 @@ export function ensureContentType(headers: string, mime: string): string { * @param schema * @returns The name to use in the input. */ -export function readLabelValue(parameter: ApiParameter, schema: ApiShapeUnion): string { +export function readLabelValue(parameter: ApiDefinitions.IApiParameter, schema: AmfShapes.IShapeUnion): string { let label = parameter.paramName || schema.displayName || parameter.name || schema.name || ''; const { required } = parameter; if (required) { diff --git a/src/lib/auth-ui/ApiKeyAuth.ts b/src/lib/auth-ui/ApiKeyAuth.ts index 3e1cfb3..22f2575 100644 --- a/src/lib/auth-ui/ApiKeyAuth.ts +++ b/src/lib/auth-ui/ApiKeyAuth.ts @@ -1,10 +1,9 @@ /* eslint-disable class-methods-use-this */ import { html, TemplateResult } from 'lit'; +import { AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; import { ApiKeyAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; -import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; -import { ApiParameter, ApiSecurityApiKeySettings, ApiShapeUnion } from '../../helpers/api.js'; export default class ApiKeyAuth extends ApiUiBase { async initializeApiModel(): Promise { @@ -16,7 +15,7 @@ export default class ApiKeyAuth extends ApiUiBase { if (!security) { return; } - if (!security.types.includes(ns.aml.vocabularies.security.ParametrizedSecurityScheme)) { + if (!security.types.includes(AmfNamespace.aml.vocabularies.security.ParametrizedSecurityScheme)) { return; } const { scheme } = security; @@ -27,7 +26,7 @@ export default class ApiKeyAuth extends ApiUiBase { if (!type || !type.startsWith('Api Key')) { return; } - const config = scheme.settings as ApiSecurityApiKeySettings | undefined; + const config = scheme.settings as ApiDefinitions.IApiSecurityApiKeySettings | undefined; if (!config) { return; } @@ -39,10 +38,10 @@ export default class ApiKeyAuth extends ApiUiBase { params.push({ binding, paramId: id, - parameter: { ... (config as ApiParameter), binding }, + parameter: { ... (config as ApiDefinitions.IApiParameter), binding }, source: 'settings', schemaId: scheme.id, - schema: (scheme as unknown as ApiShapeUnion), + schema: (scheme as unknown as AmfShapes.IShapeUnion), }); await this.requestUpdate(); diff --git a/src/lib/auth-ui/ApiUiBase.ts b/src/lib/auth-ui/ApiUiBase.ts index fc3ad11..2983b80 100644 --- a/src/lib/auth-ui/ApiUiBase.ts +++ b/src/lib/auth-ui/ApiUiBase.ts @@ -1,27 +1,27 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable class-methods-use-this */ +import { ApiDefinitions } from '@api-client/core/build/browser.js'; import AuthUiBase from "@advanced-rest-client/base/src/elements/authorization/ui/AuthUiBase.js"; -import '@anypoint-web-components/awc/anypoint-dropdown-menu.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; -import '@anypoint-web-components/awc/anypoint-input.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-button.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dropdown-menu.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-input.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; import '@advanced-rest-client/icons/arc-icon.js'; import { AmfParameterMixin } from '../AmfParameterMixin.js'; -import { ApiParametrizedSecurityScheme } from "../../helpers/api.js"; const securityValue = Symbol("securityValue"); export default class ApiUiBase extends AmfParameterMixin(AuthUiBase) { - [securityValue]?: ApiParametrizedSecurityScheme; + [securityValue]?: ApiDefinitions.IApiParametrizedSecurityScheme; - get security(): ApiParametrizedSecurityScheme | undefined { + get security(): ApiDefinitions.IApiParametrizedSecurityScheme | undefined { return this[securityValue]; } - set security(value: ApiParametrizedSecurityScheme | undefined) { + set security(value: ApiDefinitions.IApiParametrizedSecurityScheme | undefined) { const old = this[securityValue]; if (old === value) { return; diff --git a/src/lib/auth-ui/CustomAuth.ts b/src/lib/auth-ui/CustomAuth.ts index 55a1ec1..850d1df 100644 --- a/src/lib/auth-ui/CustomAuth.ts +++ b/src/lib/auth-ui/CustomAuth.ts @@ -1,12 +1,11 @@ /* eslint-disable class-methods-use-this */ import { html, TemplateResult } from 'lit'; +import { AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; import '@advanced-rest-client/highlight/arc-marked.js'; import { RamlCustomAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; import { AuthUiInit } from '@advanced-rest-client/base/api.js'; -import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; -import { ApiNodeShape, ApiParameter, ApiPropertyShape, ApiShapeUnion } from '../../helpers/api.js'; import { OperationParameter } from '../../types.js'; export default class CustomAuth extends ApiUiBase { @@ -46,7 +45,7 @@ export default class CustomAuth extends ApiUiBase { if (!security) { return; } - if (!security.types.includes(ns.aml.vocabularies.security.ParametrizedSecurityScheme)) { + if (!security.types.includes(AmfNamespace.aml.vocabularies.security.ParametrizedSecurityScheme)) { return; } const { scheme } = security; @@ -88,7 +87,7 @@ export default class CustomAuth extends ApiUiBase { }); } if (!addedParameters && queryString) { - const shape = queryString as ApiNodeShape; + const shape = queryString as AmfShapes.IApiNodeShape; const { properties } = shape; const binding = 'query'; if (!properties) { @@ -105,16 +104,16 @@ export default class CustomAuth extends ApiUiBase { this.notifyChange(); } - createParameterFromSchema(shape: ApiShapeUnion, binding: string, source: string): OperationParameter { + createParameterFromSchema(shape: AmfShapes.IShapeUnion, binding: string, source: string): OperationParameter { const { id, name } = shape; - const constructed: ApiParameter = { + const constructed: ApiDefinitions.IApiParameter = { id, binding, schema: shape, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: false, customDomainProperties: [], }; @@ -128,16 +127,16 @@ export default class CustomAuth extends ApiUiBase { }; } - createParameterFromProperty(property: ApiPropertyShape, binding: string, source: string): OperationParameter { + createParameterFromProperty(property: AmfShapes.IApiPropertyShape, binding: string, source: string): OperationParameter { const { id, range, name, minCount=0 } = property; - const constructed: ApiParameter = { + const constructed: ApiDefinitions.IApiParameter = { id, binding, schema: range, name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: minCount > 0, customDomainProperties: [], }; @@ -147,7 +146,7 @@ export default class CustomAuth extends ApiUiBase { parameter: constructed, source, schemaId: property.id, - schema: property as ApiShapeUnion, + schema: property as AmfShapes.IShapeUnion, }; } diff --git a/src/lib/auth-ui/OAuth2Auth.ts b/src/lib/auth-ui/OAuth2Auth.ts index 34571f7..a9de5cb 100644 --- a/src/lib/auth-ui/OAuth2Auth.ts +++ b/src/lib/auth-ui/OAuth2Auth.ts @@ -4,29 +4,28 @@ /* eslint-disable class-methods-use-this */ import { html, TemplateResult } from 'lit'; import Oauth2, { oauth2GrantTypes } from '@advanced-rest-client/base/src/elements/authorization/ui/OAuth2.js' -import { OAuth2CustomParameter } from '@advanced-rest-client/oauth'; +import { AmfNamespace, ApiDefinitions, AmfShapes, IOAuth2CustomParameter } from '@api-client/core/build/browser.js'; +import { IApiCustomDomainProperty } from '@api-client/core/build/src/amf/definitions/Base.js'; import { OAuth2Authorization, OAuth2DeliveryMethod, Oauth2GrantType } from '@advanced-rest-client/events/src/authorization/Authorization.js'; -import { ns } from '../../helpers/Namespace.js'; import * as InputCache from '../InputCache.js'; import { AmfInputParser, BindingType } from '../AmfInputParser.js'; import { Oauth2RamlCustomData } from '../Oauth2RamlCustomData.js'; import { AmfParameterMixin } from '../AmfParameterMixin.js'; -import { ApiArrayNode, ApiCustomDomainProperty, ApiDataNodeUnion, ApiObjectNode, ApiParameter, ApiParametrizedSecurityScheme, ApiScalarNode, ApiSecurityOAuth2Flow, ApiSecurityOAuth2Settings, ApiSecurityScheme, ApiSecurityScope } from '../../helpers/api.js'; import { OperationParameter } from '../../types.js'; const securityValue = Symbol("securityValue"); const gtValue = Symbol("gtValue"); export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { - [securityValue]?: ApiParametrizedSecurityScheme; + [securityValue]?: ApiDefinitions.IApiParametrizedSecurityScheme; [gtValue]?: string; - get security(): ApiParametrizedSecurityScheme | undefined { + get security(): ApiDefinitions.IApiParametrizedSecurityScheme | undefined { return this[securityValue]; } - set security(value: ApiParametrizedSecurityScheme | undefined) { + set security(value: ApiDefinitions.IApiParametrizedSecurityScheme | undefined) { const old = this[securityValue]; if (old === value) { return; @@ -76,7 +75,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { return; } this.setupOAuthDeliveryMethod(scheme); - const config = scheme.settings as ApiSecurityOAuth2Settings; + const config = scheme.settings as ApiDefinitions.IApiSecurityOAuth2Settings; if (!config) { return; } @@ -115,7 +114,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { return result; } - setupOAuthDeliveryMethod(scheme?: ApiSecurityScheme): void { + setupOAuthDeliveryMethod(scheme?: ApiDefinitions.IApiSecurityScheme): void { const info = this.getOauth2DeliveryMethod(scheme); if (this.oauthDeliveryMethod !== info.method) { this.oauthDeliveryMethod = info.method as OAuth2DeliveryMethod; @@ -136,7 +135,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param info Security AMF model */ - getOauth2DeliveryMethod(info?: ApiSecurityScheme): { method: string, name: string } { + getOauth2DeliveryMethod(info?: ApiDefinitions.IApiSecurityScheme): { method: string, name: string } { const result = { method: 'header', name: 'authorization' @@ -237,7 +236,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param flows List of current flows loaded with the AMF model. * @returns True if current model should be treated as RAML's model. */ - isRamlFlow(flows: ApiSecurityOAuth2Flow[]): boolean { + isRamlFlow(flows: ApiDefinitions.IApiSecurityOAuth2Flow[]): boolean { if (!Array.isArray(flows)) { return true; } @@ -258,7 +257,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param model AMF model describing settings of the security * scheme */ - preFillAmfData(model: ApiSecurityOAuth2Settings): void { + preFillAmfData(model: ApiDefinitions.IApiSecurityOAuth2Settings): void { if (!model) { return; } @@ -297,12 +296,12 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param model AMF model describing settings of the security scheme * @returns The extension definition or null */ - findOauth2CustomSettings(model: ApiSecurityOAuth2Settings): ApiCustomDomainProperty | undefined { + findOauth2CustomSettings(model: ApiDefinitions.IApiSecurityOAuth2Settings): IApiCustomDomainProperty | undefined { const { customDomainProperties = [] } = model; const properties = ['accessTokenSettings', 'authorizationGrants', 'authorizationSettings']; return customDomainProperties.find((property) => { - const node = (property.extension as ApiObjectNode); - if (!node.properties || !node.types.includes(ns.aml.vocabularies.data.Object)) { + const node = (property.extension as AmfShapes.IApiObjectNode); + if (!node.properties || !node.types.includes(AmfNamespace.aml.vocabularies.data.Object)) { return false; } return Object.keys(node.properties).some(name => properties.includes(name)); @@ -317,21 +316,21 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param customProperty The domain extension with the custom data * @returns The list of authorization grants to apply to the current operation. */ - computeGrants(grans: string[] = [], customProperty?: ApiCustomDomainProperty): string[] { - if (!customProperty || !customProperty.extension || !customProperty.extension.types.includes(ns.aml.vocabularies.data.Object)) { + computeGrants(grans: string[] = [], customProperty?: IApiCustomDomainProperty): string[] { + if (!customProperty || !customProperty.extension || !customProperty.extension.types.includes(AmfNamespace.aml.vocabularies.data.Object)) { return grans; } - const typed = customProperty.extension as ApiObjectNode; + const typed = customProperty.extension as AmfShapes.IApiObjectNode; if (!typed.properties.authorizationGrants) { return grans; } - const array = typed.properties.authorizationGrants as ApiArrayNode; + const array = typed.properties.authorizationGrants as AmfShapes.IApiArrayNode; const addedGrants: string[] = []; array.members.forEach((g) => { - if (!g.types.includes(ns.aml.vocabularies.data.Scalar)) { + if (!g.types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) { return; } - const scalar = g as ApiScalarNode; + const scalar = g as AmfShapes.IApiScalarNode; if (scalar.value) { addedGrants.push(scalar.value); } @@ -356,7 +355,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param flows List of flows in the authorization description. */ - preFillFlowData(flows: ApiSecurityOAuth2Flow[]): void { + preFillFlowData(flows: ApiDefinitions.IApiSecurityOAuth2Flow[]): void { // first step is to select the right flow. // If the user already selected a grant type before then it this looks // for a flow for already selected grant type. If its not present then @@ -376,7 +375,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param flows List of flows to search in. * @param type Grant type */ - flowForType(flows: ApiSecurityOAuth2Flow[], type?: string): any | undefined { + flowForType(flows: ApiDefinitions.IApiSecurityOAuth2Flow[], type?: string): any | undefined { if (!type) { return undefined; } @@ -402,7 +401,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param flow A flow to process. * @returns List of scopes required by an endpoint / API. */ - readFlowScopes(flow: ApiSecurityOAuth2Flow): string[] | undefined { + readFlowScopes(flow: ApiDefinitions.IApiSecurityOAuth2Flow): string[] | undefined { const { security } = this; let scopes = this.readSecurityScopes(flow.scopes); if (scopes || !security) { @@ -410,7 +409,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { } // if scopes are not defined in the operation then they may be defined in // security settings. - const config = security.scheme && security.scheme.settings as ApiSecurityOAuth2Settings | undefined; + const config = security.scheme && security.scheme.settings as ApiDefinitions.IApiSecurityOAuth2Settings | undefined; if (!config || !config.flows) { return undefined; } @@ -427,7 +426,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param flows List of flows to process. * @returns Grant types supported by this authorization. */ - readFlowsTypes(flows: ApiSecurityOAuth2Flow[]): string[] { + readFlowsTypes(flows: ApiDefinitions.IApiSecurityOAuth2Flow[]): string[] { const grants: string[] = []; flows.forEach((flow) => { let type = flow.flow; @@ -460,7 +459,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { if (!security || !security.scheme || !security.scheme.settings) { return; } - const config = security.scheme.settings as ApiSecurityOAuth2Settings; + const config = security.scheme.settings as ApiDefinitions.IApiSecurityOAuth2Settings; const { flows } = config; if (!Array.isArray(flows) || this.isRamlFlow(flows)) { return; @@ -480,7 +479,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Extracts scopes list from the security definition */ - readSecurityScopes(scopes: ApiSecurityScope[]): string[] | undefined { + readSecurityScopes(scopes: ApiDefinitions.IApiSecurityScope[]): string[] | undefined { if (!scopes) { return undefined; } @@ -497,7 +496,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param model Model for the security settings * @returns True if the security settings are annotated with PKCE extension */ - readPkceValue(model: ApiSecurityOAuth2Settings): boolean | undefined { + readPkceValue(model: ApiDefinitions.IApiSecurityOAuth2Settings): boolean | undefined { const { customDomainProperties } = model; if (!Array.isArray(customDomainProperties) || !customDomainProperties.length) { return undefined; @@ -506,8 +505,8 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { if (!pkce) { return undefined; } - const info = pkce.extension as ApiScalarNode; - if (info.dataType === ns.w3.xmlSchema.boolean) { + const info = pkce.extension as AmfShapes.IApiScalarNode; + if (info.dataType === AmfNamespace.w3.xmlSchema.boolean) { return info.value === 'true'; } return undefined; @@ -576,25 +575,25 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param customProperty Annotation applied to the OAuth settings */ - setupAnnotationParameters(customProperty?: ApiCustomDomainProperty): void { + setupAnnotationParameters(customProperty?: IApiCustomDomainProperty): void { this.parametersValue = []; /* istanbul ignore if */ if (!customProperty || !customProperty.extension) { return; } - const typed = customProperty.extension as ApiObjectNode; - const authSettings = (typed.properties.authorizationSettings as ApiObjectNode | undefined); - const tokenSettings = (typed.properties.accessTokenSettings as ApiObjectNode | undefined); + const typed = customProperty.extension as AmfShapes.IApiObjectNode; + const authSettings = (typed.properties.authorizationSettings as AmfShapes.IApiObjectNode | undefined); + const tokenSettings = (typed.properties.accessTokenSettings as AmfShapes.IApiObjectNode | undefined); if (authSettings) { - const qp = (authSettings.properties.queryParameters as ApiObjectNode | undefined); + const qp = (authSettings.properties.queryParameters as AmfShapes.IApiObjectNode | undefined); if (qp && qp.properties) { this.setupAuthRequestQueryParameters(qp.properties); } } if (tokenSettings) { - const qp = (tokenSettings.properties.queryParameters as ApiObjectNode | undefined); - const headerParams = (tokenSettings.properties.headers as ApiObjectNode | undefined); - const bodyParams = (tokenSettings.properties.body as ApiObjectNode | undefined); + const qp = (tokenSettings.properties.queryParameters as AmfShapes.IApiObjectNode | undefined); + const headerParams = (tokenSettings.properties.headers as AmfShapes.IApiObjectNode | undefined); + const bodyParams = (tokenSettings.properties.body as AmfShapes.IApiObjectNode | undefined); if (qp && qp.properties) { this.setupTokenRequestQueryParameters(qp.properties); } @@ -610,7 +609,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { /** * Appends a list of parameters to the list of rendered parameters */ - appendToParams(list: ApiParameter[], source: string): void { + appendToParams(list: ApiDefinitions.IApiParameter[], source: string): void { const params = this.parametersValue; if (Array.isArray(list)) { list.forEach((param) => { @@ -631,7 +630,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param properties List of parameters from the annotation. */ - setupAuthRequestQueryParameters(properties: { [key: string]: ApiDataNodeUnion }): void { + setupAuthRequestQueryParameters(properties: { [key: string]: AmfShapes.IApiDataNodeUnion }): void { const source = 'authQuery'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -644,7 +643,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param properties List of parameters from the annotation. */ - setupTokenRequestQueryParameters(properties: { [key: string]: ApiDataNodeUnion }): void { + setupTokenRequestQueryParameters(properties: { [key: string]: AmfShapes.IApiDataNodeUnion }): void { const source = 'tokenQuery'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -657,7 +656,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param properties params List of parameters from the annotation. */ - setupTokenRequestHeaders(properties: { [key: string]: ApiDataNodeUnion }): void { + setupTokenRequestHeaders(properties: { [key: string]: AmfShapes.IApiDataNodeUnion }): void { const source = 'tokenHeader'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -670,7 +669,7 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * * @param properties params List of parameters from the annotation. */ - setupTokenRequestBody(properties: { [key: string]: ApiDataNodeUnion }): void { + setupTokenRequestBody(properties: { [key: string]: AmfShapes.IApiDataNodeUnion }): void { const source = 'tokenBody'; this.parametersValue = this.parametersValue.filter(item => item.source !== source); const factory = new Oauth2RamlCustomData(); @@ -688,8 +687,8 @@ export default class OAuth2Auth extends AmfParameterMixin(Oauth2) { * @param reportKey The key name in the report. * @returns Array of objects with `name` and `value` properties or undefined if `params` is empty or no values are available. */ - computeCustomParameters(params: OperationParameter[], reportKey: keyof BindingType): OAuth2CustomParameter[] { - const result: OAuth2CustomParameter[] = []; + computeCustomParameters(params: OperationParameter[], reportKey: keyof BindingType): IOAuth2CustomParameter[] { + const result: IOAuth2CustomParameter[] = []; const report = AmfInputParser.reportRequestInputs(params.map(p => p.parameter), InputCache.getStore(this.target, this.globalCache), this.nilValues); const values = report[reportKey]; if (!values) { diff --git a/src/lib/auth-ui/PassThroughAuth.ts b/src/lib/auth-ui/PassThroughAuth.ts index bfcebd5..56815bf 100644 --- a/src/lib/auth-ui/PassThroughAuth.ts +++ b/src/lib/auth-ui/PassThroughAuth.ts @@ -1,12 +1,11 @@ /* eslint-disable class-methods-use-this */ import { html, TemplateResult } from 'lit'; import { AuthUiInit } from '@advanced-rest-client/base/api.js'; +import { AmfNamespace, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; import '@advanced-rest-client/highlight/arc-marked.js'; import { PassThroughAuthorization } from '@advanced-rest-client/events/src/authorization/Authorization.js'; -import { ns } from '../../helpers/Namespace.js'; import ApiUiBase from './ApiUiBase.js'; import * as InputCache from '../InputCache.js'; -import { ApiNodeShape, ApiParameter, ApiShapeUnion } from '../../helpers/api.js'; export default class PassThroughAuth extends ApiUiBase { schemeName?: string; @@ -36,7 +35,7 @@ export default class PassThroughAuth extends ApiUiBase { if (!security) { return; } - if (!security.types.includes(ns.aml.vocabularies.security.ParametrizedSecurityScheme)) { + if (!security.types.includes(AmfNamespace.aml.vocabularies.security.ParametrizedSecurityScheme)) { return; } const { scheme } = security; @@ -59,8 +58,8 @@ export default class PassThroughAuth extends ApiUiBase { this.requestUpdate(); } - appendQueryString(queryString: ApiShapeUnion): void { - const object = queryString as ApiNodeShape; + appendQueryString(queryString: AmfShapes.IShapeUnion): void { + const object = queryString as AmfShapes.IApiNodeShape; if (!object.properties || !object.properties.length) { return; } @@ -73,10 +72,10 @@ export default class PassThroughAuth extends ApiUiBase { name, examples: [], payloads: [], - types: [ns.aml.vocabularies.apiContract.Parameter], + types: [AmfNamespace.aml.vocabularies.apiContract.Parameter], required: minCount > 0, customDomainProperties: [], - } as ApiParameter; + } as ApiDefinitions.IApiParameter; }); this.appendToParams(list, 'query', true); } @@ -87,7 +86,7 @@ export default class PassThroughAuth extends ApiUiBase { * @param source * @param clear When set it clears the previously set parameters */ - appendToParams(list: ApiParameter[], source: string, clear=false): void { + appendToParams(list: ApiDefinitions.IApiParameter[], source: string, clear=false): void { let params = this.parametersValue; if (clear) { params = params.filter(p => p.source !== source); diff --git a/src/lib/navigation-layout/NaturalTree.js b/src/lib/navigation-layout/NaturalTree.ts similarity index 73% rename from src/lib/navigation-layout/NaturalTree.js rename to src/lib/navigation-layout/NaturalTree.ts index 971bad9..eae1825 100644 --- a/src/lib/navigation-layout/NaturalTree.js +++ b/src/lib/navigation-layout/NaturalTree.ts @@ -1,8 +1,8 @@ /* eslint-disable no-param-reassign */ /* eslint-disable class-methods-use-this */ /* eslint-disable no-plusplus */ -/** @typedef {import('../../types').ApiEndPointWithOperationsListItem} ApiEndPointWithOperationsListItem */ -/** @typedef {import('../../types').ApiEndpointsTreeItem} ApiEndpointsTreeItem */ + +import { ApiEndpointsTreeItem, ApiEndPointWithOperationsListItem } from "../../types.js"; /** * A class that transforms the list of endpoints and methods into @@ -10,30 +10,26 @@ * This is consistent with the legacy API navigation element sorting. */ export class NaturalTree { + result: ApiEndpointsTreeItem[]; + + basePaths: string[]; + constructor() { - /** - * @type ApiEndpointsTreeItem[] - */ this.result = []; - /** @type string[] */ this.basePaths = []; } /** - * @param {ApiEndPointWithOperationsListItem[]} list The list of endpoints as they appear in the API. - * @returns {ApiEndpointsTreeItem[]} + * @param list The list of endpoints as they appear in the API. */ - create(list) { + create(list: ApiEndPointWithOperationsListItem[]): ApiEndpointsTreeItem[] { list.forEach((item) => this.appendEndpointItem(item)); return this.result; } - /** - * @param {ApiEndPointWithOperationsListItem} item - */ - appendEndpointItem(item) { + appendEndpointItem(item: ApiEndPointWithOperationsListItem): void { const { path, name, id, operations, } = item; - const result = /** @type ApiEndpointsTreeItem */ ({ + const result: ApiEndpointsTreeItem = ({ path, label: name, name, @@ -46,7 +42,7 @@ export class NaturalTree { let tmpPath = path; if (tmpPath[0] === '/') { - tmpPath = tmpPath.substr(1); + tmpPath = tmpPath.substring(1); } const parts = tmpPath.split('/'); let indent = 0; @@ -82,12 +78,11 @@ export class NaturalTree { /** * Computes label for an endpoint when name is missing and the endpoint * is indented, hence name should be truncated. - * @param {string} currentPath Endpoint's path - * @param {string[]} parts Path parts - * @param {number} indent Endpoint indentation - * @returns {string} + * @param currentPath Endpoint's path + * @param parts Path parts + * @param indent Endpoint indentation */ - computePathName(currentPath, parts, indent) { + computePathName(currentPath: string, parts: string[], indent: number): string { const { basePaths } = this; let path = ''; diff --git a/src/schema/ApiExampleGenerator.d.ts b/src/schema/ApiExampleGenerator.d.ts deleted file mode 100644 index 82e75cd..0000000 --- a/src/schema/ApiExampleGenerator.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ApiDataNode, ApiExample, ApiShapeUnion } from '../helpers/api'; - -/** - * A class that processes AMF's Example object to read the example value - * or to generate the example for the given media type. - */ -export declare class ApiExampleGenerator { - /** - * Reads or generates an example. - * When the `mime` is set then it tries to "guess" whether the mime type corresponds to the value. - * If it doesn't then it generates the example from the structured value, when possible. - * @param example The structured value of the example - * @param mime The optional mime type of the example. When not set it won't generate example from the structured value. - * @param shape The optional shape containing this example to use with the XML examples which needs wrapping into an element. - * @returns The read or generated example. - */ - read(example: ApiExample, mime?: string, shape?: ApiShapeUnion): string|null; - - /** - * Employs some basic heuristics to determine whether the given mime type patches the content. - * @param mime The mime type for the value. - * @param value The value. - * @returns True when the value matches the mime type. - */ - mimeMatches(mime: string, value: string): boolean; - - /** - * Generates the example for the given structured value and the media type. - * @param mime The mime type for the value. - * @param structuredValue The structuredValue of the example. - * @param shape The optional shape containing this example to use with the XML examples which needs wrapping into an element. - * @returns The generated example or null if couldn't process the data. - */ - fromStructuredValue(mime: string, structuredValue: ApiDataNode, shape?: ApiShapeUnion): string|null; - - /** - * Wraps the generated XML example into an element according to the `shape` properties. - */ - wrapXmlValue(value: string|null, shape?: ApiShapeUnion): string|null; -} diff --git a/src/schema/ApiExampleGenerator.js b/src/schema/ApiExampleGenerator.js deleted file mode 100644 index 6190b72..0000000 --- a/src/schema/ApiExampleGenerator.js +++ /dev/null @@ -1,120 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { ns } from "../helpers/Namespace.js"; -import { JsonDataNodeGenerator } from './data-node/JsonDataNodeGenerator.js'; -import { XmlDataNodeGenerator } from './data-node/XmlDataNodeGenerator.js'; -import { UrlEncodedDataNodeGenerator } from './data-node/UrlEncodedDataNodeGenerator.js'; -import { formatXmlValue } from './Utils.js'; - -/** @typedef {import('../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../helpers/api').ApiDataNode} ApiDataNode */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ - -/** - * A class that processes AMF's Example object to read the example value - * or to generate the example for the given media type. - */ -export class ApiExampleGenerator { - /** - * Reads or generates an example. - * When the `mime` is set then it tries to "guess" whether the mime type corresponds to the value. - * If it doesn't then it generates the example from the structured value, when possible. - * @param {ApiExample} example The structured value of the example - * @param {string=} mime The optional mime type of the example. When not set it won't generate example from the structured value. - * @param {ApiShapeUnion=} shape The optional shape containing this example to use with the XML examples which needs wrapping into an element. - * @returns {string|null} The read or generated example. - */ - read(example, mime, shape) { - const { value, structuredValue } = example; - if (!value && !structuredValue) { - return null; - } - if (structuredValue && !value && mime) { - return this.fromStructuredValue(mime, structuredValue, shape); - } - if (!mime) { - return value; - } - if (this.mimeMatches(mime, value)) { - return value; - } - if (structuredValue) { - return this.fromStructuredValue(mime, structuredValue, shape); - } - return null; - } - - /** - * Employs some basic heuristics to determine whether the given mime type patches the content. - * @param {string} mime The mime type for the value. - * @param {string} value The value. - * @returns {boolean} True when the value matches the mime type. - */ - mimeMatches(mime, value) { - const trimmed = value.trim(); - if (mime.includes('json')) { - // JSON string has to start with either of these characters - return trimmed[0] === '{' || trimmed[0] === '['; - } - if (mime.includes('xml')) { - return trimmed.startsWith('<'); - } - if (mime.includes('x-www-form-urlencoded')) { - return trimmed.includes('=') || trimmed.includes('&'); - } - return true; - } - - /** - * Generates the example for the given structured value and the media type. - * @param {string} mime The mime type for the value. - * @param {ApiDataNode} structuredValue The structuredValue of the example. - * @param {ApiShapeUnion=} shape The optional shape containing this example to use with the XML examples which needs wrapping into an element. - * @returns {string|null} The generated example or null if couldn't process the data. - */ - fromStructuredValue(mime, structuredValue, shape) { - if (mime.includes('json')) { - const generator = new JsonDataNodeGenerator(); - return generator.generate(structuredValue); - } - let shapeName; - if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - shapeName = shape.name; - } else if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ArrayShape)) { - const typed = /** @type ApiArrayShape */ (shape); - if (typed.items && typed.items.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - shapeName = typed.items.name || shape.name; - } - } - if (mime.includes('xml')) { - const generator = new XmlDataNodeGenerator(); - let value = generator.generate(structuredValue, shapeName); - if (shape && !shapeName) { - value = this.wrapXmlValue(value, shape); - } - return value; - } - if (mime.includes('x-www-form-urlencoded')) { - const generator = new UrlEncodedDataNodeGenerator(); - return generator.generate(structuredValue, shapeName); - } - return null; - } - - /** - * Wraps the generated XML example into an element according to the `shape` properties. - * @param {string|null} value - * @param {ApiShapeUnion} shape - * @returns {string|null} - */ - wrapXmlValue(value, shape) { - if (!value || !shape) { - return value; - } - const { name } = shape; - const parts = [`<${name}>`]; - parts.push(formatXmlValue(' ', value.trim())); - parts.push(``); - return parts.join('\n'); - } -} diff --git a/src/schema/ApiMonacoSchemaGenerator.d.ts b/src/schema/ApiMonacoSchemaGenerator.d.ts deleted file mode 100644 index 2e27c71..0000000 --- a/src/schema/ApiMonacoSchemaGenerator.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ApiArrayShape, ApiNodeShape, ApiPropertyShape, ApiScalarShape, ApiShapeUnion } from '../helpers/api'; -import { MonacoArrayProperty, MonacoObjectProperty, MonacoScalarProperty, MonacoSchema } from '../types'; - -/** - * A class to generate JSON schema from an ApiShapeUnion declaration to use with the Monaco editor schemas. - */ -export declare class ApiMonacoSchemaGenerator { - /** - * @param parentUri The URI for the fileMatch property. - */ - generate(schema: ApiShapeUnion, parentUri: string): MonacoSchema[]; - - /** - * @param parentUri The URI for the fileMatch property. - */ - fromNodeShape(schema: ApiNodeShape, parentUri?: string): MonacoSchema[]; - - appendSchemaProperty(content: MonacoObjectProperty, property: ApiPropertyShape): void; - - rangeToPropertySchema(range: ApiShapeUnion): MonacoScalarProperty | MonacoObjectProperty | MonacoArrayProperty; - - scalarRangeToPropertySchema(schema: ApiScalarShape): MonacoScalarProperty; - - /** - * Translates AMF data type to JSON schema data type. - */ - schemaTypeToJsonDataType(schemaType: string): string; - - nodeShapeRangeToPropertySchema(schema: ApiNodeShape): MonacoObjectProperty; - - arrayShapeRangeToPropertySchema(schema: ApiArrayShape): MonacoArrayProperty; -} diff --git a/src/schema/ApiMonacoSchemaGenerator.js b/src/schema/ApiMonacoSchemaGenerator.js deleted file mode 100644 index 8bca054..0000000 --- a/src/schema/ApiMonacoSchemaGenerator.js +++ /dev/null @@ -1,285 +0,0 @@ -/* eslint-disable no-param-reassign */ -/* eslint-disable class-methods-use-this */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../types').MonacoSchema} MonacoSchema */ -/** @typedef {import('../types').MonacoProperty} MonacoProperty */ -/** @typedef {import('../types').MonacoScalarProperty} MonacoScalarProperty */ -/** @typedef {import('../types').MonacoObjectProperty} MonacoObjectProperty */ -/** @typedef {import('../types').MonacoArrayProperty} MonacoArrayProperty */ - -import { ns } from "../helpers/Namespace.js"; -import { collectNodeProperties } from './Utils.js'; - -/** - * @param {string} name - * @returns {string} - */ -function cleanName(name) { - if (!name) { - return name; - } - return name.replace('?', ''); -} - -/** - * A class to generate JSON schema from an ApiShapeUnion declaration to use with the Monaco editor schemas. - */ -export class ApiMonacoSchemaGenerator { - /** - * @param {ApiShapeUnion} schema - * @param {string} parentUri The URI for the fileMatch property. - */ - generate(schema, parentUri) { - /** @type MonacoSchema[] */ - this.schemas = []; - if (!schema) { - return []; - } - const { types } = schema; - if (types.includes(ns.w3.shacl.NodeShape)) { - return this.fromNodeShape(/** @type ApiNodeShape */ (schema), parentUri); - } - return []; - } - - /** - * @param {ApiNodeShape} schema - * @param {string=} parentUri The URI for the fileMatch property. - * @returns {MonacoSchema[]} - */ - fromNodeShape(schema, parentUri) { - const { id, name } = schema; - const properties = collectNodeProperties(schema); - const content = /** @type MonacoObjectProperty */ ({ - title: cleanName(name), - type: "object", - properties: {}, - required: [], - }); - const result = /** @type MonacoSchema */ ({ - uri: id, - schema: content, - }); - if (parentUri) { - result.fileMatch = [parentUri]; - } - this.schemas.push(result); - if (!Array.isArray(properties) || !properties.length) { - return this.schemas; - } - properties.forEach(property => this.appendSchemaProperty(content, property)); - return this.schemas; - } - - /** - * @param {MonacoObjectProperty} content - * @param {ApiPropertyShape} property - */ - appendSchemaProperty(content, property) { - const { name, range, minCount } = property; - const value = this.rangeToPropertySchema(range); - if (value) { - content.properties[name] = value; - if (minCount === 1) { - content.required.push(name); - } - } - } - - /** - * @param {ApiShapeUnion} range - */ - rangeToPropertySchema(range) { - const { types } = range; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this.scalarRangeToPropertySchema(/** @type ApiScalarShape */ (range)); - } - if (types.includes(ns.w3.shacl.NodeShape)) { - return this.nodeShapeRangeToPropertySchema(/** @type ApiNodeShape */ (range)); - } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) { - return this.arrayShapeRangeToPropertySchema(/** @type ApiArrayShape */ (range)); - } - return undefined; - } - - /** - * @param {ApiScalarShape} schema - * @returns {MonacoScalarProperty} - */ - scalarRangeToPropertySchema(schema) { - const { values, description, name, displayName, defaultValueStr, exclusiveMaximum, exclusiveMinimum, minimum, maximum, minLength, maxLength, id, multipleOf, pattern, readOnly, writeOnly } = schema; - const type = this.schemaTypeToJsonDataType(schema.dataType); - const result = /** @type MonacoScalarProperty */ ({ - '$id': id, - type, - title: cleanName(displayName || name), - }); - if (description) { - result.description = description; - } - if (defaultValueStr) { - result.default = defaultValueStr; - } - if (typeof exclusiveMaximum === 'boolean') { - result.exclusiveMaximum = exclusiveMaximum; - } - if (typeof exclusiveMinimum === 'boolean') { - result.exclusiveMinimum = exclusiveMinimum; - } - if (typeof maxLength === 'number') { - result.maxLength = maxLength; - } - if (typeof minLength === 'number') { - result.minLength = minLength; - } - if (typeof minimum === 'number') { - result.minimum = minimum; - } - if (typeof maximum === 'number') { - result.maximum = maximum; - } - if (typeof multipleOf === 'number') { - result.multipleOf = multipleOf; - } - if (typeof pattern === 'string') { - result.pattern = pattern; - } - if (typeof readOnly === 'boolean') { - result.readOnly = readOnly; - } - if (typeof writeOnly === 'boolean') { - result.writeOnly = writeOnly; - } - switch (schema.dataType) { - case ns.aml.vocabularies.shapes.dateTimeOnly: result.format = 'date-time'; break; - case ns.w3.xmlSchema.date: result.format = 'date'; break; - case ns.w3.xmlSchema.time: result.format = 'time'; break; - default: - } - if (Array.isArray(values) && values.length) { - // enum properties - result.enum = []; - values.forEach((value) => { - const { types } = value; - if (types.includes(ns.aml.vocabularies.data.Scalar)) { - const typed = /** @type ApiScalarNode */ (value); - if (typed.value) { - result.enum.push(typed.value); - } - } - }); - } - return result; - } - - /** - * Translates AMF data type to JSON schema data type. - * @param {string} schemaType - * @return {string} - */ - schemaTypeToJsonDataType(schemaType) { - switch (schemaType) { - case ns.aml.vocabularies.shapes.number: - case ns.aml.vocabularies.shapes.integer: - case ns.aml.vocabularies.shapes.float: - case ns.aml.vocabularies.shapes.long: - case ns.aml.vocabularies.shapes.double: - case ns.w3.xmlSchema.number: - case ns.w3.xmlSchema.integer: - case ns.w3.xmlSchema.float: - case ns.w3.xmlSchema.long: - case ns.w3.xmlSchema.double: return 'number'; - case ns.w3.xmlSchema.boolean: - case ns.aml.vocabularies.shapes.boolean: return 'boolean'; - case ns.aml.vocabularies.shapes.nil: - case ns.w3.xmlSchema.nil: return 'null'; - default: return 'string'; - } - } - - /** - * @param {ApiNodeShape} schema - * @returns {MonacoObjectProperty} - */ - nodeShapeRangeToPropertySchema(schema) { - const { description, name, displayName, id, readOnly, writeOnly, closed, minProperties, maxProperties } = schema; - const properties = collectNodeProperties(schema); - - const result = /** @type MonacoObjectProperty */ ({ - '$id': id, - type: 'object', - title: cleanName(displayName || name), - properties: {}, - required: [], - }); - if (description) { - result.description = description; - } - if (typeof readOnly === 'boolean') { - result.readOnly = readOnly; - } - if (typeof writeOnly === 'boolean') { - result.writeOnly = writeOnly; - } - if (typeof closed === 'boolean') { - result.additionalProperties = !closed; - } - if (typeof minProperties === 'number') { - result.minProperties = minProperties; - } - if (typeof maxProperties === 'number') { - result.maxProperties = maxProperties; - } - properties.forEach(property => this.appendSchemaProperty(result, property)); - return result; - } - - /** - * @param {ApiArrayShape} schema - * @returns {MonacoArrayProperty} - */ - arrayShapeRangeToPropertySchema(schema) { - const { description, name, displayName, id, readOnly, writeOnly, items, minItems, maxItems, uniqueItems } = schema; - const result = /** @type MonacoArrayProperty */ ({ - '$id': id, - type: 'array', - title: cleanName(displayName || name), - items: { - anyOf: [], - }, - required: [], - additionalItems: false, - }); - if (description) { - result.description = description; - } - if (typeof readOnly === 'boolean') { - result.readOnly = readOnly; - } - if (typeof writeOnly === 'boolean') { - result.writeOnly = writeOnly; - } - if (typeof uniqueItems === 'boolean') { - result.uniqueItems = uniqueItems; - } - if (items) { - const value = this.rangeToPropertySchema(items); - if (value) { - result.items.anyOf.push(value); - } - } - if (typeof minItems === 'number') { - result.minItems = minItems; - } - if (typeof maxItems === 'number') { - result.maxItems = maxItems; - } - return result; - } -} diff --git a/src/schema/ApiSchemaGenerator.d.ts b/src/schema/ApiSchemaGenerator.d.ts deleted file mode 100644 index 72562e5..0000000 --- a/src/schema/ApiSchemaGenerator.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ApiShapeUnion } from '../helpers/api'; -import { ShapeBase } from './shape/ShapeBase'; -import { SchemaExample, ShapeRenderOptions } from '../types'; - -/** - * A class that processes AMF's Shape to auto-generate a schema for a given media type. - * This should be used when examples for the Shape are not available but the application still needs to - * render an example or a schema from the Shape. - */ -export declare class ApiSchemaGenerator { - mime: string; - opts: Readonly; - generator?: ShapeBase; - /** - * @param mime The example mime type to format the generated example. - * @param opts Optional configuration. - */ - constructor(mime: string, opts?: ShapeRenderOptions); - - /** - * @param shape The Shape definition - * @param mime The mime type for the value. - * @returns Customized Example with the `renderValue` that is the generated Example value. - */ - static asExample(shape: ApiShapeUnion, mime: string, opts?: ShapeRenderOptions): SchemaExample|null; - - /** - * @param shape The Shape definition - * @param mime The mime type for the value. - * @returns Generated schema - */ - static asSchema(shape: ApiShapeUnion, mime: string, opts?: ShapeRenderOptions): object|string|number|boolean|null|undefined; - - /** - * Generates the schema from the AMF shape. - * - * @param shape The Shape definition - */ - generate(shape: ApiShapeUnion): object|string|number|boolean|null|undefined; - - /** - * @param shape The Shape definition - */ - toValue(shape: ApiShapeUnion): object|string|number|boolean|null|undefined; - - /** - * Generates an API Example object with the value to render. - * @param shape The Shape definition - * @returns Customized Example with the `renderValue` that is the generated Example value. - */ - toExample(shape: ApiShapeUnion): SchemaExample|null; -} diff --git a/src/schema/ApiSchemaGenerator.js b/src/schema/ApiSchemaGenerator.js deleted file mode 100644 index 6f5be40..0000000 --- a/src/schema/ApiSchemaGenerator.js +++ /dev/null @@ -1,115 +0,0 @@ -/* eslint-disable max-classes-per-file */ -/* eslint-disable no-unused-vars */ -/* eslint-disable class-methods-use-this */ -import { ns } from "../helpers/Namespace.js"; -import { ShapeJsonSchemaGenerator } from './shape/ShapeJsonSchemaGenerator.js'; -import { ShapeXmlSchemaGenerator } from './shape/ShapeXmlSchemaGenerator.js'; - -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../types').SchemaExample} SchemaExample */ -/** @typedef {import('../types').ShapeRenderOptions} ShapeRenderOptions */ -/** @typedef {import('./shape/ShapeBase').ShapeBase} ShapeBase */ - -/** - * A class that processes AMF's Shape to auto-generate a schema from examples/type for a given media type. - * This should be used when examples for the Shape are not available but the application still needs to - * render an example or a schema from the Shape. - * If examples can be found directly in the shape, use the `ApiExampleGenerator` instead. - */ -export class ApiSchemaGenerator { - /** - * - * @param {string} mime The example mime type to format the generated example. - * @param {ShapeRenderOptions=} opts Optional configuration. - */ - constructor(mime, opts={}) { - this.mime = mime; - /** - * @type Readonly - */ - this.opts = Object.freeze({ ...opts }); - /** - * @type {ShapeBase} - */ - this.generator = undefined; - if (mime.includes('json')) { - this.generator = new ShapeJsonSchemaGenerator(opts); - } else if (mime.includes('xml')) { - this.generator = new ShapeXmlSchemaGenerator(opts); - } - } - - /** - * @param {ApiShapeUnion} shape The Shape definition - * @param {string} mime The mime type for the value. - * @param {ShapeRenderOptions=} opts - * @returns {SchemaExample|null} Customized Example with the `renderValue` that is the generated Example value. - */ - static asExample(shape, mime, opts) { - const generator = new ApiSchemaGenerator(mime, opts); - return generator.toExample(shape); - } - - /** - * @param {ApiShapeUnion} shape The Shape definition - * @param {string} mime The mime type for the value. - * @param {ShapeRenderOptions=} opts - * @returns {object|string|number|boolean|null|undefined} Generated schema - */ - static asSchema(shape, mime, opts) { - const generator = new ApiSchemaGenerator(mime, opts); - return generator.toValue(shape); - } - - /** - * Generates the schema from the AMF shape. - * - * @param {ApiShapeUnion} shape The Shape definition - * @returns {object|string|number|boolean|null|undefined} - */ - generate(shape) { - const { generator } = this; - if (!generator) { - return null; - } - return generator.generate(shape); - } - - /** - * @link {#generate()} - * @param {ApiShapeUnion} shape The Shape definition - * @returns {object|string|number|boolean|null|undefined} - */ - toValue(shape) { - return this.generate(shape); - } - - /** - * Generates an API Example object with the value to render. - * @param {ApiShapeUnion} shape The Shape definition - * @returns {SchemaExample|null} Customized Example with the `renderValue` that is the generated Example value. - */ - toExample(shape) { - const renderValue = this.generate(shape); - if (renderValue === null || renderValue === undefined) { - return null; - } - const result = /** @type SchemaExample */ ({ - id: `${shape.id}/generated`, - strict: true, - types: [ns.aml.vocabularies.apiContract.Example], - mediaType: this.mime, - renderValue, - customDomainProperties: [], - }); - const typed = /** @type ApiAnyShape */ (shape); - if (Array.isArray(typed.examples) && typed.examples.length) { - const [example] = typed.examples; - if (example.value) { - result.value = example.value; - } - } - return result; - } -} diff --git a/src/schema/ApiSchemaValues.d.ts b/src/schema/ApiSchemaValues.d.ts deleted file mode 100644 index 4f3cb75..0000000 --- a/src/schema/ApiSchemaValues.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { ApiArrayShape, ApiExample, ApiParameter, ApiScalarShape, ApiShapeUnion } from "../helpers/api"; -import { ApiSchemaReadOptions } from "../types"; - -/** - * A utility class with helper functions to read values from a schema definition - */ -export declare class ApiSchemaValues { - /** - * Reads the value to be set on an input. This is for Scalar shapes only. - * - * @returns The value to set on the input. Note, it is not cast to the type. - */ - static readInputValue(parameter: ApiParameter, schema: ApiScalarShape, opts?: ApiSchemaReadOptions): any; - - /** - * @param parameter The parameter that has the array schema. - * @param schema The final schema to use to read the data from. - */ - static readInputValues(parameter: ApiParameter, schema: ApiShapeUnion, opts?: ApiSchemaReadOptions): any[]; - - /** - * Reads the value for the form input(s) from examples. - */ - static inputValueFromExamples(examples: ApiExample[]): any|null|undefined; - - /** - * Reads the array value from examples. - * @param examples Examples set on an array item. - */ - static arrayValuesFromExamples(examples: ApiExample[]): any[]; - - /** - * Generates a default value from the schema type. - * For booleans it returns `false`, for numbers `0`, nulls `null`, etc. - * It does not generate a value for `string` types! - */ - static generateDefaultValue(schema: ApiScalarShape): any; - - /** - * Casts the `value` to the corresponding data type - */ - static readTypedValue(value: any, type: string): any; - - /** - * @param schemaType Data type encoded in the parameter schema. - * @returns One of the HTML input element type values. - */ - static readInputType(schemaType: string): 'number'|'boolean'|'date'|'time'|'datetime-local'|'text'; - - /** - * Processes a value that should be a number. - */ - static parseNumberInput(value: any, defaultValue?: number): number|undefined; - - /** - * Processes a value that should be a number. - */ - static parseBooleanInput(value: any, defaultValue?: boolean): boolean|undefined; - - /** - * Processes a value that should be a date formatted as yyyy-MM-dd. - */ - static parseDateOnlyInput(value: any): string|undefined; - - /** - * Processes a value that should be a date formatted as hh:mm:ss. - */ - static parseTimeOnlyInput(input: any): string|undefined; - - /** - * Processes a value that should be a date formatted in one of the supported formats: - * - rfc3339 (default): 2016-02-28T16:41:41.090Z - * - rfc2616: Sun, 28 Feb 2016 16:41:41 GMT - */ - static parseDateTimeInput(value: any, format?: string): string|undefined; - - /** - * Processes a value that should be a date formatted as yyyy-MM-ddThh:mm - */ - static parseDateTimeOnlyInput(value: any): string|undefined; - - /** - * Parses the the value according to array schema value. - */ - static parseArrayInput(value: any, schema: ApiArrayShape): string|number|boolean|null|undefined; - - /** - * Parses the user entered value according to the schema definition. - */ - static parseUserInput(value: any, schema: ApiShapeUnion): string|number|boolean|null|undefined; - - /** - * Parses the user entered value as scalar value. - */ - static parseScalarInput(value: any, schema: ApiScalarShape): string|number|boolean|null|undefined; -} diff --git a/src/schema/ApiSchemaValues.js b/src/schema/ApiSchemaValues.js deleted file mode 100644 index 65f273a..0000000 --- a/src/schema/ApiSchemaValues.js +++ /dev/null @@ -1,377 +0,0 @@ -/* eslint-disable class-methods-use-this */ - -import { Time } from '@pawel-up/data-mock'; -import { ns } from "../helpers/Namespace.js"; -import { JsonDataNodeGenerator } from "./data-node/JsonDataNodeGenerator.js"; -import { parseBooleanInput, parseNumberInput, readTypedValue } from "./Utils.js"; - -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../helpers/api').ApiFileShape} ApiFileShape */ -/** @typedef {import('../helpers/api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../helpers/api').ApiArrayNode} ApiArrayNode */ -/** @typedef {import('../types').ApiSchemaReadOptions} ApiSchemaReadOptions */ - -/** - * A utility class with helper functions to read values from a schema definition - */ -export class ApiSchemaValues { - /** - * Reads the value to be set on an input. This is for Scalar shapes only. - * - * @param {ApiParameter} parameter - * @param {ApiScalarShape} schema - * @param {ApiSchemaReadOptions=} opts - * @returns {any} The value to set on the input. Note, it is not cast to the type. - */ - static readInputValue(parameter, schema, opts={}) { - const { required } = parameter; - const { defaultValueStr, values } = schema; - if (!required && opts.requiredOnly === true) { - return undefined; - } - if (defaultValueStr) { - return ApiSchemaValues.readTypedValue(defaultValueStr, schema.dataType); - } - if (Array.isArray(values) && values.length) { - const firstEnum = /** @type ApiScalarNode */ (values[0]); - return ApiSchemaValues.readTypedValue(firstEnum.value, firstEnum.dataType); - } - if (opts.fromExamples) { - /** @type ApiExample[] */ - let examples; - if (Array.isArray(parameter.examples) && parameter.examples.length) { - // just in case when an ApiParameter was passed. - examples = parameter.examples.filter(i => typeof i !== 'string'); - } else if (Array.isArray(schema.examples) && schema.examples.length) { - examples = schema.examples; - } - if (examples && examples.length) { - return ApiSchemaValues.inputValueFromExamples(examples); - } - } - return ApiSchemaValues.generateDefaultValue(schema); - } - - /** - * @param {ApiParameter} parameter The parameter that has the array schema. - * @param {ApiShapeUnion} schema The final schema to use to read the data from. - * @param {ApiSchemaReadOptions=} opts - * @returns {any[]} - */ - static readInputValues(parameter, schema, opts={}) { - if (!parameter.required && opts.requiredOnly === true) { - // for a non required array items just skip showing example values - // as they are not crucial to make an HTTP request. - return []; - } - const { defaultValue } = schema; - if (defaultValue) { - const gen = new JsonDataNodeGenerator(); - const result = gen.processNode(defaultValue); - if (Array.isArray(result)) { - return result; - } - } - const anySchema = /** @type ApiAnyShape */ (schema); - if (opts.fromExamples) { - /** @type ApiExample[] */ - let examples; - if (Array.isArray(parameter.examples) && parameter.examples.length) { - // just in case when an ApiParameter was passed. - examples = parameter.examples.filter(i => typeof i !== 'string'); - } else if (Array.isArray(anySchema.examples) && anySchema.examples.length) { - examples = anySchema.examples; - } - return ApiSchemaValues.arrayValuesFromExamples(examples); - } - return []; - } - - /** - * Reads the value for the form input(s) from examples. - * @param {ApiExample[]} examples - * @returns {any|null|undefined} - */ - static inputValueFromExamples(examples) { - if (!Array.isArray(examples) || !examples.length) { - return undefined; - } - const [example] = examples; - const { structuredValue } = example; - if (!structuredValue) { - return undefined; - } - if (structuredValue.types.includes(ns.aml.vocabularies.data.Scalar)) { - const value = /** @type ApiScalarNode */ (structuredValue); - return ApiSchemaValues.readTypedValue(value.value, value.dataType); - } - return undefined; - } - - /** - * Reads the array value from examples. - * @param {ApiExample[]} examples Examples set on an array item. - * @returns {any[]} - */ - static arrayValuesFromExamples(examples) { - /** @type any[] */ - const defaultReturn = []; - if (!Array.isArray(examples) || !examples.length) { - return defaultReturn; - } - const [example] = examples; - if (!example.structuredValue || !example.structuredValue.types.includes(ns.aml.vocabularies.data.Array)) { - return defaultReturn; - } - const value = /** @type ApiArrayNode */ (example.structuredValue); - const { members } = value; - if (!Array.isArray(members) || !members.length) { - return defaultReturn; - } - const result = []; - members.forEach((item) => { - const scalar = /** @type ApiScalarNode */ (item); - if (!scalar.value) { - return; - } - const typedValue = ApiSchemaValues.readTypedValue(scalar.value, scalar.dataType); - if (typeof value !== 'undefined' && value !== null) { - result.push(typedValue); - } - }); - return result; - } - - /** - * Generates a default value from the schema type. - * For booleans it returns `false`, for numbers `0`, nulls `null`, etc. - * It does not generate a value for `string` types! - * - * @param {ApiScalarShape} schema - * @returns {any} - */ - static generateDefaultValue(schema) { - const { dataType } = schema; - switch (dataType) { - case ns.w3.xmlSchema.string: return ''; - // XML schema, for DataNode - case ns.w3.xmlSchema.number: - case ns.w3.xmlSchema.integer: - case ns.w3.xmlSchema.float: - case ns.w3.xmlSchema.long: - case ns.w3.xmlSchema.double: return 0; - // AML shapes, for Shape - case ns.aml.vocabularies.shapes.number: - case ns.aml.vocabularies.shapes.integer: - case ns.aml.vocabularies.shapes.float: - case ns.aml.vocabularies.shapes.long: - case ns.aml.vocabularies.shapes.double: return 0; - case ns.aml.vocabularies.shapes.boolean: - case ns.w3.xmlSchema.boolean: return false; - case ns.aml.vocabularies.shapes.nil: - case ns.w3.xmlSchema.nil: return null; - case ns.w3.xmlSchema.date: return new Time().dateOnly(); - case ns.w3.xmlSchema.dateTime: return new Time().dateTime(/** @type {"rfc3339" | "rfc2616"} */ (schema.format === 'date-time' ? 'rfc3339' : schema.format)); - case ns.aml.vocabularies.shapes.dateTimeOnly: return new Time().dateTimeOnly(); - case ns.w3.xmlSchema.time: return new Time().timeOnly(); - default: return undefined; - } - } - - /** - * Casts the `value` to the corresponding data type - * @param {any} value - * @param {string} type The w3 schema type - * @returns {any} - */ - static readTypedValue(value, type) { - return readTypedValue(value, type); - } - - /** - * @param {string} schemaType Data type encoded in the parameter schema. - * @returns {'number'|'boolean'|'date'|'time'|'datetime-local'|'text'} One of the HTML input element type values. - */ - static readInputType(schemaType) { - switch (schemaType) { - case ns.aml.vocabularies.shapes.number: - case ns.aml.vocabularies.shapes.integer: - case ns.aml.vocabularies.shapes.float: - case ns.aml.vocabularies.shapes.long: - case ns.aml.vocabularies.shapes.double: - case ns.w3.xmlSchema.number: - case ns.w3.xmlSchema.integer: - case ns.w3.xmlSchema.float: - case ns.w3.xmlSchema.long: - case ns.w3.xmlSchema.double: return 'number'; - case ns.w3.xmlSchema.date: return 'date'; - case ns.w3.xmlSchema.time: return 'time'; - case ns.w3.xmlSchema.dateTime: - case ns.aml.vocabularies.shapes.dateTimeOnly: return 'datetime-local'; - case ns.aml.vocabularies.shapes.boolean: - case ns.w3.xmlSchema.boolean: return 'boolean'; - default: return 'text'; - } - } - - /** - * Processes a value that should be a number. - * @param {any} value - * @param {number=} defaultValue - * @returns {number|undefined} - */ - static parseNumberInput(value, defaultValue) { - return parseNumberInput(value, defaultValue); - } - - /** - * Processes a value that should be a number. - * @param {any} value - * @param {boolean=} defaultValue - * @returns {boolean|undefined} - */ - static parseBooleanInput(value, defaultValue) { - return parseBooleanInput(value, defaultValue); - } - - /** - * Processes a value that should be a date formatted as yyyy-MM-dd. - * @param {any} value - * @returns {string|undefined} - */ - static parseDateOnlyInput(value) { - const d = new Date(value); - if (Number.isNaN(d.getTime())) { - return undefined; - } - const result = d.toJSON(); - const timeSeparator = result.indexOf('T'); - return result.substr(0, timeSeparator); - } - - /** - * Processes a value that should be a date formatted as hh:mm:ss. - * @param {any} input - * @returns {string|undefined} - */ - static parseTimeOnlyInput(input) { - const value = String(input).trim(); - if (/^\d\d:\d\d$/.test(value)) { - return `${value}:00`; - } - if (/^\d\d:\d\d:\d\d$/.test(value)) { - return value; - } - return undefined; - } - - /** - * Processes a value that should be a date formatted in one of the supported formats: - * - rfc3339 (default): 2016-02-28T16:41:41.090Z - * - rfc2616: Sun, 28 Feb 2016 16:41:41 GMT - * @param {any} value - * @param {string=} format - * @returns {string|undefined} - */ - static parseDateTimeInput(value, format='rfc3339') { - const d = new Date(value); - if (Number.isNaN(d.getTime())) { - return undefined; - } - if (format === 'rfc2616') { - return d.toUTCString(); - } - // OAS has the `date-time` format describing rfc3339. - if (['rfc3339', 'date-time'].includes(format)) { - return d.toISOString(); - } - return undefined; - } - - /** - * Processes a value that should be a date formatted as yyyy-MM-ddThh:mm - * @param {any} value - * @returns {string|undefined} - */ - static parseDateTimeOnlyInput(value) { - const d = new Date(value); - if (Number.isNaN(d.getTime())) { - return undefined; - } - const jsonDate = d.toJSON(); // "yyyy-MM-ddThh:mm:ss.090Z" - const dot = jsonDate.indexOf('.'); - return jsonDate.substr(0, dot); - } - - /** - * Parses the the value according to array schema value. - * @param {any} value - * @param {ApiArrayShape} schema - * @returns {string|number|boolean|null|undefined} - */ - static parseArrayInput(value, schema) { - const { items } = schema; - if (!items) { - return String(value); - } - return ApiSchemaValues.parseUserInput(value, items); - } - - /** - * Parses the user entered value according to the schema definition. - * @param {any} value - * @param {ApiShapeUnion} schema - * @returns {string|number|boolean|null|undefined} - */ - static parseUserInput(value, schema) { - if (!schema || value === undefined || value === null) { - return value; - } - const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return ApiSchemaValues.parseScalarInput(value, /** @type ApiScalarShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return ApiSchemaValues.parseArrayInput(value, /** @type ApiArrayShape */ (schema)); - } - return value; - } - - /** - * Parses the user entered value as scalar value. - * @param {any} value - * @param {ApiScalarShape} schema - * @returns {string|number|boolean|null|undefined} - */ - static parseScalarInput(value, schema) { - switch (schema.dataType) { - // AML shapes, for Shape - case ns.aml.vocabularies.shapes.number: - case ns.aml.vocabularies.shapes.integer: - case ns.aml.vocabularies.shapes.float: - case ns.aml.vocabularies.shapes.long: - case ns.aml.vocabularies.shapes.double: - case ns.w3.xmlSchema.number: - case ns.w3.xmlSchema.integer: - case ns.w3.xmlSchema.float: - case ns.w3.xmlSchema.long: - case ns.w3.xmlSchema.double: return ApiSchemaValues.parseNumberInput(value); - case ns.aml.vocabularies.shapes.boolean: - case ns.w3.xmlSchema.boolean: return ApiSchemaValues.parseBooleanInput(value); - case ns.w3.xmlSchema.date: return ApiSchemaValues.parseDateOnlyInput(value); - case ns.w3.xmlSchema.time: return ApiSchemaValues.parseTimeOnlyInput(value); - case ns.w3.xmlSchema.dateTime: return ApiSchemaValues.parseDateTimeInput(value, schema.format); - case ns.aml.vocabularies.shapes.dateTimeOnly: return ApiSchemaValues.parseDateTimeOnlyInput(value); - default: return String(value); - } - } -} diff --git a/src/schema/Utils.js b/src/schema/Utils.js deleted file mode 100644 index 3f414df..0000000 --- a/src/schema/Utils.js +++ /dev/null @@ -1,203 +0,0 @@ -import { ns } from "../helpers/Namespace.js"; - -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../helpers/api').ApiUnionShape} ApiUnionShape */ - -/** - * @param {any} obj - * @param {number=} indent The current indent - * @return {string} - */ -export function toXml(obj, indent=0) { - if (typeof obj !== 'object') { - return obj; - } - let xml = ''; - const tabs = new Array(indent).fill(' ').join(''); - Object.keys(obj).forEach((prop) => { - xml += Array.isArray(obj[prop]) ? '' : `${tabs}<${prop}>`; - if (Array.isArray(obj[prop])) { - obj[prop].forEach((item) => { - xml += `<${prop}>\n`; - xml += tabs; - xml += toXml({ ...item }, indent + 1); - xml += `\n`; - }); - } else if (typeof obj[prop] === "object") { - xml += `\n`; - xml += toXml({ ...obj[prop] }, indent + 1); - } else { - xml += `${obj[prop]}`; - } - xml += Array.isArray(obj[prop]) ? '' : `\n`; - }); - xml = xml.replace(/<\/?[0-9]{1,}>/g, ''); - return xml -} - -/** - * @param {string} fill The fill value (spaces to put in front of the value) - * @param {any} value The value to format - * @returns {string} - */ -export function formatXmlValue(fill, value) { - const typed = String(value); - const parts = typed.split('\n').filter(i => !!i); - const formatted = parts.map(i => `${fill}${i}`).join('\n'); - return formatted; -} - -/** - * @param {string} str A key or value to encode as x-www-form-urlencoded. - * @param {boolean=} replacePlus When set it replaces `%20` with `+`. - * @returns {string} . - */ -export function wwwFormUrlEncode(str, replacePlus=false) { - // Spec says to normalize newlines to \r\n and replace %20 spaces with +. - // jQuery does this as well, so this is likely to be widely compatible. - if (str === undefined) { - return ''; - } - let result = encodeURIComponent(String(str).replace(/\r?\n/g, '\r\n')); - if (replacePlus) { - result = result.replace(/%20/g, '+'); - } - return result; -} - -/** - * Processes a value that should be a number. - * @param {any} value - * @param {number=} [defaultValue=undefined] - * @returns {number|undefined} - */ -export function parseNumberInput(value, defaultValue=undefined) { - if (typeof value === 'number') { - return value; - } - const n = Number(value); - if (Number.isNaN(n)) { - return defaultValue; - } - return n; -} - -/** - * Processes a value that should be a number. - * @param {any} value - * @param {boolean=} [defaultValue=undefined] - * @returns {boolean|undefined} - */ -export function parseBooleanInput(value, defaultValue=undefined) { - const type = typeof value; - if (type === 'boolean') { - return value; - } - if (type === 'string') { - const trimmed = value.trim(); - if (trimmed === 'true') { - return true; - } - if (trimmed === 'false') { - return false; - } - } - return defaultValue; -} - -/** - * Casts the `value` to the corresponding data type - * @param {any} value - * @param {string} type The w3 schema type - * @returns {any} - */ -export function readTypedValue(value, type) { - if (value === undefined || value === null) { - return value; - } - switch (type) { - case ns.aml.vocabularies.shapes.number: - case ns.aml.vocabularies.shapes.integer: - case ns.aml.vocabularies.shapes.float: - case ns.aml.vocabularies.shapes.long: - case ns.aml.vocabularies.shapes.double: - case ns.w3.xmlSchema.number: - case ns.w3.xmlSchema.integer: - case ns.w3.xmlSchema.float: - case ns.w3.xmlSchema.long: - case ns.w3.xmlSchema.double: return parseNumberInput(value, 0); - case ns.aml.vocabularies.shapes.boolean: - case ns.w3.xmlSchema.boolean: return parseBooleanInput(value, false); - case ns.aml.vocabularies.shapes.nil: - case ns.w3.xmlSchema.nil: - return null; - default: - return value; - } -} - -/** - * Picks the union member to render. - * @param {ApiShapeUnion[]} anyOf The list of union members - * @param {string[]=} [selectedUnions=[]] Optional list of domain ids of currently selected unions. When set is returns a member that is "selected" or the first member otherwise. - * @returns {ApiShapeUnion} - */ -export function getUnionMember(anyOf, selectedUnions=[]) { - let renderedItem = /** @type ApiShapeUnion */ (null); - if (Array.isArray(selectedUnions) && selectedUnions.length) { - renderedItem = anyOf.find((item) => selectedUnions.includes(item.id)); - } - if (!renderedItem) { - [renderedItem] = anyOf; - } - return renderedItem; -} - -/** - * @param {ApiNodeShape} schema - * @param {string[]=} [selectedUnions=[]] - * @returns {ApiPropertyShape[]} - */ -export function collectNodeProperties(schema, selectedUnions) { - /** @type ApiPropertyShape[] */ - let result = []; - const { properties, inherits } = schema; - if (properties.length) { - result = [...properties]; - } - if (Array.isArray(inherits) && inherits.length) { - inherits.forEach((s) => { - let node = s; - if (node.types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - const union = /** @type ApiUnionShape */ (node); - const { anyOf=[] } = union; - node = getUnionMember(anyOf, selectedUnions); - } - if (!node.types.includes(ns.w3.shacl.NodeShape)) { - return; - } - const typed = /** @type ApiNodeShape */ (node); - // const p = typed.properties; - // if (Array.isArray(p) && p.length) { - // result = result.concat(p); - // } - const upper = collectNodeProperties(typed); - if (upper.length) { - result = result.concat(upper) - } - }); - } - /** @type ApiPropertyShape[] */ - const merged = []; - result.forEach((item) => { - const existing = merged.find(i => i.name === item.name); - if (existing) { - // this should (?) merge properties from the two. - return; - } - merged.push(item); - }); - return merged; -} diff --git a/src/schema/data-node/DataNodeBase.js b/src/schema/data-node/DataNodeBase.js deleted file mode 100644 index 58d0ad4..0000000 --- a/src/schema/data-node/DataNodeBase.js +++ /dev/null @@ -1,87 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { ns } from "../../helpers/Namespace.js"; -import { readTypedValue } from '../Utils.js'; - -/** @typedef {import('../../helpers/api').ApiObjectNode} ApiObjectNode */ -/** @typedef {import('../../helpers/api').ApiArrayNode} ApiArrayNode */ -/** @typedef {import('../../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */ - -/** - * Base class for all schema generators based on AMF's DataNode which includes AMF's examples. - */ -export class DataNodeBase { - /** - * @param {ApiDataNode} node The AMF data node to turn into a schema. - * @returns {any|undefined} Undefined when passed non-DataNode domain element. - */ - processNode(node) { - const { types } = node; - if (types.includes(ns.aml.vocabularies.data.Scalar)) { - return this.processScalarNode(/** @type ApiScalarNode */ (node)); - } - if (types.includes(ns.aml.vocabularies.data.Array)) { - return this.processArrayNode(/** @type ApiArrayNode */ (node)); - } - if (types.includes(ns.aml.vocabularies.data.Object)) { - return this.processObjectNode(/** @type ApiObjectNode */ (node)); - } - return undefined; - } - - /** - * @param {ApiScalarNode} scalar The scalar node to process. - * @returns {any} Scalar value. - */ - processScalarNode(scalar) { - return readTypedValue(scalar.value, scalar.dataType); - } - - /** - * @param {ApiArrayNode} array The array node to process. - * @returns {any[]} Array value. - */ - processArrayNode(array) { - const container = []; - array.members.forEach((member) => { - const result = this.processNode(member); - if (typeof result !== 'undefined') { - container.push(result); - } - }); - return container; - } - - /** - * @param {ApiObjectNode} object The object node to process. - * @returns {any} Object value. - */ - processObjectNode(object) { - const container = {}; - const { properties } = object; - Object.keys(properties).forEach((key) => { - const definition = properties[key]; - const result = this.processNode(definition); - if (typeof result !== 'undefined') { - const name = this.normalizePropertyName(key); - container[name] = result; - } - }); - return container; - } - - /** - * Normalizes a property name. It decodes URL encoded values. - * @param {string} name The property name to normalize - * @returns {string} - */ - normalizePropertyName(name) { - let result = name; - try { - result = decodeURIComponent(result) - } catch (e) { - // ... - } - return result; - } -} diff --git a/src/schema/data-node/JsonDataNodeGenerator.js b/src/schema/data-node/JsonDataNodeGenerator.js deleted file mode 100644 index ba04818..0000000 --- a/src/schema/data-node/JsonDataNodeGenerator.js +++ /dev/null @@ -1,26 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { DataNodeBase } from './DataNodeBase.js'; - -/** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */ - -/** - * A class that processes AMF's `structuredValue` into a JSON example. - */ -export class JsonDataNodeGenerator extends DataNodeBase { - /** - * Generates a JSON schema from the AMF's DataNode. - * - * @param {ApiDataNode} node The AMF's data node to transform into a schema. - * @returns {string|undefined} Undefined when passed non-DataNode domain element. - */ - generate(node) { - const result = this.processNode(node); - if (!result) { - return result; - } - if (typeof result === 'string') { - return result; - } - return JSON.stringify(result, null, 2); - } -} diff --git a/src/schema/data-node/README.md b/src/schema/data-node/README.md deleted file mode 100644 index 98e2d34..0000000 --- a/src/schema/data-node/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Data node based schema generators - -In this directory you will find libraries to generate a schema from AMF generated examples (DataNode). diff --git a/src/schema/data-node/UrlEncodedDataNodeGenerator.js b/src/schema/data-node/UrlEncodedDataNodeGenerator.js deleted file mode 100644 index e919db7..0000000 --- a/src/schema/data-node/UrlEncodedDataNodeGenerator.js +++ /dev/null @@ -1,47 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { wwwFormUrlEncode } from '../Utils.js'; -import { DataNodeBase } from './DataNodeBase.js'; - -/** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */ - -export class UrlEncodedDataNodeGenerator extends DataNodeBase { - /** - * Generates a JSON example from the structured value. - * @param {ApiDataNode} node The AMF's data node to transform into a schema. - * @param {string=} shapeName When provided it wraps the returned value with the shape name. - * @returns {string|undefined} Undefined when passed non-DataNode domain element. - */ - generate(node, shapeName) { - const result = this.processNode(node); - const isArray = Array.isArray(result); - if (shapeName && (typeof result !== 'object' || isArray)) { - if (isArray) { - return /** @type any[] */ (result).map(v => `${shapeName}[]=${v}`).filter(v => !!v).join('&'); - } - return `${shapeName}=${result}`; - } - return this.createUrlEncoded(result); - } - - /** - * @param {any} obj - * @returns {string} - */ - createUrlEncoded(obj) { - if (typeof obj !== 'object') { - return String(obj); - } - const parts = Object.keys(obj).map((key) => { - let value = obj[key]; - if (typeof value === 'object' && value !== null) { - value = this.createUrlEncoded(value); - } else if (value) { - value = wwwFormUrlEncode(value, true); - } else if (value === null) { - value = 'null'; - } - return `${key}=${value}`; - }); - return parts.join('&'); - } -} diff --git a/src/schema/data-node/XmlDataNodeGenerator.js b/src/schema/data-node/XmlDataNodeGenerator.js deleted file mode 100644 index 07ef667..0000000 --- a/src/schema/data-node/XmlDataNodeGenerator.js +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { DataNodeBase } from './DataNodeBase.js'; -import { toXml } from '../Utils.js'; - -/** @typedef {import('../../helpers/api').ApiDataNode} ApiDataNode */ -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** - * A class that processes AMF's `structuredValue` into an XML example. - */ -export class XmlDataNodeGenerator extends DataNodeBase { - /** - * Generates a JSON example from the structured value. - * - * @param {ApiDataNode} node The AMF's data node to transform into a schema. - * @param {string=} shapeName When provided it wraps the returned value with the shape name. - * @returns {string|undefined} Undefined when passed non-DataNode domain element. - */ - generate(node, shapeName) { - const result = this.processNode(node); - if (!result) { - return result; - } - if (shapeName) { - if (Array.isArray(result)) { - return result.map(v => `<${shapeName}>${v}`).filter(v => !!v).join('\n'); - } - return `<${shapeName}>${result}`; - } - return toXml(result); - } -} diff --git a/src/schema/shape/README.md b/src/schema/shape/README.md deleted file mode 100644 index c4e472b..0000000 --- a/src/schema/shape/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Shape based schema generators - -In this directory you will find libraries to generate a schema from AMF shapes. -This generates a schema taking shape properties into the account. diff --git a/src/schema/shape/ShapeBase.d.ts b/src/schema/shape/ShapeBase.d.ts deleted file mode 100644 index ecd30db..0000000 --- a/src/schema/shape/ShapeBase.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApiAnyShape, ApiArrayShape, ApiExample, ApiFileShape, ApiNodeShape, ApiPropertyShape, ApiScalarShape, ApiSchemaShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../../helpers/api'; -import { Time } from '@pawel-up/data-mock'; -import { ShapeRenderOptions } from '../../types.js'; - -export const scalarShapeObject: unique symbol; -export const nilShapeObject: unique symbol; -export const nodeShapeObject: unique symbol; -export const unionShapeObject: unique symbol; -export const fileShapeObject: unique symbol; -export const schemaShapeObject: unique symbol; -export const arrayShapeObject: unique symbol; -export const tupleShapeObject: unique symbol; -export const anyShapeObject: unique symbol; -export const propertyShapeObject: unique symbol; -export const exampleToObject: unique symbol; -// export const dataTypeToExample: unique symbol; -export const scalarValue: unique symbol; -export const isNotRequiredUnion: unique symbol; - -/** - * A base class for generators that generates a schema from AMF's shape definition. - */ -export abstract class ShapeBase { - opts: Readonly; - time: Time; - - constructor(opts?: ShapeRenderOptions); - - /** - * Generates a schema from AMF's shape. - * - * @param schema The Shape definition - * @returns The generated example - */ - abstract generate(schema: ApiShapeUnion): string|undefined; - - /** - * Serializes generated values into the final mime type related form. - * - * @returns The generated example - */ - abstract serialize(value: any): string|undefined; - [scalarValue](schema: ApiScalarShape): string|number|boolean; - - /** - * Checks whether the union represents a scalar + nil which is equivalent - * to having scalar that is not required. - * - * See more about nil values in RAML: - * https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#nil-type - * - * @param union The list of unions in the shape - */ - [isNotRequiredUnion](union: ApiShapeUnion[]): boolean; - - /** - * @param example The example to turn into a JS object - */ - abstract [exampleToObject](example: ApiExample): any; - abstract [scalarShapeObject](schema: ApiScalarShape): any; - abstract [nilShapeObject](schema: ApiScalarShape): any; - abstract [nodeShapeObject](schema: ApiNodeShape): any; - abstract [unionShapeObject](schema: ApiUnionShape): any; - abstract [fileShapeObject](schema: ApiFileShape): any; - abstract [schemaShapeObject](schema: ApiSchemaShape): any; - abstract [arrayShapeObject](schema: ApiArrayShape): any; - abstract [tupleShapeObject](schema: ApiTupleShape): any; - abstract [anyShapeObject](schema: ApiAnyShape): any; - abstract [propertyShapeObject](schema: ApiPropertyShape): any; -} diff --git a/src/schema/shape/ShapeBase.js b/src/schema/shape/ShapeBase.js deleted file mode 100644 index f1f8d28..0000000 --- a/src/schema/shape/ShapeBase.js +++ /dev/null @@ -1,278 +0,0 @@ -/* eslint-disable max-classes-per-file */ -/* eslint-disable no-unused-vars */ -/* eslint-disable class-methods-use-this */ -import { Time } from '@pawel-up/data-mock'; -import { ns } from "../../helpers/Namespace.js"; -import { ApiSchemaValues } from '../ApiSchemaValues.js'; -import { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js'; - -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../../helpers/api').ApiFileShape} ApiFileShape */ -/** @typedef {import('../../helpers/api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('../../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../../types').ShapeRenderOptions} ShapeRenderOptions */ - -export const scalarShapeObject = Symbol('scalarShapeObject'); -export const nilShapeObject = Symbol('nilShapeObject'); -export const nodeShapeObject = Symbol('nodeShapeObject'); -export const unionShapeObject = Symbol('unionShapeObject'); -export const fileShapeObject = Symbol('fileShapeObject'); -export const schemaShapeObject = Symbol('schemaShapeObject'); -export const arrayShapeObject = Symbol('arrayShapeObject'); -export const tupleShapeObject = Symbol('tupleShapeObject'); -export const anyShapeObject = Symbol('anyShapeObject'); -export const propertyShapeObject = Symbol('propertyShapeObject'); -export const exampleToObject = Symbol('exampleToObject'); -// export const dataTypeToExample = Symbol('dataTypeToExample'); -export const scalarValue = Symbol('scalarExampleValue'); -export const isNotRequiredUnion = Symbol('isNotRequiredUnion'); - -/** - * A base class for generators that generates a schema from AMF's shape definition. - */ -export class ShapeBase { - /** - * @param {ShapeRenderOptions=} opts - */ - constructor(opts={}) { - /** - * @type Readonly - */ - this.opts = Object.freeze({ ...opts }); - - this.time = new Time(); - } - - /** - * Generates a schema from AMF's shape. - * @abstract - * @param {ApiShapeUnion} schema The Shape definition - * @returns {string|undefined} The generated example - */ - generate(schema) { - return undefined; - } - - /** - * Serializes generated values into the final mime type related form. - * @abstract - * @param {any} value - * @returns {string|undefined} The generated example - */ - serialize(value) { - return undefined; - } - - // /** - // * Transforms a scalar data type to a corresponding default example value. - // * @param {string} dataType The data type namespace value - // * @param {string=} format The data format - // * @return {string|number|boolean} - // */ - // [dataTypeToExample](dataType, format) { - // switch (dataType) { - // case ns.w3.xmlSchema.string: return ''; - // case ns.w3.xmlSchema.number: - // case ns.w3.xmlSchema.float: - // case ns.w3.xmlSchema.double: - // case ns.w3.xmlSchema.integer: - // case ns.w3.xmlSchema.long: - // return 0; - // case ns.w3.xmlSchema.boolean: return false; - // case ns.w3.xmlSchema.nil: return null; - // case ns.w3.xmlSchema.date: return this.time.dateOnly(); - // case ns.w3.xmlSchema.dateTime: return this.time.dateTime(/** @type {"rfc3339" | "rfc2616"} */ (format)); - // case ns.aml.vocabularies.shapes.dateTimeOnly: return this.time.dateTimeOnly(); - // case ns.w3.xmlSchema.time: return this.time.timeOnly(); - // case ns.w3.xmlSchema.base64Binary: return ''; - // default: return undefined; - // } - // } - - /** - * @param {ApiScalarShape} schema - * @returns {string|number|boolean} - */ - [scalarValue](schema) { - const { defaultValue, examples, values, inherits, dataType } = schema; - // check the default value - if (!this.opts.renderExamples && defaultValue) { - const gen = new JsonDataNodeGenerator(); - const processed = gen.processNode(defaultValue); - // return ApiSchemaValues.readTypedValue(processed, dataType); - return processed; - } - // check examples - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (typeof value !== 'undefined') { - return ApiSchemaValues.readTypedValue(value, dataType); - } - } - // check enum values - if (values && values.length) { - const typed = /** @type ApiScalarNode */ (values[0]); - if (typed.value !== undefined) { - return ApiSchemaValues.readTypedValue(typed.value, dataType); - } - } - // check parents - if (Array.isArray(inherits) && inherits.length) { - for (let i = 0, len = inherits.length; i < len; i+=1) { - const result = this[scalarValue](/** @type ApiScalarShape */ (inherits[i])); - if (result !== undefined) { - return result; - } - } - } - // return this[dataTypeToExample](dataType, format); - // create a default value. - return ApiSchemaValues.generateDefaultValue(schema); - } - - /** - * Checks whether the union represents a scalar + nil which is equivalent - * to having scalar that is not required. - * - * See more about nil values in RAML: - * https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#nil-type - * - * @param {ApiShapeUnion[]} union The list of unions in the shape - * @returns {boolean} - */ - [isNotRequiredUnion](union) { - let scalars = 0; - let hasNil = false; - - union.forEach((i) => { - if (i.types.includes(ns.aml.vocabularies.shapes.NilShape)) { - hasNil = true; - } else if (i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - const scalar = /** @type ApiScalarShape */ (i); - if (scalar.dataType === ns.w3.xmlSchema.nil) { - hasNil = true; - } else { - scalars += 1; - } - } else if (i.types.includes(ns.aml.vocabularies.shapes.FileShape)) { - scalars += 1; - } - }); - if (!hasNil) { - return false; - } - // size of union minus the nil union - if (scalars === union.length - 1) { - return true; - } - return false; - } - - /** - * @abstract - * @param {ApiExample} example The example to turn into a JS object - * @returns {any} - */ - [exampleToObject](example) { - return undefined; - } - - /** - * @abstract - * @param {ApiScalarShape} schema - * @returns {any} - */ - [scalarShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiScalarShape} schema - * @returns {any} - */ - [nilShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiNodeShape} schema - * @returns {any} - */ - [nodeShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiUnionShape} schema - * @returns {any} - */ - [unionShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiFileShape} schema - * @returns {any} - */ - [fileShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiSchemaShape} schema - * @returns {any} - */ - [schemaShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiArrayShape} schema - * @returns {any} - */ - [arrayShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiTupleShape} schema - * @returns {any} - */ - [tupleShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiAnyShape} schema - * @returns {any} - */ - [anyShapeObject](schema) { - return undefined; - } - - /** - * @abstract - * @param {ApiPropertyShape} schema - * @returns {any} - */ - [propertyShapeObject](schema) { - return undefined; - } -} diff --git a/src/schema/shape/ShapeJsonSchemaGenerator.d.ts b/src/schema/shape/ShapeJsonSchemaGenerator.d.ts deleted file mode 100644 index c0a3311..0000000 --- a/src/schema/shape/ShapeJsonSchemaGenerator.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ApiAnyShape, ApiArrayShape, ApiDataNodeUnion, ApiExample, ApiFileShape, ApiNodeShape, ApiPropertyShape, ApiScalarShape, ApiSchemaShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../../helpers/api'; -import { - ShapeBase, - scalarShapeObject, - nodeShapeObject, - unionShapeObject, - fileShapeObject, - schemaShapeObject, - arrayShapeObject, - tupleShapeObject, - anyShapeObject, - propertyShapeObject, - exampleToObject, - nilShapeObject, -} from './ShapeBase.js'; - -export const unionDefaultValue: unique symbol; - -export declare class ShapeJsonSchemaGenerator extends ShapeBase { - /** - * Generates a schema from AMF's shape. - * - * @param schema The Shape definition - */ - generate(schema: ApiShapeUnion): string|undefined; - - /** - * Processes the Shape definition and returns a JavaScript object or array. - */ - toObject(schema: ApiShapeUnion): any; - serialize(value: any): string|undefined; - [scalarShapeObject](schema: ApiScalarShape): any|undefined; - [nilShapeObject](schema: ApiScalarShape): any|undefined; - [nodeShapeObject](schema: ApiNodeShape): object; - [unionShapeObject](schema: ApiUnionShape): any; - - /** - * @param union The list of unions in the shape - * @param defaultValue The definition of a default value. - */ - [unionDefaultValue](union: ApiShapeUnion[], defaultValue: ApiDataNodeUnion): any|undefined; - [arrayShapeObject](schema: ApiArrayShape): any[]; - [tupleShapeObject](schema: ApiTupleShape): any; - [anyShapeObject](schema: ApiAnyShape): any; - - /** - * @returns The value for the property or undefined when cannot generate the value. - */ - [propertyShapeObject](schema: ApiPropertyShape): any|undefined; - - /** - * @param example The example to turn into a JS object - */ - [exampleToObject](example: ApiExample): any; - - [fileShapeObject](schema: ApiFileShape): any; - [schemaShapeObject](schema: ApiSchemaShape): any; -} diff --git a/src/schema/shape/ShapeJsonSchemaGenerator.js b/src/schema/shape/ShapeJsonSchemaGenerator.js deleted file mode 100644 index 9c5fc4e..0000000 --- a/src/schema/shape/ShapeJsonSchemaGenerator.js +++ /dev/null @@ -1,395 +0,0 @@ -/* eslint-disable no-unused-vars */ -/* eslint-disable class-methods-use-this */ -import { ns } from "../../helpers/Namespace.js"; -import { - ShapeBase, - scalarShapeObject, - nilShapeObject, - nodeShapeObject, - unionShapeObject, - fileShapeObject, - schemaShapeObject, - arrayShapeObject, - tupleShapeObject, - anyShapeObject, - scalarValue, - propertyShapeObject, - exampleToObject, - isNotRequiredUnion, -} from './ShapeBase.js'; -import { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js'; -// import { ApiSchemaValues } from '../ApiSchemaValues.js'; - -export const unionDefaultValue = Symbol('unionDefaultValue'); - -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../../helpers/api').ApiFileShape} ApiFileShape */ -/** @typedef {import('../../helpers/api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('../../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../../helpers/api').ApiDataNodeUnion} ApiDataNodeUnion */ - -export class ShapeJsonSchemaGenerator extends ShapeBase { - /** - * Generates a schema from AMF's shape. - * - * @param {ApiShapeUnion} schema The Shape definition - * @returns {string} - */ - generate(schema) { - const result = this.toObject(schema); - if (result !== null && typeof result === 'object') { - return this.serialize(result); - } - return result; - } - - /** - * Processes the Shape definition and returns a JavaScript object or array. - * @param {ApiShapeUnion} schema - * @returns {any} - */ - toObject(schema) { - const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this[scalarShapeObject](/** @type ApiScalarShape */ (schema)); - } - if (types.includes(ns.w3.shacl.NodeShape)) { - return this[nodeShapeObject](/** @type ApiNodeShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this[unionShapeObject](/** @type ApiUnionShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { - return this[fileShapeObject](/** @type ApiFileShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) { - return this[schemaShapeObject](/** @type ApiSchemaShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this[tupleShapeObject](/** @type ApiTupleShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this[arrayShapeObject](/** @type ApiArrayShape */ (schema)); - } - return this[anyShapeObject](/** @type ApiAnyShape */ (schema)); - } - - /** - * Serializes generated JS value according to the mime type. - * @param {any} value - * @returns {string|undefined} - */ - serialize(value) { - return JSON.stringify(value, null, 2); - } - - /** - * @param {ApiScalarShape} schema - * @returns {any|undefined} - */ - [scalarShapeObject](schema) { - return this[scalarValue](schema); - } - - /** - * @param {ApiScalarShape} schema - * @returns {any|undefined} - */ - [nilShapeObject](schema) { - return null; - } - - /** - * @param {ApiNodeShape} schema - * @returns {object} - */ - [nodeShapeObject](schema) { - const { inherits } = schema; - let { examples=[] } = schema; - if (Array.isArray(inherits) && inherits.length) { - inherits.forEach((parent) => { - const anyParent = /** @type ApiAnyShape */ (parent); - if (Array.isArray(anyParent.examples) && anyParent.examples.length) { - examples = examples.concat(anyParent.examples); - } - }); - } - if (this.opts.renderExamples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (value !== undefined) { - return value; - } - } - let result = {}; - const { properties } = schema; - if (Array.isArray(inherits) && inherits.length) { - inherits.forEach(((s) => { - const part = this.toObject(s); - if (typeof part === 'object') { - result = { ...result, ...part }; - } - })); - } - properties.forEach((property) => { - const { name } = property; - const value = this[propertyShapeObject](property); - if (typeof value !== 'undefined') { - result[name] = value; - } - }); - return result; - } - - /** - * @param {ApiUnionShape} schema - * @returns {any} - */ - [unionShapeObject](schema) { - let { anyOf=[], examples=[] } = schema; - if (Array.isArray(schema.inherits) && schema.inherits) { - schema.inherits.forEach((parent) => { - const anyParent = /** @type ApiAnyShape */ (parent); - if (Array.isArray(anyParent.examples) && anyParent.examples.length) { - examples = examples.concat(anyParent.examples); - } - const typed = /** @type ApiUnionShape */ (parent); - if (Array.isArray(typed.anyOf) && typed.anyOf.length) { - anyOf = anyOf.concat(typed.anyOf); - } - }); - } - const { opts } = this; - if (Array.isArray(anyOf) && anyOf.length) { - if (this[isNotRequiredUnion](anyOf)) { - // This generates schema for required values. - // This implicitly mean that the property is not required therefore the value should - // not be generated. - return undefined; - } - if (this.opts.renderExamples) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (value !== undefined) { - return value; - } - } - if (schema.defaultValue) { - return this[unionDefaultValue](anyOf, schema.defaultValue); - } - const { selectedUnions } = opts; - let renderedItem = /** @type ApiShapeUnion */ (null); - if (selectedUnions && selectedUnions.length) { - renderedItem = anyOf.find((item) => selectedUnions.includes(item.id)); - } else { - [renderedItem] = anyOf; - } - if (renderedItem) { - return this.toObject(renderedItem); - } - } - return undefined; - } - - /** - * @param {ApiShapeUnion[]} union The list of unions in the shape - * @param {ApiDataNodeUnion} defaultValue The definition of a default value. - * @returns {any|undefined} - */ - [unionDefaultValue](union, defaultValue) { - const gen = new JsonDataNodeGenerator(); - const result = gen.generate(defaultValue); - let hasNumber = false; - let hasBoolean = false; - let hasNil = false; - union.forEach((i) => { - if (i.types.includes(ns.aml.vocabularies.shapes.NilShape)) { - hasNil = true; - } - if (!i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return; - } - const scalar = /** @type ApiScalarShape */ (i); - if (!hasBoolean) { - hasBoolean = scalar.dataType === ns.w3.xmlSchema.boolean; - } - if (!hasNumber) { - hasNumber = [ - ns.w3.xmlSchema.number, - ns.w3.xmlSchema.long, - ns.w3.xmlSchema.integer, - ns.w3.xmlSchema.float, - ns.w3.xmlSchema.double, - ns.aml.vocabularies.shapes.number, - ns.aml.vocabularies.shapes.long, - ns.aml.vocabularies.shapes.integer, - ns.aml.vocabularies.shapes.float, - ns.aml.vocabularies.shapes.double, - ].includes(scalar.dataType); - } - if (!hasNil) { - hasNil = scalar.dataType === ns.w3.xmlSchema.nil; - } - }); - if (hasNumber) { - const parsed = Number(result); - if (!Number.isNaN(parsed)) { - return parsed; - } - } - if (hasBoolean) { - if (result === 'true') { - return true; - } - if (result === 'false') { - return false; - } - } - if (hasNil && (result === 'null' || result === 'nil')) { - return null; - } - return result; - } - - /** - * @param {ApiArrayShape} schema - * @returns {array} - */ - [arrayShapeObject](schema) { - const { items } = schema; - const defaultValue = schema.defaultValue || items.defaultValue; - let { examples=[] } = schema; - const anyItems = /** @type ApiAnyShape */ (items); - if (Array.isArray(anyItems.examples)) { - examples = examples.concat(anyItems.examples); - } - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (Array.isArray(value)) { - return value; - } - if (typeof value !== 'undefined') { - return [value]; - } - } - if (defaultValue) { - const gen = new JsonDataNodeGenerator(); - const arr = gen.processNode(defaultValue); - if (Array.isArray(arr)) { - return arr; - } - } - const value = this.toObject(items); - if (typeof value !== 'undefined') { - return [value]; - } - return []; - } - - /** - * @param {ApiTupleShape} schema - * @returns {any} - */ - [tupleShapeObject](schema) { - const { items, examples } = schema; - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (typeof value !== 'undefined') { - return [value]; - } - } - if (schema.defaultValue) { - const gen = new JsonDataNodeGenerator(); - const arr = gen.processNode(schema.defaultValue); - if (Array.isArray(arr)) { - return arr; - } - } - if (items.length) { - const result = []; - items.forEach((i) => { - const value = this.toObject(i); - if (typeof value !== 'undefined') { - result.push(value); - } - }); - return result; - } - return []; - } - - /** - * @param {ApiAnyShape} schema - * @returns {any} - */ - [anyShapeObject](schema) { - const { and=[] } = schema; - if (and.length) { - let result = {}; - and.forEach((item) => { - const props = this.toObject(item); - if (typeof props === 'object') { - result = { ...result, ...props }; - } - }); - return result; - } - return this[scalarShapeObject](schema); - } - - /** - * @param {ApiPropertyShape} schema - * @returns {any|undefined} The value for the property or undefined when cannot generate the value. - */ - [propertyShapeObject](schema) { - const { range, minCount=0 } = schema; - if (minCount === 0 && !this.opts.renderOptional) { - return undefined; - } - const { types } = range; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - // const defaultValue = schema.defaultValue || range.defaultValue; - // if (!this.opts.renderExamples && defaultValue) { - // const gen = new JsonDataNodeGenerator(); - // const value = gen.generate(defaultValue); - // if (value) { - // return ApiSchemaValues.readTypedValue(value, /** @type ApiScalarShape */ (range).dataType); - // } - // } - const anyRange = /** @type ApiAnyShape */ (range); - return this[scalarShapeObject](anyRange); - } - return this.toObject(range); - } - - /** - * @param {ApiExample} example The example to turn into a JS object - * @returns {any} - */ - [exampleToObject](example) { - if (example && example.structuredValue) { - const jsonGenerator = new JsonDataNodeGenerator(); - return jsonGenerator.processNode(example.structuredValue); - } - return undefined; - } - - // eslint-disable-next-line no-unused-vars - [fileShapeObject](schema) { - return super[fileShapeObject](undefined); - } - - // eslint-disable-next-line no-unused-vars - [schemaShapeObject](schema) { - return super[schemaShapeObject](undefined); - } -} diff --git a/src/schema/shape/ShapeXmlSchemaGenerator.d.ts b/src/schema/shape/ShapeXmlSchemaGenerator.d.ts deleted file mode 100644 index fe979ff..0000000 --- a/src/schema/shape/ShapeXmlSchemaGenerator.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { ApiAnyShape, ApiArrayShape, ApiDataNodeUnion, ApiExample, ApiFileShape, ApiNodeShape, ApiPropertyShape, ApiScalarShape, ApiSchemaShape, ApiShapeUnion, ApiTupleShape, ApiUnionShape } from '../../helpers/api'; -import { - ShapeBase, - scalarShapeObject, - nodeShapeObject, - unionShapeObject, - arrayShapeObject, - propertyShapeObject, - exampleToObject, - fileShapeObject, - schemaShapeObject, - tupleShapeObject, - anyShapeObject, - nilShapeObject, -} from './ShapeBase.js'; - -interface ProcessNodeOptions { - forceName?: string; - indent?: number; -} - -/** - * Normalizes given name to a value that can be accepted by `createElement` - * function on a document object. - * @param name A name to process - * @return Normalized name - */ -export function normalizeXmlTagName(name: string): string; - -export const collectProperties: unique symbol; -export const unionDefaultValue: unique symbol; -export const readCurrentUnion: unique symbol; - -export function shapeToXmlTagName(shape: ApiAnyShape): string; - -export class ShapeXmlSchemaGenerator extends ShapeBase { - /** - * Generates a XML example from the structured value. - * - * @param schema The Shape definition - */ - generate(schema: ApiShapeUnion): string; - - /** - * Processes the Shape definition and returns a JavaScript object or array. - */ - processNode(schema: ApiShapeUnion, options?: ProcessNodeOptions): string; - - /** - * Serializes generated JS value according to the mime type. - */ - serialize(value: any): string|undefined; - - /** - * Picks the union member to render. - */ - [readCurrentUnion](anyOf: ApiShapeUnion[]): ApiShapeUnion; - - [collectProperties](schema: ApiNodeShape): ApiPropertyShape[]; - - /** - * @param fill The fill value (spaces) - * @param value The value to format - */ - formatValue(fill: string, value: any): string; - - [nodeShapeObject](schema: ApiNodeShape, options?: ProcessNodeOptions): string; - [scalarShapeObject](schema: ApiScalarShape, options?: ProcessNodeOptions): string; - [nilShapeObject](schema: ApiScalarShape, options?: ProcessNodeOptions): any|undefined; - - /** - * @returns The value for the property or undefined when cannot generate the value. - */ - [propertyShapeObject](schema: ApiPropertyShape, options?: ProcessNodeOptions): string; - - [arrayShapeObject](schema: ApiArrayShape, options?: ProcessNodeOptions): string; - - /** - * @param example The example to turn into a JS object - */ - [exampleToObject](example: ApiExample): any|undefined; - - [unionShapeObject](schema: ApiUnionShape, options?: ProcessNodeOptions): string|undefined; - - /** - * @param schema The schema with unions - * @param defaultValue The definition of a default value. - */ - [unionDefaultValue](schema: ApiShapeUnion, defaultValue: ApiDataNodeUnion, options?: ProcessNodeOptions): string; - - [fileShapeObject](schema: ApiFileShape): any; - [schemaShapeObject](schema: ApiSchemaShape): any; - [tupleShapeObject](schema: ApiTupleShape): any; - [anyShapeObject](schema: ApiAnyShape): any; -} diff --git a/src/schema/shape/ShapeXmlSchemaGenerator.js b/src/schema/shape/ShapeXmlSchemaGenerator.js deleted file mode 100644 index f351f5d..0000000 --- a/src/schema/shape/ShapeXmlSchemaGenerator.js +++ /dev/null @@ -1,531 +0,0 @@ -/* eslint-disable class-methods-use-this */ -import { ns } from "../../helpers/Namespace.js"; -import { - ShapeBase, - scalarShapeObject, - nilShapeObject, - nodeShapeObject, - unionShapeObject, - fileShapeObject, - schemaShapeObject, - arrayShapeObject, - tupleShapeObject, - anyShapeObject, - scalarValue, - propertyShapeObject, - exampleToObject, - isNotRequiredUnion, -} from './ShapeBase.js'; -import { XmlDataNodeGenerator } from '../data-node/XmlDataNodeGenerator.js'; -import { collectNodeProperties, formatXmlValue, getUnionMember } from '../Utils.js'; - -/** @typedef {import('../../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../../helpers/api').ApiScalarShape} ApiScalarShape */ -/** @typedef {import('../../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../../helpers/api').ApiUnionShape} ApiUnionShape */ -/** @typedef {import('../../helpers/api').ApiFileShape} ApiFileShape */ -/** @typedef {import('../../helpers/api').ApiSchemaShape} ApiSchemaShape */ -/** @typedef {import('../../helpers/api').ApiArrayShape} ApiArrayShape */ -/** @typedef {import('../../helpers/api').ApiTupleShape} ApiTupleShape */ -/** @typedef {import('../../helpers/api').ApiAnyShape} ApiAnyShape */ -/** @typedef {import('../../helpers/api').ApiPropertyShape} ApiPropertyShape */ -/** @typedef {import('../../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../../helpers/api').ApiDataNodeUnion} ApiDataNodeUnion */ - -/** - * @typedef ProcessNodeOptions - * @property {string=} forceName - * @property {number=} indent - */ - -/** - * Normalizes given name to a value that can be accepted by `createElement` - * function on a document object. - * @param {String} name A name to process - * @return {String} Normalized name - */ -export const normalizeXmlTagName = name => name.replace(/[^a-zA-Z0-9-_.]/g, ''); -const UNKNOWN_TYPE = 'unknown-type'; - -export const collectProperties = Symbol('collectProperties'); -export const unionDefaultValue = Symbol('unionDefaultValue'); -export const readCurrentUnion = Symbol('readCurrentUnion'); - -/** - * @param {ApiAnyShape} shape - */ -export function shapeToXmlTagName(shape) { - const { name, inherits=[], xmlSerialization } = shape; - let label = xmlSerialization && xmlSerialization.name ? xmlSerialization.name : name || UNKNOWN_TYPE; - if (label === 'schema' && inherits.length) { - const n = inherits.find(i => i.name && i.name !== 'schema'); - if (n) { - label = n.name === 'type' ? n.displayName || n.name : n.name; - } - } - return normalizeXmlTagName(label); -} - -export class ShapeXmlSchemaGenerator extends ShapeBase { - /** - * Generates a XML example from the structured value. - * - * @param {ApiShapeUnion} schema The Shape definition - * @returns {string} - */ - generate(schema) { - const value = this.processNode(schema); - return value; - } - - /** - * Processes the Shape definition and returns a JavaScript object or array. - * @param {ApiShapeUnion} schema - * @param {ProcessNodeOptions=} options - * @returns {string} - */ - processNode(schema, options={}) { - const { types } = schema; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this[scalarShapeObject](/** @type ApiScalarShape */ (schema), options); - } - if (types.includes(ns.w3.shacl.NodeShape)) { - return this[nodeShapeObject](/** @type ApiNodeShape */ (schema), options); - } - if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - return this[unionShapeObject](/** @type ApiUnionShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.FileShape)) { - return this[fileShapeObject](/** @type ApiFileShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) { - return this[schemaShapeObject](/** @type ApiSchemaShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) { - return this[tupleShapeObject](/** @type ApiTupleShape */ (schema)); - } - if (types.includes(ns.aml.vocabularies.shapes.ArrayShape) || types.includes(ns.aml.vocabularies.shapes.MatrixShape)) { - return this[arrayShapeObject](/** @type ApiArrayShape */ (schema), options); - } - return this[anyShapeObject](/** @type ApiAnyShape */ (schema)); - } - - /** - * Serializes generated JS value according to the mime type. - * @param {any} value - * @returns {string|undefined} - */ - serialize(value) { - return value; - } - - /** - * Picks the union member to render. - * @param {ApiShapeUnion[]} anyOf - * @returns {ApiShapeUnion} - */ - [readCurrentUnion](anyOf) { - const { selectedUnions } = this.opts; - return getUnionMember(anyOf, selectedUnions); - } - - /** - * @param {ApiNodeShape} schema - * @returns {ApiPropertyShape[]} - */ - [collectProperties](schema) { - const { selectedUnions } = this.opts; - return collectNodeProperties(schema, selectedUnions); - } - - /** - * @param {ApiNodeShape} schema - * @param {ProcessNodeOptions=} options - * @returns {string} - */ - [nodeShapeObject](schema, options={}) { - const { inherits } = schema; - let { examples=[] } = schema; - if (Array.isArray(inherits) && inherits.length) { - inherits.forEach((parent) => { - let node = parent; - if (node.types.includes(ns.aml.vocabularies.shapes.UnionShape)) { - const union = /** @type ApiUnionShape */ (node); - const { anyOf=[] } = union; - node = this[readCurrentUnion](anyOf); - } - const anyShape = /** @type ApiAnyShape */ (node); - if (Array.isArray(anyShape.examples) && anyShape.examples.length) { - examples = examples.concat(anyShape.examples); - } - }); - } - - const label = options.forceName || shapeToXmlTagName(schema); - const attributes = []; - const parts = []; - const currentIndent = (options.indent || 0); - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (typeof value !== 'undefined') { - const fillTag = new Array(currentIndent * 2 + 0).fill(' ').join(''); - const fillValue = new Array(currentIndent * 2 + 2).fill(' ').join(''); - parts.push(`${fillTag}<${label}>`); - parts.push(formatXmlValue(fillValue, value)); - parts.push(`${fillTag}`); - return parts.join('\n'); - } - } - const properties = this[collectProperties](schema); - properties.forEach((property) => { - const { range, minCount=0 } = property; - if (minCount === 0 && !this.opts.renderOptional) { - return; - } - const anyRange = /** @type ApiAnyShape */ (range); - if (anyRange.xmlSerialization) { - // Adds to the parent attributes list. - // When a non-scalar shape has `attribute` serialization this is an API spec error. - // Ignore such situation. - if (anyRange.xmlSerialization.attribute && anyRange.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - let aLabel = normalizeXmlTagName(anyRange.xmlSerialization.name ? anyRange.xmlSerialization.name : property.name || anyRange.name || UNKNOWN_TYPE); - if (anyRange.xmlSerialization.prefix) { - aLabel = `${anyRange.xmlSerialization.prefix}:${aLabel}`; - } - const value = this[scalarValue](anyRange); - attributes.push(`${aLabel}="${value}"`); - return; - } - } - const value = this[propertyShapeObject](property, { indent: currentIndent }); - if (typeof value !== 'undefined') { - const fill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - parts.push(formatXmlValue(fill, value)); - } - }); - - let opening = `<${label}`; - if (attributes.length) { - opening += ' '; - opening += attributes.join(' '); - } - parts.unshift(`${opening}>`); - const fill = new Array(currentIndent*2).fill(' ').join(''); - parts.push(`${fill}`); - return parts.join('\n'); - } - - /** - * @param {ApiScalarShape} schema - * @param {ProcessNodeOptions=} options - * @returns {any|undefined} - */ - [scalarShapeObject](schema, options={}) { - const { xmlSerialization, defaultValue } = schema; - let content; - if (defaultValue) { - const gen = new XmlDataNodeGenerator(); - content = gen.processNode(defaultValue); - } else { - content = this[scalarValue](schema); - } - let label = options.forceName || shapeToXmlTagName(schema); - const attributes = []; - const parts = []; - if (xmlSerialization) { - const { namespace, prefix } = xmlSerialization; - if (namespace) { - const attrName = prefix ? `xmlns:${prefix}` : 'xmlns'; - attributes.push(`${attrName}="${namespace}"`); - } - if (prefix) { - label = `${prefix}:${label}`; - } - } - let opening = `<${label}`; - if (attributes.length) { - opening += ' '; - opening += attributes.join(' '); - } - opening += '>'; - parts.push(opening); - parts.push(content); - parts.push(``); - - return parts.join(''); - } - - /** - * @param {ApiScalarShape} schema - * @param {ProcessNodeOptions=} options - * @returns {any|undefined} - */ - [nilShapeObject](schema, options={}) { - const { xmlSerialization } = schema; - const content = ''; - let label = options.forceName || shapeToXmlTagName(schema); - const attributes = []; - const parts = []; - if (xmlSerialization) { - const { namespace, prefix } = xmlSerialization; - if (namespace) { - const attrName = prefix ? `xmlns:${prefix}` : 'xmlns'; - attributes.push(`${attrName}="${namespace}"`); - } - if (prefix) { - label = `${prefix}:${label}`; - } - } - let opening = `<${label}`; - if (attributes.length) { - opening += ' '; - opening += attributes.join(' '); - } - opening += '>'; - parts.push(opening); - parts.push(content); - parts.push(``); - - return parts.join(''); - } - - /** - * @param {ApiPropertyShape} schema - * @param {ProcessNodeOptions=} options - * @returns {string|undefined} The value for the property or undefined when cannot generate the value. - */ - [propertyShapeObject](schema, options) { - const { range, minCount=0 } = schema; - if (minCount === 0 && !this.opts.renderOptional) { - return undefined; - } - const { types } = range; - if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) { - return this[scalarShapeObject](/** @type ApiScalarShape */ (range)); - } - if (types.includes(ns.aml.vocabularies.shapes.NilShape)) { - return this[nilShapeObject](/** @type ApiScalarShape */ (range)); - } - return this.processNode(range, options); - } - - /** - * @param {ApiArrayShape} schema - * @param {ProcessNodeOptions=} options - * @returns {string} - */ - [arrayShapeObject](schema, options={}) { - const { items, xmlSerialization } = schema; - const label = shapeToXmlTagName(schema); - const currentIndent = (options.indent || 0); - const rootFill = new Array(currentIndent*2).fill(' ').join(''); - const parts = [ - `${rootFill}<${label}>` - ]; - let nodeName = label; - const anyItems = /** @type ApiAnyShape */ (items); - if (anyItems.xmlSerialization && anyItems.xmlSerialization.name) { - nodeName = normalizeXmlTagName(anyItems.xmlSerialization.name); - } - // Note about wrapping. - // XML array values are not wrapped by default. This means that by default - // it produces a value like this: - // - // - // - // - // When the object is marked as wrapped then the object is rendered as follows - // - // - // - // - // - // - const isWrapped = xmlSerialization && !!xmlSerialization.wrapped; - const defaultValue = schema.defaultValue || items.defaultValue; - let itemName; - if (isWrapped) { - try { - // @ts-ignore - itemName = shapeToXmlTagName(schema.items); - } catch (e) { - itemName = 'UNKNOWN-NAME' - } - } - let { examples=[] } = schema; - if (Array.isArray(anyItems.examples)) { - examples = examples.concat(anyItems.examples); - } - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (typeof value !== 'undefined') { - const tagFill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - const valueFill = new Array(currentIndent * 2 + 4).fill(' ').join(''); - parts.push(`${tagFill}<${nodeName}>`); - parts.push(`${valueFill}${value}`); - parts.push(`${tagFill}`); - } - } else if (defaultValue) { - const gen = new XmlDataNodeGenerator(); - const value = gen.generate(defaultValue); - if (value) { - const tagFill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - const valueFill = new Array(currentIndent * 2 + 4).fill(' ').join(''); - parts.push(`${tagFill}<${nodeName}>`); - parts.push(`${valueFill}${value.trim()}`); - parts.push(`${tagFill}`); - } - } else if (items.types.includes(ns.w3.shacl.NodeShape)) { - const typed = /** @type ApiNodeShape */ (items); - const tagFill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - const valueFill = isWrapped ? new Array(currentIndent * 2 + 4).fill(' ').join('') : tagFill; - if (isWrapped) { - parts.push(`${tagFill}<${itemName}>`); - } - const properties = this[collectProperties](typed); - properties.forEach((prop) => { - const value = this[propertyShapeObject](prop); - if (value) { - parts.push(`${valueFill}${value}`); - } - }); - if (isWrapped) { - parts.push(`${tagFill}`); - } - } else { - const opts = { - forceName: nodeName, - indent: currentIndent + 1, - }; - const value = this.processNode(items, opts); - if (typeof value !== 'undefined') { - const fill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - parts.push(`${fill}${value}`); - } - } - - parts.push(`${rootFill}`); - return parts.join('\n'); - } - - /** - * @param {ApiExample} example The example to turn into a JS object - * @returns {any} - */ - [exampleToObject](example) { - if (example && example.structuredValue) { - const generator = new XmlDataNodeGenerator(); - return generator.generate(example.structuredValue); - } - return undefined; - } - - /** - * @param {ApiUnionShape} schema - * @param {ProcessNodeOptions=} options - * @returns {any} - */ - [unionShapeObject](schema, options={}) { - let { anyOf=[], examples=[] } = schema; - if (Array.isArray(schema.inherits) && schema.inherits) { - schema.inherits.forEach((parent) => { - const anyParent = /** @type ApiAnyShape */ (parent); - if (Array.isArray(anyParent.examples) && anyParent.examples.length) { - examples = examples.concat(anyParent.examples); - } - const typed = /** @type ApiUnionShape */ (parent); - if (Array.isArray(typed.anyOf) && typed.anyOf.length) { - anyOf = anyOf.concat(typed.anyOf); - } - }); - } - if (Array.isArray(anyOf) && anyOf.length) { - if (this[isNotRequiredUnion](anyOf)) { - // This generates schema for required values. - // This implicitly mean that the property is not required therefore the value should - // not be generated. - return undefined; - } - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - if (value !== undefined) { - const label = shapeToXmlTagName(schema); - const currentIndent = (options.indent || 0); - const rootFill = new Array(currentIndent*2).fill(' ').join(''); - const valueFill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - const parts = []; - parts.push(`${rootFill}<${label}>`); - const formatted = String(value).split('\n').filter(i => !!i).map(i => `${valueFill}${i}`).join('\n'); - parts.push(`${formatted}`); - parts.push(`${rootFill}`); - return parts.join('\n'); - } - if (schema.defaultValue) { - return this[unionDefaultValue](schema, schema.defaultValue); - } - const member = this[readCurrentUnion](anyOf); - if (member) { - return this.processNode(member, { ...options, forceName: schema.name }); - } - } - return undefined; - } - - /** - * @param {ApiShapeUnion} schema The schema with unions - * @param {ApiDataNodeUnion} defaultValue The definition of a default value. - * @param {ProcessNodeOptions=} options - * @returns {any|undefined} - */ - [unionDefaultValue](schema, defaultValue, options={}) { - const gen = new XmlDataNodeGenerator(); - const value = gen.generate(defaultValue); - const anySchema = /** @type ApiAnyShape */ (schema); - const label = shapeToXmlTagName(anySchema); - const currentIndent = (options.indent || 0); - const rootFill = new Array(currentIndent*2).fill(' ').join(''); - const parts = [ - `${rootFill}<${label}>` - ]; - const valueFill = new Array(currentIndent * 2 + 2).fill(' ').join(''); - parts.push(`${valueFill}${String(value).trim()}`); - parts.push(`${rootFill}`); - return parts.join('\n'); - } - - [fileShapeObject](schema) { - return super[fileShapeObject](schema); - } - - [schemaShapeObject](schema) { - return super[schemaShapeObject](schema); - } - - [tupleShapeObject](schema) { - return super[tupleShapeObject](schema); - } - - /** - * @param {ApiAnyShape} schema - * @returns {string} - */ - [anyShapeObject](schema) { - const { examples=[] } = schema; - const label = shapeToXmlTagName(schema); - if (this.opts.renderExamples && examples && examples.length) { - const example = examples.find((item) => !!item.value); - const value = this[exampleToObject](example); - const parts = []; - if (typeof value !== 'undefined') { - const valueFill = ` `; - parts.push(`<${label}>`); - parts.push(`${valueFill}${value}`); - parts.push(``); - } - return parts.join('\n'); - } - return super[anyShapeObject](schema); - } -} diff --git a/src/store/AmfGraphStore.ts b/src/store/AmfGraphStore.ts index 6ec13f2..ab28c14 100644 --- a/src/store/AmfGraphStore.ts +++ b/src/store/AmfGraphStore.ts @@ -1,5 +1,5 @@ -import { v4 } from '@advanced-rest-client/uuid'; -import { DomainElement } from '../helpers/amf.js'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { AmfDefinitions, uuidV4 } from '@api-client/core/build/browser.js'; import { AmfStore } from './AmfStore.js'; /** @@ -26,8 +26,8 @@ export class AmfGraphStore { * @param graph The graph model to use to initialize the store. * @returns The store id to be used to reference when querying the store. */ - async add(graph: DomainElement): Promise { - const id = v4(); + async add(graph: AmfDefinitions.IAmfDomainElement): Promise { + const id = uuidV4(); const instance = new AmfStore(this.target, graph); this.apis.set(id, instance); return id; diff --git a/src/store/AmfStore.ts b/src/store/AmfStore.ts index 8895562..310f3ae 100644 --- a/src/store/AmfStore.ts +++ b/src/store/AmfStore.ts @@ -2,30 +2,10 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable no-unused-vars */ /* eslint-disable class-methods-use-this */ -import { AmfDocument } from '../helpers/amf.js'; -import { AmfSerializer } from '../helpers/AmfSerializer.js'; -import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api.js'; +import { AmfDefinitions, AmfSerializer, ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; +import { ServersQueryOptions } from '@api-client/core/build/src/amf/AmfMixin.js'; import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types.js'; -/** @typedef {import('../helpers/amf').AmfDocument} AmfDocument */ -/** @typedef {import('../helpers/amf').DomainElement} DomainElement */ -/** @typedef {import('../helpers/api').ApiSummary} ApiSummary */ -/** @typedef {import('../helpers/api').ApiEndPoint} ApiEndPoint */ -/** @typedef {import('../helpers/api').ApiOperation} ApiOperation */ -/** @typedef {import('../helpers/api').ServersQueryOptions} ServersQueryOptions */ -/** @typedef {import('../helpers/api').ApiServer} ApiServer */ -/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ -/** @typedef {import('../helpers/api').ApiSecurityScheme} ApiSecurityScheme */ -/** @typedef {import('../helpers/api').ApiSecurityRequirement} ApiSecurityRequirement */ -/** @typedef {import('../helpers/api').ApiRequest} ApiRequest */ -/** @typedef {import('../helpers/api').ApiResponse} ApiResponse */ -/** @typedef {import('../helpers/api').ApiPayload} ApiPayload */ -/** @typedef {import('../helpers/api').ApiShapeUnion} ApiShapeUnion */ -/** @typedef {import('../types').ApiEndPointWithOperationsListItem} ApiEndPointWithOperationsListItem */ -/** @typedef {import('../types').ApiSecuritySchemeListItem} ApiSecuritySchemeListItem */ -/** @typedef {import('../types').ApiNodeShapeListItem} ApiNodeShapeListItem */ -/** @typedef {import('../types').DocumentMeta} DocumentMeta */ - /** * An abstract base class for the store implementation that works with API Components. */ @@ -43,7 +23,7 @@ export class AmfStore { /** * @param target The event target to dispatch the events on. */ - constructor(target: EventTarget = window, graph?: AmfDocument) { + constructor(target: EventTarget = window, graph?: AmfDefinitions.IAmfDocument) { this.readonly = true; this.target = target; let amf = graph; @@ -74,7 +54,7 @@ export class AmfStore { /** * @returns API summary for the summary view. */ - async apiSummary(): Promise { + async apiSummary(): Promise { throw new Error('Not implemented'); } @@ -96,7 +76,7 @@ export class AmfStore { * Reads an endpoint by its id. * @param id The domain id of the endpoint. */ - async getEndpoint(id: string): Promise { + async getEndpoint(id: string): Promise { throw new Error('Not implemented'); } @@ -104,7 +84,7 @@ export class AmfStore { * Reads an endpoint by its path. * @param path The path value of the endpoint or channel name. */ - async getEndpointByPath(path: string): Promise { + async getEndpointByPath(path: string): Promise { throw new Error('Not implemented'); } @@ -120,7 +100,7 @@ export class AmfStore { * @param query Server query options * @returns The list of servers for given query. */ - async queryServers(query?: ServersQueryOptions): Promise { + async queryServers(query?: ServersQueryOptions): Promise { throw new Error('Not implemented'); } @@ -129,7 +109,7 @@ export class AmfStore { * @param operationId The domain id of the operation to read. * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - async getOperation(operationId: string, endpointId?: string): Promise { + async getOperation(operationId: string, endpointId?: string): Promise { throw new Error('Not implemented'); } @@ -137,14 +117,14 @@ export class AmfStore { * Finds an endpoint that has the operation. * @param id Method name or the domain id of the operation to find */ - async getOperationParent(id: string): Promise { + async getOperationParent(id: string): Promise { throw new Error('Not implemented'); } /** * Lists the documentation definitions for the API. */ - async listDocumentations(): Promise { + async listDocumentations(): Promise { throw new Error('Not implemented'); } @@ -153,7 +133,7 @@ export class AmfStore { * @param id The domain id of the documentation object * @returns The read documentation. */ - async getDocumentation(id: string): Promise { + async getDocumentation(id: string): Promise { throw new Error('Not implemented'); } @@ -161,7 +141,7 @@ export class AmfStore { * Reads the SecurityScheme object from the graph. * @param id The domain id of the SecurityScheme */ - async getSecurityScheme(id: string): Promise { + async getSecurityScheme(id: string): Promise { throw new Error('Not implemented'); } @@ -169,7 +149,7 @@ export class AmfStore { * Reads the SecurityRequirement object from the graph. * @param id The domain id of the SecurityRequirement */ - async getSecurityRequirement(id: string): Promise { + async getSecurityRequirement(id: string): Promise { throw new Error('Not implemented'); } @@ -184,7 +164,7 @@ export class AmfStore { * Reads the Request object from the graph. * @param id The domain id of the Request */ - async getRequest(id: string): Promise { + async getRequest(id: string): Promise { throw new Error('Not implemented'); } @@ -192,7 +172,7 @@ export class AmfStore { * Reads the response data from the graph. * @param id The domain id of the response. */ - async getResponse(id: string): Promise { + async getResponse(id: string): Promise { throw new Error('Not implemented'); } @@ -200,7 +180,7 @@ export class AmfStore { * Reads Payload data from the graph * @param id The domain id of the payload */ - async getPayload(id: string): Promise { + async getPayload(id: string): Promise { throw new Error('Not implemented'); } @@ -214,7 +194,7 @@ export class AmfStore { /** * @param id The domain id of the API type (schema). */ - async getType(id: string): Promise { + async getType(id: string): Promise { throw new Error('Not implemented'); } } diff --git a/src/store/InMemAmfGraphStore.ts b/src/store/InMemAmfGraphStore.ts index 6ef30e4..6b8555d 100644 --- a/src/store/InMemAmfGraphStore.ts +++ b/src/store/InMemAmfGraphStore.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable default-param-last */ -import { AmfHelperMixin } from '../helpers/AmfHelperMixin.js'; +import { AmfDefinitions, ApiDefinitions, AmfShapes, AmfMixin, AmfNamespace } from '@api-client/core/build/browser.js'; +import { ServersQueryOptions } from '@api-client/core/build/src/amf/AmfMixin.js'; import { StoreEvents } from '../events/StoreEvents.js'; import { AmfStore } from './AmfStore.js'; -import { AmfDocument, Api, CreativeWork, DomainElement } from '../helpers/amf.js'; -import { ApiSummary, ApiEndPoint, ApiOperation, ServersQueryOptions, ApiServer, ApiDocumentation, ApiSecurityScheme, ApiSecurityRequirement, ApiRequest, ApiResponse, ApiPayload, ApiShapeUnion } from '../helpers/api.js'; import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListItem, ApiNodeShapeListItem } from '../types.js'; @@ -13,12 +12,12 @@ import { DocumentMeta, ApiEndPointWithOperationsListItem, ApiSecuritySchemeListI * The graph model is kept in memory in a form of a Raw ld+json graph representation of the * AMF's domain model. */ -export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { +export class InMemAmfGraphStore extends AmfMixin(AmfStore) { /** * @param target The event target to dispatch the events on. * @param graph The full API model. */ - constructor(target: EventTarget = window, graph?: AmfDocument) { + constructor(target: EventTarget = window, graph?: AmfDefinitions.IAmfDocument) { super(target, graph); let amf = graph; if (Array.isArray(graph)) { @@ -30,7 +29,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { this.amf = amf; } - __amfChanged(amf: AmfDocument): void { + __amfChanged(amf: AmfDefinitions.IAmfDocument): void { this.serializer.amf = amf; if (this.target) { StoreEvents.graphChange(this.target); @@ -76,16 +75,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { const api = this._computeApi(amf); const isApi = !!api; result.isApi = isApi; - const { ns } = this; if (isApi) { result.isAsync = this._isAsyncAPI(amf); - } else if (result.types[0] === ns.aml.vocabularies.document.Module) { + } else if (result.types[0] === AmfNamespace.aml.vocabularies.document.Module) { result.isLibrary = true; } else { const fragmentTypes = [ - ns.aml.vocabularies.security.SecuritySchemeFragment, - ns.aml.vocabularies.apiContract.UserDocumentationFragment, - ns.aml.vocabularies.shapes.DataTypeFragment, + AmfNamespace.aml.vocabularies.security.SecuritySchemeFragment, + AmfNamespace.aml.vocabularies.apiContract.UserDocumentationFragment, + AmfNamespace.aml.vocabularies.shapes.DataTypeFragment, ]; result.isFragment = fragmentTypes.some(type => result.types.includes(type)); } @@ -95,7 +93,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * @returns API summary for the summary view. */ - async apiSummary(): Promise { + async apiSummary(): Promise { const { amf } = this; if (!amf) { return null; @@ -111,20 +109,23 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * @returns Currently loaded API's protocols */ - async apiProtocols(): Promise { + async apiProtocols(): Promise { const { amf } = this; if (!amf) { return null; } const wa = this._computeApi(amf); - const protocols = this._getValueArray(wa, this.ns.aml.vocabularies.apiContract.scheme) as string[]; + if (!wa) { + return null; + } + const protocols = this._getValueArray(wa, AmfNamespace.aml.vocabularies.apiContract.scheme) as string[]; return protocols; } /** * @returns Currently loaded API's version */ - async apiVersion(): Promise { + async apiVersion(): Promise { const { amf } = this; if (!amf) { return null; @@ -138,7 +139,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * @param id The domain id of the endpoint. * @private */ - findEndpoint(id: string): ApiEndPoint|null { + findEndpoint(id: string): ApiDefinitions.IApiEndPoint | null { const { amf } = this; if (!amf) { return null; @@ -154,12 +155,12 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { const result = this.serializer.endPoint(endpoint); return result; } - + /** * Reads an endpoint by its id. * @param id The domain id of the endpoint. */ - async getEndpoint(id: string): Promise { + async getEndpoint(id: string): Promise { return this.findEndpoint(id); } @@ -167,7 +168,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads an endpoint by its path. * @param path The path value of the endpoint or channel name. */ - async getEndpointByPath(path: string): Promise { + async getEndpointByPath(path: string): Promise { const { amf } = this; if (!amf) { return null; @@ -180,7 +181,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!Array.isArray(endpoints) || !endpoints.length) { throw new Error(`This API has no endpoints.`); } - const endpoint = endpoints.find((e) => this._getValue(e, this.ns.aml.vocabularies.apiContract.path) === path); + const endpoint = endpoints.find((e) => this._getValue(e, AmfNamespace.aml.vocabularies.apiContract.path) === path); if (!endpoint) { throw new Error(`Endpoint ${endpoint} does not exist.`); } @@ -212,7 +213,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * @param query Server query options * @returns The list of servers for given query. */ - async queryServers(query?: ServersQueryOptions): Promise { + async queryServers(query?: ServersQueryOptions): Promise { const { amf } = this; if (!amf) { return []; @@ -229,7 +230,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * @param operationId The domain id of the operation to read. * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - findOperation(operationId: string, endpointId?: string): ApiOperation|undefined { + findOperation(operationId: string, endpointId?: string): ApiDefinitions.IApiOperation | undefined { if (endpointId) { const ep = this.findEndpoint(endpointId); if (!ep) { @@ -249,7 +250,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!endpoints) { return undefined; } - const { apiContract } = this.ns.aml.vocabularies; + const { apiContract } = AmfNamespace.aml.vocabularies; const opKey = this._getAmfKey(apiContract.supportedOperation) as string; for (const endpoint of endpoints) { let operations = (endpoint as any)[opKey]; @@ -273,7 +274,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * @param operationId The domain id of the operation to read. * @param endpointId Optional endpoint id. When not set it searches through all endpoints. */ - async getOperation(operationId: string, endpointId?: string): Promise { + async getOperation(operationId: string, endpointId?: string): Promise { const op = this.findOperation(operationId, endpointId); if (!op) { throw new Error(`No operation ${operationId} in the graph`); @@ -285,7 +286,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Finds an endpoint that has the operation. * @param id Method name or the domain id of the operation to find */ - async getOperationParent(id: string): Promise { + async getOperationParent(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -305,12 +306,12 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Lists the documentation definitions for the API. */ - async listDocumentations(): Promise { + async listDocumentations(): Promise { const { amf } = this; if (!amf) { return undefined; } - if (this._hasType(amf, this.ns.aml.vocabularies.apiContract.UserDocumentationFragment)) { + if (this._hasType(amf, AmfNamespace.aml.vocabularies.apiContract.UserDocumentationFragment)) { const model = this._computeEncodes(amf); if (!model) { return undefined; @@ -321,8 +322,8 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!api) { return undefined; } - const key = this._getAmfKey(this.ns.aml.vocabularies.core.documentation) as string; - const docs = this._ensureArray((api as any)[key]) as CreativeWork[]; + const key = this._getAmfKey(AmfNamespace.aml.vocabularies.core.documentation) as string; + const docs = this._ensureArray((api as any)[key]) as AmfDefinitions.IAmfCreativeWork[]; if (docs) { return docs.map((doc) => this.serializer.documentation(doc)); } @@ -334,16 +335,16 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * @param id The domain id of the documentation object * @returns The read documentation. */ - async getDocumentation(id: string): Promise { + async getDocumentation(id: string): Promise { const { amf } = this; if (!amf) { return undefined; } const types = this.getDocumentTypes(); // when we have loaded Documentation fragment then the id doesn't matter. - if (types.includes(this.ns.aml.vocabularies.apiContract.UserDocumentationFragment)) { + if (types.includes(AmfNamespace.aml.vocabularies.apiContract.UserDocumentationFragment)) { const encodes = this._computeEncodes(amf); - return this.serializer.documentation(encodes as Api); + return this.serializer.documentation(encodes as AmfDefinitions.IAmfApi); } const api = this._computeApi(amf); if (!api) { @@ -361,16 +362,16 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads the SecurityScheme object from the graph. * @param id The domain id of the SecurityScheme */ - async getSecurityScheme(id: string): Promise { + async getSecurityScheme(id: string): Promise { const types = this.getDocumentTypes(); // when we have loaded Security fragment then the id doesn't matter. - if (types.includes(this.ns.aml.vocabularies.security.SecuritySchemeFragment)) { + if (types.includes(AmfNamespace.aml.vocabularies.security.SecuritySchemeFragment)) { const { amf } = this; if (!amf) { return undefined; } const encodes = this._computeEncodes(amf); - return this.serializer.securityScheme(encodes as Api); + return this.serializer.securityScheme(encodes as AmfDefinitions.IAmfApi); } const object = this.findSecurityScheme(id); if (!object) { @@ -383,7 +384,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads the SecurityRequirement object from the graph. * @param id The domain id of the SecurityRequirement */ - async getSecurityRequirement(id: string): Promise { + async getSecurityRequirement(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -392,15 +393,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; + const endpoints = (wa as any)[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; + const operations = endpoint[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const securityList = operation[this._getAmfKey(this.ns.aml.vocabularies.security.security) as string]; + const securityList = operation[this._getAmfKey(AmfNamespace.aml.vocabularies.security.security) as string]; if (Array.isArray(securityList)) { for (const security of securityList) { if (security['@id'] === id) { @@ -422,14 +423,14 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!amf) { return []; } - if (this._hasType(amf, this.ns.aml.vocabularies.security.SecuritySchemeFragment)) { + if (this._hasType(amf, AmfNamespace.aml.vocabularies.security.SecuritySchemeFragment)) { const model = this._computeEncodes(amf); if (!model) { return []; } return [this.serializer.securitySchemeListItem(model)]; } - const items = this.getByType(amf, this.ns.aml.vocabularies.security.SecurityScheme); + const items = this.getByType(amf, AmfNamespace.aml.vocabularies.security.SecurityScheme); return items.map(item => this.serializer.securitySchemeListItem(item)); } @@ -437,7 +438,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads the Request object from the graph. * @param id The domain id of the Request */ - async getRequest(id: string): Promise { + async getRequest(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -446,15 +447,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; + const endpoints = (wa as any)[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; + const operations = endpoint[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects) as string]; + const expectsList = operation[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.expects) as string]; if (Array.isArray(expectsList)) { for (const expects of expectsList) { if (expects['@id'] === id) { @@ -472,7 +473,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads the response data from the graph. * @param id The domain id of the response. */ - async getResponse(id: string): Promise { + async getResponse(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -481,15 +482,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; + const endpoints = (wa as any)[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; + const operations = endpoint[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns) as string]; + const returnsList = operation[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.returns) as string]; if (Array.isArray(returnsList)) { for (const returns of returnsList) { if (returns['@id'] === id) { @@ -506,8 +507,8 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { /** * Finds a payload in a request or a response object. */ - findPayload(object: DomainElement, domainId: string): ApiPayload|undefined { - const list = (object as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.payload) as string]; + findPayload(object: AmfDefinitions.IAmfDomainElement, domainId: string): ApiDefinitions.IApiPayload | undefined { + const list = (object as any)[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.payload) as string]; if (!Array.isArray(list) || !list.length) { return undefined; } @@ -522,7 +523,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { * Reads Payload data from the graph * @param id The domain id of the payload */ - async getPayload(id: string): Promise { + async getPayload(id: string): Promise { const { amf } = this; if (!amf) { return undefined; @@ -531,15 +532,15 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!wa) { return undefined; } - const endpoints = (wa as any)[this._getAmfKey(this.ns.aml.vocabularies.apiContract.endpoint) as string]; + const endpoints = (wa as any)[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.endpoint) as string]; if (!Array.isArray(endpoints)) { return undefined; } for (const endpoint of endpoints) { - const operations = endpoint[this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation) as string]; + const operations = endpoint[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation) as string]; if (Array.isArray(operations)) { for (const operation of operations) { - const expectsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.expects) as string]; + const expectsList = operation[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.expects) as string]; if (Array.isArray(expectsList)) { for (const expects of expectsList) { const payload = this.findPayload(expects, id); @@ -548,7 +549,7 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { } } } - const returnsList = operation[this._getAmfKey(this.ns.aml.vocabularies.apiContract.returns) as string]; + const returnsList = operation[this._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.returns) as string]; if (Array.isArray(returnsList)) { for (const returns of returnsList) { const payload = this.findPayload(returns, id); @@ -571,34 +572,34 @@ export class InMemAmfGraphStore extends AmfHelperMixin(AmfStore) { if (!amf) { return []; } - if (this._hasType(amf, this.ns.aml.vocabularies.shapes.DataTypeFragment)) { + if (this._hasType(amf, AmfNamespace.aml.vocabularies.shapes.DataTypeFragment)) { const model = this._computeEncodes(amf); if (!model) { return []; } return [this.serializer.unknownShape(model)]; } - const items = this.getByType(amf, this.ns.aml.vocabularies.shapes.Shape); + const items = this.getByType(amf, AmfNamespace.aml.vocabularies.shapes.Shape); return items.map(item => this.serializer.unknownShape(item)); } /** * @param id The domain id of the API type (schema). */ - async getType(id: string): Promise { + async getType(id: string): Promise { const { amf } = this; if (!amf) { return undefined; } const types = this.getDocumentTypes(); // when we have loaded Type fragment then the id doesn't matter. - if (types.includes(this.ns.aml.vocabularies.shapes.DataTypeFragment)) { + if (types.includes(AmfNamespace.aml.vocabularies.shapes.DataTypeFragment)) { const encodes = this._computeEncodes(amf); - return this.serializer.unknownShape(encodes as Api); + return this.serializer.unknownShape(encodes as AmfDefinitions.IAmfApi); } const declares = this._computeDeclares(amf); const references = this._computeReferences(amf); - const type = this._computeType(declares as DomainElement[], references as DomainElement[], id); + const type = this._computeType(declares as AmfDefinitions.IAmfDomainElement[], references as AmfDefinitions.IAmfDomainElement[], id); if (!type) { return undefined; } diff --git a/src/store/mixins/AmfStoreDomEventsMixin.d.ts b/src/store/mixins/AmfStoreDomEventsMixin.d.ts deleted file mode 100644 index 663c7d2..0000000 --- a/src/store/mixins/AmfStoreDomEventsMixin.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { EventsTargetMixin } from '@anypoint-web-components/awc'; - -export declare const eventHandler: unique symbol; - -export declare function AmfStoreDomEventsMixin {}>(base: T): T & AmfStoreDomEventsMixinConstructor; - -export declare interface AmfStoreDomEventsMixinConstructor { - new(...args: any[]): AmfStoreDomEventsMixin; - constructor(...args: any[]): AmfStoreDomEventsMixin; -} - -/** - * This mixin adds events listeners for DOM events related to the AMF store. - * It does not provide implementations for the functions called by each handler. - * This to be mixed in with an instance of the `AmfStoreService`. - * - * The implementation by default listens on the `window` object. - * Set `eventsTarget` property to listen to the events on a specific node. - */ -export declare interface AmfStoreDomEventsMixin extends EventsTargetMixin { - [eventHandler](e: CustomEvent): void; - /** - * Listens for the store DOM events. - */ - listen(node?: EventTarget): void; - - /** - * Removes store's DOM events. - */ - unlisten(node?: EventTarget): void; -} diff --git a/src/store/mixins/AmfStoreDomEventsMixin.js b/src/store/mixins/AmfStoreDomEventsMixin.ts similarity index 64% rename from src/store/mixins/AmfStoreDomEventsMixin.js rename to src/store/mixins/AmfStoreDomEventsMixin.ts index ea29a10..b76e9bf 100644 --- a/src/store/mixins/AmfStoreDomEventsMixin.js +++ b/src/store/mixins/AmfStoreDomEventsMixin.ts @@ -1,15 +1,13 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable class-methods-use-this */ import { dedupeMixin } from '@open-wc/dedupe-mixin'; import { EventsTargetMixin } from '@anypoint-web-components/awc'; import { EventTypes } from '../../events/EventTypes.js'; - export const eventHandler = Symbol('eventHandler'); -/** - * @type {Record} - */ -const eventsMap = { +const eventsMap: Record = { [EventTypes.Api.summary]: { target: 'apiSummary' }, [EventTypes.Api.protocols]: { target: 'apiProtocols' }, [EventTypes.Api.version]: { target: 'apiVersion' }, @@ -32,55 +30,76 @@ const eventsMap = { [EventTypes.Type.get]: { args: ['id'], target: 'getType' }, }; +type Constructor = new (...args: any[]) => T; + /** - * @param {*} base + * This mixin adds events listeners for DOM events related to the AMF store. + * It does not provide implementations for the functions called by each handler. + * This to be mixed in with an instance of the `AmfStoreService`. + * + * The implementation by default listens on the `window` object. + * Set `eventsTarget` property to listen to the events on a specific node. + * + * @mixin */ -const mxFunction = base => { - class AmfStoreDomEventsMixin extends EventsTargetMixin(base) { +export interface AmfStoreDomEventsMixinInterface { + [eventHandler](e: CustomEvent): void; + /** + * Listens for the store DOM events. + */ + listen(node?: EventTarget): void; + + /** + * Removes store's DOM events. + */ + unlisten(node?: EventTarget): void; +} + +/** + * This mixin adds events listeners for DOM events related to the AMF store. + * It does not provide implementations for the functions called by each handler. + * This to be mixed in with an instance of the `AmfStoreService`. + * + * The implementation by default listens on the `window` object. + * Set `eventsTarget` property to listen to the events on a specific node. + * + * @mixin + */ +export const AmfStoreDomEventsMixin = dedupeMixin(>(superClass: T): Constructor & T => { + class AmfStoreDomEventsMixinClass extends EventsTargetMixin(superClass) { /** - * @param {...any} args Base class arguments + * @param args Base class arguments */ - constructor(...args) { + constructor(...args: any[]) { super(...args); this[eventHandler] = this[eventHandler].bind(this); } /** * Listens for the store DOM events. - * @param {EventTarget} node */ - listen(node=window) { - Object.keys(eventsMap).forEach(type => node.addEventListener(type, this[eventHandler])); + listen(node: EventTarget = window): void { + Object.keys(eventsMap).forEach(type => node.addEventListener(type, this[eventHandler] as EventListener)); } /** * Removes store's DOM events. - * @param {EventTarget} node */ - unlisten(node=window) { - Object.keys(eventsMap).forEach(type => node.removeEventListener(type, this[eventHandler])); + unlisten(node: EventTarget = window): void { + Object.keys(eventsMap).forEach(type => node.removeEventListener(type, this[eventHandler] as EventListener)); } - /** - * @param {EventTarget} node - */ - _attachListeners(node) { + _attachListeners(node: EventTarget): void { super._attachListeners(node); this.listen(node); } - /** - * @param {EventTarget} node - */ - _detachListeners(node) { + _detachListeners(node: EventTarget): void { super._detachListeners(node); this.unlisten(node); } - /** - * @param {CustomEvent} e - */ - [eventHandler](e) { + [eventHandler](e: CustomEvent): void { if (e.defaultPrevented) { return; } @@ -98,26 +117,14 @@ const mxFunction = base => { } else if (!Array.isArray(args) || !args.length) { e.detail.result = this[target](); } else { - const params = []; + const params: any[] = []; args.forEach(n => { - const value = info.eventProperties ? e[n] : e.detail[n]; + const value = info.eventProperties ? (e as any)[n] : e.detail[n]; params.push(value); }); e.detail.result = this[target](...params); } } } - return AmfStoreDomEventsMixin; -} - -/** - * This mixin adds events listeners for DOM events related to the AMF store. - * It does not provide implementations for the functions called by each handler. - * This to be mixed in with an instance of the `AmfStoreService`. - * - * The implementation by default listens on the `window` object. - * Set `eventsTarget` property to listen to the events on a specific node. - * - * @mixin - */ -export const AmfStoreDomEventsMixin = dedupeMixin(mxFunction); + return AmfStoreDomEventsMixinClass as Constructor & T; +}); diff --git a/src/types.ts b/src/types.ts index 765713d..30eb59c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,8 @@ -import { HTTPRequest, RequestAuthorization } from '@advanced-rest-client/events/src/request/ArcRequest'; -import { ApiParameter, ApiShapeUnion, ApiSecurityRequirement, ApiServer, ApiEndPoint, ApiExample, ApiDocumentation } from './helpers/api.js'; +import { ApiDefinitions, AmfShapes } from '@api-client/core/build/browser.js'; +import { HTTPRequest, RequestAuthorization } from '@api-client/core/build/legacy.js'; import XhrSimpleRequestTransportElement from './elements/XhrSimpleRequestTransportElement.js'; -export declare interface ApiConsoleRequest extends HTTPRequest { +export interface ApiConsoleRequest extends HTTPRequest { /** * The authorization settings. * Some of them are already applied to the request object. @@ -22,7 +22,7 @@ export declare interface ApiConsoleRequest extends HTTPRequest { timeout?: number; } -export declare interface ApiConsoleResponse { +export interface ApiConsoleResponse { /** * The id of the request generated when the Api request event is dispatched. */ @@ -34,14 +34,14 @@ export declare interface ApiConsoleResponse { loadingTime: number; } -export declare interface ApiConsoleHTTPResponse { +export interface ApiConsoleHTTPResponse { status: number; statusText?: string; payload?: unknown; headers?: string; } -export declare interface AbortRequestEventDetail { +export interface AbortRequestEventDetail { /** * The URL of the request */ @@ -52,13 +52,13 @@ export declare interface AbortRequestEventDetail { id: string; } -export declare interface XHRQueueItem { +export interface XHRQueueItem { startTime: number; request: ApiConsoleRequest; xhr: XhrSimpleRequestTransportElement; } -export declare interface PopulationInfo { +export interface PopulationInfo { annotationName: string; annotationValue: string; fieldValue: string; @@ -75,11 +75,11 @@ export interface OperationParameter { * The parameter definition transformed from the AMF graph model. * This is set for path, query, and header parameters. */ - parameter: ApiParameter; + parameter: ApiDefinitions.IApiParameter; /** * The schema associated with the parameter. Determines the shape of the user input control. */ - schema?: ApiShapeUnion; + schema?: AmfShapes.IShapeUnion; /** * Link to `parameter.id`. */ @@ -101,7 +101,7 @@ export interface OperationParameter { export interface SecuritySelectorListItem { types: (string | undefined)[]; labels: (string | undefined)[]; - security: ApiSecurityRequirement; + security: ApiDefinitions.IApiSecurityRequirement; } export interface ParameterRenderOptions { @@ -130,12 +130,12 @@ export interface ComputeBaseUriOptions { * When the `baseUri` is set this value is ignored. * When both are missing then the URL computations ignores the base URI part and reads the path only. */ - server?: ApiServer; + server?: ApiDefinitions.IApiServer; /** * The endpoint definition used to compute path of the URL. * When not set it ignores the path part. */ - endpoint?: ApiEndPoint; + endpoint?: ApiDefinitions.IApiEndPoint; /** * The protocols to use with the computation of the URL. * When the server has no protocol (http or https) defined on the base URI @@ -155,7 +155,7 @@ export interface ComputeBaseUriOptions { } // export interface OperationParameter { -// parameter: ApiParameter; +// parameter: ApiDefinitions.IApiParameter; // schema?: ApiShapeUnion; // paramId: string; // schemaId?: string; @@ -276,7 +276,7 @@ export declare interface EndpointItem extends ApiEndpointsTreeItem, SelectableMe export declare interface OperationItem extends ApiOperationListItem, SelectableMenuItem, EditableMenuItem {} export declare interface NodeShapeItem extends ApiNodeShapeListItem, SelectableMenuItem, EditableMenuItem {} export declare interface SecurityItem extends ApiSecuritySchemeListItem, SelectableMenuItem {} -export declare interface DocumentationItem extends ApiDocumentation, SelectableMenuItem, EditableMenuItem {} +export declare interface DocumentationItem extends ApiDefinitions.IApiDocumentation, SelectableMenuItem, EditableMenuItem {} export declare type SchemaAddType = 'scalar'|'object'|'file'|'array'|'union'; export declare interface TargetModel { @@ -288,7 +288,7 @@ export declare interface TargetModel { _basePaths?: string[]; } -export declare interface SchemaExample extends ApiExample { +export declare interface SchemaExample extends AmfShapes.IApiDataExample { /** * The value to render as the example value. */ From 884f4bc79f72ae3b632092979ffd135be212f4b4 Mon Sep 17 00:00:00 2001 From: Pawel Psztyc Date: Fri, 23 Sep 2022 18:24:19 -0700 Subject: [PATCH 5/6] chore: upgrading most of the code base Signed-off-by: Pawel Psztyc --- .eslintrc | 25 +- demo/api-channel.js | 2 +- demo/api-console.js | 8 +- demo/api-documentation-partial.js | 6 +- demo/api-documentation.js | 6 +- demo/api-editor.js | 8 +- demo/api-navigation.js | 6 +- demo/api-operation.js | 6 +- demo/api-request.js | 2 +- demo/api-resource.js | 6 +- demo/api-schema-documentation.js | 2 +- demo/api-security-documentation.js | 2 +- demo/api-summary.js | 2 +- demo/request-editor.js | 4 +- demo/server-selector.js | 2 +- .../{AmfParser.mjs => AmfParser.js} | 0 .../{AmfService.mjs => AmfService.js} | 0 dev/amf-server/{ApiError.mjs => ApiError.js} | 0 dev/amf-server/{api.mjs => api.js} | 0 package-lock.json | 16 - .../ApiAnnotationDocumentElement.d.ts | 81 - ...ent.js => ApiAnnotationDocumentElement.ts} | 121 +- src/elements/ApiAuthorizationEditorElement.js | 6 +- src/elements/ApiAuthorizationMethodElement.js | 5 +- src/elements/ApiChannelDocumentElement.d.ts | 29 - ...lement.js => ApiChannelDocumentElement.ts} | 32 +- src/elements/ApiDocumentationBase.d.ts | 117 - ...ntationBase.js => ApiDocumentationBase.ts} | 177 +- .../ApiDocumentationDocumentElement.d.ts | 38 - ....js => ApiDocumentationDocumentElement.ts} | 52 +- src/elements/ApiDocumentationElement.d.ts | 287 --- ...nElement.js => ApiDocumentationElement.ts} | 491 ++-- src/elements/ApiNavigationElement.d.ts | 744 ------ ...tionElement.js => ApiNavigationElement.ts} | 1112 +++++---- src/elements/ApiNavigationLegacyElement.d.ts | 718 ------ src/elements/ApiNavigationLegacyElement.js | 2224 ----------------- src/elements/ApiOperationDocumentElement.d.ts | 341 --- ...ment.js => ApiOperationDocumentElement.ts} | 577 ++--- src/elements/ApiParameterDocumentElement.d.ts | 44 - ...ment.js => ApiParameterDocumentElement.ts} | 61 +- .../ApiParametrizedSecuritySchemeElement.d.ts | 28 - ...> ApiParametrizedSecuritySchemeElement.ts} | 55 +- src/elements/ApiPayloadDocumentElement.d.ts | 43 - ...lement.js => ApiPayloadDocumentElement.ts} | 64 +- src/elements/ApiRequestDocumentElement.d.ts | 138 - ...lement.js => ApiRequestDocumentElement.ts} | 249 +- src/elements/ApiRequestEditorElement.d.ts | 673 ----- ...rElement.js => ApiRequestEditorElement.ts} | 958 ++++--- src/elements/ApiRequestElement.ts | 25 +- ...ement.js => ApiResourceDocumentElement.ts} | 486 ++-- src/elements/ApiResponseDocumentElement.d.ts | 98 - ...ement.js => ApiResponseDocumentElement.ts} | 162 +- src/elements/ApiResponseViewElement.d.ts | 40 - ...ewElement.js => ApiResponseViewElement.ts} | 85 +- src/elements/ApiSchemaDocumentElement.d.ts | 202 -- ...Element.js => ApiSchemaDocumentElement.ts} | 501 ++-- src/elements/ApiSecurityDocumentElement.d.ts | 237 -- ...ement.js => ApiSecurityDocumentElement.ts} | 327 ++- ...ApiSecurityRequirementDocumentElement.d.ts | 15 - ... ApiSecurityRequirementDocumentElement.ts} | 42 +- src/elements/ApiServerSelectorElement.d.ts | 329 --- ...Element.js => ApiServerSelectorElement.ts} | 423 ++-- src/elements/ApiSummaryElement.d.ts | 124 - ...SummaryElement.js => ApiSummaryElement.ts} | 224 +- src/elements/SchemaCommonTemplates.d.ts | 62 - ...nTemplates.js => SchemaCommonTemplates.ts} | 183 +- src/elements/XhrSimpleRequestElement.d.ts | 180 -- ...tElement.js => XhrSimpleRequestElement.ts} | 203 +- .../XhrSimpleRequestTransportElement.ts | 3 + .../{ApiAnnotation.js => ApiAnnotation.ts} | 2 +- ...piDocumentation.js => ApiDocumentation.ts} | 2 +- ...ocument.js => ApiDocumentationDocument.ts} | 2 +- .../{ApiOperation.js => ApiOperation.ts} | 2 +- ...SecurityRequirement.js => ApiParameter.ts} | 2 +- .../styles/{ApiPayload.js => ApiPayload.ts} | 2 +- .../styles/{ApiParameter.js => ApiRequest.ts} | 2 +- .../styles/{ApiResource.js => ApiResource.ts} | 2 +- .../styles/{ApiResponse.js => ApiResponse.ts} | 3 +- .../styles/{ApiSchema.js => ApiSchema.ts} | 2 +- ...rityDocument.js => ApiSecurityDocument.ts} | 2 +- ...piRequest.js => ApiSecurityRequirement.ts} | 2 +- .../styles/{ApiSummary.js => ApiSummary.ts} | 2 +- .../styles/AuthorizationEditor copy.js | 19 - ...zationEditor.js => AuthorizationEditor.ts} | 2 +- ...zationMethod.js => AuthorizationMethod.ts} | 2 +- src/elements/styles/{Common.js => Common.ts} | 2 +- .../{Editor.styles.js => Editor.styles.ts} | 2 +- .../styles/{HttpRequest.js => HttpRequest.ts} | 2 +- .../styles/{NavStyles.js => NavStyles.ts} | 2 +- .../styles/{Navigation.js => Navigation.ts} | 2 +- .../{Panel.styles.js => Panel.styles.ts} | 2 +- ...ment.js => ParametrizedSecurityElement.ts} | 2 +- src/elements/styles/Response.styles.js | 4 - src/elements/styles/Response.styles.ts | 4 + .../{SchemaCommon.js => SchemaCommon.ts} | 2 +- .../{ServerSelector.js => ServerSelector.ts} | 2 +- src/events/OperationEvents.d.ts | 20 - src/events/OperationEvents.js | 33 - src/events/OperationEvents.ts | 29 + src/events/PayloadEvents.d.ts | 12 - src/events/PayloadEvents.js | 20 - src/events/PayloadEvents.ts | 18 + src/events/ReportingEvents.d.ts | 19 - src/events/ReportingEvents.js | 25 - src/events/ReportingEvents.ts | 28 + src/events/RequestEvents.d.ts | 71 - src/events/RequestEvents.js | 127 - src/events/RequestEvents.ts | 109 + src/events/ResponseEvents.d.ts | 12 - src/events/ResponseEvents.js | 21 - src/events/ResponseEvents.ts | 18 + src/events/SecurityEvents.d.ts | 34 - src/events/SecurityEvents.js | 64 - src/events/SecurityEvents.ts | 56 + src/events/ServerEvents.js | 75 - .../{ServerEvents.d.ts => ServerEvents.ts} | 50 +- src/events/StoreEvents.d.ts | 9 - src/events/{StoreEvents.js => StoreEvents.ts} | 5 +- src/events/TelemetryEvents.d.ts | 87 - src/events/TelemetryEvents.js | 72 - src/events/TelemetryEvents.ts | 108 + src/events/TypeEvents.d.ts | 18 - src/events/TypeEvents.js | 32 - src/events/TypeEvents.ts | 27 + src/lib/AmfParameterMixin.ts | 36 +- src/lib/ApiAuthDataHelper.ts | 4 +- src/lib/Utils.ts | 14 +- src/types.ts | 4 +- 128 files changed, 3605 insertions(+), 11247 deletions(-) rename dev/amf-server/{AmfParser.mjs => AmfParser.js} (100%) rename dev/amf-server/{AmfService.mjs => AmfService.js} (100%) rename dev/amf-server/{ApiError.mjs => ApiError.js} (100%) rename dev/amf-server/{api.mjs => api.js} (100%) delete mode 100644 src/elements/ApiAnnotationDocumentElement.d.ts rename src/elements/{ApiAnnotationDocumentElement.js => ApiAnnotationDocumentElement.ts} (55%) delete mode 100644 src/elements/ApiChannelDocumentElement.d.ts rename src/elements/{ApiChannelDocumentElement.js => ApiChannelDocumentElement.ts} (72%) delete mode 100644 src/elements/ApiDocumentationBase.d.ts rename src/elements/{ApiDocumentationBase.js => ApiDocumentationBase.ts} (61%) delete mode 100644 src/elements/ApiDocumentationDocumentElement.d.ts rename src/elements/{ApiDocumentationDocumentElement.js => ApiDocumentationDocumentElement.ts} (65%) delete mode 100644 src/elements/ApiDocumentationElement.d.ts rename src/elements/{ApiDocumentationElement.js => ApiDocumentationElement.ts} (58%) delete mode 100644 src/elements/ApiNavigationElement.d.ts rename src/elements/{ApiNavigationElement.js => ApiNavigationElement.ts} (67%) delete mode 100644 src/elements/ApiNavigationLegacyElement.d.ts delete mode 100644 src/elements/ApiNavigationLegacyElement.js delete mode 100644 src/elements/ApiOperationDocumentElement.d.ts rename src/elements/{ApiOperationDocumentElement.js => ApiOperationDocumentElement.ts} (65%) delete mode 100644 src/elements/ApiParameterDocumentElement.d.ts rename src/elements/{ApiParameterDocumentElement.js => ApiParameterDocumentElement.ts} (72%) delete mode 100644 src/elements/ApiParametrizedSecuritySchemeElement.d.ts rename src/elements/{ApiParametrizedSecuritySchemeElement.js => ApiParametrizedSecuritySchemeElement.ts} (50%) delete mode 100644 src/elements/ApiPayloadDocumentElement.d.ts rename src/elements/{ApiPayloadDocumentElement.js => ApiPayloadDocumentElement.ts} (72%) delete mode 100644 src/elements/ApiRequestDocumentElement.d.ts rename src/elements/{ApiRequestDocumentElement.js => ApiRequestDocumentElement.ts} (59%) delete mode 100644 src/elements/ApiRequestEditorElement.d.ts rename src/elements/{ApiRequestEditorElement.js => ApiRequestEditorElement.ts} (68%) rename src/elements/{ApiResourceDocumentElement.js => ApiResourceDocumentElement.ts} (60%) delete mode 100644 src/elements/ApiResponseDocumentElement.d.ts rename src/elements/{ApiResponseDocumentElement.js => ApiResponseDocumentElement.ts} (65%) delete mode 100644 src/elements/ApiResponseViewElement.d.ts rename src/elements/{ApiResponseViewElement.js => ApiResponseViewElement.ts} (66%) delete mode 100644 src/elements/ApiSchemaDocumentElement.d.ts rename src/elements/{ApiSchemaDocumentElement.js => ApiSchemaDocumentElement.ts} (60%) delete mode 100644 src/elements/ApiSecurityDocumentElement.d.ts rename src/elements/{ApiSecurityDocumentElement.js => ApiSecurityDocumentElement.ts} (62%) delete mode 100644 src/elements/ApiSecurityRequirementDocumentElement.d.ts rename src/elements/{ApiSecurityRequirementDocumentElement.js => ApiSecurityRequirementDocumentElement.ts} (69%) delete mode 100644 src/elements/ApiServerSelectorElement.d.ts rename src/elements/{ApiServerSelectorElement.js => ApiServerSelectorElement.ts} (67%) delete mode 100644 src/elements/ApiSummaryElement.d.ts rename src/elements/{ApiSummaryElement.js => ApiSummaryElement.ts} (67%) delete mode 100644 src/elements/SchemaCommonTemplates.d.ts rename src/elements/{SchemaCommonTemplates.js => SchemaCommonTemplates.ts} (70%) delete mode 100644 src/elements/XhrSimpleRequestElement.d.ts rename src/elements/{XhrSimpleRequestElement.js => XhrSimpleRequestElement.ts} (64%) rename src/elements/styles/{ApiAnnotation.js => ApiAnnotation.ts} (94%) rename src/elements/styles/{ApiDocumentation.js => ApiDocumentation.ts} (73%) rename src/elements/styles/{ApiDocumentationDocument.js => ApiDocumentationDocument.ts} (94%) rename src/elements/styles/{ApiOperation.js => ApiOperation.ts} (97%) rename src/elements/styles/{ApiSecurityRequirement.js => ApiParameter.ts} (59%) rename src/elements/styles/{ApiPayload.js => ApiPayload.ts} (72%) rename src/elements/styles/{ApiParameter.js => ApiRequest.ts} (59%) rename src/elements/styles/{ApiResource.js => ApiResource.ts} (98%) rename src/elements/styles/{ApiResponse.js => ApiResponse.ts} (91%) rename src/elements/styles/{ApiSchema.js => ApiSchema.ts} (94%) rename src/elements/styles/{ApiSecurityDocument.js => ApiSecurityDocument.ts} (96%) rename src/elements/styles/{ApiRequest.js => ApiSecurityRequirement.ts} (59%) rename src/elements/styles/{ApiSummary.js => ApiSummary.ts} (98%) delete mode 100644 src/elements/styles/AuthorizationEditor copy.js rename src/elements/styles/{AuthorizationEditor.js => AuthorizationEditor.ts} (90%) rename src/elements/styles/{AuthorizationMethod.js => AuthorizationMethod.ts} (96%) rename src/elements/styles/{Common.js => Common.ts} (99%) rename src/elements/styles/{Editor.styles.js => Editor.styles.ts} (98%) rename src/elements/styles/{HttpRequest.js => HttpRequest.ts} (94%) rename src/elements/styles/{NavStyles.js => NavStyles.ts} (99%) rename src/elements/styles/{Navigation.js => Navigation.ts} (99%) rename src/elements/styles/{Panel.styles.js => Panel.styles.ts} (79%) rename src/elements/styles/{ParametrizedSecurityElement.js => ParametrizedSecurityElement.ts} (91%) delete mode 100644 src/elements/styles/Response.styles.js create mode 100644 src/elements/styles/Response.styles.ts rename src/elements/styles/{SchemaCommon.js => SchemaCommon.ts} (99%) rename src/elements/styles/{ServerSelector.js => ServerSelector.ts} (89%) delete mode 100644 src/events/OperationEvents.d.ts delete mode 100644 src/events/OperationEvents.js create mode 100644 src/events/OperationEvents.ts delete mode 100644 src/events/PayloadEvents.d.ts delete mode 100644 src/events/PayloadEvents.js create mode 100644 src/events/PayloadEvents.ts delete mode 100644 src/events/ReportingEvents.d.ts delete mode 100644 src/events/ReportingEvents.js create mode 100644 src/events/ReportingEvents.ts delete mode 100644 src/events/RequestEvents.d.ts delete mode 100644 src/events/RequestEvents.js create mode 100644 src/events/RequestEvents.ts delete mode 100644 src/events/ResponseEvents.d.ts delete mode 100644 src/events/ResponseEvents.js create mode 100644 src/events/ResponseEvents.ts delete mode 100644 src/events/SecurityEvents.d.ts delete mode 100644 src/events/SecurityEvents.js create mode 100644 src/events/SecurityEvents.ts delete mode 100644 src/events/ServerEvents.js rename src/events/{ServerEvents.d.ts => ServerEvents.ts} (58%) delete mode 100644 src/events/StoreEvents.d.ts rename src/events/{StoreEvents.js => StoreEvents.ts} (71%) delete mode 100644 src/events/TelemetryEvents.d.ts delete mode 100644 src/events/TelemetryEvents.js create mode 100644 src/events/TelemetryEvents.ts delete mode 100644 src/events/TypeEvents.d.ts delete mode 100644 src/events/TypeEvents.js create mode 100644 src/events/TypeEvents.ts diff --git a/.eslintrc b/.eslintrc index 4929ce8..97c4a8b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,6 +16,7 @@ "no-continue": "off", "no-plusplus": "off", "no-shadow": "off", + "class-methods-use-this": "off", "@typescript-eslint/no-shadow": "error", "@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/no-unused-vars": [ @@ -32,29 +33,25 @@ }, "overrides": [ { - "files": [ - "src/pages/**/*.ts", - "src/bindings/**/*.ts" - ], + "files": [ "src/**/*.ts" ], "rules": { - "class-methods-use-this": "off" + "no-useless-constructor": "off", + "no-empty-function": "off", + "no-use-before-define": "off", + "no-dupe-class-members": "off" } }, { - "files": [ - "src/elements/**/*.ts" - ], + "files": [ "**/*.js" ], "rules": { - "class-methods-use-this": "off" + "@typescript-eslint/explicit-function-return-type": "off" } }, { - "files": [ "src/**/*.ts" ], + "files": ["demo/**", "dev/**", "test/**"], "rules": { - "no-useless-constructor": "off", - "no-empty-function": "off", - "no-use-before-define": "off", - "no-dupe-class-members": "off" + "import/no-extraneous-dependencies": "off", + "no-console": "off" } } ], diff --git a/demo/api-channel.js b/demo/api-channel.js index c82624b..bca8f15 100644 --- a/demo/api-channel.js +++ b/demo/api-channel.js @@ -1,6 +1,6 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-channel-document.js'; diff --git a/demo/api-console.js b/demo/api-console.js index 47fa738..dcda5df 100644 --- a/demo/api-console.js +++ b/demo/api-console.js @@ -1,9 +1,9 @@ import { html } from 'lit-html'; import { classMap } from 'lit-html/directives/class-map.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; -import '@anypoint-web-components/awc/anypoint-menu-button.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-menu-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; import '@advanced-rest-client/icons/arc-icon.js'; import { MonacoLoader } from "@advanced-rest-client/monaco-support"; import { ApplicationPage } from "./lib/ApplicationPage.js"; diff --git a/demo/api-documentation-partial.js b/demo/api-documentation-partial.js index bdaf293..649b07b 100644 --- a/demo/api-documentation-partial.js +++ b/demo/api-documentation-partial.js @@ -1,8 +1,8 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-dialog.js'; -import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog-scrollable.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import { AmfPartialGraphStore } from './lib/AmfPartialGraphStore.js'; import '../define/api-documentation.js'; diff --git a/demo/api-documentation.js b/demo/api-documentation.js index 6cb71a9..234977c 100644 --- a/demo/api-documentation.js +++ b/demo/api-documentation.js @@ -1,8 +1,8 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-dialog.js'; -import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog-scrollable.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-request.js'; import '../define/xhr-simple-request.js'; diff --git a/demo/api-editor.js b/demo/api-editor.js index 695271a..63eb729 100644 --- a/demo/api-editor.js +++ b/demo/api-editor.js @@ -1,9 +1,9 @@ import { html } from 'lit-html'; import { classMap } from 'lit-html/directives/class-map.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; -import '@anypoint-web-components/awc/anypoint-menu-button.js'; -import '@anypoint-web-components/awc/anypoint-listbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-menu-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-listbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; import '@advanced-rest-client/icons/arc-icon.js'; import { MonacoTheme, MonacoStyles, MonacoLoader } from '@advanced-rest-client/monaco-support'; import { DomEventsAmfStore } from "../src/store/DomEventsAmfStore.js"; diff --git a/demo/api-navigation.js b/demo/api-navigation.js index a706186..7747b9b 100644 --- a/demo/api-navigation.js +++ b/demo/api-navigation.js @@ -1,8 +1,8 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-radio-button.js'; -import '@anypoint-web-components/awc/anypoint-radio-group.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-group.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import { NavigationContextMenu, NavigationContextMenuCommands } from '../index.js'; import '../define/api-navigation.js'; diff --git a/demo/api-operation.js b/demo/api-operation.js index 0f86707..b64310a 100644 --- a/demo/api-operation.js +++ b/demo/api-operation.js @@ -1,8 +1,8 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-dialog.js'; -import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog-scrollable.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-operation-document.js'; import '../define/api-request.js'; diff --git a/demo/api-request.js b/demo/api-request.js index 44cd45d..e0cc634 100644 --- a/demo/api-request.js +++ b/demo/api-request.js @@ -1,5 +1,5 @@ import { html } from 'lit-html'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-navigation.js'; diff --git a/demo/api-resource.js b/demo/api-resource.js index deed9b8..bd3ac56 100644 --- a/demo/api-resource.js +++ b/demo/api-resource.js @@ -1,8 +1,8 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-dialog.js'; -import '@anypoint-web-components/awc/anypoint-dialog-scrollable.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-dialog-scrollable.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-resource-document.js'; import '../define/api-request.js'; diff --git a/demo/api-schema-documentation.js b/demo/api-schema-documentation.js index 45c03d5..ab640ec 100644 --- a/demo/api-schema-documentation.js +++ b/demo/api-schema-documentation.js @@ -2,7 +2,7 @@ import { html } from 'lit-html'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-schema-document.js'; import '../define/api-navigation.js'; diff --git a/demo/api-security-documentation.js b/demo/api-security-documentation.js index 1aef71e..5e7b4b3 100644 --- a/demo/api-security-documentation.js +++ b/demo/api-security-documentation.js @@ -1,7 +1,7 @@ /* eslint-disable lit-a11y/click-events-have-key-events */ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-security-document.js'; diff --git a/demo/api-summary.js b/demo/api-summary.js index eefc2b8..af3e78b 100644 --- a/demo/api-summary.js +++ b/demo/api-summary.js @@ -1,6 +1,6 @@ import { html } from 'lit-html'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-summary.js'; diff --git a/demo/request-editor.js b/demo/request-editor.js index c661b65..a882313 100644 --- a/demo/request-editor.js +++ b/demo/request-editor.js @@ -1,6 +1,6 @@ import { html } from 'lit-html'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; -import '@anypoint-web-components/awc/anypoint-item.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-item.js'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/xhr-simple-request.js'; diff --git a/demo/server-selector.js b/demo/server-selector.js index 17584d7..e323e86 100644 --- a/demo/server-selector.js +++ b/demo/server-selector.js @@ -1,5 +1,5 @@ import { html } from 'lit-html'; -import '@anypoint-web-components/awc/anypoint-checkbox.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-checkbox.js'; import '@advanced-rest-client/arc-demo-helper/arc-interactive-demo.js'; import { AmfDemoBase } from './lib/AmfDemoBase.js'; import '../define/api-server-selector.js'; diff --git a/dev/amf-server/AmfParser.mjs b/dev/amf-server/AmfParser.js similarity index 100% rename from dev/amf-server/AmfParser.mjs rename to dev/amf-server/AmfParser.js diff --git a/dev/amf-server/AmfService.mjs b/dev/amf-server/AmfService.js similarity index 100% rename from dev/amf-server/AmfService.mjs rename to dev/amf-server/AmfService.js diff --git a/dev/amf-server/ApiError.mjs b/dev/amf-server/ApiError.js similarity index 100% rename from dev/amf-server/ApiError.mjs rename to dev/amf-server/ApiError.js diff --git a/dev/amf-server/api.mjs b/dev/amf-server/api.js similarity index 100% rename from dev/amf-server/api.mjs rename to dev/amf-server/api.js diff --git a/package-lock.json b/package-lock.json index b30468f..87a4ffe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,8 +14,6 @@ "@advanced-rest-client/highlight": "^2.0.2", "@advanced-rest-client/http-code-snippets": "^4.0.1", "@advanced-rest-client/icons": "^4.0.0", - "@advanced-rest-client/oauth": "^0.2.1", - "@advanced-rest-client/uuid": "^4.0.0", "@anypoint-web-components/awc": "^3.0.12", "@api-client/context-menu": "^0.4.1", "@api-client/core": "^0.8.0", @@ -199,14 +197,6 @@ "lit-element": "^2.4.0" } }, - "node_modules/@advanced-rest-client/oauth": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.2.1.tgz", - "integrity": "sha512-R1Ke8SNs29AcOgw2MDm2d/iI7qjUIAF1DVGvnahZlKyCOrEH6xbak7BxRmEuNMayjbFdSUXQHDquUNS+lvaoNQ==", - "peerDependencies": { - "jsrsasign": "^10.4.0" - } - }, "node_modules/@advanced-rest-client/uuid": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@advanced-rest-client/uuid/-/uuid-4.0.0.tgz", @@ -9177,12 +9167,6 @@ "lit-element": "^2.4.0" } }, - "@advanced-rest-client/oauth": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@advanced-rest-client/oauth/-/oauth-0.2.1.tgz", - "integrity": "sha512-R1Ke8SNs29AcOgw2MDm2d/iI7qjUIAF1DVGvnahZlKyCOrEH6xbak7BxRmEuNMayjbFdSUXQHDquUNS+lvaoNQ==", - "requires": {} - }, "@advanced-rest-client/uuid": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@advanced-rest-client/uuid/-/uuid-4.0.0.tgz", diff --git a/src/elements/ApiAnnotationDocumentElement.d.ts b/src/elements/ApiAnnotationDocumentElement.d.ts deleted file mode 100644 index f5522cc..0000000 --- a/src/elements/ApiAnnotationDocumentElement.d.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { LitElement, TemplateResult } from 'lit-element'; -import { ApiDomainProperty, ApiCustomDomainProperty, ApiScalarNode, ApiObjectNode } from '../helpers/api'; - -export const shapeValue: unique symbol; -export const processShape: unique symbol; -export const propertiesValue: unique symbol; -export const propertyTemplate: unique symbol; -export const processVisibility: unique symbol; -export const scalarValue: unique symbol; -export const annotationWrapperTemplate: unique symbol; -export const scalarTemplate: unique symbol; -export const objectTemplate: unique symbol; -export const objectScalarPropertyTemplate: unique symbol; - -/** - * An element to render annotations (also known as custom properties) - * from AMF model. - * - * Annotations are part of RAML language and API console supports it. - * The element looks for annotations in model and renders them. - */ -export default class ApiAnnotationDocumentElement extends LitElement { - /** - * Serialized with `ApiSerializer` API domain model. - * This is to be used instead of `shape`. - */ - domainModel: ApiDomainProperty; - /** - * Computed value, true if any custom property has been found. - */ - get hasCustomProperties(): boolean; - - /** - * List of custom properties in the shape. - */ - get customProperties(): ApiCustomDomainProperty[] | undefined; - /** - * List of custom properties in the shape. - */ - set customProperties(value: ApiCustomDomainProperty[]); - - /** - * Called when the shape property change. - * Sets `hasCustomProperties` and `customList` properties. - * - * Note that for performance reasons, if the element determine that there's - * no custom properties wit will not clear `customList`. - * It will be updated only if the value actually change. - */ - [processShape](): void; - - [processVisibility](): void; - - [scalarValue](scalar: ApiScalarNode): any; - - render(): TemplateResult; - - /** - * @returns The template for the custom property. - */ - [propertyTemplate](property: ApiCustomDomainProperty): TemplateResult | string; - - /** - * @param name The annotation name - * @param content The content tp render. - * @returns The template for the custom property. - */ - [annotationWrapperTemplate](name: string, content: unknown): TemplateResult; - /** - * @returns The template for the custom property. - */ - [scalarTemplate](name: string, scalar: ApiScalarNode): TemplateResult; - /** - * @returns The template for the custom property. - */ - [objectTemplate](name: string, object: ApiObjectNode): TemplateResult; - /** - * @returns The template for the custom property. - */ - [objectScalarPropertyTemplate](name: string, scalar: ApiScalarNode): TemplateResult; -} diff --git a/src/elements/ApiAnnotationDocumentElement.js b/src/elements/ApiAnnotationDocumentElement.ts similarity index 55% rename from src/elements/ApiAnnotationDocumentElement.js rename to src/elements/ApiAnnotationDocumentElement.ts index d5f9149..c383c9b 100644 --- a/src/elements/ApiAnnotationDocumentElement.js +++ b/src/elements/ApiAnnotationDocumentElement.ts @@ -1,16 +1,11 @@ /* eslint-disable class-methods-use-this */ /* eslint-disable no-param-reassign */ -import { LitElement, html } from 'lit-element'; +import { html, TemplateResult, CSSResult, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; +import { AmfNamespace, AmfShapes } from '@api-client/core/build/browser.js'; +import { IApiCustomDomainProperty, IApiDomainProperty } from '@api-client/core/build/src/amf/definitions/Base.js'; import '@advanced-rest-client/icons/arc-icon.js'; import elementStyles from './styles/ApiAnnotation.js'; -import { ns } from '../helpers/Namespace.js'; - -/** @typedef {import('../helpers/amf').DomainElement} DomainElement */ -/** @typedef {import('../helpers/api').ApiDomainProperty} ApiDomainProperty */ -/** @typedef {import('../helpers/api').ApiCustomDomainProperty} ApiCustomDomainProperty */ -/** @typedef {import('../helpers/api').ApiScalarNode} ApiScalarNode */ -/** @typedef {import('../helpers/api').ApiObjectNode} ApiObjectNode */ -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ export const shapeValue = Symbol('shapeValue'); export const processShape = Symbol('processShape'); @@ -31,23 +26,22 @@ export const objectScalarPropertyTemplate = Symbol('objectScalarPropertyTemplate * The element looks for annotations in model and renders them. */ export default class ApiAnnotationDocumentElement extends LitElement { - get styles() { - return elementStyles; + static get styles(): CSSResult[] { + return [elementStyles]; } + [shapeValue]: IApiDomainProperty | undefined; + /** * Serialized with `ApiSerializer` API domain model. * This is to be used instead of `shape`. - * @returns {ApiDomainProperty|undefined} */ - get domainModel() { + @property({ type: Object }) + get domainModel(): IApiDomainProperty | undefined { return this[shapeValue]; } - /** - * @param {ApiDomainProperty} value - */ - set domainModel(value) { + set domainModel(value: IApiDomainProperty | undefined) { const oldValue = this[shapeValue]; if (oldValue === value) { return; @@ -56,25 +50,26 @@ export default class ApiAnnotationDocumentElement extends LitElement { this[processShape](); } + [propertiesValue]: IApiCustomDomainProperty[] | undefined; + /** - * @returns {boolean} `true` if any custom property has been found. + * @returns `true` if any custom property has been found. */ - get hasCustomProperties() { + get hasCustomProperties(): boolean { const properties = this[propertiesValue]; return Array.isArray(properties) && !!properties.length; } /** - * @returns {ApiCustomDomainProperty[]|undefined} List of custom properties in the shape. + * List of custom properties in the shape. */ - get customProperties() { + @property({ type: Array }) + get customProperties(): IApiCustomDomainProperty[] | undefined { return this[propertiesValue]; } - /** - * @param {ApiCustomDomainProperty[]} value - */ - set customProperties(value) { + + set customProperties(value: IApiCustomDomainProperty[] | undefined) { const old = this[propertiesValue]; if (old === value) { return; @@ -84,17 +79,11 @@ export default class ApiAnnotationDocumentElement extends LitElement { this.requestUpdate(); } - constructor() { - super(); - /** @type ApiCustomDomainProperty[] */ - this[propertiesValue] = undefined; - } - /** * Called when the shape property change. */ - [processShape]() { - const shape = /** @type ApiDomainProperty */ (this[shapeValue]); + [processShape](): void { + const shape = this[shapeValue]; this[propertiesValue] = undefined; if (!shape) { return; @@ -107,7 +96,7 @@ export default class ApiAnnotationDocumentElement extends LitElement { this.requestUpdate(); } - [processVisibility]() { + [processVisibility](): void { const { hasCustomProperties } = this; if (hasCustomProperties) { this.setAttribute('aria-hidden', 'false'); @@ -118,52 +107,46 @@ export default class ApiAnnotationDocumentElement extends LitElement { } } - /** - * @param {ApiScalarNode} scalar - * @returns {any} - */ - [scalarValue](scalar) { - let { value='' } = scalar; + [scalarValue](scalar: AmfShapes.IApiScalarNode): string | number | boolean { + let { value = '' } = scalar; if (value === 'nil') { value = ''; } return value; } - render() { + render(): TemplateResult | string { const { hasCustomProperties, customProperties } = this; - if (!hasCustomProperties) { + if (!hasCustomProperties || !customProperties) { return ''; } - const content = customProperties.map((property) => this[propertyTemplate](property)); + const content = customProperties.map((prop) => this[propertyTemplate](prop)); return html` - ${content} `; } /** - * @param {ApiCustomDomainProperty} property - * @returns {TemplateResult|string} The template for the custom property. + * @returns The template for the custom property. */ - [propertyTemplate](property) { - const { name, extension } = property; + [propertyTemplate](prop: IApiCustomDomainProperty): TemplateResult | string { + const { name, extension } = prop; const { types } = extension; - if (types.includes(ns.aml.vocabularies.data.Scalar)) { - return this[scalarTemplate](name, /** @type ApiScalarNode */ (extension)); - } - if (types.includes(ns.aml.vocabularies.data.Object)) { - return this[objectTemplate](name, /** @type ApiObjectNode */ (extension)); + if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) { + return this[scalarTemplate](name, extension as AmfShapes.IApiScalarNode); + } + if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) { + return this[objectTemplate](name, extension as AmfShapes.IApiObjectNode); } return ''; } - + /** - * @param {string} name The annotation name - * @param {unknown} content The content tp render. - * @returns {TemplateResult} The template for the custom property. + * @param name The annotation name + * @param content The content tp render. + * @returns The template for the custom property. */ - [annotationWrapperTemplate](name, content) { + [annotationWrapperTemplate](name: string, content: TemplateResult | (TemplateResult | string)[] | string): TemplateResult { return html`

@@ -176,26 +159,22 @@ export default class ApiAnnotationDocumentElement extends LitElement { } /** - * @param {string} name - * @param {ApiScalarNode} scalar - * @returns {TemplateResult} The template for the custom property. + * @returns The template for the custom property. */ - [scalarTemplate](name, scalar) { + [scalarTemplate](name: string, scalar: AmfShapes.IApiScalarNode): TemplateResult { const content = html`${this[scalarValue](scalar)}`; return this[annotationWrapperTemplate](name, content); } /** - * @param {string} name - * @param {ApiObjectNode} object - * @returns {TemplateResult} The template for the custom property. + * @returns The template for the custom property. */ - [objectTemplate](name, object) { - const { properties={} } = object; + [objectTemplate](name: string, object: AmfShapes.IApiObjectNode): TemplateResult { + const { properties = {} } = object; const content = Object.keys(properties).map((key) => { const value = properties[key]; const { types } = value; - if (types.includes(ns.aml.vocabularies.data.Scalar)) { + if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) { return this[objectScalarPropertyTemplate](key, value); } return key; @@ -204,11 +183,9 @@ export default class ApiAnnotationDocumentElement extends LitElement { } /** - * @param {string} name - * @param {ApiScalarNode} scalar - * @returns {TemplateResult} The template for the custom property. + * @returns The template for the custom property. */ - [objectScalarPropertyTemplate](name, scalar) { + [objectScalarPropertyTemplate](name: string, scalar: AmfShapes.IApiScalarNode): TemplateResult { const value = this[scalarValue](scalar); return html`
diff --git a/src/elements/ApiAuthorizationEditorElement.js b/src/elements/ApiAuthorizationEditorElement.js index 4398b51..37d076f 100644 --- a/src/elements/ApiAuthorizationEditorElement.js +++ b/src/elements/ApiAuthorizationEditorElement.js @@ -1,6 +1,8 @@ /* eslint-disable no-plusplus */ /* eslint-disable class-methods-use-this */ -import { html, LitElement } from 'lit-element'; +import { html, TemplateResult, CSSResult, LitElement } from 'lit'; +import { property, state } from 'lit/decorators.js'; +import { ApiDefinitions } from '@api-client/core/build/browser.js'; import '@advanced-rest-client/base/define/authorization-method.js'; import elementStyles from './styles/AuthorizationEditor.js'; import '../../define/api-authorization-method.js'; @@ -41,7 +43,7 @@ export const createSettings = Symbol('createSettings'); export const openIdConnectTemplate = Symbol('openIdConnectTemplate'); export default class ApiAuthorizationEditorElement extends LitElement { - get styles() { + static get styles(): CSSResult[] { return elementStyles; } diff --git a/src/elements/ApiAuthorizationMethodElement.js b/src/elements/ApiAuthorizationMethodElement.js index 62772dc..984d964 100644 --- a/src/elements/ApiAuthorizationMethodElement.js +++ b/src/elements/ApiAuthorizationMethodElement.js @@ -46,7 +46,7 @@ export default class ApiAuthorizationMethodElement extends AuthorizationMethod { /** * @returns {CSSResult} */ - get styles() { + static get styles(): CSSResult[] { // @ts-ignore return [ super.styles, @@ -224,7 +224,8 @@ export default class ApiAuthorizationMethodElement extends AuthorizationMethod { } this[factory] = instance; instance.defaults(); - await this.requestUpdate(); + this.requestUpdate(); + await this.updateComplete; this.dispatchEvent(new Event('resize', { bubbles: true, composed: true })); } diff --git a/src/elements/ApiChannelDocumentElement.d.ts b/src/elements/ApiChannelDocumentElement.d.ts deleted file mode 100644 index 497f1fa..0000000 --- a/src/elements/ApiChannelDocumentElement.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TemplateResult } from 'lit-element'; -import ApiResourceDocumentElement, { urlTemplate, titleTemplate, computeUrlValue, operationTemplate, } from './ApiResourceDocumentElement.js'; -import { ApiOperation } from '../helpers/api'; - -/** - * A web component that renders the async API Channel documentation page - */ -export default class ApiChannelDocumentElement extends ApiResourceDocumentElement { - /** - * Computes the URL value for the current serves, selected server, and endpoint's path. - */ - [computeUrlValue](): void; - - /** - * @returns The template for the Operation title. - */ - [titleTemplate](): TemplateResult|string; - - /** - * @returns The template for the operation's URL. - */ - [urlTemplate](): TemplateResult|string; - - /** - * @param operation The graph id of the operation. - * @returns The template for the API operation. - */ - [operationTemplate](operation: ApiOperation): TemplateResult|string; -} diff --git a/src/elements/ApiChannelDocumentElement.js b/src/elements/ApiChannelDocumentElement.ts similarity index 72% rename from src/elements/ApiChannelDocumentElement.js rename to src/elements/ApiChannelDocumentElement.ts index 06365c8..26bc207 100644 --- a/src/elements/ApiChannelDocumentElement.js +++ b/src/elements/ApiChannelDocumentElement.ts @@ -1,5 +1,5 @@ -/* eslint-disable class-methods-use-this */ -import { html } from 'lit-element'; +import { html, TemplateResult } from 'lit'; +import { ApiDefinitions } from '@api-client/core/build/browser.js'; import ApiResourceDocumentElement, { endpointValue, urlValue, @@ -11,9 +11,6 @@ import ApiResourceDocumentElement, { import '../../define/api-operation-document.js' import '../../define/api-parameter-document.js'; -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('../helpers/api').ApiOperation} ApiOperation */ - /** * A web component that renders the async API Channel documentation page */ @@ -21,7 +18,7 @@ export default class ApiChannelDocumentElement extends ApiResourceDocumentElemen /** * Computes the URL value for the current serves, selected server, and endpoint's path. */ - [computeUrlValue]() { + [computeUrlValue](): void { const { server, protocol='' } = this; let url = ''; if (server) { @@ -42,10 +39,13 @@ export default class ApiChannelDocumentElement extends ApiResourceDocumentElemen } /** - * @returns {TemplateResult|string} The template for the Operation title. + * @returns The template for the Operation title. */ - [titleTemplate]() { + [titleTemplate](): TemplateResult|string { const endPoint = this[endpointValue]; + if (!endPoint) { + return ''; + } const { name, path } = endPoint; const label = name || path; if (!label) { @@ -62,9 +62,9 @@ export default class ApiChannelDocumentElement extends ApiResourceDocumentElemen } /** - * @returns {TemplateResult} The template for the operation's URL. + * @returns The template for the operation's URL. */ - [urlTemplate]() { + [urlTemplate](): TemplateResult { const url = this[urlValue]; return html`
@@ -74,18 +74,18 @@ export default class ApiChannelDocumentElement extends ApiResourceDocumentElemen } /** - * @param {ApiOperation} operation The graph id of the operation. - * @returns {TemplateResult} The template for the API operation. + * @param operation The graph id of the operation. + * @returns The template for the API operation. */ - [operationTemplate](operation) { - const { serverId, endpoint, baseUri } = this; + [operationTemplate](endpoint: ApiDefinitions.IApiEndPoint, operation: ApiDefinitions.IApiOperation): TemplateResult { + const { serverId, baseUri } = this; return html`; - - /** - * A handler for the section toggle button click. - */ - [sectionToggleClickHandler](e: Event): void; - - /** - * @param examples The list of examples to evaluate - * @param mediaType The media type to use with examples processing. - */ - [evaluateExamples](examples: ApiExample[], mediaType: string): SchemaExample[]; - - /** - * @param example The example to evaluate - * @param mediaType The media type to use with examples processing. - */ - [evaluateExample](example: ApiExample, mediaType: string): SchemaExample; - - /** - * @return The template for the section toggle button - */ - [sectionToggleTemplate](ctrlProperty: string): TemplateResult; - /** - * @param label The section label. - * @param openedProperty The name of the element property to be toggled when interacting with the toggle button. - * @param content The content to render. - * @returns The template for a toggle section with a content. - */ - [paramsSectionTemplate](label: string, openedProperty: string, content: TemplateResult | TemplateResult[]): TemplateResult; - /** - * @param model The parameter to render. - * @param dataName Optional data-name for this parameter - * @return The template for the schema item document - */ - [schemaItemTemplate](model: ApiParameter, dataName?: string): TemplateResult; - /** - * @param description The description to render. - * @returns The template for the markdown description. - */ - [descriptionTemplate](description: string): TemplateResult|string; - /** - * @param customDomainProperties - * @returns The template for the custom domain properties - */ - [customDomainPropertiesTemplate](customDomainProperties: ApiCustomDomainProperty[]): TemplateResult|string; - /** - * @returns The template for the examples section. - */ - [examplesTemplate](): TemplateResult|string; - - /** - * @returns The template for a single example - */ - [exampleTemplate](item: SchemaExample): TemplateResult|string; -} diff --git a/src/elements/ApiDocumentationBase.js b/src/elements/ApiDocumentationBase.ts similarity index 61% rename from src/elements/ApiDocumentationBase.js rename to src/elements/ApiDocumentationBase.ts index 97a1fab..16314f1 100644 --- a/src/elements/ApiDocumentationBase.js +++ b/src/elements/ApiDocumentationBase.ts @@ -1,23 +1,20 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable lit-a11y/click-events-have-key-events */ /* eslint-disable class-methods-use-this */ -import { LitElement, html } from 'lit-element'; -import { classMap } from 'lit-html/directives/class-map.js'; -import { ifDefined } from 'lit-html/directives/if-defined.js'; -import { EventsTargetMixin } from '@anypoint-web-components/awc'; -import '@anypoint-web-components/awc/anypoint-button.js'; -import '@anypoint-web-components/awc/anypoint-collapse.js'; +import { LitElement, html, TemplateResult } from 'lit'; +import { property } from 'lit/decorators.js'; +import { IApiCustomDomainProperty } from '@api-client/core/build/src/amf/definitions/Base.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { EventsTargetMixin } from '@anypoint-web-components/awc'; +import { ApiExampleGenerator, AmfShapes, ApiDefinitions } from '@api-client/core/build/browser.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-collapse.js'; import '@advanced-rest-client/icons/arc-icon.js'; import '@advanced-rest-client/highlight/arc-marked.js'; -import { ApiExampleGenerator } from '../schema/ApiExampleGenerator.js'; import { EventTypes } from '../events/EventTypes.js'; import '../../define/api-annotation-document.js'; - -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('../helpers/amf').DomainElement} DomainElement */ -/** @typedef {import('../helpers/api').ApiParameter} ApiParameter */ -/** @typedef {import('../helpers/api').ApiCustomDomainProperty} ApiCustomDomainProperty */ -/** @typedef {import('../helpers/api').ApiExample} ApiExample */ -/** @typedef {import('../types').SchemaExample} SchemaExample */ +import { SchemaExample } from '../types.js'; export const sectionToggleClickHandler = Symbol('sectionToggleClickHandler'); export const processDebounce = Symbol('queryDebounce'); @@ -40,17 +37,17 @@ export const graphChangeHandler = Symbol('graphChangeHandler'); * A base class for the documentation components with common templates and functions. */ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { + [domainIdValue]?: string; + /** - * @returns {string|undefined} The domain id of the object to render. + * The domain id of the object to render. + * @attribute */ - get domainId() { + @property({ type: String, reflect: true }) get domainId(): string | undefined { return this[domainIdValue]; } - /** - * @returns {string|undefined} The domain id of the object to render. - */ - set domainId(value) { + set domainId(value: string | undefined) { const old = this[domainIdValue]; if (old === value) { return; @@ -62,44 +59,36 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } } - static get properties() { - return { - /** - * The domain id of the object to render. - */ - domainId: { type: String, reflect: true }, - /** - * Enables Anypoint platform styles. - */ - anypoint: { type: Boolean, reflect: true }, - }; - } + /** + * Enables Anypoint platform styles. + * @attribute + */ + @property({ type: Boolean, reflect: true }) anypoint?: boolean; + + /** + * The timeout after which the `queryGraph()` function is called + * in the debouncer. + */ + protected queryDebouncerTimeout?: number; + + [examplesValue]?: SchemaExample[]; + + [debounceValue]?: any; constructor() { super(); - /** - * The timeout after which the `queryGraph()` function is called - * in the debouncer. - */ this.queryDebouncerTimeout = 1; - /** @type {boolean} */ - this.anypoint = undefined; - /** - * @type {SchemaExample[]} - */ - this[examplesValue] = undefined; - this[graphChangeHandler] = this[graphChangeHandler].bind(this); } - connectedCallback() { + connectedCallback(): void { super.connectedCallback(); if (this.domainId) { this[processDebounce](); } } - disconnectedCallback() { + disconnectedCallback(): void { super.disconnectedCallback(); if (this[debounceValue]) { clearTimeout(this[debounceValue]); @@ -107,18 +96,13 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } } - /** - * @param {EventTarget} node - */ - _attachListeners(node) { + _attachListeners(node: EventTarget): void { node.addEventListener(EventTypes.Store.graphChange, this[graphChangeHandler]); super._attachListeners(node); } - /** - * @param {EventTarget} node - */ - _detachListeners(node) { + + _detachListeners(node: EventTarget): void { node.removeEventListener(EventTypes.Store.graphChange, this[graphChangeHandler]); super._detachListeners(node); } @@ -126,14 +110,14 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { /** * Handler for the event dispatched by the store when the graph model change. */ - [graphChangeHandler]() { + [graphChangeHandler](): void { this[processDebounce](); } /** * Calls the `queryGraph()` function in a debouncer. */ - [processDebounce]() { + [processDebounce](): void { if (this[debounceValue]) { clearTimeout(this[debounceValue]); } @@ -147,17 +131,16 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { * The main function to use to process the AMF model. * To be implemented by the child classes. */ - processGraph() { + processGraph(): void | Promise { // ... } /** * At current state there's no way to tell where to navigate when relative * link is clicked. To prevent 404 anchors this prevents any relative link click. - * @param {Event} e */ - [clickHandler](e) { - const node = /** @type HTMLElement */ (e.target); + [clickHandler](e: Event): void { + const node = (e.target as HTMLElement); if (node.localName !== 'a') { return; } @@ -178,32 +161,29 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { /** * A handler for the section toggle button click. - * @param {Event} e */ - [sectionToggleClickHandler](e) { - const button = /** @type HTMLElement */ (e.currentTarget); - const { ctrlProperty } = button.dataset; - if (!ctrlProperty) { + [sectionToggleClickHandler](e: Event): void { + const button = (e.currentTarget as HTMLElement); + const prop = button.dataset.ctrlProperty; + if (!prop) { return; } - this[ctrlProperty] = !this[ctrlProperty]; + (this as any)[prop] = !(this as any)[prop]; } /** - * @param {ApiExample[]} examples The list of examples to evaluate - * @param {string} mediaType The media type to use with examples processing. - * @returns {SchemaExample[]} + * @param examples The list of examples to evaluate + * @param mediaType The media type to use with examples processing. */ - [evaluateExamples](examples, mediaType) { + [evaluateExamples](examples: AmfShapes.IApiDataExample[], mediaType: string): SchemaExample[] { return examples.map((example) => this[evaluateExample](example, mediaType)) } /** - * @param {ApiExample} example The example to evaluate - * @param {string} mediaType The media type to use with examples processing. - * @returns {SchemaExample} + * @param example The example to evaluate + * @param mediaType The media type to use with examples processing. */ - [evaluateExample](example, mediaType) { + [evaluateExample](example: AmfShapes.IApiDataExample, mediaType: string): SchemaExample { let value; if (mediaType) { const generator = new ApiExampleGenerator(); @@ -213,10 +193,10 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } const { name, displayName } = example; const label = displayName || name; - const result = /** @type SchemaExample */ ({ + const result: SchemaExample = { ...example, renderValue: value, - }); + }; if (label && !label.startsWith('example_')) { result.label = label; } @@ -224,11 +204,10 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } /** - * @param {string} ctrlProperty - * @return {TemplateResult|string} The template for the section toggle button + * @returns The template for the section toggle button */ - [sectionToggleTemplate](ctrlProperty) { - const label = this[ctrlProperty] ? 'Hide' : 'Show'; + [sectionToggleTemplate](ctrlProperty: string): TemplateResult | string { + const label = (this as any)[ctrlProperty] ? 'Hide' : 'Show'; return html` ${label} @@ -237,13 +216,13 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } /** - * @param {string} label The section label. - * @param {string} openedProperty The name of the element property to be toggled when interacting with the toggle button. - * @param {TemplateResult|TemplateResult[]} content The content to render. - * @returns {TemplateResult} The template for a toggle section with a content. + * @param label The section label. + * @param openedProperty The name of the element property to be toggled when interacting with the toggle button. + * @param content The content to render. + * @returns The template for a toggle section with a content. */ - [paramsSectionTemplate](label, openedProperty, content) { - const opened = this[openedProperty]; + [paramsSectionTemplate](label: string, openedProperty: string, content: TemplateResult | (TemplateResult | string)[]): TemplateResult { + const opened = (this as any)[openedProperty]; const classes = { 'params-title': true, opened, @@ -266,11 +245,11 @@ export class ApiDocumentationBase extends EventsTargetMixin(LitElement) { } /** - * @param {ApiParameter} model The parameter to render. - * @param {string=} dataName Optional data-name for this parameter - * @return {TemplateResult} The template for the schema item document + * @param model The parameter to render. + * @param dataName Optional data-name for this parameter + * @returns The template for the schema item document */ - [schemaItemTemplate](model, dataName) { + [schemaItemTemplate](model: ApiDefinitions.IApiParameter, dataName?: string): TemplateResult { return html` diff --git a/src/elements/ApiDocumentationDocumentElement.d.ts b/src/elements/ApiDocumentationDocumentElement.d.ts deleted file mode 100644 index 8d64051..0000000 --- a/src/elements/ApiDocumentationDocumentElement.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { TemplateResult } from 'lit-element'; -import { ApiDocumentation } from '../helpers/api'; -import { ApiDocumentationBase } from './ApiDocumentationBase'; - -export const documentationValue: unique symbol; -export const titleTemplate: unique symbol; -export const queryDocument: unique symbol; - -/** - * A web component that renders the documentation page for an API documentation (like in RAML documentations) built from - * the AMF graph model. - */ -export default class ApiDocumentationDocumentElement extends ApiDocumentationBase { - /** - * @returns The serialized to a JS object graph model - */ - documentation: ApiDocumentation|undefined; - - [documentationValue]: ApiDocumentation; - constructor(); - - /** - * Queries the graph store for the API Documentation data. - */ - processGraph(): Promise; - - /** - * Queries for the documentation model. - */ - [queryDocument](): Promise; - - render(): TemplateResult; - - /** - * @returns The template for the Documentation title. - */ - [titleTemplate](): TemplateResult; -} diff --git a/src/elements/ApiDocumentationDocumentElement.js b/src/elements/ApiDocumentationDocumentElement.ts similarity index 65% rename from src/elements/ApiDocumentationDocumentElement.js rename to src/elements/ApiDocumentationDocumentElement.ts index e892f5f..8bcf5fe 100644 --- a/src/elements/ApiDocumentationDocumentElement.js +++ b/src/elements/ApiDocumentationDocumentElement.ts @@ -1,5 +1,6 @@ /* eslint-disable class-methods-use-this */ -import { html } from 'lit-element'; +import { html, TemplateResult, CSSResult } from 'lit'; +import { ApiDefinitions } from '@api-client/core/build/browser.js'; import { MarkdownStyles } from '@advanced-rest-client/highlight'; import { HttpStyles } from '@advanced-rest-client/base/api.js'; import elementStyles from './styles/ApiDocumentationDocument.js'; @@ -7,9 +8,6 @@ import commonStyles from './styles/Common.js'; import { ApiDocumentationBase, descriptionTemplate } from './ApiDocumentationBase.js'; import { Events } from '../events/Events.js'; -/** @typedef {import('lit-element').TemplateResult} TemplateResult */ -/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ - export const documentationValue = Symbol('documentationValue'); export const titleTemplate = Symbol('titleTemplate'); export const queryDocument = Symbol('queryDocument'); @@ -19,20 +17,19 @@ export const queryDocument = Symbol('queryDocument'); * the AMF graph model. */ export default class ApiDocumentationDocumentElement extends ApiDocumentationBase { - get styles() { + static get styles(): CSSResult[] { return [elementStyles, commonStyles, HttpStyles.default, MarkdownStyles]; } + [documentationValue]: ApiDefinitions.IApiDocumentation | undefined + /** - * @returns {ApiDocumentation|undefined} The serialized to a JS object graph model + * The serialized to a JS object graph model */ - get documentation() { + get documentation(): ApiDefinitions.IApiDocumentation | undefined { return this[documentationValue]; } - /** - * @param {ApiDocumentation} value The serialized to a JS object graph model - */ set documentation(value) { const old = this[documentationValue]; if (old === value) { @@ -42,26 +39,19 @@ export default class ApiDocumentationDocumentElement extends ApiDocumentationBas this.processGraph(); } - constructor() { - super(); - /** @type {ApiDocumentation} */ - this[documentationValue] = undefined; - } - /** * Queries the graph store for the API Documentation data. - * @returns {Promise} */ - async processGraph() { + async processGraph(): Promise { await this[queryDocument](); - await this.requestUpdate(); + this.requestUpdate(); + await this.updateComplete; } /** * Queries for the documentation model. - * @returns {Promise} */ - async [queryDocument]() { + async [queryDocument](): Promise { const { domainId } = this; if (!domainId) { return; @@ -75,27 +65,27 @@ export default class ApiDocumentationDocumentElement extends ApiDocumentationBas this[documentationValue] = info; } catch (e) { this[documentationValue] = undefined; - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Unable to query for API documentation data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Unable to query for API documentation data: ${ex.message}`, this.localName); } } - render() { - if (!this[documentationValue]) { + render(): TemplateResult { + const docs = this[documentationValue]; + if (!docs) { return html``; } return html` - - ${this[titleTemplate]()} - ${this[descriptionTemplate](this[documentationValue].description)} + ${this[titleTemplate](docs)} + ${this[descriptionTemplate](docs.description)} `; } /** - * @returns {TemplateResult|string} The template for the Documentation title. + * @returns The template for the Documentation title. */ - [titleTemplate]() { - const docs = this[documentationValue]; + [titleTemplate](docs: ApiDefinitions.IApiDocumentation): TemplateResult | string { const { title } = docs; if (!title) { return ''; diff --git a/src/elements/ApiDocumentationElement.d.ts b/src/elements/ApiDocumentationElement.d.ts deleted file mode 100644 index 1a96639..0000000 --- a/src/elements/ApiDocumentationElement.d.ts +++ /dev/null @@ -1,287 +0,0 @@ -import { TemplateResult } from 'lit-element'; -import { Oauth2Credentials } from '@advanced-rest-client/base'; -import { ApiDocumentationBase } from './ApiDocumentationBase.js'; -import { ApiSummary } from '../helpers/api'; -import { ServerType, SelectionType, DocumentMeta } from '../types'; -import { ApiNavigationEvent } from '../events/NavigationEvents'; - -export const operationIdValue: unique symbol; -export const domainIdValue: unique symbol; -export const domainTypeValue: unique symbol; -export const navigationHandler: unique symbol; -export const navEventsRegistered: unique symbol; -export const registerNavigationEvents: unique symbol; -export const unregisterNavigationEvents: unique symbol; -export const handleNavigationEventsValue: unique symbol; -export const processApiSpecSelection: unique symbol; -export const processLibrarySelection: unique symbol; -export const renderedViewValue: unique symbol; -export const renderedModelValue: unique symbol; -export const processFragment: unique symbol; -export const processPartial: unique symbol; -export const processEndpointPartial: unique symbol; -export const apiSummaryValue: unique symbol; -export const serverSelectorTemplate: unique symbol; -export const serversCountHandler: unique symbol; -export const serverChangeHandler: unique symbol; -export const modelTemplate: unique symbol; -export const summaryTemplate: unique symbol; -export const securityTemplate: unique symbol; -export const documentationTemplate: unique symbol; -export const schemaTemplate: unique symbol; -export const resourceTemplate: unique symbol; - -/** - * A main documentation view for an AMF model representing a sync or an async API. - * - * This element works with the [AMF](https://github.com/mulesoft/amf) data model. - * - * @fires tryit - * @fires apirequest - * @fires apiabort - * @fires apinavigate - */ -export default class ApiDocumentationElement extends ApiDocumentationBase { - /** - * Type of the selected domain item. - * @attribute - */ - domainType: SelectionType; - [domainTypeValue]: SelectionType; - /** - * The domain id of the currently rendered API operation. - * When selecting an operation the `domainId` is the id if the parent endpoint. - * @attribute - */ - operationId: string; - [operationIdValue]: string; - /** - * By default application hosting the element must set `domainId` and - * `domainType` properties. When using `api-navigation` element - * by setting this property the element listens for navigation events - * and updates the state - * @attribute - */ - handleNavigationEvents: boolean; - [handleNavigationEventsValue]: boolean; - /** - * A property to set to override AMF's model base URI information. - * @attribute - */ - baseUri: string; - /** - * When set it renders the "try it" button that dispatches the `tryit` event. - * @attribute - */ - tryItButton: boolean; - /** - * When set it renders the "try it" panel next to the operation documentation. - * Setting this automatically disables the `tryItButton` property. - * - * Note, use this only when there's enough space on the screen to render 2 panels side-by-side. - * @attribute - */ - tryItPanel: boolean; - /** - * OAuth2 redirect URI. - * This value **must** be set in order for OAuth 1/2 to work properly. - * This is only required in inline mode (`inlineMethods`). - * @attribute - */ - redirectUri: string; - /** - * When set it renders the URL input above the URL parameters in the HTTP editor. - * @attribute - */ - httpUrlEditor: boolean; - /** - * When set it applies the authorization values to the request dispatched - * with the API request event. - * If possible, it applies the authorization values to query parameter or headers - * depending on the configuration. - * - * When the values arr applied to the request the authorization config is kept in the - * request object, but its `enabled` state is always `false`, meaning other potential - * processors should ignore this values. - * - * If this property is not set then the application hosting this component should - * process the authorization data and apply them to the request. - * @attribute - */ - httpApplyAuthorization: boolean; - /** - * List of credentials source passed to the HTTP editor - * @attribute - */ - httpCredentialsSource: Oauth2Credentials; - /** - * Optional property to set on the request editor. - * When true, the server selector is not rendered - * @attribute - */ - noServerSelector: boolean; - /** - * When set it renders "add custom" item button in the HTTP request editor. - * If the element is to be used without AMF model this should always - * be enabled. Otherwise users won't be able to add a parameter. - * @attribute - */ - httpAllowCustom: boolean; - /** - * Optional property to set on the request editor. - * If true, the server selector custom base URI option is rendered - * @attribute - */ - allowCustomBaseUri: boolean; - /** - * The URI of the server currently selected in the server selector - * @attribute - */ - serverValue: string; - /** - * The type of the server currently selected in the server selector - * @attribute - */ - serverType: ServerType; - serversCount: number; - /** - * Former `effectiveBaseUri`. - * @returns The URI for the API defined by the `baseUri` property or the `serverValue`. - */ - get apiBaseUri(): string | undefined; - - /** - * @deprecated Use `apiBaseUri` instead. - */ - get effectiveBaseUri(): string | undefined; - - /** @returns The domain type of the rendered view. */ - get renderedView(): string; - - /** @returns The domain model rendered in the view. */ - get renderedModel(): any; - - get renderSelector(): boolean; - - /** - * This is a computed value from the AMF model. - * @returns true when whe currently loaded API is an async API. - */ - get isAsync(): boolean; - /** - * @returns The mime type of the schema that is being rendered. - */ - get schemaMime(): string|undefined; - get documentMeta(): DocumentMeta; - [apiSummaryValue]: ApiSummary; - [navEventsRegistered]: boolean; - /** - * The mime type of the currently selected schema. - * @attribute - */ - schemaMimeType: string; - - constructor(); - - disconnectedCallback(): void; - - /** - * Registers the api navigation event listener handler - * on the window object. - */ - [registerNavigationEvents](): void; - - /** - * Removes event listener from window object for the API navigation event. - */ - [unregisterNavigationEvents](): void; - - /** - * Handler for the API navigation event. - * - * Note, when the current type is set to `operation` then the `operationId` is - * set instead of `domainId`, which is set to the parent endpoint id. - */ - [navigationHandler](e: ApiNavigationEvent): void; - - processGraph(): Promise; - - /** - * Processes selection for the web API data model. It ignores the input if - * `domainId` or `domainType` is not set. - * - * @param model WebApi AMF model. Do not use an array here. - */ - [processApiSpecSelection](): void; - - /** - * Processes selection for a library data model. It ignores the input if - * `domainId` or `domainType` is not set. - * @param model Library AMF model. Do not use an array here. - */ - [processLibrarySelection](): void; - - /** - * Processes fragment model and sets current selection and the model. - * - * @param model RAML fragment model - * @param domainType The selected domain type. - */ - [processFragment](domainType: SelectionType): void; - - /** - * Sets the partial model to be rendered. - * - * @param model RAML partial model - * @param domainType The domain type representing the partial model. - */ - [processPartial](domainType: SelectionType): void; - - /** - * Processes endpoint data from partial model definition. - * It sets models that are used by the docs. - * - * If `selected` or `selectedType` is not set then it automatically selects - * an endpoint. - */ - [processEndpointPartial](): void; - - [serversCountHandler](e: CustomEvent): void; - [serverChangeHandler](e: CustomEvent): void; - - render(): TemplateResult; - - /** - * @returns The template for the server selector. - */ - [serverSelectorTemplate](): TemplateResult|string; - - /** - * @returns The template for the server selector. - */ - [modelTemplate](): TemplateResult|string; - - /** - * @returns The template for the API summary page. - */ - [summaryTemplate](): TemplateResult|string; - - /** - * @returns The template for the API security definition page. - */ - [securityTemplate](): TemplateResult|string; - /** - * @returns The template for the RAML's documentation page. - */ - [documentationTemplate](): TemplateResult|string; - - /** - * @returns The template for the API schema page. - */ - [schemaTemplate](): TemplateResult|string; - - /** - * @returns The template for the API endpoint page. - */ - [resourceTemplate](): TemplateResult|string; -} diff --git a/src/elements/ApiDocumentationElement.js b/src/elements/ApiDocumentationElement.ts similarity index 58% rename from src/elements/ApiDocumentationElement.js rename to src/elements/ApiDocumentationElement.ts index 0376b53..60f2e24 100644 --- a/src/elements/ApiDocumentationElement.js +++ b/src/elements/ApiDocumentationElement.ts @@ -1,17 +1,19 @@ /* eslint-disable no-param-reassign */ -/* eslint-disable class-methods-use-this */ -import { html } from 'lit-element'; -import '@anypoint-web-components/awc/anypoint-radio-button.js'; -import '@anypoint-web-components/awc/anypoint-radio-group.js'; +import { html, TemplateResult, CSSResult } from 'lit'; +import { property } from 'lit/decorators.js'; +import { ApiDefinitions, AmfNamespace } from '@api-client/core/build/browser.js'; +import { Oauth2Credentials } from '@advanced-rest-client/base'; +import { AnypointRadioGroupElement } from '@anypoint-web-components/awc'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-radio-group.js'; import elementStyles from './styles/ApiDocumentation.js'; -import { +import { ApiDocumentationBase, processDebounce, domainIdValue, } from './ApiDocumentationBase.js'; import { EventTypes } from '../events/EventTypes.js'; import { Events } from '../events/Events.js'; -import { ns } from '../helpers/Namespace.js'; import '../../define/api-summary.js' import '../../define/api-operation-document.js' import '../../define/api-resource-document.js'; @@ -19,6 +21,9 @@ import '../../define/api-security-document.js'; import '../../define/api-documentation-document.js'; import '../../define/api-schema-document.js'; import '../../define/api-server-selector.js'; +import { DocumentMeta, SelectionType } from '../types.js'; +import { ServerChangeEvent, ServerCountChangeEvent } from '../events/ServerEvents.js'; +import { ApiNavigationEvent } from '../events/NavigationEvents.js'; /** @typedef {import('lit-element').TemplateResult} TemplateResult */ /** @typedef {import('../helpers/api').ApiSummary} ApiSummary */ @@ -65,113 +70,145 @@ export const queryApiSummary = Symbol('queryApiSummary'); * This element works with the [AMF](https://github.com/mulesoft/amf) data model. */ export default class ApiDocumentationElement extends ApiDocumentationBase { - get styles() { - return elementStyles; - } - - static get properties() { - return { - /** - * Type of the selected domain item. - */ - domainType: { type: String }, - /** - * The domain id of the currently rendered API operation. - * When selecting an operation the `domainId` is the id if the parent endpoint. - */ - operationId: { type: String }, - /** - * By default application hosting the element must set `domainId` and - * `domainType` properties. When using `api-navigation` element - * by setting this property the element listens for navigation events - * and updates the state - */ - handleNavigationEvents: { type: Boolean }, - /** - * A property to set to override AMF's model base URI information. - */ - baseUri: { type: String }, - /** - * When set it renders the "try it" button that dispatches the `tryit` event. - */ - tryItButton: { type: Boolean, reflect: true }, - /** - * When set it renders the "try it" panel next to the operation documentation. - * Setting this automatically disables the `tryItButton` property. - * - * Note, use this only when there's enough space on the screen to render 2 panels side-by-side. - */ - tryItPanel: { type: Boolean, reflect: true }, - /** - * OAuth2 redirect URI. - * This value **must** be set in order for OAuth 1/2 to work properly. - * This is only required in inline mode (`inlineMethods`). - */ - redirectUri: { type: String }, - /** - * When set it renders the URL input above the URL parameters in the HTTP editor. - */ - httpUrlEditor: { type: Boolean, reflect: true }, - /** - * When set it applies the authorization values to the request dispatched - * with the API request event. - * If possible, it applies the authorization values to query parameter or headers - * depending on the configuration. - * - * When the values arr applied to the request the authorization config is kept in the - * request object, but its `enabled` state is always `false`, meaning other potential - * processors should ignore this values. - * - * If this property is not set then the application hosting this component should - * process the authorization data and apply them to the request. - */ - httpApplyAuthorization: { type: Boolean, reflect: true }, - /** - * List of credentials source passed to the HTTP editor - */ - httpCredentialsSource: { type: Array }, - /** - * Optional property to set on the request editor. - * When true, the server selector is not rendered - */ - noServerSelector: { type: Boolean }, - /** - * When set it renders "add custom" item button in the HTTP request editor. - * If the element is to be used without AMF model this should always - * be enabled. Otherwise users won't be able to add a parameter. - */ - httpAllowCustom: { type: Boolean }, - /** - * Optional property to set on the request editor. - * If true, the server selector custom base URI option is rendered - */ - allowCustomBaseUri: { type: Boolean }, - /** - * The URI of the server currently selected in the server selector - */ - serverValue: { type: String }, - /** - * The type of the server currently selected in the server selector - */ - serverType: { type: String }, - /** - * The mime type of the currently selected schema. - */ - schemaMimeType: { type: String }, - }; + static get styles(): CSSResult[] { + return [elementStyles]; } + [domainTypeValue]: SelectionType | undefined; + + [operationIdValue]: string | undefined; + + [handleNavigationEventsValue]: boolean | undefined; + + [renderedViewValue]: string | undefined; + + [apiSummaryValue]?: ApiDefinitions.IApiSummary; + + [documentMetaValue]?: DocumentMeta; + + [navEventsRegistered]: boolean; + + /** + * A property to set to override AMF's model base URI information. + * @attribute + */ + @property({ type: String }) + baseUri?: string; + /** - * @returns {SelectionType|undefined} The domain id of the object to render. + * When set it renders the "try it" button that dispatches the `tryit` event. + * @attribute */ - get domainType() { - return this[domainTypeValue]; - } + @property({ type: Boolean, reflect: true }) + tryItButton?: boolean; + + /** + * When set it renders the "try it" panel next to the operation documentation. + * Setting this automatically disables the `tryItButton` property. + * + * Note, use this only when there's enough space on the screen to render 2 panels side-by-side. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + tryItPanel?: boolean; + + /** + * OAuth2 redirect URI. + * This value **must** be set in order for OAuth 1/2 to work properly. + * This is only required in inline mode (`inlineMethods`). + * @attribute + */ + @property({ type: String }) + redirectUri?: string; /** - * @returns {SelectionType|undefined} The domain id of the object to render. + * When set it renders the URL input above the URL parameters in the HTTP editor. + * @attribute */ - set domainType(value) { + @property({ type: Boolean, reflect: true }) + httpUrlEditor?: boolean; + + /** + * When set it applies the authorization values to the request dispatched + * with the API request event. + * If possible, it applies the authorization values to query parameter or headers + * depending on the configuration. + * + * When the values arr applied to the request the authorization config is kept in the + * request object, but its `enabled` state is always `false`, meaning other potential + * processors should ignore this values. + * + * If this property is not set then the application hosting this component should + * process the authorization data and apply them to the request. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + httpApplyAuthorization?: boolean; + + /** + * List of credentials source passed to the HTTP editor + */ + @property({ type: Array }) + httpCredentialsSource?: Oauth2Credentials[]; + + /** + * Optional property to set on the request editor. + * When true, the server selector is not rendered + * @attribute + */ + @property({ type: Boolean, reflect: true }) + noServerSelector?: boolean; + + /** + * When set it renders "add custom" item button in the HTTP request editor. + * If the element is to be used without AMF model this should always + * be enabled. Otherwise users won't be able to add a parameter. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + httpAllowCustom?: boolean; + + /** + * Optional property to set on the request editor. + * If true, the server selector custom base URI option is rendered + * @attribute + */ + @property({ type: Boolean, reflect: true }) + allowCustomBaseUri?: boolean; + + /** + * The URI of the server currently selected in the server selector + * @attribute + */ + @property({ type: String }) + serverValue?: string; + + /** + * The type of the server currently selected in the server selector + * @attribute + */ + @property({ type: String }) + serverType?: string; + + /** + * The mime type of the currently selected schema. + * @attribute + */ + @property({ type: String }) + schemaMimeType?: string; + + serversCount?: number; + + /** + * The type of the selected domain item. + * @attribute + */ + @property({ type: String, reflect: true }) + get domainType(): SelectionType | undefined { + return this[domainTypeValue]; + } + + set domainType(value: SelectionType | undefined) { const old = this[domainTypeValue]; if (old === value) { return; @@ -184,16 +221,16 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { } /** - * @returns {string|undefined} The domain id of the object to render. + * The domain id of the currently rendered API operation. + * When selecting an operation the `domainId` is the id if the parent endpoint. + * @attribute */ - get operationId() { + @property({ type: String, reflect: true }) + get operationId(): string | undefined { return this[operationIdValue]; } - /** - * @returns {string|undefined} The domain id of the object to render. - */ - set operationId(value) { + set operationId(value: string | undefined) { const old = this[operationIdValue]; if (old === value) { return; @@ -205,13 +242,19 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { } } - /** @returns {boolean} */ - get handleNavigationEvents() { + /** + * By default application hosting the element must set `domainId` and + * `domainType` properties. When using `api-navigation` element + * by setting this property the element listens for navigation events + * and updates the state + * @attribute + */ + @property({ type: Boolean, reflect: true }) + get handleNavigationEvents(): boolean | undefined { return this[handleNavigationEventsValue]; } - /** @param {boolean} value */ - set handleNavigationEvents(value) { + set handleNavigationEvents(value: boolean | undefined) { const old = this[handleNavigationEventsValue]; if (old === value) { return; @@ -226,9 +269,9 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { /** * Former `effectiveBaseUri`. - * @returns {string|undefined} The URI for the API defined by the `baseUri` property or the `serverValue`. + * @returns The URI for the API defined by the `baseUri` property or the `serverValue`. */ - get apiBaseUri() { + get apiBaseUri(): string | undefined { const { baseUri, serverValue } = this; return baseUri || serverValue; } @@ -236,31 +279,30 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { /** * @deprecated Use `apiBaseUri` instead. */ - get effectiveBaseUri() { + get effectiveBaseUri(): string | undefined { return this.apiBaseUri; } - /** @returns {string} The domain type of the rendered view. */ - get renderedView() { + /** The domain type of the rendered view. */ + get renderedView(): string | undefined { return this[renderedViewValue]; } - /** @returns {boolean} */ - get renderSelector() { - const { domainType, serversCount, allowCustomBaseUri } = this; - const isOperationOrEndpoint = !!domainType && (['operation', 'resource'].includes(domainType)); - const moreThanOneServer = serversCount >= 2; - if (isOperationOrEndpoint) { - return allowCustomBaseUri || moreThanOneServer; - } - return false; + get renderSelector(): boolean { + const { domainType, serversCount=0, allowCustomBaseUri } = this; + const isOperationOrEndpoint = !!domainType && (['operation', 'resource'].includes(domainType)); + const moreThanOneServer = serversCount >= 2; + if (isOperationOrEndpoint) { + return allowCustomBaseUri || moreThanOneServer; + } + return false; } /** * This is a computed value from the AMF model. - * @returns {boolean} true when whe currently loaded API is an async API. + * @returns true when whe currently loaded API is an async API. */ - get isAsync() { + get isAsync(): boolean { const { documentMeta } = this; if (!documentMeta) { return false; @@ -269,9 +311,9 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { } /** - * @returns {string|undefined} The mime type of the schema that is being rendered. + * @returns The mime type of the schema that is being rendered. */ - get schemaMime() { + get schemaMime(): string|undefined { const { schemaMimeType } = this; if (schemaMimeType) { return schemaMimeType; @@ -280,66 +322,30 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { if (!summary) { return undefined; } - const { accepts=[] } = summary; + const { accepts = [] } = summary; if (!accepts.length) { return undefined; } return accepts[0]; } - /** @type DocumentMeta */ - get documentMeta() { + get documentMeta(): DocumentMeta | undefined { return this[documentMetaValue]; } constructor() { super(); - /** @type {SelectionType} */ - this.domainType = undefined; - /** @type {string} */ - this.operationId = undefined; - /** @type {string} */ - this.baseUri = undefined; - /** @type {boolean} */ - this.tryItButton = undefined; - /** @type {boolean} */ - this.tryItPanel = undefined; - /** @type {boolean} */ - this.httpUrlEditor = undefined; - /** @type {boolean} */ - this.noServerSelector = undefined; - /** @type {boolean} */ - this.allowCustomBaseUri = undefined; - /** @type {boolean} */ - this.httpAllowCustom = undefined; - /** @type {string} */ - this.redirectUri = undefined; - /** @type {ServerType} */ - this.serverType = undefined; - /** @type {string} */ - this.serverValue = undefined; - /** @type {number} */ - this.serversCount = undefined; - /** @type {boolean} */ - this.httpApplyAuthorization = undefined; - this.httpCredentialsSource = undefined; - /** @type {ApiSummary} */ - this[apiSummaryValue] = undefined; - /** @type {string} */ - this.schemaMimeType = undefined; this[navigationHandler] = this[navigationHandler].bind(this); this[navEventsRegistered] = false; - /** @type DocumentMeta */ - this[documentMetaValue] = undefined; } - connectedCallback() { + connectedCallback(): void { super.connectedCallback(); this[processDebounce](); } - disconnectedCallback() { + disconnectedCallback(): void { super.disconnectedCallback(); if (this[navEventsRegistered]) { this[unregisterNavigationEvents](); @@ -350,17 +356,17 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * Registers the api navigation event listener handler * on the window object. */ - [registerNavigationEvents]() { + [registerNavigationEvents](): void { this[navEventsRegistered] = true; - window.addEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler]); + window.addEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler] as EventListener); } /** * Removes event listener from window object for the API navigation event. */ - [unregisterNavigationEvents]() { + [unregisterNavigationEvents](): void { this[navEventsRegistered] = false; - window.removeEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler]); + window.removeEventListener(EventTypes.Navigation.apiNavigate, this[navigationHandler] as EventListener); } /** @@ -368,10 +374,8 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * * Note, when the current type is set to `operation` then the `operationId` is * set instead of `domainId`, which is set to the parent endpoint id. - * - * @param {ApiNavigationEvent} e */ - [navigationHandler](e) { + [navigationHandler](e: ApiNavigationEvent): void { const { domainId, domainType, parentId, passive } = e.detail; if (passive === true) { return; @@ -379,7 +383,7 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { this.domainType = domainType; if (domainType === 'operation') { this.operationId = domainId; - this.domainId = parentId; + this.domainId = parentId; } else { this.operationId = undefined; this.domainId = domainId; @@ -387,10 +391,7 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { this.processGraph(); } - /** - * @returns {Promise} - */ - async processGraph() { + async processGraph(): Promise { this.schemaMimeType = undefined; await this[queryDocumentMeta](); const { documentMeta } = this; @@ -408,15 +409,14 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { return; } const { isFragment, types } = documentMeta; - + if (isFragment) { - /** @type SelectionType */ - let type; - if (types.includes(ns.aml.vocabularies.security.SecuritySchemeFragment)) { + let type: SelectionType | undefined; + if (types.includes(AmfNamespace.aml.vocabularies.security.SecuritySchemeFragment)) { type = 'security'; - } else if (types.includes(ns.aml.vocabularies.apiContract.UserDocumentationFragment)) { + } else if (types.includes(AmfNamespace.aml.vocabularies.apiContract.UserDocumentationFragment)) { type = 'documentation'; - } else if (types.includes(ns.aml.vocabularies.shapes.DataTypeFragment)) { + } else if (types.includes(AmfNamespace.aml.vocabularies.shapes.DataTypeFragment)) { type = 'schema'; } this[processFragment](type); @@ -427,18 +427,17 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { // partial models // - if (types.includes(ns.aml.vocabularies.apiContract.EndPoint)) { + if (types.includes(AmfNamespace.aml.vocabularies.apiContract.EndPoint)) { this[processEndpointPartial](); return; } - /** @type SelectionType */ - let type; - if (types.includes(ns.aml.vocabularies.core.CreativeWork)) { + let type: SelectionType | undefined; + if (types.includes(AmfNamespace.aml.vocabularies.core.CreativeWork)) { type = 'documentation'; - } else if (types.includes(ns.aml.vocabularies.security.SecurityScheme)) { + } else if (types.includes(AmfNamespace.aml.vocabularies.security.SecurityScheme)) { type = 'security'; - } else if (types.includes(ns.w3.shacl.Shape)) { + } else if (types.includes(AmfNamespace.w3.shacl.Shape)) { type = 'schema'; } this[processPartial](type); @@ -447,14 +446,15 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { /** * Reads the currently loaded document meta data from the store. */ - async [queryDocumentMeta]() { + async [queryDocumentMeta](): Promise { this[documentMetaValue] = undefined; try { const info = await Events.Api.documentMeta(this); this[documentMetaValue] = info; } catch (e) { - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Unable to query for the document meta data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Unable to query for the document meta data: ${ex.message}`, this.localName); } } @@ -462,14 +462,15 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * Reads the API summary. * Called only when the currently loaded document is an API. */ - async [queryApiSummary]() { + async [queryApiSummary](): Promise { try { const info = await Events.Api.summary(this); this[apiSummaryValue] = info; } catch (e) { this[apiSummaryValue] = undefined; - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Unable to query for the API summary data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Unable to query for the API summary data: ${ex.message}`, this.localName); } } @@ -477,7 +478,7 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * Processes selection for the web API data model. It ignores the input if * `domainId` or `domainType` is not set. */ - [processApiSpecSelection]() { + [processApiSpecSelection](): void { const { domainId, tryItPanel } = this; let { domainType } = this; if (!domainId || !domainType) { @@ -495,7 +496,7 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * Processes selection for a library data model. It ignores the input if * `domainId` or `domainType` is not set. */ - [processLibrarySelection]() { + [processLibrarySelection](): void { const { domainId, domainType } = this; if (!domainId || !domainType) { // Not all required properties were set. @@ -508,10 +509,10 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { /** * Processes fragment model and sets current selection and the model. * - * @param {SelectionType} domainType The selected domain type. + * @param domainType The selected domain type. */ - [processFragment](domainType) { - this[domainIdValue] = this.documentMeta.encodesId; + [processFragment](domainType?: SelectionType): void { + this[domainIdValue] = this.documentMeta?.encodesId; this[renderedViewValue] = domainType; this.requestUpdate(); } @@ -519,9 +520,9 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { /** * Sets the partial model to be rendered. * - * @param {SelectionType} domainType The domain type representing the partial model. + * @param domainType The domain type representing the partial model. */ - [processPartial](domainType) { + [processPartial](domainType?: SelectionType): void { this[renderedViewValue] = domainType; this.requestUpdate(); } @@ -532,39 +533,30 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { * * If `selected` or `selectedType` is not set then it automatically selects */ - [processEndpointPartial]() { + [processEndpointPartial](): void { const { tryItPanel } = this; let { domainType } = this; - if (!domainType || tryItPanel) { - domainType = 'resource'; - } + if (!domainType || tryItPanel) { + domainType = 'resource'; + } if (!['operation', 'resource'].includes(domainType)) { domainType = 'resource'; } - this[renderedViewValue] = domainType; + this[renderedViewValue] = domainType; this.requestUpdate(); } - /** - * @param {ServerCountChangeEvent} e - */ - [serversCountHandler](e) { + [serversCountHandler](e: ServerCountChangeEvent): void { this.serversCount = e.detail.value; } - /** - * @param {ServerChangeEvent} e - */ - [serverChangeHandler](e) { + [serverChangeHandler](e: ServerChangeEvent): void { this.serverValue = e.detail.value; this.serverType = e.detail.type; } - /** - * @param {Event} e - */ - [mediaTypeSelectHandler](e) { - const group = /** @type AnypointRadioGroupElement */ (e.target); + [mediaTypeSelectHandler](e: Event): void { + const group = (e.target as AnypointRadioGroupElement); const { selectedItem } = group; if (!selectedItem) { return; @@ -573,16 +565,16 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { this.schemaMimeType = mime; } - render() { - return html` + render(): TemplateResult { + return html` ${this[serverSelectorTemplate]()} ${this[modelTemplate]()}`; } /** - * @returns {TemplateResult|string} The template for the server selector. + * @returns The template for the server selector. */ - [serverSelectorTemplate]() { + [serverSelectorTemplate](): TemplateResult|string { if (this.noServerSelector) { return ''; } @@ -607,9 +599,9 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { } /** - * @returns {TemplateResult|string} The template for the server selector. + * @returns The template for the server selector. */ - [modelTemplate]() { + [modelTemplate](): TemplateResult|string { switch (this[renderedViewValue]) { case 'summary': return this[summaryTemplate](); case 'security': return this[securityTemplate](); @@ -623,18 +615,18 @@ export default class ApiDocumentationElement extends ApiDocumentationBase { } /** - * @returns {TemplateResult|string} The template for the API summary page. + * @returns The template for the API summary page. */ - [summaryTemplate]() { + [summaryTemplate](): TemplateResult|string { const { baseUri, anypoint } = this; return html` `; } /** - * @returns {TemplateResult|string} The template for the API security definition page. + * @returns The template for the API security definition page. */ - [securityTemplate]() { + [securityTemplate](): TemplateResult|string { const { domainId, anypoint } = this; return html` - ${accepts.map((item) => - html`${item}`)} + ${accepts.map((item) => + html`${item}`)}
`; diff --git a/src/elements/ApiNavigationElement.d.ts b/src/elements/ApiNavigationElement.d.ts deleted file mode 100644 index 1fcf948..0000000 --- a/src/elements/ApiNavigationElement.d.ts +++ /dev/null @@ -1,744 +0,0 @@ -import { LitElement, TemplateResult, CSSResult } from 'lit-element'; -import { EventsTargetMixin } from '@anypoint-web-components/awc'; -import { - ApiEndPointWithOperationsListItem, - EndpointItem, - OperationItem, - DocumentationItem, - NodeShapeItem, - SecurityItem, - SelectableMenuItem, - EditableMenuItem, - SelectionType, - SchemaAddType, - NavigationLayout, - DocumentMeta, -} from '../types'; - -export declare const apiIdValue: unique symbol; -export declare const isAsyncValue: unique symbol; -export declare const queryingValue: unique symbol; -export declare const abortControllerValue: unique symbol; -export declare const selectedValue: unique symbol; -export declare const documentationsValue: unique symbol; -export declare const schemasValue: unique symbol; -export declare const securityValue: unique symbol; -export declare const sourceEndpointsValue: unique symbol; -export declare const endpointsValue: unique symbol; -export declare const layoutValue: unique symbol; -export declare const queryValue: unique symbol; -export declare const openedEndpointsValue: unique symbol; -export declare const queryApi: unique symbol; -export declare const queryEndpoints: unique symbol; -export declare const layoutEndpoints: unique symbol; -export declare const queryDocumentations: unique symbol; -export declare const querySchemas: unique symbol; -export declare const querySecurity: unique symbol; -export declare const createFlatTreeItems: unique symbol; -export declare const getFilteredEndpoints: unique symbol; -export declare const getFilteredDocumentations: unique symbol; -export declare const getFilteredSchemas: unique symbol; -export declare const getFilteredSecurity: unique symbol; -export declare const computeEndpointPaddingValue: unique symbol; -export declare const computeEndpointPaddingLeft: unique symbol; -export declare const computeOperationPaddingValue: unique symbol; -export declare const computeOperationPaddingLeft: unique symbol; -export declare const itemClickHandler: unique symbol; -export declare const itemKeydownHandler: unique symbol; -export declare const toggleSectionClickHandler: unique symbol; -export declare const toggleSectionKeydownHandler: unique symbol; -export declare const endpointToggleClickHandler: unique symbol; -export declare const focusHandler: unique symbol; -export declare const keydownHandler: unique symbol; -export declare const summaryTemplate: unique symbol; -export declare const endpointsTemplate: unique symbol; -export declare const endpointTemplate: unique symbol; -export declare const endpointToggleTemplate: unique symbol; -export declare const operationItemTemplate: unique symbol; -export declare const documentationsTemplate: unique symbol; -export declare const documentationTemplate: unique symbol; -export declare const externalDocumentationTemplate: unique symbol; -export declare const schemasTemplate: unique symbol; -export declare const schemaTemplate: unique symbol; -export declare const securitiesTemplate: unique symbol; -export declare const securityTemplate: unique symbol; -export declare const keyDownAction: unique symbol; -export declare const keyUpAction: unique symbol; -export declare const keyShiftTabAction: unique symbol; -export declare const keyEscAction: unique symbol; -export declare const keySpaceAction: unique symbol; -export declare const shiftTabPressedValue: unique symbol; -export declare const focusedItemValue: unique symbol; -export declare const selectedItemValue: unique symbol; -export declare const focusItem: unique symbol; -export declare const listActiveItems: unique symbol; -export declare const itemsValue: unique symbol; -export declare const listSectionActiveNodes: unique symbol; -export declare const keyArrowRightAction: unique symbol; -export declare const keyArrowLeftAction: unique symbol; -export declare const makeSelection: unique symbol; -export declare const selectItem: unique symbol; -export declare const deselectItem: unique symbol; -export declare const findSelectable: unique symbol; -export declare const toggleSectionElement: unique symbol; -export declare const summarySelected: unique symbol; -export declare const filterTemplate: unique symbol; -export declare const processQuery: unique symbol; -export declare const searchHandler: unique symbol; -export declare const resetTabindices: unique symbol; -export declare const notifyNavigation: unique symbol; -export declare const addingEndpointValue: unique symbol; -export declare const addEndpointInputTemplate: unique symbol; -export declare const addEndpointKeydownHandler: unique symbol; -export declare const commitNewEndpoint: unique symbol; -export declare const cancelNewEndpoint: unique symbol; -export declare const findViewModelItem: unique symbol; -export declare const renameInputTemplate: unique symbol; -export declare const renameKeydownHandler: unique symbol; -export declare const renameBlurHandler: unique symbol; -export declare const updateNameHandler: unique symbol; -export declare const addDocumentationInputTemplate: unique symbol; -export declare const addDocumentationKeydownHandler: unique symbol; -export declare const addingDocumentationValue: unique symbol; -export declare const addingExternalValue: unique symbol; -export declare const commitNewDocumentation: unique symbol; -export declare const externalDocumentationHandler: unique symbol; -export declare const addingSchemaValue: unique symbol; -export declare const addSchemaInputTemplate: unique symbol; -export declare const addSchemaKeydownHandler: unique symbol; -export declare const commitNewSchema: unique symbol; -export declare const addingSchemaTypeValue: unique symbol; -export declare const graphChangeHandler: unique symbol; -export declare const documentMetaValue: unique symbol; - -/** - * @fires graphload - */ -export default class ApiNavigationElement extends EventsTargetMixin(LitElement) { - static get styles(): CSSResult; - - [apiIdValue]: string; - [queryingValue]: boolean; - [abortControllerValue]?: AbortController; - [endpointsValue]: EndpointItem[]; - [sourceEndpointsValue]: ApiEndPointWithOperationsListItem[]; - [documentationsValue]: DocumentationItem[]; - [schemasValue]: NodeShapeItem[]; - [securityValue]: SecurityItem[]; - /** - * The processed and final query term for the list items. - */ - [queryValue]: string; - /** - * Information read from the AMF store indicating that the currently loaded API - * is an API. - */ - [isAsyncValue]: boolean; - /** - * Holds a list of ids of currently opened endpoints. - */ - [openedEndpointsValue]: string[]; - /** - * Cached list of all list elements - */ - [itemsValue]: HTMLElement[]; - [addingEndpointValue]?: boolean; - [addingDocumentationValue]?: boolean; - [addingExternalValue]?: boolean; - [addingSchemaValue]?: boolean; - [addingSchemaTypeValue]?: string; - - /** - * When true then the element is currently querying for the graph data. - */ - get querying(): boolean; - - /** - * Set only when `querying`. Use to abort the query operation. - * When calling `abort` on the controller the element stops querying and processing the graph data. - * All data that already has been processed are not cleared. - */ - get abortController(): AbortController | undefined; - - /** - * @returns true when `_docs` property is set with values - */ - get hasDocs(): boolean; - - /** - * @returns true when has schemas definitions - */ - get hasSchemas(): boolean; - - /** - * @returns true when `_security` property is set with values - */ - get hasSecurity(): boolean; - - /** - * @returns true when `_endpoints` property is set with values - */ - get hasEndpoints(): boolean; - - /** - * A reference to currently selected element. - */ - get selectedItem(): HTMLElement | undefined; - - /** - * The currently focused item. - */ - get focusedItem(): HTMLElement | undefined; - /** - * The domain id that is currently being selected. - * @attribute - */ - domainId: string; - /** - * Type of the selected item. - */ - get domainType(): SelectionType; - /** - * If set it renders `API summary` menu option. - * It will allow to set `selected` and `selectedType` to `summary` - * when this option is set. - * @attribute - */ - summary: boolean; - /** - * A label for the `summary` section. - * @attribute - */ - summaryLabel: string; - /** - * Determines and changes state of documentation panel. - * @attribute - */ - documentationsOpened: boolean; - /** - * Determines and changes state of schemas (types) panel. - * @attribute - */ - schemasOpened: boolean; - /** - * Determines and changes state of security panel. - * @attribute - */ - securityOpened: boolean; - /** - * Determines and changes state of endpoints panel. - * @attribute - */ - endpointsOpened: boolean; - /** - * Filters list elements by this value when set. - * Clear the value to reset the search. - * - * This is not currently exposed in element's UI due - * to complexity of search and performance. - * @attribute - */ - query: string; - /** - * Size of endpoint indentation for nested resources. - * In pixels. - * - * The attribute name for this property is `indent-size`. Note, that this - * will change to web consistent name `indentSize` in the future. - * @attribute - */ - indentSize: number; - /** - * By default the endpoints are rendered one-by-one as defined in the API spec file - * without any transformation. Set this option to sort the - * When this option is set it re-arrange the endpoints to the one of specified layout options. - * - * - tree - creates a tree structure from the endpoints list - * - natural - behavior consistent with the previous version of the navigation. Creates a tree structure based on the previous endpoints. - * - natural-sort - as `natural` but endpoints are sorted by name. - * - off (or none) - just like in the API spec. - * - * Note, the resulted tree structure will likely be different to the one encoded - * in the API spec file. - * @attribute - */ - layout: NavigationLayout; - /** - * When set it renders an input to filter the menu items. - * @attribute - */ - filter: boolean; - /** - * When set the element won't query the store when attached to the DOM. - * Instead set the `apiId` property or directly call the `queryGraph()` function. - * @attribute - */ - manualQuery: boolean; - /** - * When set it enables graph items editing functionality. - * The user can double-click on a menu item and edit its name. - * @attribute - */ - edit: boolean; - /** - * When set it expands or opens all endpoints and makes all operations visible. - * Note, the user can toggle an endpoint anyway so this property does not mean - * that all endpoints are expanded. When it's true then it means that all endpoints - * was expanded at some point in time. - * @attribute - */ - endpointsExpanded: boolean; - - /** - * @return True when the summary entry is rendered. - * Summary should be rendered only when `summary` is set and current model is not a RAML fragment. - */ - get summaryRendered(): boolean; - get documentMeta(): DocumentMeta; - - constructor(); - - /** - * Ensures aria role attribute is in place. - * Attaches element's listeners. - */ - connectedCallback(): void; - - disconnectedCallback(): void; - - /** - * Queries for the API data from the graph store. - */ - queryGraph(): Promise; - - /** - * Queries for the current API base info. - */ - [queryApi](signal: AbortSignal): Promise; - - /** - * Queries and sets endpoints data - */ - [queryEndpoints](signal: AbortSignal): Promise; - - /** - * Queries and sets documentations data - */ - [queryDocumentations](signal: AbortSignal): Promise; - - /** - * Queries and sets types (schemas) data - */ - [querySchemas](signal: AbortSignal): Promise; - - /** - * Queries and sets security data - */ - [querySecurity](signal: AbortSignal): Promise; - - [createFlatTreeItems](items: ApiEndPointWithOperationsListItem[]): EndpointItem[]; - /** - * Processes endpoints layout for the given configuration. - */ - [layoutEndpoints](): void; - - /** - * Filters the current endpoints by the current query value. - */ - [getFilteredEndpoints](): EndpointItem[] | undefined; - - /** - * Computes `style` attribute value for endpoint item. - * It sets padding-left property to indent resources. - * See https://github.com/mulesoft/api-console/issues/571. - * - * @param indent The computed indentation of the item. - * @returns The value for the left padding of the endpoint menu item. - */ - [computeEndpointPaddingValue](indent?: number): string; - - /** - * Computes endpoint list item left padding from CSS variables. - */ - [computeEndpointPaddingLeft](): number - - /** - * Computes `style` attribute value for an operation item. - * It sets padding-left property to indent operations relative to a resource. - * - * @param indent The computed indentation of the parent resource. - * @returns The value for the left padding of the endpoint menu item. - */ - [computeOperationPaddingValue](indent?: number): string; - - /** - * Computes operation list item left padding from CSS variables. - */ - [computeOperationPaddingLeft](): number; - - /** - * A handler for the click event on a menu list item. - * Makes a selection from the target. - */ - [itemClickHandler](e: MouseEvent): void; - - /** - * A handler for the click event on endpoints toggle button. - */ - [endpointToggleClickHandler](e: MouseEvent): void; - - /** - * Toggles operations visibility for an endpoint. - * @param graphId The Endpoint graph id. - */ - toggleEndpoint(graphId: string): void; - - /** - * A handler for the click event on a section item. Toggles the clicked section. - */ - [toggleSectionClickHandler](e: MouseEvent): void; - - /** - * Toggles a section of the menu represented by the element (section list item). - */ - [toggleSectionElement](element: HTMLElement): void; - - /** - * @returns List of documentation items filtered by the current query. - */ - [getFilteredDocumentations](): DocumentationItem[]; - - /** - * @returns List of schemas items filtered by the current query. - */ - [getFilteredSchemas](): NodeShapeItem[]; - - /** - * @returns List of security items filtered by the current query. - */ - [getFilteredSecurity](): SecurityItem[]; - - /** - * A handler for the focus event on this element. - */ - [focusHandler](e: FocusEvent): void; - - /** - * Sets a list item focused - */ - [focusItem](item: HTMLElement): void; - - /** - * Handler for the keydown event. - */ - [keydownHandler](e: KeyboardEvent): void; - - /** - * Handler that is called when the down key is pressed. - * - * @param e A key combination event. - */ - [keyDownAction](e: KeyboardEvent): void; - - /** - * Handler that is called when the up key is pressed. - * - * @param e A key combination event. - */ - [keyUpAction](e: KeyboardEvent): void; - - /** - * Handles shift+tab keypress on the menu. - */ - [keyShiftTabAction](): void; - - /** - * Handler that is called when the esc key is pressed. - */ - [keyEscAction](): void; - - /** - * A handler for the space bar key down. - */ - [keySpaceAction](e: KeyboardEvent): void; - - /** - * A handler for the key right down. Opens operations when needed. - */ - [keyArrowRightAction](e: KeyboardEvent): void; - - /** - * A handler for the key left down. Closes operations when needed. - */ - [keyArrowLeftAction](e: KeyboardEvent): void; - - /** - * Focuses on the previous item in the navigation. - */ - focusPrevious(): void; - - /** - * Focuses on the next item in the navigation. - */ - focusNext(): void; - - /** - * Selects an item in the navigation. - * Note, this dispatches the navigation action event. - */ - select(id: string): void; - - /** - * Lists all HTML elements that are currently rendered in the view. - * @returns Currently rendered items. - */ - [listActiveItems](): HTMLElement[]; - - /** - * @param selector The prefix for the query selector - * @returns Nodes returned from query function. - */ - [listSectionActiveNodes](selector: string): HTMLElement[]; - - /** - * Selects an item in the menu. - * - * @param id The domain id of the node to be selected - * @param type The selected type of the item. - */ - [makeSelection](id: string, type: string): void; - - /** - * Selects an item. - * @param id The domain id of the menu item. - * @param type The type of the data. - */ - [selectItem](id: string, type: string): void; - - /** - * Removes all selections from an item. - * @param id The domain id of the menu item. - * @param type The type of the data. - */ - [deselectItem](id: string, type: string): void; - - /** - * Finds a selectable item by its id and type. - * @param id The domain id of the menu item. - * @param type The type of the data. - */ - [findSelectable](id: string, type: string): SelectableMenuItem | null; - - /** - * @param value The new query. Empty or null to clear the query - */ - [processQuery](value: string): void; - - /** - * A handler for the search event from the filter input. - */ - [searchHandler](e: Event): void; - - /** - * Opens all sections of the menu and all endpoints. - */ - expandAll(): void; - - /** - * Closes all sections of the menu and all endpoints. - */ - collapseAll(): void; - - /** - * Opens all endpoints exposing all operations - */ - expandAllEndpoints(): void; - - /** - * Hides all operations and collapses all endpoints. - */ - collapseAllEndpoints(): void; - - /** - * Triggers a flow when the user can define a new endpoint in the navigation. - * This renders an input in the view (in the endpoints list) where the user can enter the path name. - */ - addEndpoint(): Promise; - - /** - * Triggers a flow when the user can define a new documentation document. - * This renders an input in the view (in the documentation list) where the user can enter the name. - * @param isExternal Whether the documentation is a link to a www document. - */ - addDocumentation(isExternal?: boolean): Promise; - /** - * Triggers a flow when the user can define a new schema in the navigation. - * This renders an input in the view (in the schema list) where the user can enter the schema name. - * @param type The type of the schema to add. Default to `object`. - */ - addSchema(type?: SchemaAddType): Promise; - /** - * Resets all tabindex attributes to the appropriate value based on the - * current selection state. The appropriate value is `0` (focusable) for - * the default selected item, and `-1` (not keyboard focusable) for all - * other items. Also sets the correct initial values for aria-selected - * attribute, true for default selected item and false for others. - */ - [resetTabindices](): void; - - /** - * Dispatches the navigation event. - * @param id The domain id of the selected node - * @param type The domain type. - */ - [notifyNavigation](id: string, type: string): void; - - /** - * Event handler for the keydown event of the add endpoint input. - */ - [addEndpointKeydownHandler](e: KeyboardEvent): void; - - /** - * Event handler for the keydown event of the add documentation input. - */ - [addDocumentationKeydownHandler](e: KeyboardEvent): void; - /** - * Event handler for the keydown event of the add schema input. - */ - [addSchemaKeydownHandler](e: KeyboardEvent): void; - [commitNewEndpoint](): Promise; - [cancelNewEndpoint](): Promise; - /** - * @param value The title of the documentation. - */ - [commitNewDocumentation](value?: string): Promise; - /** - * @param value The name of the schema. - */ - [commitNewSchema](value?: string): Promise; - - /** - * Triggers a rename action for the menu item identified by the `id`. - * @param id The domain id of the item to edit. - */ - renameAction(id: string): Promise; - - /** - * @param {string} id The domain id of the item to find. - */ - [findViewModelItem](id: string): SelectableMenuItem & EditableMenuItem | null; - - /** - * A key down event handler on the rename input - */ - [renameKeydownHandler](e: KeyboardEvent): Promise; - - /** - * A blur event handler on the rename input - */ - [renameBlurHandler](e: Event): Promise; - - /** - * Updates the name or the display name of the menu object - * @param id The id of the domain object to update - * @param value The new value. - * @param type The object type - * @returns A promise when the update operation finish. - */ - [updateNameHandler](id: string, value: string, type: SelectionType): Promise; - - /** - * Click handler for the external navigation item. - * Dispatches the external navigation event. When this event is handled (cancelled) - * the original event is cancelled to prevent default behavior. - */ - [externalDocumentationHandler](e: Event): void; - - render(): TemplateResult; - - /** - * @returns The template for the summary filed. - */ - [summaryTemplate](): TemplateResult | string; - - /** - * @returns The template for the list of endpoints. - */ - [endpointsTemplate](): TemplateResult | string; - - /** - * @returns The template for an endpoint. - */ - [endpointTemplate](item: EndpointItem): TemplateResult; - - /** - * @param id The domain id of the endpoint. - * @returns The template for endpoint's toggle button. - */ - [endpointToggleTemplate](id: string): TemplateResult; - - /** - * @param item The endpoint definition - * @param op The operation definition. - * @returns The template for an operation list item. - */ - [operationItemTemplate](item: EndpointItem, op: OperationItem): TemplateResult; - - /** - * @returns The template for the documentations section. - */ - [documentationsTemplate](): TemplateResult | string; - - /** - * @returns The template for the documentation list item. - */ - [documentationTemplate](item: DocumentationItem): TemplateResult; - - /** - * @returns The template for the external documentation list item. - */ - [externalDocumentationTemplate](item: DocumentationItem): TemplateResult; - - /** - * @returns The template for the types (schemas) section. - */ - [schemasTemplate](): TemplateResult | string; - - /** - * @returns The template for the documentation list item. - */ - [schemaTemplate](item: NodeShapeItem): TemplateResult; - - /** - * @returns The template for the security section. - */ - [securitiesTemplate](): TemplateResult | string; - - /** - * @returns The template for the security list item. - */ - [securityTemplate](item: SecurityItem): TemplateResult; - /** - * @returns The template for the filter input. - */ - [filterTemplate](): TemplateResult | string; - /** - * @return The template for the new endpoint input. - */ - [addEndpointInputTemplate](): TemplateResult; - /** - * @return The template for the new documentation input. - */ - [addDocumentationInputTemplate](): TemplateResult; - /** - * @return The template for the new schema input. - */ - [addSchemaInputTemplate](): TemplateResult; - /** - * @param id The domain id of the item being edited - * @param label The current name to render. - * @param type - * @returns The template for the rename input. - */ - [renameInputTemplate](id: string, label: string, type: SelectionType): TemplateResult; -} diff --git a/src/elements/ApiNavigationElement.js b/src/elements/ApiNavigationElement.ts similarity index 67% rename from src/elements/ApiNavigationElement.js rename to src/elements/ApiNavigationElement.ts index b1856c0..6a3cc05 100644 --- a/src/elements/ApiNavigationElement.js +++ b/src/elements/ApiNavigationElement.ts @@ -1,45 +1,24 @@ /* eslint-disable lit-a11y/click-events-have-key-events */ -/* eslint-disable no-continue */ -/* eslint-disable no-plusplus */ /* eslint-disable prefer-destructuring */ -/* eslint-disable class-methods-use-this */ -import { LitElement, html } from 'lit-element'; -import { EventsTargetMixin } from '@anypoint-web-components/awc'; -import { styleMap } from 'lit-html/directives/style-map.js'; -import { classMap } from 'lit-html/directives/class-map.js'; -import { ifDefined } from 'lit-html/directives/if-defined.js'; +import { html, TemplateResult, CSSResult, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; +import { ApiDefinitions } from '@api-client/core/build/browser.js'; +import { AnypointCollapseElement, EventsTargetMixin } from '@anypoint-web-components/awc'; +import { styleMap } from 'lit/directives/style-map.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { HttpStyles } from '@advanced-rest-client/base/api.js'; -import '@anypoint-web-components/awc/anypoint-icon-button.js'; -import '@anypoint-web-components/awc/anypoint-collapse.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-icon-button.js'; +import '@anypoint-web-components/awc/dist/define/anypoint-collapse.js'; import '@advanced-rest-client/icons/arc-icon.js'; import navStyles from './styles/NavStyles.js'; -import { ns } from '../helpers/Namespace.js'; import { ApiSorting } from '../lib/navigation-layout/ApiSorting.js'; import { EndpointsTree } from '../lib/navigation-layout/EndpointsTree.js'; import { NaturalTree } from '../lib/navigation-layout/NaturalTree.js'; import { EventTypes } from '../events/EventTypes.js'; import { Events } from '../events/Events.js'; import { cancelEvent } from '../lib/Utils.js' - -/** @typedef {import('lit-html').TemplateResult} TemplateResult */ -/** @typedef {import('@anypoint-web-components/awc').AnypointCollapseElement} AnypointCollapseElement */ -/** @typedef {import('../helpers/api').ApiEndPoint} ApiEndPoint */ -/** @typedef {import('../helpers/api').ApiOperation} ApiOperation */ -/** @typedef {import('../helpers/api').ApiDocumentation} ApiDocumentation */ -/** @typedef {import('../helpers/api').ApiNodeShape} ApiNodeShape */ -/** @typedef {import('../helpers/api').ApiCustomDomainProperty} ApiCustomDomainProperty */ -/** @typedef {import('../types').ApiEndPointWithOperationsListItem} ApiEndPointWithOperationsListItem */ -/** @typedef {import('../types').EndpointItem} EndpointItem */ -/** @typedef {import('../types').OperationItem} OperationItem */ -/** @typedef {import('../types').DocumentationItem} DocumentationItem */ -/** @typedef {import('../types').NodeShapeItem} NodeShapeItem */ -/** @typedef {import('../types').SecurityItem} SecurityItem */ -/** @typedef {import('../types').SelectableMenuItem} SelectableMenuItem */ -/** @typedef {import('../types').EditableMenuItem} EditableMenuItem */ -/** @typedef {import('../types').SchemaAddType} SchemaAddType */ -/** @typedef {import('../types').SelectionType} SelectionType */ -/** @typedef {import('../types').DocumentMeta} DocumentMeta */ -/** @typedef {import('../types').NavigationLayout} NavigationLayout */ +import { ApiEndpointsTreeItem, ApiEndPointWithOperationsListItem, DocumentMeta, NavigationLayout, SelectionType, SelectableMenuItem, EndpointItem, EditableMenuItem, SchemaAddType, OperationItem, DocumentationItem, NodeShapeItem, SecurityItem } from '../types.js'; export const queryingValue = Symbol('queryingValue'); export const abortControllerValue = Symbol('abortControllerValue'); @@ -137,37 +116,96 @@ export const graphChangeHandler = Symbol('graphChangeHandler'); export const documentMetaValue = Symbol('documentMetaValue'); export default class ApiNavigationElement extends EventsTargetMixin(LitElement) { - static get styles() { + static get styles(): CSSResult[] { return [navStyles, HttpStyles.default]; } + [queryingValue]?: boolean; + + [abortControllerValue]?: AbortController; + + [domainIdValue]?: string; + + [domainTypeValue]?: SelectionType; + + [selectedItemValue]?: HTMLElement; + + [focusedItemValue]?: HTMLElement; + + /** + * The processed and final query term for the list items. + */ + [queryValue]?: string; + + [documentMetaValue]?: DocumentMeta; + + [layoutValue]?: NavigationLayout; + + [endpointsExpandedValue]?: boolean; + + [endpointsValue]?: EndpointItem[]; + + [documentationsValue]?: ApiDefinitions.IDocumentationItem[]; + + [schemasValue]?: ApiDefinitions.INodeShapeItem[]; + + [securityValue]?: ApiDefinitions.ISecurityItem[]; + /** - * @returns {boolean} When true then the element is currently querying for the graph data. + * Holds a list of ids of currently opened endpoints. */ - get querying() { + [openedEndpointsValue]: string[]; + + /** + * Cached list of all list elements + */ + [itemsValue]?: HTMLElement[]; + + [sourceEndpointsValue]?: ApiDefinitions.IApiEndPointWithOperationsListItem[]; + + [shiftTabPressedValue]?: boolean; + + [summarySelected]?: boolean; + + [addingSchemaTypeValue]?: string; + + [addingSchemaValue]?: boolean; + + [addingDocumentationValue]?: boolean; + + [addingExternalValue]?: boolean; + + [addingEndpointValue]?: boolean; + + /** + * When true then the element is currently querying for the graph data. + */ + get querying(): boolean { return this[queryingValue] || false; } /** - * @returns {AbortController|undefined} Set only when `querying`. Use to abort the query operation. + * Set when `querying`. Use to abort the query operation. * When calling `abort` on the controller the element stops querying and processing the graph data. * All data that already has been processed are not cleared. */ - get abortController() { + get abortController(): AbortController | undefined { return this[abortControllerValue]; } - /** - * @returns {string|undefined} The current selection domain id. + /** + * A model `@id` of selected documentation part. + * Special case is for `summary` view. It's not part of an API + * but most applications has some kins of summary view for the + * API. + * @attribute */ - get domainId() { + @property({ type: String, reflect: true }) + get domainId(): string | undefined { return this[domainIdValue]; } - /** - * @returns {string|undefined} The domain id that is currently being selected. - */ - set domainId(value) { + set domainId(value: string | undefined) { const old = this[domainIdValue]; if (old === value) { return; @@ -178,63 +216,72 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } /** - * @returns {SelectionType}Type of the selected domain item. + * Type of the selected domain item. */ - get domainType() { + get domainType(): SelectionType | undefined { return this[domainTypeValue]; } /** - * @return {Boolean} true when `_docs` property is set with values + * true when `_docs` property is set with values */ - get hasDocs() { + get hasDocs(): boolean { const docs = this[documentationsValue]; return Array.isArray(docs) && !!docs.length; } /** - * @return {Boolean} true when has schemas definitions + * true when has schemas definitions */ - get hasSchemas() { + get hasSchemas(): boolean { const items = this[schemasValue]; return Array.isArray(items) && !!items.length; } /** - * @return {Boolean} true when `_security` property is set with values + * true when `_security` property is set with values */ - get hasSecurity() { + get hasSecurity(): boolean { const items = this[securityValue]; return Array.isArray(items) && !!items.length; } /** - * @return {Boolean} true when `_endpoints` property is set with values + * true when `_endpoints` property is set with values */ - get hasEndpoints() { + get hasEndpoints(): boolean { const items = this[endpointsValue]; return Array.isArray(items) && !!items.length; } /** - * @return {HTMLElement=} A reference to currently selected element. + * A reference to currently selected element. */ - get selectedItem() { + get selectedItem(): HTMLElement | undefined { return this[selectedItemValue]; } /** - * @return {HTMLElement=} The currently focused item. + * The currently focused item. */ - get focusedItem() { + get focusedItem(): HTMLElement | undefined { return this[focusedItemValue]; } - get query() { + /** + * Filters list elements by this value when set. + * Clear the value to reset the search. + * + * This is not currently exposed in element's UI due + * to complexity of search and performance. + * @attribute + */ + @property({ type: String }) + get query(): string | undefined { return this[queryValue]; } - set query(value) { + set query(value: string | undefined) { const old = this[queryValue]; if (old === value) { return; @@ -244,18 +291,30 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) this.requestUpdate('query', old); } - /** @type DocumentMeta */ - get documentMeta() { + get documentMeta(): DocumentMeta | undefined { return this[documentMetaValue]; } - /** @returns {NavigationLayout} */ - get layout() { + /** + * By default the endpoints are rendered one-by-one as defined in the API spec file + * without any tree structure. When this option is set it sorts the endpoints + * alphabetically and creates a tree structure for the endpoints. + * + * - tree - creates a tree structure from the endpoints list + * - natural - behavior consistent with the previous version of the navigation. Creates a tree structure based on the previous endpoints. + * - natural-sort - as `natural` but endpoints are sorted by name. + * - off (or none) - just like in the API spec. + * + * Note, the resulted tree structure will likely be different to the one encoded + * in the API spec file. + * @attribute + */ + @property({ type: String, reflect: true }) + get layout(): NavigationLayout | undefined { return this[layoutValue]; } - /** @param {NavigationLayout} value */ - set layout(value) { + set layout(value: NavigationLayout | undefined) { const old = this[layoutValue]; if (old === value) { return; @@ -265,16 +324,23 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) this.requestUpdate('layout', old); } - /** @returns {boolean} */ - get endpointsExpanded() { - if (typeof this[endpointsExpandedValue] !== 'boolean') { + /** + * When set it expands or opens all endpoints and makes all operations visible. + * Note, the user can toggle an endpoint anyway so this property does not mean + * that all endpoints are expanded. When it's true then it means that all endpoints + * was expanded at some point in time. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + get endpointsExpanded(): boolean { + const value = this[endpointsExpandedValue]; + if (typeof value !== 'boolean') { return false; } - return this[endpointsExpandedValue]; + return value; } - /** @param {boolean} value */ - set endpointsExpanded(value) { + set endpointsExpanded(value: boolean | undefined) { const old = this[endpointsExpandedValue]; if (old === value) { return; @@ -288,10 +354,10 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } /** - * @return {boolean} True when the summary entry is rendered. + * True when the summary entry is rendered. * Summary should be rendered only when `summary` is set and current model is not a RAML fragment. */ - get summaryRendered() { + get summaryRendered(): boolean { const { summary, documentMeta } = this; if (!summary || !documentMeta) { return false; @@ -300,147 +366,104 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) return !isFragment && !isLibrary; } - static get properties() { - return { - /** - * When this property change the element queries the graph store for the data model. - * It can be skipped when the application calls the `queryGraph()` method imperatively. - */ - apiId: { type: String, reflect: true, }, - /** - * A model `@id` of selected documentation part. - * Special case is for `summary` view. It's not part of an API - * but most applications has some kins of summary view for the - * API. - */ - domainId: { type: String, reflect: true }, - /** - * If set it renders `API summary` menu option. - * It will allow to set `domainId` and `domainType` to `summary` - * when this option is set. - */ - summary: { type: Boolean, reflect: true }, - /** - * A label for the `summary` section. - */ - summaryLabel: { type: String, reflect: true }, - /** - * Determines and changes state of documentation panel. - */ - documentationsOpened: { type: Boolean, reflect: true }, - /** - * Determines and changes state of schemas (types) panel. - */ - schemasOpened: { type: Boolean, reflect: true }, - /** - * Determines and changes state of security panel. - */ - securityOpened: { type: Boolean, reflect: true }, - /** - * Determines and changes state of endpoints panel. - */ - endpointsOpened: { type: Boolean, reflect: true }, - /** - * Filters list elements by this value when set. - * Clear the value to reset the search. - * - * This is not currently exposed in element's UI due - * to complexity of search and performance. - */ - query: { type: String }, - /** - * Size of endpoint indentation for nested resources. - * In pixels. - * - * The attribute name for this property is `indent-size`. Note, that this - * will change to web consistent name `indentSize` in the future. - */ - indentSize: { type: Number, reflect: true, }, - /** - * By default the endpoints are rendered one-by-one as defined in the API spec file - * without any tree structure. When this option is set it sorts the endpoints - * alphabetically and creates a tree structure for the endpoints. - * - * - tree - creates a tree structure from the endpoints list - * - natural - behavior consistent with the previous version of the navigation. Creates a tree structure based on the previous endpoints. - * - natural-sort - as `natural` but endpoints are sorted by name. - * - off (or none) - just like in the API spec. - * - * Note, the resulted tree structure will likely be different to the one encoded - * in the API spec file. - */ - layout: { type: String, reflect: true, }, - /** - * When set it renders an input to filter the menu items. - */ - filter: { type: Boolean, reflect: true, }, - /** - * When set the element won't query the store when attached to the DOM. - * Instead set the `apiId` property or directly call the `queryGraph()` function. - */ - manualQuery: { type: Boolean, reflect: true, }, - /** - * When set it enables graph items editing functionality. - * The user can double-click on a menu item and edit its name. - */ - edit: { type: Boolean, reflect: true, }, - /** - * When set it expands or opens all endpoints and makes all operations visible. - * Note, the user can toggle an endpoint anyway so this property does not mean - * that all endpoints are expanded. When it's true then it means that all endpoints - * was expanded at some point in time. - */ - endpointsExpanded: { type: Boolean, reflect: true, }, - }; - } + /** + * When this property change the element queries the graph store for the data model. + * It can be skipped when the application calls the `queryGraph()` method imperatively. + * @attribute + */ + @property({ type: String, reflect: true }) + apiId?: string; + + /** + * If set it renders `API summary` menu option. + * It will allow to set `domainId` and `domainType` to `summary` + * when this option is set. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + summary?: boolean; + + /** + * A label for the `summary` section. + * @attribute + */ + @property({ type: String, reflect: true }) + summaryLabel: string; + + /** + * Determines and changes state of documentation panel. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + documentationsOpened?: boolean; + + /** + * Determines and changes state of schemas (types) panel. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + schemasOpened?: boolean; + + /** + * Determines and changes state of security panel. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + securityOpened?: boolean; + + /** + * Determines and changes state of endpoints panel. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + endpointsOpened?: boolean; + + /** + * Size of endpoint indentation for nested resources. + * In pixels. + * + * The attribute name for this property is `indent-size`. Note, that this + * will change to web consistent name `indentSize` in the future. + * @attribute + */ + @property({ type: Number, reflect: true }) + indentSize?: number; + + /** + * When set it renders an input to filter the menu items. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + filter?: boolean; + + /** + * When set the element won't query the store when attached to the DOM. + * Instead set the `apiId` property or directly call the `queryGraph()` function. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + manualQuery?: boolean; + + /** + * When set it enables graph items editing functionality. + * The user can double-click on a menu item and edit its name. + * @attribute + */ + @property({ type: Boolean, reflect: true }) + edit?: boolean; + + /** + * @attribute + */ + @property({ type: Boolean, reflect: true }) + anypoint?: boolean; constructor() { super(); this.summaryLabel = 'Summary'; - this.summary = false; - this.anypoint = false; this.indentSize = 8; - this.endpointsOpened = false; - this.documentationsOpened = false; - this.schemasOpened = false; - this.securityOpened = false; - this.filter = false; - this.edit = false; - this.manualQuery = false; - - /** - * @type {EndpointItem[]} - */ - this[endpointsValue] = undefined; - /** - * @type {DocumentationItem[]} - */ - this[documentationsValue] = undefined; - /** - * @type {NodeShapeItem[]} - */ - this[schemasValue] = undefined; - /** - * @type {SecurityItem[]} - */ - this[securityValue] = undefined; - /** - * The processed and final query term for the list items. - * @type {string} - */ - this[queryValue] = undefined; - /** - * Holds a list of ids of currently opened endpoints. - * @type {string[]} - */ + this[openedEndpointsValue] = []; - /** - * Cached list of all list elements - * @type {HTMLElement[]} - */ - this[itemsValue] = undefined; - /** @type DocumentMeta */ - this[documentMetaValue] = undefined; this[focusHandler] = this[focusHandler].bind(this); this[keydownHandler] = this[keydownHandler].bind(this); @@ -451,7 +474,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * Ensures aria role attribute is in place. * Attaches element's listeners. */ - connectedCallback() { + connectedCallback(): void { super.connectedCallback(); if (!this.getAttribute('aria-label')) { this.setAttribute('aria-label', 'API navigation'); @@ -466,25 +489,19 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } } - disconnectedCallback() { + disconnectedCallback(): void { super.disconnectedCallback(); this.removeEventListener('focus', this[focusHandler]); this.removeEventListener('keydown', this[keydownHandler]); this[itemsValue] = undefined; } - /** - * @param {EventTarget} node - */ - _attachListeners(node) { + _attachListeners(node: EventTarget): void { super._attachListeners(node); node.addEventListener(EventTypes.Store.graphChange, this[graphChangeHandler]); } - /** - * @param {EventTarget} node - */ - _detachListeners(node) { + _detachListeners(node: EventTarget): void { super._detachListeners(node); node.removeEventListener(EventTypes.Store.graphChange, this[graphChangeHandler]); } @@ -492,14 +509,14 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handler for the event dispatched by the store when the graph model change. */ - [graphChangeHandler]() { + [graphChangeHandler](): void { this.queryGraph(); } /** * Queries for the API data from the graph store. */ - async queryGraph() { + async queryGraph(): Promise { if (this.querying) { return; } @@ -518,16 +535,16 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) this[queryingValue] = false; this[abortControllerValue] = undefined; this[openedEndpointsValue] = []; - await this.requestUpdate(); + this.requestUpdate(); + await this.updateComplete; this[resetTabindices](); this.dispatchEvent(new Event('graphload')); } /** * Queries for the current API base info. - * @param {AbortSignal} signal */ - async [queryApi](signal) { + async [queryApi](signal: AbortSignal): Promise { this[documentMetaValue] = undefined; try { const info = await Events.Api.documentMeta(this); @@ -536,16 +553,16 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } this[documentMetaValue] = info; } catch (e) { - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Enable to query for API data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Enable to query for API data: ${ex.message}`, this.localName); } } /** * Queries and sets endpoints data - * @param {AbortSignal} signal */ - async [queryEndpoints](signal) { + async [queryEndpoints](signal: AbortSignal): Promise { if (signal.aborted) { return; } @@ -559,17 +576,17 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } this[sourceEndpointsValue] = result; } catch (e) { + const ex = e as Error; this[sourceEndpointsValue] = undefined; - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Enable to query for Endpoints data: ${e.message}`, this.localName); + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Enable to query for Endpoints data: ${ex.message}`, this.localName); } } /** * Queries and sets documentations data - * @param {AbortSignal} signal */ - async [queryDocumentations](signal) { + async [queryDocumentations](signal: AbortSignal): Promise { this[documentationsValue] = undefined; if (signal.aborted) { return; @@ -581,16 +598,16 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } this[documentationsValue] = result; } catch (e) { - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Enable to query for Documents data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Enable to query for Documents data: ${ex.message}`, this.localName); } } /** * Queries and sets types (schemas) data - * @param {AbortSignal} signal */ - async [querySchemas](signal) { + async [querySchemas](signal: AbortSignal): Promise { this[schemasValue] = undefined; if (signal.aborted) { return; @@ -602,16 +619,16 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } this[schemasValue] = result; } catch (e) { - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Enable to query for Schemas data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Enable to query for Schemas data: ${ex.message}`, this.localName); } } /** * Queries and sets security data - * @param {AbortSignal} signal */ - async [querySecurity](signal) { + async [querySecurity](signal: AbortSignal): Promise { this[securityValue] = undefined; if (signal.aborted) { return; @@ -623,16 +640,13 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } this[securityValue] = result; } catch (e) { - Events.Telemetry.exception(this, e.message, false); - Events.Reporting.error(this, e, `Enable to query for Security data: ${e.message}`, this.localName); + const ex = e as Error; + Events.Telemetry.exception(this, ex.message, false); + Events.Reporting.error(this, ex, `Enable to query for Security data: ${ex.message}`, this.localName); } } - /** - * @param {ApiEndPointWithOperationsListItem[]} items - * @returns {EndpointItem[]} - */ - [createFlatTreeItems](items) { + [createFlatTreeItems](items: ApiDefinitions.IApiEndPointWithOperationsListItem[]): ApiDefinitions.IEndpointItem[] { if (!Array.isArray(items) || !items.length) { return []; } @@ -648,7 +662,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Processes endpoints layout for the given configuration. */ - [layoutEndpoints]() { + [layoutEndpoints](): void { const { layout } = this; const endpoints = this[sourceEndpointsValue]; if (!endpoints) { @@ -666,7 +680,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) return; } if (layout === 'natural-sort') { - const sorted = /** @type ApiEndPointWithOperationsListItem[] */ (ApiSorting.sortEndpointsByPath([...endpoints])); + const sorted = ApiSorting.sortEndpointsByPath([...endpoints]) as ApiEndPointWithOperationsListItem[]; this[endpointsValue] = new NaturalTree().create(sorted); return; } @@ -678,9 +692,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Filters the current endpoints by the current query value. - * @returns {EndpointItem[]|undefined} */ - [getFilteredEndpoints]() { + [getFilteredEndpoints](): ApiEndpointsTreeItem[] | undefined { const value = this[endpointsValue]; if (!value || !value.length) { return undefined; @@ -689,9 +702,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) if (!q) { return value; } - const result = []; + const result: ApiEndpointsTreeItem[] = []; value.forEach((endpoint) => { - const { path, label, operations=[] } = endpoint; + const { path, label = '', operations = [] } = endpoint; const lPath = path.toLowerCase(); const lLabel = label.toLowerCase(); // If the endpoint's path or label matches the query include whole item @@ -703,7 +716,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) // then do not include the endpoint. const ops = operations.filter((op) => op.method.toLowerCase().includes(q) || (op.name || '').toLowerCase().includes(q)); if (ops.length) { - const copy = { ...endpoint }; + const copy = { ...endpoint } as ApiEndpointsTreeItem; copy.operations = ops; result[result.length] = copy; } @@ -716,23 +729,22 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * It sets padding-left property to indent resources. * See https://github.com/mulesoft/api-console/issues/571. * - * @param {number} indent The computed indentation of the item. - * @return {string} The value for the left padding of the endpoint menu item. + * @param indent The computed indentation of the item. + * @returns The value for the left padding of the endpoint menu item. */ - [computeEndpointPaddingValue](indent=0) { + [computeEndpointPaddingValue](indent = 0): string { const padding = this[computeEndpointPaddingLeft](); if (indent < 1) { return `${padding}px`; } - const result = indent * this.indentSize + padding; + const result = indent * (this.indentSize || 0) + padding; return `${result}px`; } /** * Computes endpoint list item left padding from CSS variables. - * @return {number} */ - [computeEndpointPaddingLeft]() { + [computeEndpointPaddingLeft](): number { const prop = '--api-navigation-list-item-padding'; const defaultPadding = 16; const padding = getComputedStyle(this).getPropertyValue(prop); @@ -772,13 +784,13 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * Computes `style` attribute value for an operation item. * It sets padding-left property to indent operations relative to a resource. * - * @param {number} indent The computed indentation of the parent resource. - * @return {string} The value for the left padding of the endpoint menu item. + * @param indent The computed indentation of the parent resource. + * @returns The value for the left padding of the endpoint menu item. */ - [computeOperationPaddingValue](indent=0) { + [computeOperationPaddingValue](indent = 0): string { const endpointAdjustment = 32; const padding = this[computeOperationPaddingLeft]() + endpointAdjustment; - const { indentSize } = this; + const { indentSize = 0 } = this; if (indentSize < 1) { return `${padding}px`; } @@ -788,9 +800,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Computes operation list item left padding from CSS variables. - * @return {number} */ - [computeOperationPaddingLeft]() { + [computeOperationPaddingLeft](): number { const prop = '--api-navigation-operation-item-padding-left'; let paddingLeft = getComputedStyle(this).getPropertyValue(prop); const defaultPadding = 24; @@ -808,13 +819,12 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the click event on a menu list item. * Makes a selection from the target. - * @param {MouseEvent} e */ - [itemClickHandler](e) { - const node = /** @type HTMLElement */ (e.currentTarget); + [itemClickHandler](e: MouseEvent): void { + const node = e.currentTarget as HTMLElement; const { graphId, graphShape } = node.dataset; if (graphId && graphShape) { - this[makeSelection](graphId, /** @type SelectionType */ (graphShape)); + this[makeSelection](graphId, graphShape as SelectionType); } else { // this is probably the abstract endpoint from the EndpointTree class. // We are preventing default so the element can ignore focusing on the item. @@ -825,10 +835,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the click event on endpoints toggle button. - * @param {MouseEvent} e */ - [endpointToggleClickHandler](e) { - const node = /** @type HTMLElement */ (e.currentTarget); + [endpointToggleClickHandler](e: MouseEvent): void { + const node = e.currentTarget as HTMLElement; const { graphId } = node.dataset; if (graphId) { this.toggleEndpoint(graphId); @@ -843,9 +852,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Toggles operations visibility for an endpoint. - * @param {string} graphId The Endpoint graph id. + * @param graphId The Endpoint graph id. */ - toggleEndpoint(graphId) { + toggleEndpoint(graphId: string): void { const index = this[openedEndpointsValue].indexOf(graphId); if (index === -1) { this[openedEndpointsValue].push(graphId); @@ -857,10 +866,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the click event on a section item. Toggles the clicked section. - * @param {MouseEvent} e */ - [toggleSectionClickHandler](e) { - const node = /** @type HTMLElement */ (e.currentTarget); + [toggleSectionClickHandler](e: MouseEvent): void { + const node = e.currentTarget as HTMLElement; this[toggleSectionElement](node); Events.Telemetry.event(this, { category: 'API navigation', @@ -869,22 +877,26 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) }); } + [toggleSectionKeydownHandler](): void { + throw new Error(`Not implemented.`); + } + /** * Toggles a section of the menu represented by the element (section list item). - * @param {HTMLElement} element */ - [toggleSectionElement](element) { - const { property } = element.dataset; - if (!property) { + [toggleSectionElement](element: HTMLElement): void { + const prop = element.dataset.property; + if (!prop) { return; } - this[property] = !this[property]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this as any)[prop] = !(this as any)[prop]; } /** - * @returns {DocumentationItem[]} List of documentation items filtered by the current query. + * @returns The list of documentation items filtered by the current query. */ - [getFilteredDocumentations]() { + [getFilteredDocumentations](): ApiDefinitions.IDocumentationItem[] { const items = this[documentationsValue]; if (!Array.isArray(items) || !items.length) { return []; @@ -893,14 +905,14 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) if (!q) { return items; } - return items.filter((doc) => + return items.filter((doc) => (doc.title || '').toLocaleLowerCase().includes(q)); } /** - * @return {NodeShapeItem[]} List of schemas items filtered by the current query. + * @returns The list of schemas items filtered by the current query. */ - [getFilteredSchemas]() { + [getFilteredSchemas](): ApiDefinitions.INodeShapeItem[] { const items = this[schemasValue]; if (!Array.isArray(items) || !items.length) { return []; @@ -909,15 +921,15 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) if (!q) { return items; } - return items.filter((doc) => - (doc.name || '').toLocaleLowerCase().includes(q) || + return items.filter((doc) => + (doc.name || '').toLocaleLowerCase().includes(q) || (doc.displayName || '').toLocaleLowerCase().includes(q)); } /** - * @return {SecurityItem[]} List of security items filtered by the current query. + * @returns The list of security items filtered by the current query. */ - [getFilteredSecurity]() { + [getFilteredSecurity](): ApiDefinitions.ISecurityItem[] { const items = this[securityValue]; if (!Array.isArray(items) || !items.length) { return []; @@ -926,27 +938,26 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) if (!q) { return items; } - return items.filter((doc) => - (doc.name || '').toLocaleLowerCase().includes(q) || - (doc.displayName || '').toLocaleLowerCase().includes(q) || + return items.filter((doc) => + (doc.name || '').toLocaleLowerCase().includes(q) || + (doc.displayName || '').toLocaleLowerCase().includes(q) || (doc.type || '').toLocaleLowerCase().includes(q)); } /** * A handler for the focus event on this element. - * @param {FocusEvent} e */ - [focusHandler](e) { + [focusHandler](e: FocusEvent): void { if (this[shiftTabPressedValue]) { // do not focus the menu itself return; } const path = e.composedPath(); - const rootTarget = /** @type HTMLElement */ (path[0]); + const rootTarget = path[0] as HTMLElement; if (rootTarget !== this && typeof rootTarget.tabIndex !== 'undefined' && !this.contains(rootTarget)) { return; } - this[focusedItemValue] = null; + this[focusedItemValue] = undefined; const { selectedItem } = this; if (selectedItem) { this[focusItem](selectedItem); @@ -957,9 +968,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Sets a list item focused - * @param {HTMLElement} item */ - [focusItem](item) { + [focusItem](item: HTMLElement): void { const old = this[focusedItemValue]; this[focusedItemValue] = item; if (old) { @@ -973,11 +983,10 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handler for the keydown event. - * @param {KeyboardEvent} e */ - [keydownHandler](e) { + [keydownHandler](e: KeyboardEvent): void { const path = e.composedPath(); - const target = /** @type HTMLElement */ (path[0]); + const target = path[0] as HTMLElement; if (target.localName === 'input') { return; } @@ -1003,10 +1012,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handler that is called when the down key is pressed. - * - * @param {KeyboardEvent} e A key combination event. */ - [keyDownAction](e) { + [keyDownAction](e: KeyboardEvent): void { e.preventDefault(); e.stopPropagation(); this.focusNext(); @@ -1014,10 +1021,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handler that is called when the up key is pressed. - * - * @param {KeyboardEvent} e A key combination event. */ - [keyUpAction](e) { + [keyUpAction](e: KeyboardEvent): void { e.preventDefault(); this.focusPrevious(); } @@ -1025,13 +1030,15 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handles shift+tab keypress on the menu. */ - [keyShiftTabAction]() { + [keyShiftTabAction](): void { const oldTabIndex = this.getAttribute('tabindex'); this[shiftTabPressedValue] = true; - this[focusedItemValue] = null; + this[focusedItemValue] = undefined; this.setAttribute('tabindex', '-1'); setTimeout(() => { - this.setAttribute('tabindex', oldTabIndex); + if (oldTabIndex) { + this.setAttribute('tabindex', oldTabIndex); + } this[shiftTabPressedValue] = false; }, 1); } @@ -1039,7 +1046,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Handler that is called when the esc key is pressed. */ - [keyEscAction]() { + [keyEscAction](): void { const { focusedItem } = this; if (focusedItem) { focusedItem.blur(); @@ -1048,13 +1055,12 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the space bar key down. - * @param {KeyboardEvent} e */ - [keySpaceAction](e) { + [keySpaceAction](e: KeyboardEvent): void { e.preventDefault(); e.stopPropagation(); const path = e.composedPath(); - const target = /** @type HTMLElement */ (path && path[0]); + const target = path && path[0] as HTMLElement; if (!target) { return; } @@ -1064,18 +1070,17 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } else if (classList.contains('list-item')) { const { graphId, graphShape } = dataset; if (graphId && graphShape) { - this[makeSelection](graphId, /** @type SelectionType */ (graphShape)); + this[makeSelection](graphId, graphShape as SelectionType); } } } /** * A handler for the key right down. Opens operations when needed. - * @param {KeyboardEvent} e */ - [keyArrowRightAction](e) { + [keyArrowRightAction](e: KeyboardEvent): void { const path = e.composedPath(); - const target = /** @type HTMLElement */ (path && path[0]); + const target = path && path[0] as HTMLElement; if (!target) { return; } @@ -1090,11 +1095,10 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the key left down. Closes operations when needed. - * @param {KeyboardEvent} e */ - [keyArrowLeftAction](e) { + [keyArrowLeftAction](e: KeyboardEvent): void { const path = e.composedPath(); - const target = /** @type HTMLElement */ (path && path[0]); + const target = path && path[0] as HTMLElement; if (!target) { return; } @@ -1111,18 +1115,17 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Focuses on the previous item in the navigation. */ - focusPrevious() { + focusPrevious(): void { const items = this[listActiveItems](); const { length } = items; - const curFocusIndex = items.indexOf(this[focusedItemValue]); + const curFocusIndex = this[focusedItemValue] ? items.indexOf(this[focusedItemValue]) : -1; for (let i = 1; i < length + 1; i++) { const item = items[(curFocusIndex - i + length) % length]; if (item && !item.hasAttribute('disabled')) { - const owner = (item.getRootNode && item.getRootNode()) || document; + const owner = (item.getRootNode && item.getRootNode()) as Document || document; this[focusItem](item); // Focus might not have worked, if the element was hidden or not // focusable. In that case, try again. - // @ts-ignore if (owner.activeElement === item) { return; } @@ -1133,18 +1136,17 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Focuses on the next item in the navigation. */ - focusNext() { + focusNext(): void { const items = this[listActiveItems](); const { length } = items; - const curFocusIndex = items.indexOf(this[focusedItemValue]); + const curFocusIndex = this[focusedItemValue] ? items.indexOf(this[focusedItemValue]) : -1; for (let i = 1; i < length + 1; i++) { const item = items[(curFocusIndex + i) % length]; if (!item.hasAttribute('disabled')) { - const owner = (item.getRootNode && item.getRootNode()) || document; + const owner = (item.getRootNode && item.getRootNode()) as Document || document; this[focusItem](item); // Focus might not have worked, if the element was hidden or not // focusable. In that case, try again. - // @ts-ignore if (owner.activeElement === item) { return; } @@ -1155,49 +1157,52 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Selects an item in the navigation. * Note, this dispatches the navigation action event. - * @param {string} id */ - select(id) { - if (!id) { + select(id?: string): void { + const { shadowRoot } = this; + if (!id || !shadowRoot) { return; } - const element = /** @type HTMLElement */ (this.shadowRoot.querySelector(`[data-graph-id="${id}"]`)); + const element = (shadowRoot.querySelector(`[data-graph-id="${id}"]`)) as HTMLElement | null; if (!element) { return; } const { graphShape } = element.dataset; - this[makeSelection](id, /** @type SelectionType */ (graphShape)); + this[makeSelection](id, graphShape as SelectionType); } /** * Lists all HTML elements that are currently rendered in the view. - * @return {HTMLElement[]} Currently rendered items. + * @returns Currently rendered items. */ - [listActiveItems]() { + [listActiveItems](): HTMLElement[] { if (this[itemsValue]) { return this[itemsValue]; } const { shadowRoot } = this; - let result = /** @type HTMLElement[] */ ([]); + if (!shadowRoot) { + return []; + } + let result: HTMLElement[] = []; if (this.summary) { const node = shadowRoot.querySelector('.list-item.summary'); if (node) { - result[result.length] = /** @type HTMLElement */ (node); + result[result.length] = node as HTMLElement; } } if (this.hasEndpoints) { const node = shadowRoot.querySelector('.endpoints .section-title'); if (node) { - result[result.length] = /** @type HTMLElement */ (node); + result[result.length] = node as HTMLElement; } const nodes = Array.from(shadowRoot.querySelectorAll('.endpoints .list-item.endpoint')); nodes.forEach((item) => { - result[result.length] = /** @type HTMLElement */ (item); + result[result.length] = item as HTMLElement; const collapse = item.nextElementSibling; if (!collapse || collapse.localName !== 'anypoint-collapse') { return; } - const children = /** @type HTMLElement[] */ (Array.from(collapse.querySelectorAll('.list-item.operation'))); + const children = Array.from(collapse.querySelectorAll('.list-item.operation')) as HTMLElement[]; if (children.length) { result = result.concat(children); } @@ -1220,17 +1225,21 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } /** - * @param {string} selector The prefix for the query selector - * @return {HTMLElement[]} Nodes returned from query function. + * @param selector The prefix for the query selector + * @returns Nodes returned from query function. */ - [listSectionActiveNodes](selector) { - let result = /** @type HTMLElement[] */ ([]); - const node = this.shadowRoot.querySelector(`${selector} .section-title`); + [listSectionActiveNodes](selector: string): HTMLElement[] { + const { shadowRoot } = this; + let result: HTMLElement[] = []; + if (!shadowRoot) { + return result; + } + const node = shadowRoot.querySelector(`${selector} .section-title`); if (node) { - result[result.length] = /** @type HTMLElement */ (node); + result[result.length] = node as HTMLElement; const collapse = node.nextElementSibling; if (collapse) { - const children = /** @type HTMLElement[] */ (Array.from(collapse.querySelectorAll('.list-item'))); + const children = Array.from(collapse.querySelectorAll('.list-item')) as HTMLElement[]; if (children.length) { result = result.concat(children); } @@ -1242,16 +1251,20 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Selects an item in the menu. * - * @param {string} id The domain id of the node to be selected - * @param {SelectionType} type The selected type of the item. + * @param id The domain id of the node to be selected + * @param type The selected type of the item. */ - [makeSelection](id, type) { - const element = /** @type HTMLElement */ (this.shadowRoot.querySelector(`[data-graph-id="${id}"]`)); + [makeSelection](id: string, type: SelectionType): void { + const { shadowRoot } = this; + if (!shadowRoot) { + return ; + } + const element = (shadowRoot.querySelector(`[data-graph-id="${id}"]`)) as HTMLElement | null; if (!element) { return; } this[selectedItemValue] = element; - this[deselectItem](this.domainId, this.domainType); + this[deselectItem](this.domainId as string, this.domainType as SelectionType); this[domainIdValue] = id; this[domainTypeValue] = type; if (id === 'summary') { @@ -1268,7 +1281,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) return; } if (parent.localName === 'anypoint-collapse') { - /** @type AnypointCollapseElement */ (parent).opened = true; + (parent as AnypointCollapseElement).opened = true; } parent = parent.parentElement; } @@ -1276,10 +1289,10 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Selects an item. - * @param {string} id The domain id of the menu item. - * @param {SelectionType} type The type of the data. + * @param id The domain id of the menu item. + * @param type The type of the data. */ - [selectItem](id, type) { + [selectItem](id: string, type: SelectionType): void { const selectable = this[findSelectable](id, type); if (selectable) { selectable.selected = true; @@ -1289,10 +1302,10 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Removes all selections from an item. - * @param {string} id The domain id of the menu item. - * @param {SelectionType} type The type of the data. + * @param id The domain id of the menu item. + * @param type The type of the data. */ - [deselectItem](id, type) { + [deselectItem](id: string, type: SelectionType): void { this[summarySelected] = false; const selectable = this[findSelectable](id, type); if (selectable) { @@ -1304,27 +1317,26 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Finds a selectable item by its id and type. - * @param {string} id The domain id of the menu item. - * @param {SelectionType} type The type of the data. - * @returns {SelectableMenuItem|null} + * @param id The domain id of the menu item. + * @param type The type of the data. */ - [findSelectable](id, type) { + [findSelectable](id: string, type: SelectionType): SelectableMenuItem|undefined { if (!id || !type) { - return null; + return undefined; } - let selectable = /** @type SelectableMenuItem */ (null); + let selectable: SelectableMenuItem | undefined; if (type === 'resource') { - selectable = /** @type EndpointItem[] */ (this[endpointsValue] || []).find((item) => item.id === id); + selectable = (this[endpointsValue] || []).find((item) => item.id === id); } else if (type === 'operation') { - const endpoint = /** @type EndpointItem[] */ (this[endpointsValue] || []).find((item) => { + const endpoint = (this[endpointsValue] || []).find((item) => { if (!Array.isArray(item.operations) || !item.operations.length) { return false; } - const op = item.operations.find((opItem) => opItem.id === id); + const op = item.operations.find((opItem) => opItem.id === id); return !!op; }); if (endpoint) { - selectable = /** @type OperationItem[] */ (endpoint.operations).find((item) => item.id === id); + selectable = endpoint.operations.find((item) => item.id === id); } } else if (type === 'documentation') { selectable = (this[documentationsValue] || []).find((item) => item.id === id); @@ -1337,9 +1349,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } /** - * @param {string} value The new query. Empty or null to clear the query + * @param value The new query. Empty or null to clear the query */ - [processQuery](value) { + [processQuery](value?: string): void { if (typeof value !== 'string' || value.trim() === '') { this[queryValue] = undefined; } else { @@ -1350,10 +1362,9 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A handler for the search event from the filter input. - * @param {Event} e */ - [searchHandler](e) { - const input = /** @type HTMLInputElement */ (e.target); + [searchHandler](e: Event): void { + const input = (e.target as HTMLInputElement); this.query = input.value; Events.Telemetry.event(this, { category: 'API navigation', @@ -1365,7 +1376,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Opens all sections of the menu and all endpoints. */ - expandAll() { + expandAll(): void { this.endpointsOpened = true; this.schemasOpened = true; this.securityOpened = true; @@ -1376,7 +1387,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Closes all sections of the menu and all endpoints. */ - collapseAll() { + collapseAll(): void { this.endpointsOpened = false; this.schemasOpened = false; this.securityOpened = false; @@ -1387,9 +1398,13 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Opens all endpoints exposing all operations */ - expandAllEndpoints() { + expandAllEndpoints(): void { + const { shadowRoot } = this; + if (!shadowRoot) { + return; + } this.endpointsOpened = true; - const items = /** @type HTMLInputElement[] */ (Array.from(this.shadowRoot.querySelectorAll('section.endpoints .list-item.endpoint'))); + const items = Array.from(shadowRoot.querySelectorAll('section.endpoints .list-item.endpoint')) as HTMLInputElement[]; this[openedEndpointsValue] = []; items.forEach((item) => { const { graphId } = item.dataset; @@ -1404,7 +1419,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Hides all operations and collapses all endpoints. */ - collapseAllEndpoints() { + collapseAllEndpoints(): void { this[openedEndpointsValue] = []; this[endpointsExpandedValue] = false; this.requestUpdate(); @@ -1414,57 +1429,66 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * Triggers a flow when the user can define a new endpoint in the navigation. * This renders an input in the view (in the endpoints list) where the user can enter the path name. */ - async addEndpoint() { + async addEndpoint(): Promise { if (!this.endpointsOpened) { this.endpointsOpened = true; await this.updateComplete; } this[addingEndpointValue] = true; - await this.requestUpdate(); - const wrap = this.shadowRoot.querySelector('.add-endpoint-input'); - wrap.scrollIntoView(); - const input = wrap.querySelector('input'); - input.focus(); - input.select(); + this.requestUpdate(); + await this.updateComplete; + const wrap = this.shadowRoot?.querySelector('.add-endpoint-input'); + if (wrap) { + wrap.scrollIntoView(); + const input = wrap.querySelector('input') as HTMLInputElement; + input.focus(); + input.select(); + } } /** * Triggers a flow when the user can define a new documentation document. * This renders an input in the view (in the documentation list) where the user can enter the name. - * @param {boolean=} isExternal Whether the documentation is a link to a www document. + * @param isExternal Whether the documentation is a link to a www document. */ - async addDocumentation(isExternal=false) { + async addDocumentation(isExternal = false) : Promise{ if (!this.documentationsOpened) { this.documentationsOpened = true; } this[addingDocumentationValue] = true; this[addingExternalValue] = isExternal; - await this.requestUpdate(); + this.requestUpdate(); + await this.updateComplete; const selector = isExternal ? '.add-external-doc-input' : '.add-documentation-input'; - const wrap = this.shadowRoot.querySelector(selector); - wrap.scrollIntoView(); - const input = wrap.querySelector('input'); - input.focus(); - input.select(); + const wrap = this.shadowRoot?.querySelector(selector) as HTMLInputElement; + if (wrap) { + wrap.scrollIntoView(); + const input = wrap.querySelector('input') as HTMLInputElement; + input.focus(); + input.select(); + } } /** * Triggers a flow when the user can define a new schema in the navigation. * This renders an input in the view (in the schema list) where the user can enter the schema name. - * @param {SchemaAddType=} type The type of the schema to add. Default to `object`. + * @param type The type of the schema to add. Default to `object`. */ - async addSchema(type='object') { + async addSchema(type: SchemaAddType = 'object'): Promise { if (!this.schemasOpened) { this.schemasOpened = true; } this[addingSchemaValue] = true; this[addingSchemaTypeValue] = type; - await this.requestUpdate(); - const wrap = this.shadowRoot.querySelector('.add-schema-input'); - wrap.scrollIntoView(); - const input = wrap.querySelector('input'); - input.focus(); - input.select(); + this.requestUpdate(); + await this.updateComplete; + const wrap = this.shadowRoot?.querySelector('.add-schema-input'); + if (wrap) { + wrap.scrollIntoView(); + const input = wrap.querySelector('input') as HTMLInputElement; + input.focus(); + input.select(); + } } /** @@ -1474,7 +1498,7 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * other items. Also sets the correct initial values for aria-selected * attribute, true for default selected item and false for others. */ - [resetTabindices]() { + [resetTabindices](): void { const { selectedItem } = this; const items = this[listActiveItems](); items.forEach((item) => item.setAttribute('tabindex', item === selectedItem ? '0' : '-1')); @@ -1482,15 +1506,15 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Dispatches the navigation event. - * @param {string} id The domain id of the selected node - * @param {SelectionType} type The domain type. + * @param id The domain id of the selected node + * @param type The domain type. */ - [notifyNavigation](id, type) { + [notifyNavigation](id: string, type: SelectionType): void { let parent; if (type === 'operation' && id) { - const node = /** @type HTMLElement */ (this.shadowRoot.querySelector(`.operation[data-graph-id="${id}"]`)); + const node = this.shadowRoot?.querySelector(`.operation[data-graph-id="${id}"]`); if (node) { - parent = node.dataset.graphParent; + parent = (node as HTMLElement).dataset.graphParent; } } Events.Navigation.apiNavigate(this, id, type, parent); @@ -1503,9 +1527,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Event handler for the keydown event of the add endpoint input. - * @param {KeyboardEvent} e */ - [addEndpointKeydownHandler](e) { + [addEndpointKeydownHandler](e: KeyboardEvent): void { if (e.key === 'Enter' || e.key === 'NumpadEnter') { e.preventDefault(); this[commitNewEndpoint](); @@ -1517,12 +1540,11 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Event handler for the keydown event of the add documentation input. - * @param {KeyboardEvent} e */ - [addDocumentationKeydownHandler](e) { + [addDocumentationKeydownHandler](e: KeyboardEvent): void { if (e.key === 'Enter' || e.key === 'NumpadEnter') { e.preventDefault(); - const input = /** @type HTMLInputElement */ (e.target); + const input = e.target as HTMLInputElement; this[commitNewDocumentation](input.value); } else if (e.key === 'Escape') { e.preventDefault(); @@ -1534,12 +1556,11 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Event handler for the keydown event of the add schema input. - * @param {KeyboardEvent} e */ - [addSchemaKeydownHandler](e) { + [addSchemaKeydownHandler](e: KeyboardEvent): void { if (e.key === 'Enter' || e.key === 'NumpadEnter') { e.preventDefault(); - const input = /** @type HTMLInputElement */ (e.target); + const input = (e.target as HTMLInputElement); this[commitNewSchema](input.value); } else if (e.key === 'Escape') { e.preventDefault(); @@ -1549,12 +1570,12 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } } - async [commitNewEndpoint]() { - const input = /** @type HTMLInputElement */ (this.shadowRoot.querySelector('.add-endpoint-input input')) + async [commitNewEndpoint](): Promise { + const input = this.shadowRoot?.querySelector('.add-endpoint-input input'); if (!input) { return; } - const name = input.value.trim(); + const name = (input as HTMLInputElement).value.trim(); if (!name) { return; } @@ -1562,25 +1583,28 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) await this[cancelNewEndpoint](); } - async [cancelNewEndpoint]() { + async [cancelNewEndpoint](): Promise { this[addingEndpointValue] = false; - await this.requestUpdate(); + this.requestUpdate(); + await this.updateComplete; } /** - * @param {string} value The title of the documentation. + * @param value The title of the documentation. */ - async [commitNewDocumentation](value='') { + async [commitNewDocumentation](value = ''): Promise { const name = value.trim(); if (!name) { return; } - const opts = { title: name }; - const isExternal = this[addingExternalValue]; - if (isExternal) { - const input = /** @type HTMLInputElement */ (this.shadowRoot.querySelector('.add-external-doc-input input')) - opts.url = input.value; - } + // const opts = { title: name }; + // const isExternal = this[addingExternalValue]; + // if (isExternal) { + // const input = (this.shadowRoot?.querySelector('.add-external-doc-input input')); + // if (input) { + // opts.url = (input as HTMLInputElement).value; + // } + // } this[addingDocumentationValue] = false; this[addingExternalValue] = undefined; // await Events.Documentation.add(this, opts); @@ -1588,24 +1612,24 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) } /** - * @param {string} value The name of the schema. + * @param value The name of the schema. */ - async [commitNewSchema](value='') { + async [commitNewSchema](value = ''): Promise { const name = value.trim(); if (!name) { return; } - const type = this[addingSchemaTypeValue]; - const opts = { name }; + // const type = this[addingSchemaTypeValue]; + // const opts = { name }; - switch (type) { - case 'object': opts.type = ns.w3.shacl.NodeShape; break; - case 'scalar': opts.type = ns.aml.vocabularies.shapes.ScalarShape; break; - case 'array': opts.type = ns.aml.vocabularies.shapes.ArrayShape; break; - case 'file': opts.type = ns.aml.vocabularies.shapes.FileShape; break; - case 'union': opts.type = ns.aml.vocabularies.shapes.UnionShape; break; - default: - } + // switch (type) { + // case 'object': opts.type = AmfNamespace.w3.shacl.NodeShape; break; + // case 'scalar': opts.type = AmfNamespace.aml.vocabularies.shapes.ScalarShape; break; + // case 'array': opts.type = AmfNamespace.aml.vocabularies.shapes.ArrayShape; break; + // case 'file': opts.type = AmfNamespace.aml.vocabularies.shapes.FileShape; break; + // case 'union': opts.type = AmfNamespace.aml.vocabularies.shapes.UnionShape; break; + // default: + // } this[addingSchemaValue] = false; this[addingSchemaTypeValue] = undefined; // await Events.Type.add(this, opts); @@ -1614,25 +1638,29 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * Triggers a rename action for the menu item identified by the `id`. - * @param {string} id The domain id of the item to edit. + * @param id The domain id of the item to edit. */ - async renameAction(id) { + async renameAction(id: string): Promise { + const { shadowRoot } = this; + if (!shadowRoot) { + throw new Error(`Invalid state. The DOM is not ready.`); + } const item = this[findViewModelItem](id); if (!item) { return; } item.nameEditor = true; - await this.requestUpdate(); - const input = /** @type HTMLInputElement */ (this.shadowRoot.querySelector(`input[data-id="${id}"]`)); + this.requestUpdate(); + await this.updateComplete; + const input = (shadowRoot.querySelector(`input[data-id="${id}"]`)) as HTMLInputElement; input.select(); input.focus(); } /** - * @param {string} id The domain id of the item to find. - * @returns {SelectableMenuItem & EditableMenuItem | null} + * @param id The domain id of the item to find. */ - [findViewModelItem](id) { + [findViewModelItem](id: string): SelectableMenuItem & EditableMenuItem | null { const endpoints = this[endpointsValue]; if (endpoints && endpoints.length) { for (let i = 0, len = endpoints.length; i < len; i++) { @@ -1665,19 +1693,18 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) /** * A key down event handler on the rename input - * @param {KeyboardEvent} e */ - async [renameKeydownHandler](e) { + async [renameKeydownHandler](e: KeyboardEvent): Promise { // do not interfere with the navigation logic. e.stopPropagation(); if (!['Enter', 'NumpadEnter', 'Escape'].includes(e.code)) { return; } e.preventDefault(); - const input = /** @type HTMLInputElement */ (e.target); + const input = e.target as HTMLInputElement; const { value, dataset } = input; const { id, type } = dataset; - const item = this[findViewModelItem](id); + const item = this[findViewModelItem](id as string); if (!item) { return; } @@ -1686,34 +1713,33 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) if (e.code === 'Escape') { return; } - await this[updateNameHandler](id, value, /** @type SelectionType */ (type)); + await this[updateNameHandler](id as string, value, type as SelectionType); } /** * A blur event handler on the rename input - * @param {Event} e */ - async [renameBlurHandler](e) { - const input = /** @type HTMLInputElement */ (e.target); + async [renameBlurHandler](e: Event): Promise { + const input = e.target as HTMLInputElement; const { value, dataset } = input; const { id, type } = dataset; - const item = this[findViewModelItem](id); + const item = this[findViewModelItem](id as string); if (!item) { return; } item.nameEditor = false; this.requestUpdate(); - await this[updateNameHandler](id, value, /** @type SelectionType */ (type)); + await this[updateNameHandler](id as string, value, type as SelectionType); } /** * Updates the name or the display name of the menu object - * @param {string} id The id of the domain object to update - * @param {string} value The new value. - * @param {SelectionType} type The object type - * @returns {Promise} A promise when the update operation finish. + * @param id The id of the domain object to update + * @param value The new value. + * @param type The object type + * @returns A promise when the update operation finish. */ - async [updateNameHandler](id, value, type) { + async [updateNameHandler](id: string, value: string, type: SelectionType): Promise { const updateValue = value.trim(); if (!updateValue) { return; @@ -1737,7 +1763,8 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) try { await promise; } catch (e) { - Events.Reporting.error(this, e, `Unable rename object: ${e.message}`, 'graph-api-navigation'); + const ex = e as Error; + Events.Reporting.error(this, ex, `Unable rename object: ${ex.message}`, 'graph-api-navigation'); } } @@ -1745,17 +1772,16 @@ export default class ApiNavigationElement extends EventsTargetMixin(LitElement) * Click handler for the external navigation item. * Dispatches the external navigation event. When this event is handled (cancelled) * the original event is cancelled to prevent default behavior. - * @param {Event} e */ - [externalDocumentationHandler](e) { - const a = /** @type HTMLAnchorElement */ (e.currentTarget); + [externalDocumentationHandler](e: Event): void { + const a = e.currentTarget as HTMLAnchorElement; const handled = Events.Navigation.navigateExternal(this, a.href); if (handled) { cancelEvent(e); } } - render() { + render(): TemplateResult { return html`