Skip to content

Commit

Permalink
build(reference): use nodenext for TypeScript modules
Browse files Browse the repository at this point in the history
Refs #4385
  • Loading branch information
glowcloud committed Nov 13, 2024
1 parent 09fe866 commit 015d2b5
Show file tree
Hide file tree
Showing 187 changed files with 649 additions and 614 deletions.
22 changes: 22 additions & 0 deletions packages/apidom-reference/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"settings": {
"import/resolver": {
"typescript": {
"project": ["./tsconfig.json"]
}
}
},
"rules": {
"import/extensions": [
"error",
"always",
{
"ts": "always",
"tsx": "always",
"js": "always",
"jsx": "never",
"ignorePackages": true
}
]
}
}
4 changes: 2 additions & 2 deletions packages/apidom-reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@
"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",
"perf": "cross-env BABEL_ENV=es babel ./test/perf/index.ts --out-file ./test/perf/index.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/index.mjs",
"perf:openapi-3-1-dereference": "cross-env BABEL_ENV=es babel ./test/perf/openapi-3-1-dereference.ts --out-file ./test/perf/openapi-3-1-dereference.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/openapi-3-1-dereference.mjs",
"typescript:check-types": "tsc --noEmit",
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"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",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
"postpack": "rimraf NOTICE LICENSES"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-reference/src/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type } from 'ramda';
import { isString } from 'ramda-adjunct';
import { ParseResultElement } from '@swagger-api/apidom-core';

import * as url from './util/url';
import * as url from './util/url.ts';

