@microsoft/api-extractor-model 7.15.4 → 7.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/rollup.d.ts +16 -4
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/mixins/ApiParameterListMixin.d.ts +1 -0
- package/lib/mixins/ApiParameterListMixin.d.ts.map +1 -1
- package/lib/mixins/ApiParameterListMixin.js +4 -1
- package/lib/mixins/ApiParameterListMixin.js.map +1 -1
- package/lib/model/DeserializerContext.d.ts +10 -4
- package/lib/model/DeserializerContext.d.ts.map +1 -1
- package/lib/model/DeserializerContext.js +10 -4
- package/lib/model/DeserializerContext.js.map +1 -1
- package/lib/model/ModelReferenceResolver.js +3 -2
- package/lib/model/ModelReferenceResolver.js.map +1 -1
- package/lib/model/Parameter.d.ts +5 -0
- package/lib/model/Parameter.d.ts.map +1 -1
- package/lib/model/Parameter.js +1 -0
- package/lib/model/Parameter.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ a namespace containing static members of the class.
|
|
|
61
61
|
## Links
|
|
62
62
|
|
|
63
63
|
- [CHANGELOG.md](
|
|
64
|
-
https://github.com/microsoft/rushstack/blob/
|
|
64
|
+
https://github.com/microsoft/rushstack/blob/main/libraries/api-extractor-model/CHANGELOG.md) - Find
|
|
65
65
|
out what's new in the latest version
|
|
66
66
|
- [API Reference](https://rushstack.io/pages/api/api-extractor-model/)
|
|
67
67
|
|
package/dist/rollup.d.ts
CHANGED
|
@@ -735,30 +735,36 @@ declare enum ApiJsonSchemaVersion {
|
|
|
735
735
|
*/
|
|
736
736
|
V_1001 = 1001,
|
|
737
737
|
/**
|
|
738
|
-
* Remove
|
|
738
|
+
* Remove `canonicalReference` field. This field was for diagnostic purposes only and was never deserialized.
|
|
739
739
|
*/
|
|
740
740
|
V_1002 = 1002,
|
|
741
741
|
/**
|
|
742
|
-
* Reintroduce the
|
|
742
|
+
* Reintroduce the `canonicalReference` field using the experimental new TSDoc declaration reference notation.
|
|
743
743
|
*
|
|
744
744
|
* This is not a breaking change because this field is never deserialized; it is provided for informational
|
|
745
745
|
* purposes only.
|
|
746
746
|
*/
|
|
747
747
|
V_1003 = 1003,
|
|
748
748
|
/**
|
|
749
|
-
* Add a
|
|
749
|
+
* Add a `tsdocConfig` field that tracks the TSDoc configuration for parsing doc comments.
|
|
750
750
|
*
|
|
751
751
|
* This is not a breaking change because an older implementation will still work correctly. The
|
|
752
752
|
* custom tags will be skipped over by the parser.
|
|
753
753
|
*/
|
|
754
754
|
V_1004 = 1004,
|
|
755
|
+
/**
|
|
756
|
+
* Add an `isOptional` field to `IApiParameterOptions` to track whether a function parameter is optional.
|
|
757
|
+
*
|
|
758
|
+
* When loading older JSON files, the value defaults to `false`.
|
|
759
|
+
*/
|
|
760
|
+
V_1005 = 1005,
|
|
755
761
|
/**
|
|
756
762
|
* The current latest .api.json schema version.
|
|
757
763
|
*
|
|
758
764
|
* IMPORTANT: When incrementing this number, consider whether `OLDEST_SUPPORTED` or `OLDEST_FORWARDS_COMPATIBLE`
|
|
759
765
|
* should be updated.
|
|
760
766
|
*/
|
|
761
|
-
LATEST =
|
|
767
|
+
LATEST = 1005,
|
|
762
768
|
/**
|
|
763
769
|
* The oldest .api.json schema version that is still supported for backwards compatibility.
|
|
764
770
|
*
|
|
@@ -1981,6 +1987,7 @@ export declare interface IApiParameterListMixinOptions extends IApiItemOptions {
|
|
|
1981
1987
|
export declare interface IApiParameterOptions {
|
|
1982
1988
|
parameterName: string;
|
|
1983
1989
|
parameterTypeTokenRange: IExcerptTokenRange;
|
|
1990
|
+
isOptional: boolean;
|
|
1984
1991
|
}
|
|
1985
1992
|
|
|
1986
1993
|
declare interface IApiPropertyItemJson extends IApiDeclaredItemJson {
|
|
@@ -2121,6 +2128,7 @@ export declare interface IExcerptTokenRange {
|
|
|
2121
2128
|
export declare interface IParameterOptions {
|
|
2122
2129
|
name: string;
|
|
2123
2130
|
parameterTypeExcerpt: Excerpt;
|
|
2131
|
+
isOptional: boolean;
|
|
2124
2132
|
parent: ApiParameterListMixin;
|
|
2125
2133
|
}
|
|
2126
2134
|
|
|
@@ -2178,6 +2186,10 @@ export declare class Parameter {
|
|
|
2178
2186
|
* The parameter name.
|
|
2179
2187
|
*/
|
|
2180
2188
|
name: string;
|
|
2189
|
+
/**
|
|
2190
|
+
* Whether the parameter is optional.
|
|
2191
|
+
*/
|
|
2192
|
+
isOptional: boolean;
|
|
2181
2193
|
private _parent;
|
|
2182
2194
|
constructor(options: IParameterOptions);
|
|
2183
2195
|
/**
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -8,6 +8,7 @@ import { IExcerptTokenRange } from './Excerpt';
|
|
|
8
8
|
export interface IApiParameterOptions {
|
|
9
9
|
parameterName: string;
|
|
10
10
|
parameterTypeTokenRange: IExcerptTokenRange;
|
|
11
|
+
isOptional: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Constructor options for {@link (ApiParameterListMixin:interface)}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiParameterListMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI/C;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiParameterListMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE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({
|
|
33
33
|
name: parameterOptions.parameterName,
|
|
34
34
|
parameterTypeExcerpt: this.buildExcerpt(parameterOptions.parameterTypeTokenRange),
|
|
35
|
+
// Prior to ApiJsonSchemaVersion.V_1005 this input will be undefined
|
|
36
|
+
isOptional: !!parameterOptions.isOptional,
|
|
35
37
|
parent: this
|
|
36
38
|
});
|
|
37
39
|
this[_parameters].push(parameter);
|
|
@@ -62,7 +64,8 @@ function ApiParameterListMixin(baseClass
|
|
|
62
64
|
for (const parameter of this.parameters) {
|
|
63
65
|
parameterObjects.push({
|
|
64
66
|
parameterName: parameter.name,
|
|
65
|
-
parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange
|
|
67
|
+
parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange,
|
|
68
|
+
isOptional: parameter.isOptional
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
jsonObject.parameters = parameterObjects;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiParameterListMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,4DAA4D;;;AAG5D,kDAA+C;AAC/C,8DAA2D;AAE3D,oEAA6D;
|
|
1
|
+
{"version":3,"file":"ApiParameterListMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,4DAA4D;;;AAG5D,kDAA+C;AAC/C,8DAA2D;AAE3D,oEAA6D;AA2B7D,MAAM,cAAc,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC;AACrF,MAAM,WAAW,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AAwD/E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,SAAqB;AACrB,8DAA8D;;IAE9D,MAAM,UAAW,SAAQ,SAAS;QAIhC,8DAA8D;QAC9D,YAAmB,GAAG,IAAW;YAC/B,KAAK,CAAC,GAAG,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,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAEhC,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YAE9C,MAAM,gBAAgB,GAA2B,EAAE,CAAC;YACpD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;gBACvC,gBAAgB,CAAC,IAAI,CAAC;oBACpB,aAAa,EAAE,SAAS,CAAC,IAAI;oBAC7B,uBAAuB,EAAE,SAAS,CAAC,oBAAoB,CAAC,UAAU;oBAClE,UAAU,EAAE,SAAS,CAAC,UAAU;iBACjC,CAAC,CAAC;aACJ;YAED,UAAU,CAAC,UAAU,GAAG,gBAAgB,CAAC;QAC3C,CAAC;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA5ED,sDA4EC;AAED;;;GAGG;AACH,WAAiB,qBAAqB;IACpC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAgB;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAFe,mCAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAarC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.s\n\nimport { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';\nimport { Parameter } from '../model/Parameter';\nimport { ApiDeclaredItem } from '../items/ApiDeclaredItem';\nimport { IExcerptTokenRange } from './Excerpt';\nimport { InternalError } from '@rushstack/node-core-library';\nimport { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Represents parameter information that is part of {@link IApiParameterListMixinOptions}\n * @public\n */\nexport interface IApiParameterOptions {\n parameterName: string;\n parameterTypeTokenRange: IExcerptTokenRange;\n isOptional: boolean;\n}\n\n/**\n * Constructor options for {@link (ApiParameterListMixin:interface)}.\n * @public\n */\nexport interface IApiParameterListMixinOptions extends IApiItemOptions {\n overloadIndex: number;\n parameters: IApiParameterOptions[];\n}\n\nexport interface IApiParameterListJson extends IApiItemJson {\n overloadIndex: number;\n parameters: IApiParameterOptions[];\n}\n\nconst _overloadIndex: unique symbol = Symbol('ApiParameterListMixin._overloadIndex');\nconst _parameters: unique symbol = Symbol('ApiParameterListMixin._parameters');\n\n/**\n * The mixin base class for API items that can have function parameters (but not necessarily a return value).\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiParameterListMixin extends ApiItem {\n /**\n * When a function has multiple overloaded declarations, this zero-based integer index can be used to unqiuely\n * identify them.\n *\n * @remarks\n *\n * Consider this overloaded declaration:\n *\n * ```ts\n * export namespace Versioning {\n * // TSDoc: Versioning.(addVersions:1)\n * export function addVersions(x: number, y: number): number;\n *\n * // TSDoc: Versioning.(addVersions:2)\n * export function addVersions(x: string, y: string): string;\n *\n * // (implementation)\n * export function addVersions(x: number|string, y: number|string): number|string {\n * // . . .\n * }\n * }\n * ```\n *\n * In the above example, there are two overloaded declarations. The overload using numbers will have\n * `overloadIndex = 1`. The overload using strings will have `overloadIndex = 2`. The third declaration that\n * accepts all possible inputs is considered part of the implementation, and is not processed by API Extractor.\n */\n readonly overloadIndex: number;\n\n /**\n * The function parameters.\n */\n readonly parameters: ReadonlyArray<Parameter>;\n\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link (ApiParameterListMixin:interface)}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiParameterListMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiParameterListMixin) {\n class MixedClass extends baseClass implements ApiParameterListMixin {\n public readonly [_overloadIndex]: number;\n public readonly [_parameters]: Parameter[];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n\n const options: IApiParameterListMixinOptions = args[0];\n this[_overloadIndex] = options.overloadIndex;\n\n this[_parameters] = [];\n\n if (this instanceof ApiDeclaredItem) {\n if (options.parameters) {\n for (const parameterOptions of options.parameters) {\n const parameter: Parameter = new Parameter({\n name: parameterOptions.parameterName,\n parameterTypeExcerpt: this.buildExcerpt(parameterOptions.parameterTypeTokenRange),\n // Prior to ApiJsonSchemaVersion.V_1005 this input will be undefined\n isOptional: !!parameterOptions.isOptional,\n parent: this\n });\n\n this[_parameters].push(parameter);\n }\n }\n } else {\n throw new InternalError('ApiReturnTypeMixin expects a base class that inherits from ApiDeclaredItem');\n }\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiParameterListMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiParameterListJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n\n options.overloadIndex = jsonObject.overloadIndex;\n options.parameters = jsonObject.parameters || [];\n }\n\n public get overloadIndex(): number {\n return this[_overloadIndex];\n }\n\n public get parameters(): ReadonlyArray<Parameter> {\n return this[_parameters];\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiParameterListJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.overloadIndex = this.overloadIndex;\n\n const parameterObjects: IApiParameterOptions[] = [];\n for (const parameter of this.parameters) {\n parameterObjects.push({\n parameterName: parameter.name,\n parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange,\n isOptional: parameter.isOptional\n });\n }\n\n jsonObject.parameters = parameterObjects;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiParameterListMixin:interface)}.\n * @public\n */\nexport namespace ApiParameterListMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiParameterListMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiParameterListMixin {\n return apiItem.hasOwnProperty(_parameters);\n }\n}\n"]}
|
|
@@ -9,30 +9,36 @@ export declare enum ApiJsonSchemaVersion {
|
|
|
9
9
|
*/
|
|
10
10
|
V_1001 = 1001,
|
|
11
11
|
/**
|
|
12
|
-
* Remove
|
|
12
|
+
* Remove `canonicalReference` field. This field was for diagnostic purposes only and was never deserialized.
|
|
13
13
|
*/
|
|
14
14
|
V_1002 = 1002,
|
|
15
15
|
/**
|
|
16
|
-
* Reintroduce the
|
|
16
|
+
* Reintroduce the `canonicalReference` field using the experimental new TSDoc declaration reference notation.
|
|
17
17
|
*
|
|
18
18
|
* This is not a breaking change because this field is never deserialized; it is provided for informational
|
|
19
19
|
* purposes only.
|
|
20
20
|
*/
|
|
21
21
|
V_1003 = 1003,
|
|
22
22
|
/**
|
|
23
|
-
* Add a
|
|
23
|
+
* Add a `tsdocConfig` field that tracks the TSDoc configuration for parsing doc comments.
|
|
24
24
|
*
|
|
25
25
|
* This is not a breaking change because an older implementation will still work correctly. The
|
|
26
26
|
* custom tags will be skipped over by the parser.
|
|
27
27
|
*/
|
|
28
28
|
V_1004 = 1004,
|
|
29
|
+
/**
|
|
30
|
+
* Add an `isOptional` field to `IApiParameterOptions` to track whether a function parameter is optional.
|
|
31
|
+
*
|
|
32
|
+
* When loading older JSON files, the value defaults to `false`.
|
|
33
|
+
*/
|
|
34
|
+
V_1005 = 1005,
|
|
29
35
|
/**
|
|
30
36
|
* The current latest .api.json schema version.
|
|
31
37
|
*
|
|
32
38
|
* IMPORTANT: When incrementing this number, consider whether `OLDEST_SUPPORTED` or `OLDEST_FORWARDS_COMPATIBLE`
|
|
33
39
|
* should be updated.
|
|
34
40
|
*/
|
|
35
|
-
LATEST =
|
|
41
|
+
LATEST = 1005,
|
|
36
42
|
/**
|
|
37
43
|
* The oldest .api.json schema version that is still supported for backwards compatibility.
|
|
38
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializerContext.d.ts","sourceRoot":"","sources":["../../src/model/DeserializerContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,oBAAY,oBAAoB;IAC9B;;OAEG;IACH,MAAM,OAAO;IAEb;;OAEG;IACH,MAAM,OAAO;IAEb;;OAEG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAS;IAEf;;;;;OAKG;IACH,gBAAgB,OAAS;IAEzB;;;;;;OAMG;IACH,0BAA0B,OAAS;CACpC;AAED,qBAAa,mBAAmB;IAC9B;;OAEG;IACH,SAAgB,eAAe,EAAE,MAAM,CAAC;IAExC;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,SAAgB,oBAAoB,EAAE,oBAAoB,CAAC;IAE3D;;OAEG;IACH,SAAgB,kBAAkB,EAAE,kBAAkB,CAAC;gBAEpC,OAAO,EAAE,mBAAmB;CAOhD"}
|
|
1
|
+
{"version":3,"file":"DeserializerContext.d.ts","sourceRoot":"","sources":["../../src/model/DeserializerContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,oBAAY,oBAAoB;IAC9B;;OAEG;IACH,MAAM,OAAO;IAEb;;OAEG;IACH,MAAM,OAAO;IAEb;;OAEG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAO;IAEb;;;;OAIG;IACH,MAAM,OAAO;IAEb;;;;;OAKG;IACH,MAAM,OAAS;IAEf;;;;;OAKG;IACH,gBAAgB,OAAS;IAEzB;;;;;;OAMG;IACH,0BAA0B,OAAS;CACpC;AAED,qBAAa,mBAAmB;IAC9B;;OAEG;IACH,SAAgB,eAAe,EAAE,MAAM,CAAC;IAExC;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,SAAgB,oBAAoB,EAAE,oBAAoB,CAAC;IAE3D;;OAEG;IACH,SAAgB,kBAAkB,EAAE,kBAAkB,CAAC;gBAEpC,OAAO,EAAE,mBAAmB;CAOhD"}
|
|
@@ -14,30 +14,36 @@ var ApiJsonSchemaVersion;
|
|
|
14
14
|
*/
|
|
15
15
|
ApiJsonSchemaVersion[ApiJsonSchemaVersion["V_1001"] = 1001] = "V_1001";
|
|
16
16
|
/**
|
|
17
|
-
* Remove
|
|
17
|
+
* Remove `canonicalReference` field. This field was for diagnostic purposes only and was never deserialized.
|
|
18
18
|
*/
|
|
19
19
|
ApiJsonSchemaVersion[ApiJsonSchemaVersion["V_1002"] = 1002] = "V_1002";
|
|
20
20
|
/**
|
|
21
|
-
* Reintroduce the
|
|
21
|
+
* Reintroduce the `canonicalReference` field using the experimental new TSDoc declaration reference notation.
|
|
22
22
|
*
|
|
23
23
|
* This is not a breaking change because this field is never deserialized; it is provided for informational
|
|
24
24
|
* purposes only.
|
|
25
25
|
*/
|
|
26
26
|
ApiJsonSchemaVersion[ApiJsonSchemaVersion["V_1003"] = 1003] = "V_1003";
|
|
27
27
|
/**
|
|
28
|
-
* Add a
|
|
28
|
+
* Add a `tsdocConfig` field that tracks the TSDoc configuration for parsing doc comments.
|
|
29
29
|
*
|
|
30
30
|
* This is not a breaking change because an older implementation will still work correctly. The
|
|
31
31
|
* custom tags will be skipped over by the parser.
|
|
32
32
|
*/
|
|
33
33
|
ApiJsonSchemaVersion[ApiJsonSchemaVersion["V_1004"] = 1004] = "V_1004";
|
|
34
|
+
/**
|
|
35
|
+
* Add an `isOptional` field to `IApiParameterOptions` to track whether a function parameter is optional.
|
|
36
|
+
*
|
|
37
|
+
* When loading older JSON files, the value defaults to `false`.
|
|
38
|
+
*/
|
|
39
|
+
ApiJsonSchemaVersion[ApiJsonSchemaVersion["V_1005"] = 1005] = "V_1005";
|
|
34
40
|
/**
|
|
35
41
|
* The current latest .api.json schema version.
|
|
36
42
|
*
|
|
37
43
|
* IMPORTANT: When incrementing this number, consider whether `OLDEST_SUPPORTED` or `OLDEST_FORWARDS_COMPATIBLE`
|
|
38
44
|
* should be updated.
|
|
39
45
|
*/
|
|
40
|
-
ApiJsonSchemaVersion[ApiJsonSchemaVersion["LATEST"] =
|
|
46
|
+
ApiJsonSchemaVersion[ApiJsonSchemaVersion["LATEST"] = 1005] = "LATEST";
|
|
41
47
|
/**
|
|
42
48
|
* The oldest .api.json schema version that is still supported for backwards compatibility.
|
|
43
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeserializerContext.js","sourceRoot":"","sources":["../../src/model/DeserializerContext.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,IAAY,
|
|
1
|
+
{"version":3,"file":"DeserializerContext.js","sourceRoot":"","sources":["../../src/model/DeserializerContext.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,IAAY,oBA+DX;AA/DD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,sEAAa,CAAA;IAEb;;OAEG;IACH,sEAAa,CAAA;IAEb;;OAEG;IACH,sEAAa,CAAA;IAEb;;;;;OAKG;IACH,sEAAa,CAAA;IAEb;;;;;OAKG;IACH,sEAAa,CAAA;IAEb;;;;OAIG;IACH,sEAAa,CAAA;IAEb;;;;;OAKG;IACH,sEAAe,CAAA;IAEf;;;;;OAKG;IACH,0FAAyB,CAAA;IAEzB;;;;;;OAMG;IACH,8GAAmC,CAAA;AACrC,CAAC,EA/DW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA+D/B;AAED,MAAa,mBAAmB;IA0B9B,YAAmB,OAA4B;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;QACzD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACvD,CAAC;CACF;AAjCD,kDAiCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { TSDocConfiguration } from '@microsoft/tsdoc';\n\nexport enum ApiJsonSchemaVersion {\n /**\n * The initial release.\n */\n V_1000 = 1000,\n\n /**\n * Add support for type parameters and type alias types.\n */\n V_1001 = 1001,\n\n /**\n * Remove `canonicalReference` field. This field was for diagnostic purposes only and was never deserialized.\n */\n V_1002 = 1002,\n\n /**\n * Reintroduce the `canonicalReference` field using the experimental new TSDoc declaration reference notation.\n *\n * This is not a breaking change because this field is never deserialized; it is provided for informational\n * purposes only.\n */\n V_1003 = 1003,\n\n /**\n * Add a `tsdocConfig` field that tracks the TSDoc configuration for parsing doc comments.\n *\n * This is not a breaking change because an older implementation will still work correctly. The\n * custom tags will be skipped over by the parser.\n */\n V_1004 = 1004,\n\n /**\n * Add an `isOptional` field to `IApiParameterOptions` to track whether a function parameter is optional.\n *\n * When loading older JSON files, the value defaults to `false`.\n */\n V_1005 = 1005,\n\n /**\n * The current latest .api.json schema version.\n *\n * IMPORTANT: When incrementing this number, consider whether `OLDEST_SUPPORTED` or `OLDEST_FORWARDS_COMPATIBLE`\n * should be updated.\n */\n LATEST = V_1005,\n\n /**\n * The oldest .api.json schema version that is still supported for backwards compatibility.\n *\n * This must be updated if you change to the file format and do not implement compatibility logic for\n * deserializing the older representation.\n */\n OLDEST_SUPPORTED = V_1001,\n\n /**\n * Used to assign `IApiPackageMetadataJson.oldestForwardsCompatibleVersion`.\n *\n * This value must be \\<= `ApiJsonSchemaVersion.LATEST`. It must be reset to the `LATEST` value\n * if the older library would not be able to deserialize your new file format. Adding a nonessential field\n * is generally okay. Removing, modifying, or reinterpreting existing fields is NOT safe.\n */\n OLDEST_FORWARDS_COMPATIBLE = V_1001\n}\n\nexport class DeserializerContext {\n /**\n * The path of the file being deserialized, which may be useful for diagnostic purposes.\n */\n public readonly apiJsonFilename: string;\n\n /**\n * Metadata from `IApiPackageMetadataJson.toolPackage`.\n */\n public readonly toolPackage: string;\n\n /**\n * Metadata from `IApiPackageMetadataJson.toolVersion`.\n */\n public readonly toolVersion: string;\n\n /**\n * The version of the schema being deserialized, as obtained from `IApiPackageMetadataJson.schemaVersion`.\n */\n public readonly versionToDeserialize: ApiJsonSchemaVersion;\n\n /**\n * The TSDoc configuration for the context.\n */\n public readonly tsdocConfiguration: TSDocConfiguration;\n\n public constructor(options: DeserializerContext) {\n this.apiJsonFilename = options.apiJsonFilename;\n this.toolPackage = options.toolPackage;\n this.toolVersion = options.toolVersion;\n this.versionToDeserialize = options.versionToDeserialize;\n this.tsdocConfiguration = options.tsdocConfiguration;\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ModelReferenceResolver = void 0;
|
|
6
|
+
const tsdoc_1 = require("@microsoft/tsdoc");
|
|
6
7
|
const ApiItem_1 = require("../items/ApiItem");
|
|
7
8
|
const ApiItemContainerMixin_1 = require("../mixins/ApiItemContainerMixin");
|
|
8
9
|
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
|
|
@@ -83,10 +84,10 @@ class ModelReferenceResolver {
|
|
|
83
84
|
else {
|
|
84
85
|
let memberSelectorResult;
|
|
85
86
|
switch (memberSelector.selectorKind) {
|
|
86
|
-
case
|
|
87
|
+
case tsdoc_1.SelectorKind.System:
|
|
87
88
|
memberSelectorResult = this._selectUsingSystemSelector(foundMembers, memberSelector, identifier);
|
|
88
89
|
break;
|
|
89
|
-
case
|
|
90
|
+
case tsdoc_1.SelectorKind.Index:
|
|
90
91
|
memberSelectorResult = this._selectUsingIndexSelector(foundMembers, memberSelector, identifier);
|
|
91
92
|
break;
|
|
92
93
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelReferenceResolver.js","sourceRoot":"","sources":["../../src/model/ModelReferenceResolver.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,8CAAwD;AAIxD,2EAAwE;AACxE,2EAAwE;AAoBxE;;;;;;;GAOG;AACH,MAAa,sBAAsB;IAGjC,YAAmB,QAAkB;QACnC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,OAAO,CACZ,oBAA6C,EAC7C,cAAmC;QAEnC,MAAM,MAAM,GAAuC;YACjD,eAAe,EAAE,SAAS;YAC1B,YAAY,EAAE,SAAS;SACxB,CAAC;QAEF,IAAI,UAAU,GAA2B,SAAS,CAAC;QAEnD,iCAAiC;QACjC,IAAI,oBAAoB,CAAC,WAAW,KAAK,SAAS,EAAE;YAClD,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAClF,IAAI,UAAU,KAAK,SAAS,EAAE;g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C,YAAY,GAAG,8BAA8B,UAAU,iCAAiC,YAAY,GAAG,CAAC;SAChH;QACD,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,yBAAyB,CAC/B,YAAoC,EACpC,cAAiC,EACjC,UAAkB;QAElB,MAAM,MAAM,GAAuC;YACjD,eAAe,EAAE,SAAS;YAC1B,YAAY,EAAE,SAAS;SACxB,CAAC;QAEF,MAAM,eAAe,GAAc,EAAE,CAAC;QAEtC,MAAM,qBAAqB,GAAW,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACxE,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,IAAI,6CAAqB,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE;gBACpD,IAAI,WAAW,CAAC,aAAa,KAAK,qBAAqB,EAAE;oBACvD,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACnC;aACF;SACF;QAED,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,CAAC,YAAY;gBACjB,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,6BAA6B;oBAC1E,yBAAyB,qBAAqB,GAAG,CAAC;YACpD,OAAO,MAAM,CAAC;SACf;QAED,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,MAAM,CAAC;SACf;QAED,MAAM,CAAC,YAAY,GAAG,wBAAwB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACzF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArMD,wDAqMC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { DocDeclarationReference, DocMemberSelector, SelectorKind } from '@microsoft/tsdoc';\nimport { ApiItem, ApiItemKind } from '../items/ApiItem';\nimport { ApiModel } from './ApiModel';\nimport { ApiPackage } from './ApiPackage';\nimport { ApiEntryPoint } from './ApiEntryPoint';\nimport { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';\nimport { ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\n\n/**\n * Result object for {@link ApiModel.resolveDeclarationReference}.\n *\n * @public\n */\nexport interface IResolveDeclarationReferenceResult {\n /**\n * The referenced ApiItem, if the declaration reference could be resolved.\n */\n resolvedApiItem: ApiItem | undefined;\n\n /**\n * If resolvedApiItem is undefined, then this will always contain an error message explaining why the\n * resolution failed.\n */\n errorMessage: string | undefined;\n}\n\n/**\n * This resolves a TSDoc declaration reference by walking the `ApiModel` hierarchy.\n *\n * @remarks\n *\n * This class is analogous to `AstReferenceResolver` from the `@microsoft/api-extractor` project,\n * which resolves declaration references by walking the compiler state.\n */\nexport class ModelReferenceResolver {\n private readonly _apiModel: ApiModel;\n\n public constructor(apiModel: ApiModel) {\n this._apiModel = apiModel;\n }\n\n public resolve(\n declarationReference: DocDeclarationReference,\n contextApiItem: ApiItem | undefined\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n let apiPackage: ApiPackage | undefined = undefined;\n\n // Is this an absolute reference?\n if (declarationReference.packageName !== undefined) {\n apiPackage = this._apiModel.tryGetPackageByName(declarationReference.packageName);\n if (apiPackage === undefined) {\n result.errorMessage = `The package \"${declarationReference.packageName}\" could not be located`;\n return result;\n }\n } else {\n // If the package name is omitted, try to infer it from the context\n if (contextApiItem !== undefined) {\n apiPackage = contextApiItem.getAssociatedPackage();\n }\n\n if (apiPackage === undefined) {\n result.errorMessage =\n `The reference does not include a package name, and the package could not be inferred` +\n ` from the context`;\n return result;\n }\n }\n\n const importPath: string = declarationReference.importPath || '';\n\n const foundEntryPoints: ReadonlyArray<ApiEntryPoint> = apiPackage.findEntryPointsByPath(importPath);\n if (foundEntryPoints.length !== 1) {\n result.errorMessage = `The import path \"${importPath}\" could not be resolved`;\n return result;\n }\n\n let currentItem: ApiItem = foundEntryPoints[0];\n\n // Now search for the member reference\n for (const memberReference of declarationReference.memberReferences) {\n if (memberReference.memberSymbol !== undefined) {\n result.errorMessage = `Symbols are not yet supported in declaration references`;\n return result;\n }\n\n if (memberReference.memberIdentifier === undefined) {\n result.errorMessage = `Missing member identifier`;\n return result;\n }\n\n const identifier: string = memberReference.memberIdentifier.identifier;\n\n if (!ApiItemContainerMixin.isBaseClassOf(currentItem)) {\n // For example, {@link MyClass.myMethod.X} is invalid because methods cannot contain members\n result.errorMessage = `Unable to resolve ${JSON.stringify(\n identifier\n )} because ${currentItem.getScopedNameWithinPackage()} cannot act as a container`;\n return result;\n }\n\n const foundMembers: ReadonlyArray<ApiItem> = currentItem.findMembersByName(identifier);\n if (foundMembers.length === 0) {\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was not found`;\n return result;\n }\n\n const memberSelector: DocMemberSelector | undefined = memberReference.selector;\n if (memberSelector === undefined) {\n if (foundMembers.length > 1) {\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`;\n return result;\n }\n currentItem = foundMembers[0];\n } else {\n let memberSelectorResult: IResolveDeclarationReferenceResult;\n switch (memberSelector.selectorKind) {\n case SelectorKind.System:\n memberSelectorResult = this._selectUsingSystemSelector(foundMembers, memberSelector, identifier);\n break;\n case SelectorKind.Index:\n memberSelectorResult = this._selectUsingIndexSelector(foundMembers, memberSelector, identifier);\n break;\n default:\n result.errorMessage = `The selector \"${memberSelector.selector}\" is not a supported selector type`;\n return result;\n }\n if (memberSelectorResult.resolvedApiItem === undefined) {\n return memberSelectorResult;\n }\n currentItem = memberSelectorResult.resolvedApiItem;\n }\n }\n result.resolvedApiItem = currentItem;\n return result;\n }\n\n private _selectUsingSystemSelector(\n foundMembers: ReadonlyArray<ApiItem>,\n memberSelector: DocMemberSelector,\n identifier: string\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n const selectorName: string = memberSelector.selector;\n\n let selectorItemKind: ApiItemKind;\n switch (selectorName) {\n case 'class':\n selectorItemKind = ApiItemKind.Class;\n break;\n case 'enum':\n selectorItemKind = ApiItemKind.Enum;\n break;\n case 'function':\n selectorItemKind = ApiItemKind.Function;\n break;\n case 'interface':\n selectorItemKind = ApiItemKind.Interface;\n break;\n case 'namespace':\n selectorItemKind = ApiItemKind.Namespace;\n break;\n case 'type':\n selectorItemKind = ApiItemKind.TypeAlias;\n break;\n case 'variable':\n selectorItemKind = ApiItemKind.Variable;\n break;\n default:\n result.errorMessage = `Unsupported system selector \"${selectorName}\"`;\n return result;\n }\n\n const matches: ApiItem[] = foundMembers.filter((x) => x.kind === selectorItemKind);\n if (matches.length === 0) {\n result.errorMessage =\n `A declaration for \"${identifier}\" was not found that matches the` +\n ` TSDoc selector \"${selectorName}\"`;\n return result;\n }\n if (matches.length > 1) {\n result.errorMessage = `More than one declaration \"${identifier}\" matches the TSDoc selector \"${selectorName}\"`;\n }\n result.resolvedApiItem = matches[0];\n return result;\n }\n\n private _selectUsingIndexSelector(\n foundMembers: ReadonlyArray<ApiItem>,\n memberSelector: DocMemberSelector,\n identifier: string\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n const selectedMembers: ApiItem[] = [];\n\n const selectorOverloadIndex: number = parseInt(memberSelector.selector);\n for (const foundMember of foundMembers) {\n if (ApiParameterListMixin.isBaseClassOf(foundMember)) {\n if (foundMember.overloadIndex === selectorOverloadIndex) {\n selectedMembers.push(foundMember);\n }\n }\n }\n\n if (selectedMembers.length === 0) {\n result.errorMessage =\n `An overload for ${JSON.stringify(identifier)} was not found that matches` +\n ` the TSDoc selector \":${selectorOverloadIndex}\"`;\n return result;\n }\n\n if (selectedMembers.length === 1) {\n result.resolvedApiItem = selectedMembers[0];\n return result;\n }\n\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`;\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelReferenceResolver.js","sourceRoot":"","sources":["../../src/model/ModelReferenceResolver.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4CAA4F;AAC5F,8CAAwD;AAIxD,2EAAwE;AACxE,2EAAwE;AAoBxE;;;;;;;GAOG;AACH,MAAa,sBAAsB;IAGjC,YAAmB,QAAkB;QACnC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,OAAO,CACZ,oBAA6C,EAC7C,cAAmC;QAEnC,MAAM,MAAM,GAAuC;YACjD,eAAe,EAAE,SAAS;YAC1B,YAAY,EAAE,SAAS;SACxB,CAAC;QAEF,IAAI,UAAU,GAA2B,SAAS,CAAC;QAEnD,iCAAiC;QACjC,IAAI,oBAAoB,CAAC,WAAW,KAAK,SAAS,EAAE;YAClD,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAClF,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,MAAM,CAAC,YAAY,GAAG,gBAAgB,oBAAoB,CAAC,WAAW,wBAAwB,CAAC;gBAC/F,OAAO,MAAM,CAAC;aACf;SACF;aAAM;YACL,mEAAmE;YACnE,IAAI,cAAc,KAAK,SAAS,EAAE;gBAChC,UAAU,GAAG,cAAc,CAAC,oBAAoB,EAAE,CAAC;aACpD;YAED,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,MAAM,CAAC,YAAY;oBACjB,sFAAsF;wBACtF,mBAAmB,CAAC;gBACtB,OAAO,MAAM,CAAC;aACf;SACF;QAED,MAAM,UAAU,GAAW,oBAAoB,CAAC,UAAU,IAAI,EAAE,CAAC;QAEjE,MAAM,gBAAgB,GAAiC,UAAU,CAAC,qBAAqB,CAA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MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,IAAI,6CAAqB,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE;gBACpD,IAAI,WAAW,CAAC,aAAa,KAAK,qBAAqB,EAAE;oBACvD,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBACnC;aACF;SACF;QAED,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,CAAC,YAAY;gBACjB,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,6BAA6B;oBAC1E,yBAAyB,qBAAqB,GAAG,CAAC;YACpD,OAAO,MAAM,CAAC;SACf;QAED,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,MAAM,CAAC;SACf;QAED,MAAM,CAAC,YAAY,GAAG,wBAAwB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACzF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArMD,wDAqMC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { DocDeclarationReference, DocMemberSelector, SelectorKind } from '@microsoft/tsdoc';\nimport { ApiItem, ApiItemKind } from '../items/ApiItem';\nimport { ApiModel } from './ApiModel';\nimport { ApiPackage } from './ApiPackage';\nimport { ApiEntryPoint } from './ApiEntryPoint';\nimport { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin';\nimport { ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\n\n/**\n * Result object for {@link ApiModel.resolveDeclarationReference}.\n *\n * @public\n */\nexport interface IResolveDeclarationReferenceResult {\n /**\n * The referenced ApiItem, if the declaration reference could be resolved.\n */\n resolvedApiItem: ApiItem | undefined;\n\n /**\n * If resolvedApiItem is undefined, then this will always contain an error message explaining why the\n * resolution failed.\n */\n errorMessage: string | undefined;\n}\n\n/**\n * This resolves a TSDoc declaration reference by walking the `ApiModel` hierarchy.\n *\n * @remarks\n *\n * This class is analogous to `AstReferenceResolver` from the `@microsoft/api-extractor` project,\n * which resolves declaration references by walking the compiler state.\n */\nexport class ModelReferenceResolver {\n private readonly _apiModel: ApiModel;\n\n public constructor(apiModel: ApiModel) {\n this._apiModel = apiModel;\n }\n\n public resolve(\n declarationReference: DocDeclarationReference,\n contextApiItem: ApiItem | undefined\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n let apiPackage: ApiPackage | undefined = undefined;\n\n // Is this an absolute reference?\n if (declarationReference.packageName !== undefined) {\n apiPackage = this._apiModel.tryGetPackageByName(declarationReference.packageName);\n if (apiPackage === undefined) {\n result.errorMessage = `The package \"${declarationReference.packageName}\" could not be located`;\n return result;\n }\n } else {\n // If the package name is omitted, try to infer it from the context\n if (contextApiItem !== undefined) {\n apiPackage = contextApiItem.getAssociatedPackage();\n }\n\n if (apiPackage === undefined) {\n result.errorMessage =\n `The reference does not include a package name, and the package could not be inferred` +\n ` from the context`;\n return result;\n }\n }\n\n const importPath: string = declarationReference.importPath || '';\n\n const foundEntryPoints: ReadonlyArray<ApiEntryPoint> = apiPackage.findEntryPointsByPath(importPath);\n if (foundEntryPoints.length !== 1) {\n result.errorMessage = `The import path \"${importPath}\" could not be resolved`;\n return result;\n }\n\n let currentItem: ApiItem = foundEntryPoints[0];\n\n // Now search for the member reference\n for (const memberReference of declarationReference.memberReferences) {\n if (memberReference.memberSymbol !== undefined) {\n result.errorMessage = `Symbols are not yet supported in declaration references`;\n return result;\n }\n\n if (memberReference.memberIdentifier === undefined) {\n result.errorMessage = `Missing member identifier`;\n return result;\n }\n\n const identifier: string = memberReference.memberIdentifier.identifier;\n\n if (!ApiItemContainerMixin.isBaseClassOf(currentItem)) {\n // For example, {@link MyClass.myMethod.X} is invalid because methods cannot contain members\n result.errorMessage = `Unable to resolve ${JSON.stringify(\n identifier\n )} because ${currentItem.getScopedNameWithinPackage()} cannot act as a container`;\n return result;\n }\n\n const foundMembers: ReadonlyArray<ApiItem> = currentItem.findMembersByName(identifier);\n if (foundMembers.length === 0) {\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was not found`;\n return result;\n }\n\n const memberSelector: DocMemberSelector | undefined = memberReference.selector;\n if (memberSelector === undefined) {\n if (foundMembers.length > 1) {\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`;\n return result;\n }\n currentItem = foundMembers[0];\n } else {\n let memberSelectorResult: IResolveDeclarationReferenceResult;\n switch (memberSelector.selectorKind) {\n case SelectorKind.System:\n memberSelectorResult = this._selectUsingSystemSelector(foundMembers, memberSelector, identifier);\n break;\n case SelectorKind.Index:\n memberSelectorResult = this._selectUsingIndexSelector(foundMembers, memberSelector, identifier);\n break;\n default:\n result.errorMessage = `The selector \"${memberSelector.selector}\" is not a supported selector type`;\n return result;\n }\n if (memberSelectorResult.resolvedApiItem === undefined) {\n return memberSelectorResult;\n }\n currentItem = memberSelectorResult.resolvedApiItem;\n }\n }\n result.resolvedApiItem = currentItem;\n return result;\n }\n\n private _selectUsingSystemSelector(\n foundMembers: ReadonlyArray<ApiItem>,\n memberSelector: DocMemberSelector,\n identifier: string\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n const selectorName: string = memberSelector.selector;\n\n let selectorItemKind: ApiItemKind;\n switch (selectorName) {\n case 'class':\n selectorItemKind = ApiItemKind.Class;\n break;\n case 'enum':\n selectorItemKind = ApiItemKind.Enum;\n break;\n case 'function':\n selectorItemKind = ApiItemKind.Function;\n break;\n case 'interface':\n selectorItemKind = ApiItemKind.Interface;\n break;\n case 'namespace':\n selectorItemKind = ApiItemKind.Namespace;\n break;\n case 'type':\n selectorItemKind = ApiItemKind.TypeAlias;\n break;\n case 'variable':\n selectorItemKind = ApiItemKind.Variable;\n break;\n default:\n result.errorMessage = `Unsupported system selector \"${selectorName}\"`;\n return result;\n }\n\n const matches: ApiItem[] = foundMembers.filter((x) => x.kind === selectorItemKind);\n if (matches.length === 0) {\n result.errorMessage =\n `A declaration for \"${identifier}\" was not found that matches the` +\n ` TSDoc selector \"${selectorName}\"`;\n return result;\n }\n if (matches.length > 1) {\n result.errorMessage = `More than one declaration \"${identifier}\" matches the TSDoc selector \"${selectorName}\"`;\n }\n result.resolvedApiItem = matches[0];\n return result;\n }\n\n private _selectUsingIndexSelector(\n foundMembers: ReadonlyArray<ApiItem>,\n memberSelector: DocMemberSelector,\n identifier: string\n ): IResolveDeclarationReferenceResult {\n const result: IResolveDeclarationReferenceResult = {\n resolvedApiItem: undefined,\n errorMessage: undefined\n };\n\n const selectedMembers: ApiItem[] = [];\n\n const selectorOverloadIndex: number = parseInt(memberSelector.selector);\n for (const foundMember of foundMembers) {\n if (ApiParameterListMixin.isBaseClassOf(foundMember)) {\n if (foundMember.overloadIndex === selectorOverloadIndex) {\n selectedMembers.push(foundMember);\n }\n }\n }\n\n if (selectedMembers.length === 0) {\n result.errorMessage =\n `An overload for ${JSON.stringify(identifier)} was not found that matches` +\n ` the TSDoc selector \":${selectorOverloadIndex}\"`;\n return result;\n }\n\n if (selectedMembers.length === 1) {\n result.resolvedApiItem = selectedMembers[0];\n return result;\n }\n\n result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`;\n return result;\n }\n}\n"]}
|
package/lib/model/Parameter.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ApiParameterListMixin } from '../mixins/ApiParameterListMixin';
|
|
|
8
8
|
export interface IParameterOptions {
|
|
9
9
|
name: string;
|
|
10
10
|
parameterTypeExcerpt: Excerpt;
|
|
11
|
+
isOptional: boolean;
|
|
11
12
|
parent: ApiParameterListMixin;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -36,6 +37,10 @@ export declare class Parameter {
|
|
|
36
37
|
* The parameter name.
|
|
37
38
|
*/
|
|
38
39
|
name: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the parameter is optional.
|
|
42
|
+
*/
|
|
43
|
+
isOptional: boolean;
|
|
39
44
|
private _parent;
|
|
40
45
|
constructor(options: IParameterOptions);
|
|
41
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parameter.d.ts","sourceRoot":"","sources":["../../src/model/Parameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACH,SAAgB,oBAAoB,EAAE,OAAO,CAAC;IAE9C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAC;IAEpB,OAAO,CAAC,OAAO,CAAwB;gBAEpB,OAAO,EAAE,iBAAiB;
|
|
1
|
+
{"version":3,"file":"Parameter.d.ts","sourceRoot":"","sources":["../../src/model/Parameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,EAAE,OAAO,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACH,SAAgB,oBAAoB,EAAE,OAAO,CAAC;IAE9C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACI,UAAU,EAAE,OAAO,CAAC;IAE3B,OAAO,CAAC,OAAO,CAAwB;gBAEpB,OAAO,EAAE,iBAAiB;IAO7C;;OAEG;IACH,IAAW,eAAe,IAAI,KAAK,CAAC,aAAa,GAAG,SAAS,CAM5D;CACF"}
|
package/lib/model/Parameter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parameter.js","sourceRoot":"","sources":["../../src/model/Parameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,kEAA+D;
|
|
1
|
+
{"version":3,"file":"Parameter.js","sourceRoot":"","sources":["../../src/model/Parameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,kEAA+D;AAe/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,SAAS;IAkBpB,YAAmB,OAA0B;QAC3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;QACzD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,eAAe;QACxB,IAAI,IAAI,CAAC,OAAO,YAAY,qCAAiB,EAAE;YAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;gBAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACtE;SACF;IACH,CAAC;CACF;AAnCD,8BAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as tsdoc from '@microsoft/tsdoc';\n\nimport { ApiDocumentedItem } from '../items/ApiDocumentedItem';\nimport { Excerpt } from '../mixins/Excerpt';\nimport { ApiParameterListMixin } from '../mixins/ApiParameterListMixin';\n\n/**\n * Constructor options for {@link Parameter}.\n * @public\n */\nexport interface IParameterOptions {\n name: string;\n parameterTypeExcerpt: Excerpt;\n isOptional: boolean;\n parent: ApiParameterListMixin;\n}\n\n/**\n * Represents a named parameter for a function-like declaration.\n *\n * @remarks\n *\n * `Parameter` represents a TypeScript declaration such as `x: number` in this example:\n *\n * ```ts\n * export function add(x: number, y: number): number {\n * return x + y;\n * }\n * ```\n *\n * `Parameter` objects belong to the {@link (ApiParameterListMixin:interface).parameters} collection.\n *\n * @public\n */\nexport class Parameter {\n /**\n * An {@link Excerpt} that describes the type of the parameter.\n */\n public readonly parameterTypeExcerpt: Excerpt;\n\n /**\n * The parameter name.\n */\n public name: string;\n\n /**\n * Whether the parameter is optional.\n */\n public isOptional: boolean;\n\n private _parent: ApiParameterListMixin;\n\n public constructor(options: IParameterOptions) {\n this.name = options.name;\n this.parameterTypeExcerpt = options.parameterTypeExcerpt;\n this.isOptional = options.isOptional;\n this._parent = options.parent;\n }\n\n /**\n * Returns the `@param` documentation for this parameter, if present.\n */\n public get tsdocParamBlock(): tsdoc.DocParamBlock | undefined {\n if (this._parent instanceof ApiDocumentedItem) {\n if (this._parent.tsdocComment) {\n return this._parent.tsdocComment.params.tryGetBlockByName(this.name);\n }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/api-extractor-model",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.16.2",
|
|
4
4
|
"description": "A helper library for loading and saving the .api.json files created by API Extractor",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/microsoft/rushstack.git",
|
|
8
|
-
"directory": "
|
|
8
|
+
"directory": "libraries/api-extractor-model"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://api-extractor.com",
|
|
11
11
|
"main": "lib/index.js",
|
|
12
12
|
"typings": "dist/rollup.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@microsoft/tsdoc": "0.
|
|
16
|
-
"@microsoft/tsdoc-config": "~0.
|
|
17
|
-
"@rushstack/node-core-library": "3.45.
|
|
15
|
+
"@microsoft/tsdoc": "0.14.1",
|
|
16
|
+
"@microsoft/tsdoc-config": "~0.16.1",
|
|
17
|
+
"@rushstack/node-core-library": "3.45.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@rushstack/eslint-config": "2.5.
|
|
21
|
-
"@rushstack/heft": "0.44.
|
|
22
|
-
"@rushstack/heft-node-rig": "1.7
|
|
20
|
+
"@rushstack/eslint-config": "2.5.3",
|
|
21
|
+
"@rushstack/heft": "0.44.9",
|
|
22
|
+
"@rushstack/heft-node-rig": "1.8.7",
|
|
23
23
|
"@types/heft-jest": "1.0.1",
|
|
24
24
|
"@types/node": "12.20.24"
|
|
25
25
|
},
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"_phase:build": "heft build --clean",
|
|
29
29
|
"_phase:test": "heft test --no-build"
|
|
30
30
|
},
|
|
31
|
-
"readme": "# @microsoft/api-extractor-model\n\nUse this library to read and write *.api.json files as defined by the [API Extractor](https://api-extractor.com/) tool.\nThese files are used to generate a documentation website for your TypeScript package. The files store the\nAPI signatures and doc comments that were extracted from your package.\n\nAPI documentation for this package: https://rushstack.io/pages/api/api-extractor-model/\n\n## Example Usage\n\nThe following code sample shows how to load `example.api.json`, which would be generated by API Extractor\nwhen it analyzes a hypothetical NPM package called `example`:\n\n```ts\nimport { ApiModel, ApiPackage } from '@microsoft/api-extractor-model';\n\nconst apiModel: ApiModel = new ApiModel();\nconst apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');\n\nfor (const member of apiPackage.members) {\n console.log(member.displayName);\n}\n```\n\nThe `ApiModel` is acts as a container for various packages that are loaded and operated on as a group.\nFor example, a documentation tool may need to resolve `@link` references across different packages.\nIn this case we would load the various packages into the `ApiModel`, and then use\nthe `ApiModel.resolveDeclarationReference()` to resolve the `@link` targets.\n\nThe data structure forms a tree of various classes that start with the `Api` prefix. The nesting hierarchy\nmight look like this:\n\n```\n- ApiModel\n - ApiPackage\n - ApiEntryPoint\n - ApiClass\n - ApiMethod\n - ApiProperty\n - ApiEnum\n - ApiEnumMember\n - ApiInterface\n - ApiMethodSignature\n - ApiPropertySignature\n - ApiNamespace\n - (ApiClass, ApiEnum, ApiInterface, ...)\n```\n\nYou can use the `ApiItem.members` property to traverse this tree.\n\nNote that the non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\nTypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\nfeatures that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\nto extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\nthe function that generates a subclass, an interface that describes the members of the subclass, and\na namespace containing static members of the class.\n\n> For a complete project that uses these APIs to generate an API reference web site,\n> see the [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter) source code.\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/
|
|
31
|
+
"readme": "# @microsoft/api-extractor-model\n\nUse this library to read and write *.api.json files as defined by the [API Extractor](https://api-extractor.com/) tool.\nThese files are used to generate a documentation website for your TypeScript package. The files store the\nAPI signatures and doc comments that were extracted from your package.\n\nAPI documentation for this package: https://rushstack.io/pages/api/api-extractor-model/\n\n## Example Usage\n\nThe following code sample shows how to load `example.api.json`, which would be generated by API Extractor\nwhen it analyzes a hypothetical NPM package called `example`:\n\n```ts\nimport { ApiModel, ApiPackage } from '@microsoft/api-extractor-model';\n\nconst apiModel: ApiModel = new ApiModel();\nconst apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');\n\nfor (const member of apiPackage.members) {\n console.log(member.displayName);\n}\n```\n\nThe `ApiModel` is acts as a container for various packages that are loaded and operated on as a group.\nFor example, a documentation tool may need to resolve `@link` references across different packages.\nIn this case we would load the various packages into the `ApiModel`, and then use\nthe `ApiModel.resolveDeclarationReference()` to resolve the `@link` targets.\n\nThe data structure forms a tree of various classes that start with the `Api` prefix. The nesting hierarchy\nmight look like this:\n\n```\n- ApiModel\n - ApiPackage\n - ApiEntryPoint\n - ApiClass\n - ApiMethod\n - ApiProperty\n - ApiEnum\n - ApiEnumMember\n - ApiInterface\n - ApiMethodSignature\n - ApiPropertySignature\n - ApiNamespace\n - (ApiClass, ApiEnum, ApiInterface, ...)\n```\n\nYou can use the `ApiItem.members` property to traverse this tree.\n\nNote that the non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\nTypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\nfeatures that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\nto extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\nthe function that generates a subclass, an interface that describes the members of the subclass, and\na namespace containing static members of the class.\n\n> For a complete project that uses these APIs to generate an API reference web site,\n> see the [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter) source code.\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/main/libraries/api-extractor-model/CHANGELOG.md) - Find\n out what's new in the latest version\n- [API Reference](https://rushstack.io/pages/api/api-extractor-model/)\n\nAPI Extractor is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
|
|
32
32
|
}
|