Skip to content

Commit

Permalink
chore(ast): use API Extractor for TypeScript rollup
Browse files Browse the repository at this point in the history
Refs #4382
  • Loading branch information
glowcloud committed Nov 18, 2024
1 parent 8541f0a commit 2d5114c
Show file tree
Hide file tree
Showing 48 changed files with 345 additions and 38 deletions.
4 changes: 4 additions & 0 deletions packages/apidom-ast/config/api-extractor/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../../api-extractor.json"
}
12 changes: 0 additions & 12 deletions packages/apidom-ast/config/rollup/types.dist.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/apidom-ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"unpkg": "./dist/apidom.ast.min.js",
"main": "./src/index.cjs",
"exports": {
"types": "./types/dist.d.ts",
"types": "./types/apidom-ast.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
"types": "./types/dist.d.ts",
"types": "./types/apidom-ast.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'",
Expand All @@ -26,7 +26,7 @@
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
"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",
"typescript:check-types": "tsc --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",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
"postpack": "rimraf NOTICE LICENSES"
},
Expand All @@ -52,7 +52,7 @@
"src/**/*.mjs",
"src/**/*.cjs",
"dist/",
"types/dist.d.ts",
"types/apidom-ast.d.ts",
"LICENSES",
"NOTICE",
"README.md",
Expand Down
6 changes: 6 additions & 0 deletions packages/apidom-ast/src/Error.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import Node from './Node.ts';
import type { NodeOptions } from './Node.ts';

/**
* @public
*/
export interface ErrorOptions extends NodeOptions {
readonly value?: unknown;
readonly isUnexpected?: boolean;
}

