Socket
Socket
Sign inDemoInstall

@microsoft/api-extractor

Package Overview
Dependencies
Maintainers
2
Versions
487
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/api-extractor - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

lib/definitions/ApiModuleVariable.d.ts

12

CHANGELOG.json

@@ -5,2 +5,14 @@ {

{
"version": "2.0.6",
"tag": "@microsoft/api-extractor_v2.0.6",
"date": "Thu, 04 May 2017 01:56:35 GMT",
"comments": {
"patch": [
{
"comment": "Added support for Namespace with ApiNamespace"
}
]
}
},
{
"version": "2.0.5",

@@ -7,0 +19,0 @@ "tag": "@microsoft/api-extractor_v2.0.5",

9

CHANGELOG.md
# Change Log - @microsoft/api-extractor
This log was last generated on Sat, 22 Apr 2017 01:02:03 GMT and should not be manually modified.
This log was last generated on Thu, 04 May 2017 01:56:35 GMT and should not be manually modified.
## 2.0.6
Thu, 04 May 2017 01:56:35 GMT
### Patches
- Added support for Namespace with ApiNamespace
## 2.0.5

@@ -6,0 +13,0 @@ Sat, 22 Apr 2017 01:02:03 GMT

@@ -9,4 +9,6 @@ import ApiPackage from './definitions/ApiPackage';

import ApiMethod from './definitions/ApiMethod';
import ApiNamespace from './definitions/ApiNamespace';
import ApiParameter from './definitions/ApiParameter';
import ApiProperty from './definitions/ApiProperty';
import ApiModuleVariable from './definitions/ApiModuleVariable';
import { ApiTag } from './definitions/ApiDocumentation';

@@ -26,2 +28,4 @@ /**

protected abstract visitApiMember(apiMember: ApiMember, refObject?: Object): void;
protected abstract visitApiNamespace(apiNamespace: ApiNamespace, refObject?: Object): void;
protected abstract visitApiModuleVariable(apiModuleVariable: ApiModuleVariable, refObject?: Object): void;
protected visitApiMethod(apiMethod: ApiMethod, refObject?: Object): void;

@@ -28,0 +32,0 @@ protected visitApiProperty(apiProperty: ApiProperty, refObject?: Object): void;

@@ -9,3 +9,5 @@ "use strict";

var ApiMethod_1 = require("./definitions/ApiMethod");
var ApiNamespace_1 = require("./definitions/ApiNamespace");
var ApiProperty_1 = require("./definitions/ApiProperty");
var ApiModuleVariable_1 = require("./definitions/ApiModuleVariable");
/**

@@ -43,2 +45,8 @@ * This is a helper class that provides a standard way to walk the ApiItem

}
else if (apiItem instanceof ApiNamespace_1.default) {
this.visitApiNamespace(apiItem, refObject);
}
else if (apiItem instanceof ApiModuleVariable_1.default) {
this.visitApiModuleVariable(apiItem, refObject);
}
else {

@@ -45,0 +53,0 @@ throw new Error('Not implemented');

4

lib/DebugRun.js

@@ -17,3 +17,3 @@ // NOTE: THIS SOURCE FILE IS FOR DEBUGGING PURPOSES ONLY.

jsx: ts.JsxEmit.React,
rootDir: './testInputs/example2',
rootDir: './testInputs/example4',
typeRoots: ['./'] // We need to ignore @types in these tests

@@ -29,3 +29,3 @@ };

extractor.loadExternalPackages('./testInputs/external-api-json');
extractor.analyze({ entryPointFile: './testInputs/example2/src/index.ts',
extractor.analyze({ entryPointFile: './testInputs/example4/src/index.ts',
otherFiles: [] });

@@ -32,0 +32,0 @@ var externalPackageApiRef = {

@@ -52,2 +52,10 @@ import * as ts from 'typescript';

Constructor = 10,
/**
* A Typescript namespace.
*/
Namespace = 11,
/**
* A Typescript BlockScopedVariable.
*/
ModuleVariable = 12,
}

@@ -54,0 +62,0 @@ /**

@@ -60,2 +60,10 @@ /* tslint:disable:no-bitwise */

ApiItemKind[ApiItemKind["Constructor"] = 10] = "Constructor";
/**
* A Typescript namespace.
*/
ApiItemKind[ApiItemKind["Namespace"] = 11] = "Namespace";
/**
* A Typescript BlockScopedVariable.
*/
ApiItemKind[ApiItemKind["ModuleVariable"] = 12] = "ModuleVariable";
})(ApiItemKind = exports.ApiItemKind || (exports.ApiItemKind = {}));

