Skip to content

Commit

Permalink
chore(reference): add missing exports for TypeScript rollup (#4557)
Browse files Browse the repository at this point in the history
Refs #4382
  • Loading branch information
glowcloud authored Nov 25, 2024
1 parent 041848a commit 95707f0
Show file tree
Hide file tree
Showing 40 changed files with 583 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,36 @@ import { mediaTypes, isOpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-
import File from '../../../File.ts';
import BundleStrategy, { BundleStrategyOptions } from '../BundleStrategy.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../../../dereference/strategies/DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type { default as BundleStrategy, BundleStrategyOptions } from '../BundleStrategy.ts';

/**
* @public
*/
export interface OpenAPI3_1BundleStrategyOptions extends Omit<BundleStrategyOptions, 'name'> {}

/**
* @public
*/
class OpenAPI3_1BundleStrategy extends BundleStrategy {
constructor(options?: OpenAPI3_1BundleStrategyOptions) {
super({ ...(options ?? {}), name: 'openapi-3-1' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,44 @@ import ReferenceSet from '../../../ReferenceSet.ts';
import ApiDOMDereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type { ApiDOMDereferenceVisitorOptions } from './visitor.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type {
default as BundleStrategy,
BundleStrategyOptions,
} from '../../../bundle/strategies/BundleStrategy.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];

/**
* @public
*/
export interface ApiDOMDereferenceStrategyOptions
extends Omit<DereferenceStrategyOptions, 'name'> {}

/**
* @public
*/
class ApiDOMDereferenceStrategy extends DereferenceStrategy {
constructor(options?: ApiDOMDereferenceStrategyOptions) {
super({ ...(options ?? {}), name: 'apidom' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const hasElementID = (element: Element): boolean => !!element.id;

/**
* Evaluates element ID against ApiDOM fragment.
* @public
*/
export const evaluate = <T extends Element>(elementID: string, element: T): Element | undefined => {
const { cache } = evaluate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
* 6. When path is used in an element that includes the data of the pointer (such as with ref), the referenced path MAY need to be converted to a refract structure in order to be valid
*
* WARNING: this implementation only supports referencing elements in the local document. Points 2-4 are not supported.
* @public
*/

export interface ApiDOMDereferenceVisitorOptions {
readonly reference: Reference;
readonly options: ReferenceOptions;
}

/**
* @public
*/
class ApiDOMDereferenceVisitor {
protected readonly reference: Reference;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,45 @@ import ReferenceSet from '../../../ReferenceSet.ts';
import AsyncAPI2DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type { AsyncAPI2DereferenceVisitorOptions, mutationReplacer } from './visitor.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type {
default as BundleStrategy,
BundleStrategyOptions,
} from '../../../bundle/strategies/BundleStrategy.ts';
export type { AncestorLineage } from '../../util.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];

/**
* @public
*/
export interface AsyncAPI2DeferenceStrategyOptions
extends Omit<DereferenceStrategyOptions, 'name'> {}

/**
* @public
*/
class AsyncAPI2DereferenceStrategy extends DereferenceStrategy {
constructor(options?: AsyncAPI2DeferenceStrategyOptions) {
super({ ...(options ?? {}), name: 'asyncapi-2' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
// initialize element identity manager
const identityManager = new IdentityManager();

// custom mutation replacer
const mutationReplacer = (
/**
* Custom mutation replacer.
* @public
*/
export const mutationReplacer = (
newElement: Element,
oldElement: Element,
key: string | number,
Expand All @@ -56,6 +59,9 @@ const mutationReplacer = (
}
};

/**
* @public
*/
export interface AsyncAPI2DereferenceVisitorOptions {
readonly namespace: Namespace;
readonly reference: Reference;
Expand All @@ -65,6 +71,9 @@ export interface AsyncAPI2DereferenceVisitorOptions {
readonly refractCache?: Map<string, Element>;
}

/**
* @public
*/
class AsyncAPI2DereferenceVisitor {
protected readonly indirections: Element[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,46 @@ import ReferenceSet from '../../../ReferenceSet.ts';
import OpenAPI2DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type { OpenAPI2DereferenceVisitorOptions, mutationReplacer } from './visitor.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type {
default as BundleStrategy,
BundleStrategyOptions,
} from '../../../bundle/strategies/BundleStrategy.ts';
export type { AncestorLineage } from '../../util.ts';
export type { AsyncAPI2DereferenceVisitorOptions } from '../asyncapi-2/visitor.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];

/**
* @public
*/
export interface OpenAPI2DereferenceStrategyOptions
extends Omit<DereferenceStrategyOptions, 'name'> {}

/**
* @public
*/
class OpenAPI2DereferenceStrategy extends DereferenceStrategy {
constructor(options?: OpenAPI2DereferenceStrategyOptions) {
super({ ...(options ?? {}), name: 'openapi-2' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
// initialize element identity manager
const identityManager = new IdentityManager();

// custom mutation replacer
const mutationReplacer = (
/**
* Custom mutation replacer.
* @public
*/
export const mutationReplacer = (
newElement: Element,
oldElement: Element,
key: string | number,
Expand All @@ -58,6 +61,9 @@ const mutationReplacer = (
}
};

/**
* @public
*/
export interface OpenAPI2DereferenceVisitorOptions {
readonly namespace: Namespace;
readonly reference: Reference;
Expand All @@ -67,6 +73,9 @@ export interface OpenAPI2DereferenceVisitorOptions {
readonly refractCache?: Map<string, Element>;
}

/**
* @public
*/
class OpenAPI2DereferenceVisitor {
protected readonly indirections: Element[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,45 @@ import ReferenceSet from '../../../ReferenceSet.ts';
import OpenAPI3_0DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type { OpenAPI3_0DereferenceVisitorOptions, mutationReplacer } from './visitor.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type {
default as BundleStrategy,
BundleStrategyOptions,
} from '../../../bundle/strategies/BundleStrategy.ts';
export type { AncestorLineage } from '../../util.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];

/**
* @public
*/
export interface OpenAPI3_0DereferenceStrategyOptions
extends Omit<DereferenceStrategyOptions, 'name'> {}

/**
* @public
*/
class OpenAPI3_0DereferenceStrategy extends DereferenceStrategy {
constructor(options?: OpenAPI3_0DereferenceStrategyOptions) {
super({ ...(options ?? {}), name: 'openapi-3-0' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
// initialize element identity manager
const identityManager = new IdentityManager();

// custom mutation replacer
const mutationReplacer = (
/**
* Custom mutation replacer.
* @public
*/
export const mutationReplacer = (
newElement: Element,
oldElement: Element,
key: string | number,
Expand All @@ -60,6 +63,9 @@ const mutationReplacer = (
}
};

/**
* @public
*/
export interface OpenAPI3_0DereferenceVisitorOptions {
readonly namespace: Namespace;
readonly reference: Reference;
Expand All @@ -69,6 +75,9 @@ export interface OpenAPI3_0DereferenceVisitorOptions {
readonly refractCache?: Map<string, Element>;
}

/**
* @public
*/
class OpenAPI3_0DereferenceVisitor {
protected readonly indirections: Element[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,45 @@ import ReferenceSet from '../../../ReferenceSet.ts';
import OpenAPI3_1DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

export type {
default as DereferenceStrategy,
DereferenceStrategyOptions,
} from '../DereferenceStrategy.ts';
export type { default as File, FileOptions } from '../../../File.ts';
export type { default as Reference, ReferenceOptions } from '../../../Reference.ts';
export type { default as ReferenceSet, ReferenceSetOptions } from '../../../ReferenceSet.ts';
export type { OpenAPI3_1DereferenceVisitorOptions, mutationReplacer } from './visitor.ts';
export type {
ReferenceOptions as ApiDOMReferenceOptions,
ReferenceBundleOptions as ApiDOMReferenceBundleOptions,
ReferenceDereferenceOptions as ApiDOMReferenceDereferenceOptions,
ReferenceParseOptions as ApiDOMReferenceParseOptions,
ReferenceResolveOptions as ApiDOMReferenceResolveOptions,
} from '../../../options/index.ts';
export type { default as Parser, ParserOptions } from '../../../parse/parsers/Parser.ts';
export type { default as Resolver, ResolverOptions } from '../../../resolve/resolvers/Resolver.ts';
export type {
default as ResolveStrategy,
ResolveStrategyOptions,
} from '../../../resolve/strategies/ResolveStrategy.ts';
export type {
default as BundleStrategy,
BundleStrategyOptions,
} from '../../../bundle/strategies/BundleStrategy.ts';
export type { AncestorLineage } from '../../util.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];

/**
* @public
*/
export interface OpenAPI3_1DereferenceStrategyOptions
extends Omit<DereferenceStrategyOptions, 'name'> {}

/**
* @public
*/
class OpenAPI3_1DereferenceStrategy extends DereferenceStrategy {
constructor(options?: OpenAPI3_1DereferenceStrategyOptions) {
super({ ...(options ?? {}), name: 'openapi-3-1' });
Expand Down
Loading

0 comments on commit 95707f0

Please sign in to comment.