/**
* @public
*/
class Error extends Node {
public static readonly type: string = 'error';

Expand Down
6 changes: 6 additions & 0 deletions packages/apidom-ast/src/Literal.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import Node from './Node.ts';
import type { NodeOptions } from './Node.ts';

/**
* @public
*/
export interface LiteralOptions extends NodeOptions {
readonly value?: unknown;
}

/**
* @public
*/
class Literal extends Node {
public static readonly type: string = 'literal';

Expand Down
6 changes: 6 additions & 0 deletions packages/apidom-ast/src/Node.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import Position from './Position.ts';

/**
* @public
*/
export interface NodeOptions {
readonly children?: unknown[];
readonly position?: Position;
readonly isMissing?: boolean;
}

/**
* @public
*/
class Node {
public static readonly type: string = 'node';

Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/ParseResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { head } from 'ramda';

import Node from './Node.ts';

/**
* @public
*/
class ParseResult extends Node {
public static readonly type: string = 'parseResult';

Expand Down
16 changes: 14 additions & 2 deletions packages/apidom-ast/src/Position.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/* eslint-disable max-classes-per-file */

interface PointOptions {
/**
* @public
*/
export interface PointOptions {
readonly row: number;
readonly column: number;
readonly char: number;
}

/**
* @public
*/
export class Point {
public static readonly type: string = 'point';

Expand All @@ -24,11 +30,17 @@ export class Point {
}
}

interface PositionOptions {
/**
* @public
*/
export interface PositionOptions {
readonly start: Point;
readonly end: Point;
}

/**
* @public
*/
class Position {
public static readonly type: string = 'position';

Expand Down
14 changes: 14 additions & 0 deletions packages/apidom-ast/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ export { default as JsonNode } from './json/nodes/JsonNode.ts';
export { default as JsonDocument } from './json/nodes/JsonDocument.ts';
export { default as JsonObject } from './json/nodes/JsonObject.ts';
export { default as JsonProperty } from './json/nodes/JsonProperty.ts';
export type { JsonValue as JsonValueType } from './json/nodes/JsonProperty.ts';
export { default as JsonArray } from './json/nodes/JsonArray.ts';
export { default as JsonValue } from './json/nodes/JsonValue.ts';
export type { JsonValueOptions } from './json/nodes/JsonValue.ts';
export { default as JsonKey } from './json/nodes/JsonKey.ts';
export { default as JsonString } from './json/nodes/JsonString.ts';
export { default as JsonStringContent } from './json/nodes/JsonStringContent.ts';
Expand All @@ -29,18 +31,26 @@ export {
} from './json/nodes/predicates.ts';
// YAML AST related exports
export { default as YamlAlias } from './yaml/nodes/YamlAlias.ts';
export type { YamlAliasOptions } from './yaml/nodes/YamlAlias.ts';
export { default as YamlCollection } from './yaml/nodes/YamlCollection.ts';
export { default as YamlComment } from './yaml/nodes/YamlComment.ts';
export type { YamlCommentOptions } from './yaml/nodes/YamlComment.ts';
export { default as YamlDirective } from './yaml/nodes/YamlDirective.ts';
export type { YamlDirectiveOptions, YamlDirectiveParameters } from './yaml/nodes/YamlDirective.ts';
export { default as YamlDocument } from './yaml/nodes/YamlDocument.ts';
export { default as YamlKeyValuePair } from './yaml/nodes/YamlKeyValuePair.ts';
export type { YamlKeyValuePairOptions } from './yaml/nodes/YamlKeyValuePair.ts';
export { default as YamlMapping } from './yaml/nodes/YamlMapping.ts';
export { default as YamlNode } from './yaml/nodes/YamlNode.ts';
export type { YamlNodeOptions } from './yaml/nodes/YamlNode.ts';
export { default as YamlScalar } from './yaml/nodes/YamlScalar.ts';
export type { YamlScalarOptions } from './yaml/nodes/YamlScalar.ts';
export { default as YamlSequence } from './yaml/nodes/YamlSequence.ts';
export { default as YamlStream } from './yaml/nodes/YamlStream.ts';
export { default as YamlTag, YamlNodeKind } from './yaml/nodes/YamlTag.ts';
export type { YamlTagOptions } from './yaml/nodes/YamlTag.ts';
export { default as YamlAnchor } from './yaml/nodes/YamlAnchor.ts';
export type { YamlAnchorOptions } from './yaml/nodes/YamlAnchor.ts';
export { YamlStyle, YamlStyleGroup } from './yaml/nodes/YamlStyle.ts';
export { default as YamlFailsafeSchema } from './yaml/schemas/failsafe/index.ts';
export { default as YamlJsonSchema } from './yaml/schemas/json/index.ts';
Expand All @@ -64,9 +74,13 @@ export { default as YamlSchemaError } from './yaml/errors/YamlSchemaError.ts';
export { default as YamlTagError } from './yaml/errors/YamlTagError.ts';
export type { YamlTagErrorOptions } from './yaml/errors/YamlTagError.ts';
// generic AST related exports
export type { default as Node, NodeOptions } from './Node.ts';
export { default as Literal } from './Literal.ts';
export type { LiteralOptions } from './Literal.ts';
export { Point, default as Position } from './Position.ts';
export type { PointOptions, PositionOptions } from './Position.ts';
export { default as Error } from './Error.ts';
export type { ErrorOptions } from './Error.ts';
export { default as ParseResult } from './ParseResult.ts';
export { isParseResult, isLiteral, isPoint, isPosition } from './predicates.ts';
// AST traversal related exports
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonArray.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import JsonNode from './JsonNode.ts';
import { isFalse, isTrue, isNull, isNumber, isString, isArray, isObject } from './predicates.ts';

/**
* @public
*/
class JsonArray extends JsonNode {
public static readonly type = 'array';

Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { head } from 'ramda';

import JsonNode from './JsonNode.ts';

/**
* @public
*/
class JsonDocument extends JsonNode {
public static readonly type = 'document';

Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonEscapeSequence.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonEscapeSequence extends JsonValue {
public static readonly type = 'escapeSequence';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonFalse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonFalse extends JsonValue {
public static readonly type = 'false';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonString from './JsonString.ts';

/**
* @public
*/
class JsonKey extends JsonString {
public static readonly type = 'key';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Node from '../../Node.ts';

/**
* @public
*/
class JsonNode extends Node {}

export default JsonNode;
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonNull.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonNull extends JsonValue {
public static readonly type = 'null';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonNumber.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonNumber extends JsonValue {
public static readonly type = 'number';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import JsonNode from './JsonNode.ts';
import { isProperty } from './predicates.ts';
import type JsonProperty from './JsonProperty.ts';

/**
* @public
*/
class JsonObject extends JsonNode {
public static readonly type = 'object';

Expand Down
15 changes: 14 additions & 1 deletion packages/apidom-ast/src/json/nodes/JsonProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,21 @@ import type JsonNumber from './JsonNumber.ts';
import type JsonArray from './JsonArray.ts';
import type JsonObject from './JsonObject.ts';

type JsonValue = JsonFalse | JsonTrue | JsonNull | JsonNumber | JsonString | JsonArray | JsonObject;
/**
* @public
*/
export type JsonValue =
| JsonFalse
| JsonTrue
| JsonNull
| JsonNumber
| JsonString
| JsonArray
| JsonObject;

/**
* @public
*/
class JsonProperty extends JsonNode {
public static readonly type = 'property';

Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { isEscapeSequence, isStringContent } from './predicates.ts';

type JsonStringLike = JsonStringContent | JsonEscapeSequence;

/**
* @public
*/
class JsonString extends JsonNode {
public static readonly type: string = 'string';

Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonStringContent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonStringContent extends JsonValue {
public static readonly type = 'stringContent';
}
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonTrue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import JsonValue from './JsonValue.ts';

/**
* @public
*/
class JsonTrue extends JsonValue {
public static readonly type = 'true';
}
Expand Down
6 changes: 6 additions & 0 deletions packages/apidom-ast/src/json/nodes/JsonValue.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import JsonNode from './JsonNode.ts';
import type { NodeOptions } from '../../Node.ts';

/**
* @public
*/
export interface JsonValueOptions extends NodeOptions {
value: string;
}

/**
* @public
*/
class JsonValue extends JsonNode {
public static readonly type: string = 'value';

Expand Down
Loading

0 comments on commit 2d5114c

Please sign in to comment.