@@ -62,0 +70,0 @@ /**

@@ -1,2 +0,1 @@

/// <reference types="es6-collections" />
import ApiItem, { IApiItemOptions } from './ApiItem';

@@ -8,5 +7,11 @@ /**

declare abstract class ApiItemContainer extends ApiItem {
memberItems: Map<string, ApiItem>;
private _memberItems;
constructor(options: IApiItemOptions);
/**
* Find a member in this namespace by name and return it if found.
*
* @param memberName - the name of the exported ApiItem
*/
getMemberItem(memberName: string): ApiItem;
/**
* Return a list of the child items for this container, sorted alphabetically.

@@ -13,0 +18,0 @@ */

@@ -22,6 +22,14 @@ "use strict";

var _this = _super.call(this, options) || this;
_this.memberItems = new Map();
_this._memberItems = new Map();
return _this;
}
/**
* Find a member in this namespace by name and return it if found.
*
* @param memberName - the name of the exported ApiItem
*/
ApiItemContainer.prototype.getMemberItem = function (memberName) {
return this._memberItems.get(memberName);
};
/**
* Return a list of the child items for this container, sorted alphabetically.

@@ -31,3 +39,3 @@ */

var apiItems = [];
this.memberItems.forEach(function (apiItem) {
this._memberItems.forEach(function (apiItem) {
apiItems.push(apiItem);

@@ -47,3 +55,3 @@ });

this.innerItems.push(apiItem);
this.memberItems.set(apiItem.name, apiItem);
this._memberItems.set(apiItem.name, apiItem);
}

@@ -56,3 +64,3 @@ };