/**
* This class represents a File object with url and data.
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-reference/src/Reference.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Element } from '@swagger-api/apidom-core';

import ReferenceSet from './ReferenceSet';
import ReferenceSet from './ReferenceSet.ts';

export interface ReferenceOptions<T = Element> {
readonly uri: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-reference/src/ReferenceSet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isNotUndefined, isString } from 'ramda-adjunct';

import type Reference from './Reference';
import type Reference from './Reference.ts';

export interface ReferenceSetOptions {
readonly refs?: Reference[];
Expand Down
16 changes: 8 additions & 8 deletions packages/apidom-reference/src/bundle/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { isEmpty, propEq } from 'ramda';
import { ParseResultElement } from '@swagger-api/apidom-core';

import File from '../File';
import * as plugins from '../util/plugins';
import UnmatchedBundleStrategyError from '../errors/UnmatchedBundleStrategyError';
import BundleError from '../errors/BundleError';
import parse from '../parse';
import { merge as mergeOptions } from '../options/util';
import * as url from '../util/url';
import type { ReferenceOptions } from '../options';
import File from '../File.ts';
import * as plugins from '../util/plugins.ts';
import UnmatchedBundleStrategyError from '../errors/UnmatchedBundleStrategyError.ts';
import BundleError from '../errors/BundleError.ts';
import parse from '../parse/index.ts';
import { merge as mergeOptions } from '../options/util.ts';
import * as url from '../util/url.ts';
import type { ReferenceOptions } from '../options/index.ts';

/**
* Bundle a file with all its external references to a compound document.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ParseResultElement } from '@swagger-api/apidom-core';

import File from '../../File';
import type { ReferenceOptions } from '../../options';
import File from '../../File.ts';
import type { ReferenceOptions } from '../../options/index.ts';

export interface BundleStrategyOptions {
readonly name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ParseResultElement } from '@swagger-api/apidom-core';
import { mediaTypes, isOpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-3-1';

import File from '../../../File';
import BundleStrategy, { BundleStrategyOptions } from '../BundleStrategy';
import File from '../../../File.ts';
import BundleStrategy, { BundleStrategyOptions } from '../BundleStrategy.ts';

export interface OpenAPI3_1BundleStrategyOptions extends Omit<BundleStrategyOptions, 'name'> {}

Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-reference/src/configuration/empty.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '../index';
export * from '../index.ts';
62 changes: 31 additions & 31 deletions packages/apidom-reference/src/configuration/saturated.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import FileResolver from '../resolve/resolvers/file/index-node';
import HTTPResolverAxios from '../resolve/resolvers/http-axios';
import OpenAPI2ResolveStrategy from '../resolve/strategies/openapi-2';
import OpenAPI3_0ResolveStrategy from '../resolve/strategies/openapi-3-0';
import OpenAPI3_1ResolveStrategy from '../resolve/strategies/openapi-3-1';
import AsyncAPI2ResolveStrategy from '../resolve/strategies/asyncapi-2';
import ApiDOMResolveStrategy from '../resolve/strategies/apidom';
import APIDesignSystemsJSONParser from '../parse/parsers/api-design-systems-json';
import APIDesignSystemsYAMLParser from '../parse/parsers/api-design-systems-yaml';
import OpenAPIJSON2Parser from '../parse/parsers/openapi-json-2';
import OpenAPIYAML2Parser from '../parse/parsers/openapi-yaml-2';
import OpenAPIJSON3_0Parser from '../parse/parsers/openapi-json-3-0';
import OpenAPIYAML3_0Parser from '../parse/parsers/openapi-yaml-3-0';
import OpenAPIJSON3_1Parser from '../parse/parsers/openapi-json-3-1';
import OpenAPIYAML3_1Parser from '../parse/parsers/openapi-yaml-3-1';
import AsyncAPIJSON2Parser from '../parse/parsers/asyncapi-json-2';
import AsyncAPIYAML2Parser from '../parse/parsers/asyncapi-yaml-2';
import WorkflowsJSON1Parser from '../parse/parsers/workflows-json-1';
import WorkflowsYAML1Parser from '../parse/parsers/workflows-yaml-1';
import APIDOMJSONParser from '../parse/parsers/apidom-json';
import JSONParser from '../parse/parsers/json';
import YAMLParser from '../parse/parsers/yaml-1-2';
import BinaryParser from '../parse/parsers/binary/index-node';
import ApiDOMDereferenceStrategy from '../dereference/strategies/apidom';
import OpenAPI2DereferenceStrategy from '../dereference/strategies/openapi-2';
import OpenAPI3_0DereferenceStrategy from '../dereference/strategies/openapi-3-0';
import OpenAPI3_1DereferenceStrategy from '../dereference/strategies/openapi-3-1';
import AsyncAPI2DereferenceStrategy from '../dereference/strategies/asyncapi-2';
import OpenAPI3_1BundleStrategy from '../bundle/strategies/openapi-3-1';
import { options } from '../index';
import FileResolver from '../resolve/resolvers/file/index-node.ts';
import HTTPResolverAxios from '../resolve/resolvers/http-axios/index.ts';
import OpenAPI2ResolveStrategy from '../resolve/strategies/openapi-2/index.ts';
import OpenAPI3_0ResolveStrategy from '../resolve/strategies/openapi-3-0/index.ts';
import OpenAPI3_1ResolveStrategy from '../resolve/strategies/openapi-3-1/index.ts';
import AsyncAPI2ResolveStrategy from '../resolve/strategies/asyncapi-2/index.ts';
import ApiDOMResolveStrategy from '../resolve/strategies/apidom/index.ts';
import APIDesignSystemsJSONParser from '../parse/parsers/api-design-systems-json/index.ts';
import APIDesignSystemsYAMLParser from '../parse/parsers/api-design-systems-yaml/index.ts';
import OpenAPIJSON2Parser from '../parse/parsers/openapi-json-2/index.ts';
import OpenAPIYAML2Parser from '../parse/parsers/openapi-yaml-2/index.ts';
import OpenAPIJSON3_0Parser from '../parse/parsers/openapi-json-3-0/index.ts';
import OpenAPIYAML3_0Parser from '../parse/parsers/openapi-yaml-3-0/index.ts';
import OpenAPIJSON3_1Parser from '../parse/parsers/openapi-json-3-1/index.ts';
import OpenAPIYAML3_1Parser from '../parse/parsers/openapi-yaml-3-1/index.ts';
import AsyncAPIJSON2Parser from '../parse/parsers/asyncapi-json-2/index.ts';
import AsyncAPIYAML2Parser from '../parse/parsers/asyncapi-yaml-2/index.ts';
import WorkflowsJSON1Parser from '../parse/parsers/workflows-json-1/index.ts';
import WorkflowsYAML1Parser from '../parse/parsers/workflows-yaml-1/index.ts';
import APIDOMJSONParser from '../parse/parsers/apidom-json/index.ts';
import JSONParser from '../parse/parsers/json/index.ts';
import YAMLParser from '../parse/parsers/yaml-1-2/index.ts';
import BinaryParser from '../parse/parsers/binary/index-node.ts';
import ApiDOMDereferenceStrategy from '../dereference/strategies/apidom/index.ts';
import OpenAPI2DereferenceStrategy from '../dereference/strategies/openapi-2/index.ts';
import OpenAPI3_0DereferenceStrategy from '../dereference/strategies/openapi-3-0/index.ts';
import OpenAPI3_1DereferenceStrategy from '../dereference/strategies/openapi-3-1/index.ts';
import AsyncAPI2DereferenceStrategy from '../dereference/strategies/asyncapi-2/index.ts';
import OpenAPI3_1BundleStrategy from '../bundle/strategies/openapi-3-1/index.ts';
import { options } from '../index.ts';

options.parse.parsers = [
new OpenAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
Expand Down Expand Up @@ -71,4 +71,4 @@ options.dereference.strategies = [

options.bundle.strategies = [new OpenAPI3_1BundleStrategy()];

export * from '../index';
export * from '../index.ts';
16 changes: 8 additions & 8 deletions packages/apidom-reference/src/dereference/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
cloneShallow,
} from '@swagger-api/apidom-core';

import File from '../File';
import * as plugins from '../util/plugins';
import UnmatchedDereferenceStrategyError from '../errors/UnmatchedDereferenceStrategyError';
import DereferenceError from '../errors/DereferenceError';
import parse from '../parse';
import { merge as mergeOptions } from '../options/util';
import * as url from '../util/url';
import type { ReferenceOptions } from '../options';
import File from '../File.ts';
import * as plugins from '../util/plugins.ts';
import UnmatchedDereferenceStrategyError from '../errors/UnmatchedDereferenceStrategyError.ts';
import DereferenceError from '../errors/DereferenceError.ts';
import parse from '../parse/index.ts';
import { merge as mergeOptions } from '../options/util.ts';
import * as url from '../util/url.ts';
import type { ReferenceOptions } from '../options/index.ts';

/**
* Dereferences ApiDOM with all its external references.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Element } from 'minim';

import File from '../../File';
import type { ReferenceOptions } from '../../options';
import File from '../../File.ts';
import type { ReferenceOptions } from '../../options/index.ts';

export interface DereferenceStrategyOptions {
readonly name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Element, isElement, cloneDeep, visit } from '@swagger-api/apidom-core';

import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy';
import File from '../../../File';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import ApiDOMDereferenceVisitor from './visitor';
import type { ReferenceOptions } from '../../../options';
import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy.ts';
import File from '../../../File.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import ApiDOMDereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isUndefined } from 'ramda-adjunct';
import { Element, filter, toValue } from '@swagger-api/apidom-core';

import EvaluationElementIdError from '../../../../errors/EvaluationElementIdError';
import EvaluationElementIdError from '../../../../errors/EvaluationElementIdError.ts';

const hasElementID = (element: Element): boolean => !!element.id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
} from '@swagger-api/apidom-core';
import { uriToPointer as uriToElementID } from '@swagger-api/apidom-json-pointer';

import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError';
import * as url from '../../../util/url';
import parse from '../../../parse';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import { evaluate } from './selectors/element-id';
import type { ReferenceOptions } from '../../../options';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError.ts';
import * as url from '../../../util/url.ts';
import parse from '../../../parse/index.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import { evaluate } from './selectors/element-id.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import asyncApi2Namespace, {
mediaTypes,
} from '@swagger-api/apidom-ns-asyncapi-2';

import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy';
import File from '../../../File';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import AsyncAPI2DereferenceVisitor from './visitor';
import type { ReferenceOptions } from '../../../options';
import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy.ts';
import File from '../../../File.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import AsyncAPI2DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import {
ReferenceElement,
} from '@swagger-api/apidom-ns-asyncapi-2';

import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError';
import { AncestorLineage } from '../../util';
import * as url from '../../../util/url';
import parse from '../../../parse';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import type { ReferenceOptions } from '../../../options';
import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError.ts';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError.ts';
import { AncestorLineage } from '../../util.ts';
import * as url from '../../../util/url.ts';
import parse from '../../../parse/index.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import openApi2Namespace, {
mediaTypes,
} from '@swagger-api/apidom-ns-openapi-2';

import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy';
import File from '../../../File';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import OpenAPI2DereferenceVisitor from './visitor';
import type { ReferenceOptions } from '../../../options';
import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy.ts';
import File from '../../../File.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import OpenAPI2DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import {
JSONReferenceElement,
} from '@swagger-api/apidom-ns-openapi-2';

import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError';
import { AncestorLineage } from '../../util';
import * as url from '../../../util/url';
import parse from '../../../parse';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import type { ReferenceOptions } from '../../../options';
import { AsyncAPI2DereferenceVisitorOptions } from '../asyncapi-2/visitor';
import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError.ts';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError.ts';
import { AncestorLineage } from '../../util.ts';
import * as url from '../../../util/url.ts';
import parse from '../../../parse/index.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import type { ReferenceOptions } from '../../../options/index.ts';
import { AsyncAPI2DereferenceVisitorOptions } from '../asyncapi-2/visitor.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import openApi3_0Namespace, {
mediaTypes,
} from '@swagger-api/apidom-ns-openapi-3-0';

import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy';
import File from '../../../File';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import OpenAPI3_0DereferenceVisitor from './visitor';
import type { ReferenceOptions } from '../../../options';
import DereferenceStrategy, { DereferenceStrategyOptions } from '../DereferenceStrategy.ts';
import File from '../../../File.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import OpenAPI3_0DereferenceVisitor from './visitor.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

// @ts-ignore
const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import {
isReferenceLikeElement,
} from '@swagger-api/apidom-ns-openapi-3-0';

import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError';
import * as url from '../../../util/url';
import parse from '../../../parse';
import Reference from '../../../Reference';
import ReferenceSet from '../../../ReferenceSet';
import { AncestorLineage } from '../../util';
import type { ReferenceOptions } from '../../../options';
import MaximumDereferenceDepthError from '../../../errors/MaximumDereferenceDepthError.ts';
import MaximumResolveDepthError from '../../../errors/MaximumResolveDepthError.ts';
import * as url from '../../../util/url.ts';
import parse from '../../../parse/index.ts';
import Reference from '../../../Reference.ts';
import ReferenceSet from '../../../ReferenceSet.ts';
import { AncestorLineage } from '../../util.ts';
import type { ReferenceOptions } from '../../../options/index.ts';

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

0 comments on commit 015d2b5

Please sign in to comment.