From cf569dc5c25400e8fd0508b3c8c5371d0354314b Mon Sep 17 00:00:00 2001 From: Oliwia Rogala Date: Mon, 25 Nov 2024 14:00:51 +0100 Subject: [PATCH] chore(ns-api-design-systems): use API Extractor for TypeScript rollup (#4550) Refs #4382 --- .../config/api-extractor/api-extractor.json | 4 ++++ .../config/rollup/types.dist.js | 11 --------- .../apidom-ns-api-design-systems/package.json | 8 +++---- .../src/elements/Info.ts | 3 +++ .../src/elements/Main.ts | 3 +++ .../src/elements/Principle.ts | 3 +++ .../src/elements/Requirement.ts | 3 +++ .../src/elements/RequirementLevel.ts | 3 +++ .../src/elements/Scenario.ts | 3 +++ .../src/elements/Standard.ts | 3 +++ .../src/elements/StandardIdentifier.ts | 3 +++ .../apidom-ns-api-design-systems/src/index.ts | 3 +++ .../src/media-types.ts | 11 ++++++++- .../src/namespace.ts | 3 +++ .../src/predicates.ts | 24 +++++++++++++++++++ .../standard-identifier-accessors.ts | 3 +++ .../standard-identifier-selectors.ts | 3 +++ .../src/refractor/specification.ts | 1 + .../src/refractor/visitors/FallbackVisitor.ts | 3 +++ .../visitors/SpecificationVisitor.ts | 4 ++++ .../src/refractor/visitors/Visitor.ts | 6 +++++ .../visitors/api-design-systems/info/index.ts | 6 +++++ .../main/PrinciplesVisitor.ts | 6 +++++ .../main/ScenariosVisitor.ts | 6 +++++ .../main/StandardsVisitor.ts | 6 +++++ .../visitors/api-design-systems/main/index.ts | 6 +++++ .../api-design-systems/principle/index.ts | 6 +++++ .../requirement-level/index.ts | 6 +++++ .../api-design-systems/requirement/index.ts | 6 +++++ .../scenario/ThenVisitor.ts | 6 +++++ .../api-design-systems/scenario/index.ts | 6 +++++ .../standard-identifier/index.ts | 6 +++++ .../api-design-systems/standard/index.ts | 6 +++++ .../visitors/generics/FixedFieldsVisitor.ts | 9 +++++++ .../src/traversal/visitor.ts | 7 +++++- .../src/validator/openapi-3-1/validator.ts | 3 +++ 36 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 packages/apidom-ns-api-design-systems/config/api-extractor/api-extractor.json delete mode 100644 packages/apidom-ns-api-design-systems/config/rollup/types.dist.js diff --git a/packages/apidom-ns-api-design-systems/config/api-extractor/api-extractor.json b/packages/apidom-ns-api-design-systems/config/api-extractor/api-extractor.json new file mode 100644 index 0000000000..7de0d99447 --- /dev/null +++ b/packages/apidom-ns-api-design-systems/config/api-extractor/api-extractor.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "extends": "../../../../api-extractor.json" +} diff --git a/packages/apidom-ns-api-design-systems/config/rollup/types.dist.js b/packages/apidom-ns-api-design-systems/config/rollup/types.dist.js deleted file mode 100644 index 308fe65359..0000000000 --- a/packages/apidom-ns-api-design-systems/config/rollup/types.dist.js +++ /dev/null @@ -1,11 +0,0 @@ -import dts from 'rollup-plugin-dts'; - -const config = [ - { - input: './types/index.d.ts', - output: [{ file: 'types/dist.d.ts', format: 'es' }], - plugins: [dts()], - }, -]; - -export default config; diff --git a/packages/apidom-ns-api-design-systems/package.json b/packages/apidom-ns-api-design-systems/package.json index 1f5aa41409..6d9edacba1 100644 --- a/packages/apidom-ns-api-design-systems/package.json +++ b/packages/apidom-ns-api-design-systems/package.json @@ -14,11 +14,11 @@ "unpkg": "./dist/apidom-ns-api-design-systems.browser.min.js", "main": "./src/index.cjs", "exports": { - "types": "./types/dist.d.ts", + "types": "./types/apidom-ns-api-design-systems.d.ts", "import": "./src/index.mjs", "require": "./src/index.cjs" }, - "types": "./types/dist.d.ts", + "types": "./types/apidom-ns-api-design-systems.d.ts", "scripts": { "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser", "build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'", @@ -30,7 +30,7 @@ "test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha", "test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 mocha", "typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit", - "typescript:declaration": "tsc -p tsconfig.declaration.json && rollup -c config/rollup/types.dist.js", + "typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json 2>&1 | shx grep -v 'Visitor_base'", "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .", "postpack": "rimraf NOTICE LICENSES" }, @@ -54,7 +54,7 @@ "src/**/*.mjs", "src/**/*.cjs", "dist/", - "types/dist.d.ts", + "types/apidom-ns-api-design-systems.d.ts", "LICENSES", "NOTICE", "README.md", diff --git a/packages/apidom-ns-api-design-systems/src/elements/Info.ts b/packages/apidom-ns-api-design-systems/src/elements/Info.ts index 07f6281360..044c91bade 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Info.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Info.ts @@ -1,5 +1,8 @@ import { ObjectElement, StringElement, Attributes, Meta } from '@swagger-api/apidom-core'; +/** + * @public + */ class Info extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/Main.ts b/packages/apidom-ns-api-design-systems/src/elements/Main.ts index 088e6771ae..76d64c4610 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Main.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Main.ts @@ -8,6 +8,9 @@ import { import InfoElement from './Info.ts'; +/** + * @public + */ class Main extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/Principle.ts b/packages/apidom-ns-api-design-systems/src/elements/Principle.ts index f4f318c5de..e8a175456a 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Principle.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Principle.ts @@ -2,6 +2,9 @@ import { ObjectElement, StringElement, Attributes, Meta } from '@swagger-api/api import RequirementLevelElement from './RequirementLevel.ts'; +/** + * @public + */ class Principle extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/Requirement.ts b/packages/apidom-ns-api-design-systems/src/elements/Requirement.ts index 273c95d9e7..f363e83395 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Requirement.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Requirement.ts @@ -9,6 +9,9 @@ import { import StandardIdentifierElement from './StandardIdentifier.ts'; import RequirementLevelElement from './RequirementLevel.ts'; +/** + * @public + */ class Requirement extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/RequirementLevel.ts b/packages/apidom-ns-api-design-systems/src/elements/RequirementLevel.ts index 0f7bb5bb83..8df2c64ee2 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/RequirementLevel.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/RequirementLevel.ts @@ -1,5 +1,8 @@ import { StringElement, Attributes, Meta } from '@swagger-api/apidom-core'; +/** + * @public + */ class RequirementLevel extends StringElement { constructor(content?: string, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/Scenario.ts b/packages/apidom-ns-api-design-systems/src/elements/Scenario.ts index c5e6279c66..c21e6ca63f 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Scenario.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Scenario.ts @@ -8,6 +8,9 @@ import { import StandardIdentifierElement from './StandardIdentifier.ts'; +/** + * @public + */ class Scenario extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/Standard.ts b/packages/apidom-ns-api-design-systems/src/elements/Standard.ts index 85ec91d224..da7f5bec4a 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/Standard.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/Standard.ts @@ -2,6 +2,9 @@ import { ObjectElement, StringElement, Attributes, Meta } from '@swagger-api/api import RequirementLevelElement from './RequirementLevel.ts'; +/** + * @public + */ class Standard extends ObjectElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/elements/StandardIdentifier.ts b/packages/apidom-ns-api-design-systems/src/elements/StandardIdentifier.ts index b9c25974ff..f6802d5b81 100644 --- a/packages/apidom-ns-api-design-systems/src/elements/StandardIdentifier.ts +++ b/packages/apidom-ns-api-design-systems/src/elements/StandardIdentifier.ts @@ -1,5 +1,8 @@ import { ArrayElement, Attributes, Meta } from '@swagger-api/apidom-core'; +/** + * @public + */ class StandardIdentifier extends ArrayElement { constructor(content?: string[], meta?: Meta, attributes?: Attributes) { super(content, meta, attributes); diff --git a/packages/apidom-ns-api-design-systems/src/index.ts b/packages/apidom-ns-api-design-systems/src/index.ts index 70e1677266..0557bb2760 100644 --- a/packages/apidom-ns-api-design-systems/src/index.ts +++ b/packages/apidom-ns-api-design-systems/src/index.ts @@ -12,10 +12,13 @@ export { } from '@swagger-api/apidom-core'; export { default as mediaTypes, ApiDesignSystemsMediaTypes } from './media-types.ts'; +export type { Format } from './media-types.ts'; // eslint-disable-next-line no-restricted-exports export { default } from './namespace.ts'; +export type { default as specificationObj } from './refractor/specification.ts'; + export { default as refractPluginOpenApi3_1StandardIdentifierSelectors } from './refractor/plugins/openapi-3-1/standard-identifier-selectors.ts'; export { default as refractPluginOpenApi3_1StandardIdentifierAccessors } from './refractor/plugins/openapi-3-1/standard-identifier-accessors.ts'; export { default as validateOpenAPI3_1 } from './validator/openapi-3-1/validator.ts'; diff --git a/packages/apidom-ns-api-design-systems/src/media-types.ts b/packages/apidom-ns-api-design-systems/src/media-types.ts index b0f3b46e32..93aee63a4c 100644 --- a/packages/apidom-ns-api-design-systems/src/media-types.ts +++ b/packages/apidom-ns-api-design-systems/src/media-types.ts @@ -1,8 +1,14 @@ import { last } from 'ramda'; import { MediaTypes } from '@swagger-api/apidom-core'; -type Format = 'generic' | 'json' | 'yaml'; +/** + * @public + */ +export type Format = 'generic' | 'json' | 'yaml'; +/** + * @public + */ export class ApiDesignSystemsMediaTypes extends MediaTypes { filterByFormat(format: Format = 'generic') { const effectiveFormat = format === 'generic' ? 'apidesignsystems;version' : format; @@ -24,6 +30,9 @@ export class ApiDesignSystemsMediaTypes extends MediaTypes { } } +/** + * @public + */ const mediaTypes = new ApiDesignSystemsMediaTypes( 'application/vnd.aai.apidesignsystems;version=2021-05-07', 'application/vnd.aai.apidesignsystems+json;version=2021-05-07', diff --git a/packages/apidom-ns-api-design-systems/src/namespace.ts b/packages/apidom-ns-api-design-systems/src/namespace.ts index 2bbf6f9544..305254c190 100644 --- a/packages/apidom-ns-api-design-systems/src/namespace.ts +++ b/packages/apidom-ns-api-design-systems/src/namespace.ts @@ -12,6 +12,9 @@ import ScenarioElement from './elements/Scenario.ts'; import StandardElement from './elements/Standard.ts'; import StandardIdentifierElement from './elements/StandardIdentifier.ts'; +/** + * @public + */ const apiDesignSystems = { namespace: (options: NamespacePluginOptions) => { const { base } = options; diff --git a/packages/apidom-ns-api-design-systems/src/predicates.ts b/packages/apidom-ns-api-design-systems/src/predicates.ts index 7ec1d675fc..af9876efdd 100644 --- a/packages/apidom-ns-api-design-systems/src/predicates.ts +++ b/packages/apidom-ns-api-design-systems/src/predicates.ts @@ -9,6 +9,9 @@ import ScenarioElement from './elements/Scenario.ts'; import StandardElement from './elements/Standard.ts'; import StandardIdentifierElement from './elements/StandardIdentifier.ts'; +/** + * @public + */ export const isMainElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is MainElement => @@ -19,6 +22,9 @@ export const isMainElement = createPredicate( }, ); +/** + * @public + */ export const isInfoElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is InfoElement => @@ -29,6 +35,9 @@ export const isInfoElement = createPredicate( }, ); +/** + * @public + */ export const isPrincipleElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is PrincipleElement => @@ -39,6 +48,9 @@ export const isPrincipleElement = createPredicate( }, ); +/** + * @public + */ export const isRequirementElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is RequirementElement => @@ -49,6 +61,9 @@ export const isRequirementElement = createPredicate( }, ); +/** + * @public + */ export const isRequirementLevelElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is RequirementLevelElement => @@ -59,6 +74,9 @@ export const isRequirementLevelElement = createPredicate( }, ); +/** + * @public + */ export const isScenarioElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is ScenarioElement => @@ -69,6 +87,9 @@ export const isScenarioElement = createPredicate( }, ); +/** + * @public + */ export const isStandardElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is StandardElement => @@ -79,6 +100,9 @@ export const isStandardElement = createPredicate( }, ); +/** + * @public + */ export const isStandardIdentifierElement = createPredicate( ({ hasBasicElementProps, isElementType, primitiveEq }) => { return (element: unknown): element is StandardIdentifierElement => diff --git a/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-accessors.ts b/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-accessors.ts index dca0884402..7c677ab587 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-accessors.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-accessors.ts @@ -10,6 +10,9 @@ import { isObjectElement, } from '@swagger-api/apidom-ns-openapi-3-1'; +/** + * @public + */ const plugin = () => () => { return { visitor: { diff --git a/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-selectors.ts b/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-selectors.ts index cb2191e02c..6a82d0fd8d 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-selectors.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/plugins/openapi-3-1/standard-identifier-selectors.ts @@ -9,6 +9,9 @@ import { isObjectElement, } from '@swagger-api/apidom-ns-openapi-3-1'; +/** + * @public + */ const plugin = () => () => { let operationIdentifiers: string[][] = []; let responseIdentifiers: string[][] = []; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/specification.ts b/packages/apidom-ns-api-design-systems/src/refractor/specification.ts index 4547e0f9f3..7e66928873 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/specification.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/specification.ts @@ -22,6 +22,7 @@ import MainScenariosVisitor from './visitors/api-design-systems/main/ScenariosVi * existing ones by manipulating it. * * Note: Specification object allows to use absolute internal JSON pointers. + * @public */ const specification = { visitors: { diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/FallbackVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/FallbackVisitor.ts index 4a21eecb70..e134b91e0c 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/FallbackVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/FallbackVisitor.ts @@ -11,6 +11,9 @@ import Visitor, { VisitorOptions } from './Visitor.ts'; export type { VisitorOptions as FallbackVisitorOptions }; +/** + * @public + */ class FallbackVisitor extends Visitor { enter(element: Element) { this.element = cloneDeep(element); diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/SpecificationVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/SpecificationVisitor.ts index e355598cef..1a699c19af 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/SpecificationVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/SpecificationVisitor.ts @@ -9,11 +9,15 @@ import type specification from '../specification.ts'; /** * This is a base class for every visitor that does * internal look-ups to retrieve other child visitors. + * @public */ export interface SpecificationVisitorOptions extends VisitorOptions { readonly specObj: typeof specification; } +/** + * @public + */ class SpecificationVisitor extends Visitor { protected readonly specObj: typeof specification; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/Visitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/Visitor.ts index 973c504198..a9b5296e53 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/Visitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/Visitor.ts @@ -1,7 +1,13 @@ import { Element, ObjectElement, hasElementSourceMap, deepmerge } from '@swagger-api/apidom-core'; +/** + * @public + */ export interface VisitorOptions {} +/** + * @public + */ class Visitor { public element!: Element; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/info/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/info/index.ts index 9cdb05721b..dfc246c513 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/info/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/info/index.ts @@ -7,8 +7,14 @@ import FixedFieldsVisitor, { FixedFieldsVisitorOptions, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface InfoVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class InfoVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: InfoElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/PrinciplesVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/PrinciplesVisitor.ts index b6c1d8de7b..bfd765b38b 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/PrinciplesVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/PrinciplesVisitor.ts @@ -4,10 +4,16 @@ import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.ts'; import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; +/** + * @public + */ export interface PrinciplesVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class PrinciplesVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare readonly element: ArrayElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/ScenariosVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/ScenariosVisitor.ts index eb96ec638a..6f456e51c1 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/ScenariosVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/ScenariosVisitor.ts @@ -4,10 +4,16 @@ import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.ts'; import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; +/** + * @public + */ export interface ScenariosVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class ScenariosVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare readonly element: ArrayElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/StandardsVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/StandardsVisitor.ts index 03e999e1fa..591b6b2a02 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/StandardsVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/StandardsVisitor.ts @@ -4,10 +4,16 @@ import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.ts'; import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; +/** + * @public + */ export interface StandardsVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class StandardsVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare readonly element: ArrayElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/index.ts index ca02505c09..5420c83bfe 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/main/index.ts @@ -8,8 +8,14 @@ import FixedFieldsVisitor, { SpecPath, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface MainVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class MainVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: MainElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/principle/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/principle/index.ts index 01f2f31082..1a8de758f7 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/principle/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/principle/index.ts @@ -8,10 +8,16 @@ import FixedFieldsVisitor, { SpecPath, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface PrincipleVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class PrincipleVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: PrincipleElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement-level/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement-level/index.ts index e72dbdde54..3465f34806 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement-level/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement-level/index.ts @@ -5,10 +5,16 @@ import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.t import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; import RequirementLevelElement from '../../../../elements/RequirementLevel.ts'; +/** + * @public + */ export interface RequirementLevelVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class RequirementLevelVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare element: RequirementLevelElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement/index.ts index e8742becbf..9dfccce235 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/requirement/index.ts @@ -8,10 +8,16 @@ import FixedFieldsVisitor, { SpecPath, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface RequirementVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class RequirementVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: RequirementElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/ThenVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/ThenVisitor.ts index eda0bacf3b..b8e81b9fc7 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/ThenVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/ThenVisitor.ts @@ -4,8 +4,14 @@ import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.ts'; import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; +/** + * @public + */ export interface ThenVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class ThenVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare readonly element: ArrayElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/index.ts index 4581556204..e82d58baea 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/scenario/index.ts @@ -8,8 +8,14 @@ import FixedFieldsVisitor, { SpecPath, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface ScenarioVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class ScenarioVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: ScenarioElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard-identifier/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard-identifier/index.ts index c1c8aa698a..11efb39df7 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard-identifier/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard-identifier/index.ts @@ -5,10 +5,16 @@ import FallbackVisitor, { FallbackVisitorOptions } from '../../FallbackVisitor.t import SpecificationVisitor, { SpecificationVisitorOptions } from '../../SpecificationVisitor.ts'; import StandardIdentifierElement from '../../../../elements/StandardIdentifier.ts'; +/** + * @public + */ export interface StandardIdentifierVisitorOptions extends SpecificationVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class StandardIdentifierVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) { public declare readonly element: StandardIdentifierElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard/index.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard/index.ts index 4bdb4f5f9c..ba2b83ea5b 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard/index.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/api-design-systems/standard/index.ts @@ -8,8 +8,14 @@ import FixedFieldsVisitor, { SpecPath, } from '../../generics/FixedFieldsVisitor.ts'; +/** + * @public + */ export interface StandardVisitorOptions extends FixedFieldsVisitorOptions, FallbackVisitorOptions {} +/** + * @public + */ class StandardVisitor extends Mixin(FixedFieldsVisitor, FallbackVisitor) { public declare readonly element: StandardElement; diff --git a/packages/apidom-ns-api-design-systems/src/refractor/visitors/generics/FixedFieldsVisitor.ts b/packages/apidom-ns-api-design-systems/src/refractor/visitors/generics/FixedFieldsVisitor.ts index 9e11598284..a00deac941 100644 --- a/packages/apidom-ns-api-design-systems/src/refractor/visitors/generics/FixedFieldsVisitor.ts +++ b/packages/apidom-ns-api-design-systems/src/refractor/visitors/generics/FixedFieldsVisitor.ts @@ -10,13 +10,22 @@ import { import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts'; +/** + * @public + */ export type SpecPath = (element: unknown) => T; +/** + * @public + */ export interface FixedFieldsVisitorOptions extends SpecificationVisitorOptions { readonly specPath: SpecPath; readonly ignoredFields?: string[]; } +/** + * @public + */ class FixedFieldsVisitor extends SpecificationVisitor { protected specPath: SpecPath; diff --git a/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts b/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts index 8ff7cd816f..57a344c658 100644 --- a/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts +++ b/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts @@ -1,6 +1,8 @@ import { isElement, keyMap as keyMapBase, Element } from '@swagger-api/apidom-core'; -// getNodeType :: Node -> String +/** + * @public + */ export const getNodeType = (element: T): string | undefined => { if (!isElement(element)) { return undefined; @@ -8,6 +10,9 @@ export const getNodeType = (element: T): string | undefined = return `${element.element.charAt(0).toUpperCase() + element.element.slice(1)}Element`; }; +/** + * @public + */ export const keyMap = { /** * API Design Systems 2021-05-07 specification elements. diff --git a/packages/apidom-ns-api-design-systems/src/validator/openapi-3-1/validator.ts b/packages/apidom-ns-api-design-systems/src/validator/openapi-3-1/validator.ts index 6c00a905c4..5529f46947 100644 --- a/packages/apidom-ns-api-design-systems/src/validator/openapi-3-1/validator.ts +++ b/packages/apidom-ns-api-design-systems/src/validator/openapi-3-1/validator.ts @@ -97,6 +97,9 @@ const validateScenario = (scenario: ScenarioElement, openApiElement: OpenApi3_1E return annotations; }; +/** + * @public + */ const validate = (mainElement: MainElement, openApiElement: OpenApi3_1Element) => { const { scenarios } = mainElement; const annotations: AnnotationElement[] = [];