_super.prototype.visitTypeReferencesForApiItem.call(this);
this.memberItems.forEach(function (apiItem) {
this._memberItems.forEach(function (apiItem) {
apiItem.visitTypeReferencesForApiItem();

@@ -59,0 +67,0 @@ });

import * as ts from 'typescript';
import Extractor from '../Extractor';
import ApiItem from './ApiItem';
import ApiItemContainer from './ApiItemContainer';

@@ -25,9 +24,3 @@ /**

tryGetExportedSymbolName(symbol: ts.Symbol): string;
/**
* Find a member in this package by name and return it if found.
*
* @param memberName - the name of the member ApiItem
*/
getMemberItem(memberName: string): ApiItem;
shouldHaveDocumentation(): boolean;
}

@@ -20,2 +20,3 @@ /* tslint:disable:no-bitwise */

var ApiItemContainer_1 = require("./ApiItemContainer");
var ApiNamespace_1 = require("./ApiNamespace");
var TypeScriptHelpers_1 = require("../TypeScriptHelpers");

@@ -56,2 +57,5 @@ var PackageJsonHelpers_1 = require("../PackageJsonHelpers");

}
else if (followedSymbol.flags & ts.SymbolFlags.ValueModule) {
_this.addMemberItem(new ApiNamespace_1.default(options));
}
else if (followedSymbol.flags & ts.SymbolFlags.Function) {

@@ -119,13 +123,2 @@ _this.addMemberItem(new ApiFunction_1.default(options));

};
/**
* Find a member in this package by name and return it if found.
*
* @param memberName - the name of the member ApiItem
*/
ApiPackage.prototype.getMemberItem = function (memberName) {
if (this.memberItems.has(memberName)) {
return this.memberItems.get(memberName);
}
return undefined;
};
ApiPackage.prototype.shouldHaveDocumentation = function () {

@@ -132,0 +125,0 @@ // We don't write JSDoc for the ApiPackage object

@@ -93,3 +93,3 @@ /* tslint:disable:no-bitwise */

_this._setterNames.forEach(function (setterName) {
if (!_this.memberItems.has(setterName)) {
if (!_this.getMemberItem(setterName)) {
_this.reportError("Found setter named " + setterName + " with no corresponding getter. WriteOnly properties are prohibited.");

@@ -96,0 +96,0 @@ }

@@ -63,3 +63,3 @@ "use strict";

// get() returns undefined if there is no match
apiItem = apiItemContainer.memberItems.get(apiDefinitionRef.memberName);
apiItem = apiItemContainer.getMemberItem(apiDefinitionRef.memberName);
}

@@ -66,0 +66,0 @@ else {

@@ -22,2 +22,19 @@ // @public

// WARNING: Export "complexType1" must specify and be of type"string", "number" or "boolean"
// WARNING: Export "missingType" must specify and be of type"string", "number" or "boolean"
// WARNING: Export "propTwo" is missing the "const" modifier. Currently the "namespace" block only supports constant variables.
// WARNING: Unsupported export "ClassesNotAllowed" Currently the "namespace" block only supports constant variables.
// WARNING: Unsupported export "InterfacesNotAllowed" Currently the "namespace" block only supports constant variables.
// WARNING: Unsupported export "aFunctionNotAllowed" Currently the "namespace" block only supports constant variables.
// @public
module NamespaceExport {
// (undocumented)
booleanConstant1: boolean = true;
numberConstant1: number = 24;
stringConstant1: string = '\uED68';
}
// (No packageDescription for this package)

@@ -10,2 +10,4 @@ import Extractor from '../Extractor';

import ApiMember from '../definitions/ApiMember';
import ApiNamespace from '../definitions/ApiNamespace';
import ApiModuleVariable from '../definitions/ApiModuleVariable';
import IndentedWriter from '../IndentedWriter';

@@ -49,2 +51,4 @@ /**

protected visitApiPackage(apiPackage: ApiPackage): void;
protected visitApiNamespace(apiNamespace: ApiNamespace): void;
protected visitApiModuleVariable(apiModuleVariable: ApiModuleVariable): void;
protected visitApiMember(apiMember: ApiMember): void;

@@ -51,0 +55,0 @@ protected visitApiFunction(apiFunction: ApiFunction): void;

@@ -118,2 +118,22 @@ "use strict";

};
ApiFileGenerator.prototype.visitApiNamespace = function (apiNamespace) {
var _this = this;
this._writeJsdocSynopsis(apiNamespace);
// We have decided to call the apiNamespace a 'module' in our
// public API documentation.
this._indentedWriter.writeLine("module " + apiNamespace.name + " {");
this._indentedWriter.indentScope(function () {
for (var _i = 0, _a = apiNamespace.getSortedMemberItems(); _i < _a.length; _i++) {
var apiItem = _a[_i];
_this.visit(apiItem);
_this._indentedWriter.writeLine();
_this._indentedWriter.writeLine();
}
});
this._indentedWriter.write('}');
};
ApiFileGenerator.prototype.visitApiModuleVariable = function (apiModuleVariable) {
this._writeJsdocSynopsis(apiModuleVariable);
this._indentedWriter.write(apiModuleVariable.name + ": " + apiModuleVariable.type + " = " + apiModuleVariable.value + ";");
};
ApiFileGenerator.prototype.visitApiMember = function (apiMember) {

@@ -120,0 +140,0 @@ if (apiMember.documentation) {

@@ -16,2 +16,4 @@ import { ApiItemKind } from '../definitions/ApiItem';

private static _KIND_METHOD;
private static _KIND_NAMESPACE;
private static _KIND_MODULEVARIABLE;
/**

@@ -18,0 +20,0 @@ * Uses the lowercase string that represents 'kind' in an API JSON file, and

@@ -38,2 +38,6 @@ "use strict";

return ApiItem_1.ApiItemKind.Method;
case (this._KIND_NAMESPACE):
return ApiItem_1.ApiItemKind.Namespace;
case (this._KIND_MODULEVARIABLE):
return ApiItem_1.ApiItemKind.ModuleVariable;
default:

@@ -66,2 +70,6 @@ throw new Error('Unsupported kind when converting JSON item kind to API item kind.');

return this._KIND_METHOD;
case (ApiItem_1.ApiItemKind.Namespace):
return this._KIND_NAMESPACE;
case (ApiItem_1.ApiItemKind.ModuleVariable):
return this._KIND_MODULEVARIABLE;
default:

@@ -82,4 +90,6 @@ throw new Error('Unsupported API item kind when converting to string used in API JSON file.');

ApiJsonFile._KIND_METHOD = 'method';
ApiJsonFile._KIND_NAMESPACE = 'namespace';
ApiJsonFile._KIND_MODULEVARIABLE = 'module variable';
exports.default = ApiJsonFile;
//# sourceMappingURL=ApiJsonFile.js.map

@@ -11,2 +11,4 @@ import Extractor from '../Extractor';

import ApiMember from '../definitions/ApiMember';
import ApiNamespace from '../definitions/ApiNamespace';
import ApiModuleVariable from '../definitions/ApiModuleVariable';
import ApiMethod from '../definitions/ApiMethod';

@@ -35,6 +37,8 @@ import { ApiTag } from '../definitions/ApiDocumentation';

protected visitApiPackage(apiPackage: ApiPackage, refObject?: Object): void;
protected visitApiNamespace(apiNamespace: ApiNamespace, refObject?: Object): void;
protected visitApiMember(apiMember: ApiMember, refObject?: Object): void;
protected visitApiProperty(apiProperty: ApiProperty, refObject?: Object): void;
protected visitApiModuleVariable(apiModuleVariable: ApiModuleVariable, refObject?: Object): void;
protected visitApiMethod(apiMethod: ApiMethod, refObject?: Object): void;
protected visitApiParam(apiParam: ApiParameter, refObject?: Object): void;
}

@@ -159,2 +159,21 @@ "use strict";

};
ApiJsonGenerator.prototype.visitApiNamespace = function (apiNamespace, refObject) {
if (!apiNamespace.supportedName) {
return;
}
var membersNode = {};
for (var _i = 0, _a = apiNamespace.getSortedMemberItems(); _i < _a.length; _i++) {
var apiItem = _a[_i];
this.visit(apiItem, membersNode);
}
var newNode = {
kind: ApiJsonFile_1.default.convertKindToJson(apiNamespace.kind),
deprecatedMessage: apiNamespace.documentation.deprecatedMessage || [],
summary: apiNamespace.documentation.summary || [],
remarks: apiNamespace.documentation.remarks || [],
isBeta: apiNamespace.documentation.apiTag === ApiDocumentation_1.ApiTag.Beta,
exports: membersNode
};
refObject[apiNamespace.name] = newNode;
};
ApiJsonGenerator.prototype.visitApiMember = function (apiMember, refObject) {

@@ -186,2 +205,14 @@ if (!apiMember.supportedName) {

};
ApiJsonGenerator.prototype.visitApiModuleVariable = function (apiModuleVariable, refObject) {
var newNode = {
kind: ApiJsonFile_1.default.convertKindToJson(apiModuleVariable.kind),
type: apiModuleVariable.type,
value: apiModuleVariable.value,
deprecatedMessage: apiModuleVariable.documentation.deprecatedMessage || [],
summary: apiModuleVariable.documentation.summary || [],
remarks: apiModuleVariable.documentation.remarks || [],
isBeta: apiModuleVariable.documentation.apiTag === ApiDocumentation_1.ApiTag.Beta
};
refObject[apiModuleVariable.name] = newNode;
};
ApiJsonGenerator.prototype.visitApiMethod = function (apiMethod, refObject) {

@@ -188,0 +219,0 @@ if (!apiMethod.supportedName) {

@@ -40,2 +40,25 @@ /// <reference types="mocha" />

});
it('Example 4', function () {
var inputFolder = './testInputs/example4';
var outputFile = './lib/example4-output.json';
var expectedFile = path.join(inputFolder, 'example4-output.json');
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder,
typeRoots: ['./'] // We need to ignore @types in these tests
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
extractor.loadExternalPackages('./testInputs/external-api-json');
extractor.analyze({
entryPointFile: path.join(inputFolder, 'src/index.ts')
});
var apiJsonGenerator = new ApiJsonGenerator_1.default();
apiJsonGenerator.writeJsonFile(outputFile, extractor);
TestFileComparer_1.default.assertFileMatchesExpected(outputFile, expectedFile);
});
});

@@ -42,0 +65,0 @@ });

@@ -30,2 +30,3 @@ /* tslint:disable:no-bitwise */

}
console.log("" + indent + kindName + ": [" + trimmedText + "]");
try {

@@ -32,0 +33,0 @@ for (var _i = 0, _a = node.getChildren(); _i < _a.length; _i++) {

@@ -230,2 +230,41 @@ {

//---------------------------------------------------------------------------------------------
"moduleVariableApiItem": {
"description": "A TypeScript BlockScopedVariable",
"type": "object",
"properties": {
"kind": {
"description": "The kind of API definition",
"type": "string",
"enum": [ "module variable" ]
},
"type": {
"description": "The data type of this module variable",
"type": "string"
},
"value": {
"description": "The value of this module variable",
"type": "string"
},
"summary": {
"$ref": "#/definitions/docElementCollection"
},
"isBeta": {
"description": "Whether the API method is beta",
"type": "boolean"
},
// Optional properties:
"remarks": {
"$ref": "#/definitions/docElementCollection"
},
"deprecatedMessage": {
"$ref": "#/definitions/docElementCollection"
}
},
"additionalProperties": false,
"required": [ "kind", "type", "value", "summary", "isBeta"]
},
//---------------------------------------------------------------------------------------------
"methodApiItem": {

@@ -574,2 +613,44 @@ "description": "A member function of a TypeScript class or interface",

"required": [ "kind", "summary", "isBeta" ]
},
//---------------------------------------------------------------------------------------------
"namespaceApiItem": {
"description": "A TypeScript namespace definition",
"type": "object",
"properties": {
"kind": {
"description": "The kind of API definition",
"type": "string",
"enum": [ "namespace" ]
},
"summary": {
"$ref": "#/definitions/docElementCollection"
},
"exports": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_]+[a-zA-Z_0-9]*$": {
"oneOf": [
{ "$ref": "#/definitions/moduleVariableApiItem" }
]
}
},
"additionalProperties": false
},
"isBeta": {
"description": "Whether the API interface is beta",
"type": "boolean"
},
// Optional properties:
"remarks": {
"$ref": "#/definitions/docElementCollection"
},
"deprecatedMessage": {
"$ref": "#/definitions/docElementCollection"
}
},
"additionalProperties": false,
"required": [ "kind", "exports", "summary", "isBeta" ]
}

@@ -607,2 +688,3 @@ },

{ "$ref": "#/definitions/interfaceApiItem" },
{ "$ref": "#/definitions/namespaceApiItem" },
{ "$ref": "#/definitions/enumApiItem" },

@@ -609,0 +691,0 @@ { "$ref": "#/definitions/functionApiItem" }

{
"name": "@microsoft/api-extractor",
"version": "2.0.5",
"version": "2.0.6",
"description": "Validatation, documentation, and auditing for the exported API of a TypeScript package",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc