From 5380cf2a252452830789e2951fe2ee4ef791d5d1 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Wed, 5 Dec 2018 11:15:50 +0100 Subject: [PATCH 001/139] Copy mongoose-paginate declaration to mongoose-paginate-v2. --- types/mongoose-paginate-v2/index.d.ts | 51 ++++++++++++ .../mongoose-paginate-tests.ts | 71 +++++++++++++++++ types/mongoose-paginate-v2/tsconfig.json | 23 ++++++ types/mongoose-paginate-v2/tslint.json | 79 +++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 types/mongoose-paginate-v2/index.d.ts create mode 100644 types/mongoose-paginate-v2/mongoose-paginate-tests.ts create mode 100644 types/mongoose-paginate-v2/tsconfig.json create mode 100644 types/mongoose-paginate-v2/tslint.json diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts new file mode 100644 index 0000000000..ad54786f53 --- /dev/null +++ b/types/mongoose-paginate-v2/index.d.ts @@ -0,0 +1,51 @@ +// Type definitions for mongoose-paginate 5.0.0 +// Project: https://github.com/edwardhotchkiss/mongoose-paginate +// Definitions by: Linus Brolin , simonxca +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare module 'mongoose' { + export interface PaginateOptions { + select?: Object | string; + sort?: Object | string; + populate?: Array | Array | Object | string; + lean?: boolean; + leanWithId?: boolean; + offset?: number; + page?: number; + limit?: number; + } + + export interface PaginateResult { + docs: Array; + total: number; + limit: number; + page?: number; + pages?: number; + offset?: number; + } + + interface PaginateModel extends Model { + paginate(query?: Object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; + } + + export function model( + name: string, + schema?: Schema, + collection?: string, + skipInit?: boolean): PaginateModel; + + export function model>( + name: string, + schema?: Schema, + collection?: string, + skipInit?: boolean): U; +} + +declare module 'mongoose-paginate' { + import mongoose = require('mongoose'); + var _: (schema: mongoose.Schema) => void; + export = _; +} diff --git a/types/mongoose-paginate-v2/mongoose-paginate-tests.ts b/types/mongoose-paginate-v2/mongoose-paginate-tests.ts new file mode 100644 index 0000000000..d55f8a454e --- /dev/null +++ b/types/mongoose-paginate-v2/mongoose-paginate-tests.ts @@ -0,0 +1,71 @@ +/** + * Created by Linus Brolin . + */ + +import { + Schema, + model, + PaginateModel, + PaginateOptions, + PaginateResult, + Document +} from 'mongoose'; +import mongoosePaginate = require('mongoose-paginate'); +import { Router, Request, Response } from 'express'; + + +//#region Test Models +interface User extends Document { + email: string; + username: string; + password: string; +} + +const UserSchema: Schema = new Schema({ + email: String, + username: String, + password: String +}); + +UserSchema.plugin(mongoosePaginate); + +interface UserModel extends PaginateModel {}; + +let UserModel: UserModel = model('User', UserSchema) as UserModel; +//#endregion + + +//#region Test Paginate +let router: Router = Router(); + +router.get('/users.json', function(req: Request, res: Response) { + let descending: boolean = true; + let options: PaginateOptions = {} as PaginateOptions; + options.select = 'email username'; + options.sort = { 'username': (descending ? -1 : 1) }; + options.populate = ''; + options.lean = true; + options.leanWithId = false; + options.offset = 0; + options.page = 1; + options.limit = 10; + + UserModel + .paginate({}, options, (err: any, value: PaginateResult) => { + if (err) { + console.log(err); + return res.status(500).send(err); + } + + console.log('total: ' + value.total); + console.log('limit: ' + value.limit); + console.log('page: ' + value.page); + console.log('pages: ' + value.pages); + console.log('offset: ' + value.offset); + console.log('docs: '); + console.dir(value.docs); + return res.json(value); + }); + +}); +//#endregion diff --git a/types/mongoose-paginate-v2/tsconfig.json b/types/mongoose-paginate-v2/tsconfig.json new file mode 100644 index 0000000000..3194368f11 --- /dev/null +++ b/types/mongoose-paginate-v2/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mongoose-paginate-tests.ts" + ] +} \ No newline at end of file diff --git a/types/mongoose-paginate-v2/tslint.json b/types/mongoose-paginate-v2/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/mongoose-paginate-v2/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From ad776bc550c59a14f387157c2ea1dc733790fe49 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Wed, 5 Dec 2018 11:40:07 +0100 Subject: [PATCH 002/139] Update declarations to correspond with mongoose-paginate-v2 module. --- types/mongoose-paginate-v2/index.d.ts | 23 ++++++++++++++++--- ...tests.ts => mongoose-paginate-v2-tests.ts} | 22 ++++++++++++++---- types/mongoose-paginate-v2/tsconfig.json | 4 ++-- 3 files changed, 39 insertions(+), 10 deletions(-) rename types/mongoose-paginate-v2/{mongoose-paginate-tests.ts => mongoose-paginate-v2-tests.ts} (68%) diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index ad54786f53..6c9103f852 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -1,15 +1,31 @@ -// Type definitions for mongoose-paginate 5.0.0 +// Type definitions for mongoose-paginate-v2 1.0.13 // Project: https://github.com/edwardhotchkiss/mongoose-paginate -// Definitions by: Linus Brolin , simonxca +// Definitions by: Linus Brolin +// simonxca +// woutgg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +// +// Based on type declarations for mongoose-paginate 5.0.0. /// declare module 'mongoose' { + export interface CustomLabels { + totalDocs?: string, + limit?: string, + page?: string, + totalPages?: string, + docs?: string, + nextPage?: string, + prevPage?: string, + } + export interface PaginateOptions { select?: Object | string; sort?: Object | string; + customLabels?: CustomLabels, + collation?: CollationOptions, populate?: Array | Array | Object | string; lean?: boolean; leanWithId?: boolean; @@ -25,6 +41,7 @@ declare module 'mongoose' { page?: number; pages?: number; offset?: number; + [customLabel: string]: Array | number | undefined; } interface PaginateModel extends Model { @@ -44,7 +61,7 @@ declare module 'mongoose' { skipInit?: boolean): U; } -declare module 'mongoose-paginate' { +declare module 'mongoose-paginate-v2' { import mongoose = require('mongoose'); var _: (schema: mongoose.Schema) => void; export = _; diff --git a/types/mongoose-paginate-v2/mongoose-paginate-tests.ts b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts similarity index 68% rename from types/mongoose-paginate-v2/mongoose-paginate-tests.ts rename to types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts index d55f8a454e..8410c740e5 100644 --- a/types/mongoose-paginate-v2/mongoose-paginate-tests.ts +++ b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts @@ -43,12 +43,22 @@ router.get('/users.json', function(req: Request, res: Response) { let options: PaginateOptions = {} as PaginateOptions; options.select = 'email username'; options.sort = { 'username': (descending ? -1 : 1) }; + options.collation = { locale: 'en_US', strength: 1 }; options.populate = ''; options.lean = true; options.leanWithId = false; options.offset = 0; options.page = 1; options.limit = 10; + options.customLabels = { + totalDocs: 'totalDocsCustom', + limit: 'limitCustom', + page: 'pageCustom', + totalPages: 'totalPagesCustom', + docs: 'docsCustom', + nextPage: 'nextPageCustom', + prevPage: 'prevPageCustom' + }; UserModel .paginate({}, options, (err: any, value: PaginateResult) => { @@ -57,13 +67,15 @@ router.get('/users.json', function(req: Request, res: Response) { return res.status(500).send(err); } - console.log('total: ' + value.total); - console.log('limit: ' + value.limit); - console.log('page: ' + value.page); - console.log('pages: ' + value.pages); + console.log('totalDocs: ' + value.totalDocsCustom); + console.log('limit: ' + value.limitCustom); + console.log('page: ' + value.pageCustom); + console.log('nextPage: ' + value.nextPageCustom); + console.log('prevPage: ' + value.prevPageCustom); + console.log('totalPages: ' + value.totalPagesCustom); console.log('offset: ' + value.offset); console.log('docs: '); - console.dir(value.docs); + console.dir(value.docsCustom); return res.json(value); }); diff --git a/types/mongoose-paginate-v2/tsconfig.json b/types/mongoose-paginate-v2/tsconfig.json index 3194368f11..1e367240a9 100644 --- a/types/mongoose-paginate-v2/tsconfig.json +++ b/types/mongoose-paginate-v2/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "mongoose-paginate-tests.ts" + "mongoose-paginate-v2-tests.ts" ] -} \ No newline at end of file +} From ef1ca953366b7decc3f553fc83afdd6cf72ae492 Mon Sep 17 00:00:00 2001 From: Tim Griesser Date: Tue, 11 Dec 2018 17:06:37 -0500 Subject: [PATCH 003/139] Remove global Express.Request.user declaration This should be defined by the consumer based on what they know the type might be, rather than by the type definitions --- types/express-jwt/index.d.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/types/express-jwt/index.d.ts b/types/express-jwt/index.d.ts index 1187f4fbca..d1029849cc 100644 --- a/types/express-jwt/index.d.ts +++ b/types/express-jwt/index.d.ts @@ -58,10 +58,3 @@ declare namespace jwt { constructor(code: ErrorCode, error: { message: string }); } } -declare global { - namespace Express { - export interface Request { - user?: any - } - } -} From b8afa6b51d275d3902b34aa2fcc66c4fb87cbdb6 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Tue, 18 Dec 2018 07:57:24 +0100 Subject: [PATCH 004/139] Fix project URL. --- types/mongoose-paginate-v2/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index 6c9103f852..242cbdcd9a 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for mongoose-paginate-v2 1.0.13 -// Project: https://github.com/edwardhotchkiss/mongoose-paginate +// Project: https://github.com/aravindnc/mongoose-paginate-v2 // Definitions by: Linus Brolin // simonxca // woutgg From a623516aa78e67b507e5135869f4404bd9f91ef6 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Mon, 24 Dec 2018 12:39:12 +0100 Subject: [PATCH 005/139] Remove model type parameter and overload. --- types/mongoose-paginate-v2/index.d.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index 242cbdcd9a..3c178c5908 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -48,17 +48,11 @@ declare module 'mongoose' { paginate(query?: Object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; } - export function model( + export function model( name: string, schema?: Schema, collection?: string, - skipInit?: boolean): PaginateModel; - - export function model>( - name: string, - schema?: Schema, - collection?: string, - skipInit?: boolean): U; + skipInit?: boolean): PaginateModel; } declare module 'mongoose-paginate-v2' { From e94a58fba1849dcc033ab433a4f213258a95651f Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Wed, 26 Dec 2018 15:30:12 +0100 Subject: [PATCH 006/139] GAS "December 13, 2018" update --- .../google-apps-script.base.d.ts | 18 +- .../google-apps-script.card-service.d.ts | 753 ++++++++++++++++++ .../google-apps-script.charts.d.ts | 18 +- .../google-apps-script.data-studio.d.ts | 301 +++++++ .../google-apps-script.forms.d.ts | 7 +- .../google-apps-script.gmail.d.ts | 3 +- .../google-apps-script.groups.d.ts | 8 +- .../google-apps-script.script.d.ts | 6 +- .../google-apps-script.slides.d.ts | 97 ++- .../google-apps-script.spreadsheet.d.ts | 135 +++- .../google-apps-script.utilities.d.ts | 15 +- 11 files changed, 1320 insertions(+), 41 deletions(-) create mode 100644 types/google-apps-script/google-apps-script.card-service.d.ts create mode 100644 types/google-apps-script/google-apps-script.data-studio.d.ts diff --git a/types/google-apps-script/google-apps-script.base.d.ts b/types/google-apps-script/google-apps-script.base.d.ts index 7558263306..0b5236af0f 100644 --- a/types/google-apps-script/google-apps-script.base.d.ts +++ b/types/google-apps-script/google-apps-script.base.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ declare namespace GoogleAppsScript { export module Base { - /** + /** * A data interchange object for Apps Script services. */ export interface Blob { @@ -74,9 +74,10 @@ declare namespace GoogleAppsScript { } /** - * This class provides access to G Suite specific dialog boxes. + * This class provides access to dialog boxes specific to Google Sheets. * * The methods in this class are only available for use in the context of a Google Spreadsheet. + * Please use G Suite dialogs instead. * See also * * ButtonSet @@ -163,9 +164,9 @@ declare namespace GoogleAppsScript { /** * An enumeration that provides access to MIME-type declarations without typing the strings - * explicitly. Any method that expects a MIME type rendered as a string (for example, - * 'image/png') will also accept one of the values below, so long as the method - * supports the underlying MIME type. + * explicitly. Methods that expect a MIME type rendered as a string (for example, + * 'image/png') also accept any of the values below, so long as the method supports the + * underlying MIME type. * * // Use MimeType enum to log the name of every Google Doc in the user's Drive. * var docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS); @@ -305,11 +306,15 @@ declare namespace GoogleAppsScript { * } */ export interface console { + error(): void; error(formatOrObject: Object, ...values: Object[]): void; + info(): void; info(formatOrObject: Object, ...values: Object[]): void; + log(): void; log(formatOrObject: Object, ...values: Object[]): void; time(label: string): void; timeEnd(label: string): void; + warn(): void; warn(formatOrObject: Object, ...values: Object[]): void; } @@ -321,3 +326,4 @@ declare var Logger: GoogleAppsScript.Base.Logger; // conflicts with MimeType in lib.d.ts // declare var MimeType: GoogleAppsScript.Base.MimeType; declare var Session: GoogleAppsScript.Base.Session; +declare var console: GoogleAppsScript.Base.console; diff --git a/types/google-apps-script/google-apps-script.card-service.d.ts b/types/google-apps-script/google-apps-script.card-service.d.ts new file mode 100644 index 0000000000..64f5194595 --- /dev/null +++ b/types/google-apps-script/google-apps-script.card-service.d.ts @@ -0,0 +1,753 @@ +// Type definitions for Google Apps Script 2018-12-26 +// Project: https://developers.google.com/apps-script/ +// Definitions by: motemen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare namespace GoogleAppsScript { + export module Card_Service { + /** + * An action that enables interactivity within UI elements. The action does not happen directly on + * the client but rather invokes an Apps Script callback function with optional parameters. + * + * var image = CardService.newImage() + * .setOnClickAction(CardService.newAction() + * .setFunctionName("handleImageClick") + * .setParameters({imageSrc: 'carImage'})); + */ + export interface Action { + setFunctionName(functionName: string): Action; + setLoadIndicator(loadIndicator: LoadIndicator): Action; + setParameters(parameters: Object): Action; + setMethodName(functionName: string): Action; + } + + /** + * The response object that may be returned from a callback function (e.g., a form response handler) + * to perform one or more actions on the client. Some combinations of actions are not supported. + * + * // An action that opens a link + * var actionResponse = CardService.newActionResponseBuilder() + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://www.google.com")) + * .build(); + * + * // An action that shows a notification. + * var actionResponse = CardService.newActionResponseBuilder() + * .setNotification(CardService.newNotification() + * .setType(CardService.NotificationType.INFO) + * .setText("Some info to display to user")) + * .build(); + * + * // An action that shows an additional card. It also sets a flag to indicate that the original + * // state data has changed. + * + * var cardBuilder = CardService.newCardBuilder(); + * // Build card ... + * var actionResponse = CardService.newActionResponseBuilder() + * .setNavigation(CardService.newNavigation() + * .pushCard(cardBuilder.build())) + * .setStateChanged(true) + * .build(); + */ + export interface ActionResponse { + printJson(): string; + } + + /** + * A builder for ActionResponse objects. + */ + export interface ActionResponseBuilder { + build(): ActionResponse; + setNavigation(navigation: Navigation): ActionResponseBuilder; + setNotification(notification: Notification): ActionResponseBuilder; + setOpenLink(openLink: OpenLink): ActionResponseBuilder; + setStateChanged(stateChanged: boolean): ActionResponseBuilder; + } + + /** + * An authorization action that will send the user to the AuthorizationUrl when clicked. + * + * CardService.newAuthorizationAction() + * .setAuthorizationUrl("http://google.com/"); + */ + export interface AuthorizationAction { + setAuthorizationUrl(authorizationUrl: string): AuthorizationAction; + } + + /** + * An error that can be returned to trigger an authorization card to be shown to the user. + * + * CardService.newAuthorizationException() + * .setAuthorizationUrl("http://auth.com/") + * .setResourceDisplayName("Example Resource") + * .throwException(); + */ + export interface AuthorizationException { + printJson(): string; + setAuthorizationUrl(authUrl: string): AuthorizationException; + setCustomUiCallback(callback: string): AuthorizationException; + setResourceDisplayName(name: string): AuthorizationException; + throwException(): void; + } + + /** + * A base class for all buttons. + */ + export interface Button { + setAuthorizationAction(action: AuthorizationAction): Button; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): Button; + setOnClickAction(action: Action): Button; + setOnClickOpenLinkAction(action: Action): Button; + setOpenLink(openLink: OpenLink): Button; + } + + /** + * Holds a set of Button objects that are displayed in a row. + * + * var textButton = CardService.newTextButton(); + * // Finish building the text button... + * + * var imageButton = CardService.newImageButton(); + * // Finish building the image button... + * + * var buttonSet = CardService.newButtonSet() + * .addButton(textButton) + * .addButton(imageButton); + */ + export interface ButtonSet { + addButton(button: Button): ButtonSet; + } + + /** + * A context card that represents a single view in the + * UI. + * + * var cardSection = CardService.newCardSection(); + * // Finish building the card section ... + * + * var card = CardService.newCardBuilder() + * .setName("Card name") + * .setHeader(CardService.newCardHeader().setTitle("Card title")) + * .addSection(cardSection) + * .build(); + */ + export interface Card { + printJson(): string; + } + + /** + * A clickable menu item that is added to the card header menu. + * + * var action = CardService.newAction(); + * // Finish building the action... + * + * var cardAction = CardService.newCardAction() + * .setText("Card action") + * .setOnClickAction(action); + */ + export interface CardAction { + setAuthorizationAction(action: AuthorizationAction): CardAction; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): CardAction; + setOnClickAction(action: Action): CardAction; + setOnClickOpenLinkAction(action: Action): CardAction; + setOpenLink(openLink: OpenLink): CardAction; + setText(text: string): CardAction; + } + + /** + * A builder for Card objects. + */ + export interface CardBuilder { + addCardAction(cardAction: CardAction): CardBuilder; + addSection(section: CardSection): CardBuilder; + build(): Card; + setHeader(cardHeader: CardHeader): CardBuilder; + setName(name: string): CardBuilder; + } + + /** + * The header of a Card. + * + * var cardHeader = CardService.newCardHeader() + * .setTitle("Card header title") + * .setSubtitle("Card header subtitle") + * .setImageStyle(CardService.ImageStyle.CIRCLE) + * .setImageUrl("https://image.png"); + */ + export interface CardHeader { + setImageAltText(imageAltText: string): CardHeader; + setImageStyle(imageStyle: ImageStyle): CardHeader; + setImageUrl(imageUrl: string): CardHeader; + setSubtitle(subtitle: string): CardHeader; + setTitle(title: string): CardHeader; + } + + /** + * A card section holds groups of widgets and provides visual separation between them. + * + * var image = CardService.newImage(); + * // Build image ... + * var textParagraph = CardService.newTextParagraph(); + * // Build text paragraph ... + * + * var cardSection = CardService.newCardSection() + * .setHeader("Section header") + * .addWidget(image) + * .addWidget(textParagraph); + */ + export interface CardSection { + addWidget(widget: Widget): CardSection; + setCollapsible(collapsible: boolean): CardSection; + setHeader(header: string): CardSection; + setNumUncollapsibleWidgets(numUncollapsibleWidgets: Integer): CardSection; + } + + /** + * CardService provides the ability to create generic cards used across different Google + * extensibility products, such as Gmail add-ons. + * + * Currently you can only use this service to construct Gmail add-ons. + * + * return CardService.newCardBuilder() + * .setHeader(CardService.newCardHeader().setTitle("CardTitle")) + * .build(); + * + * Or you can return multiple Cards like so: + * + * return [ + * CardService.newCardBuilder().build(), + * CardService.newCardBuilder().build(), + * CardService.newCardBuilder().build() + * ] + * + * The following shows how you could define a card with a header, text, an image and a menu item: + * + * function createWidgetDemoCard() { + * return CardService + * .newCardBuilder() + * .setHeader( + * CardService.newCardHeader() + * .setTitle('Widget demonstration') + * .setSubtitle('Check out these widgets') + * .setImageStyle(CardService.ImageStyle.SQUARE) + * .setImageUrl( + * 'https://www.example.com/images/headerImage.png')) + * .addSection( + * CardService.newCardSection() + * .setHeader('Simple widgets') // optional + * .addWidget(CardService.newTextParagraph().setText( + * 'These widgets are display-only. ' + + * 'A text paragraph can have multiple lines and ' + + * 'formatting.')) + * .addWidget(CardService.newImage().setImageUrl( + * 'https://www.example.com/images/mapsImage.png'))) + * .addCardAction(CardService.newCardAction().setText('Gmail').setOpenLink( + * CardService.newOpenLink().setUrl('https://mail.google.com/mail'))) + * .build(); + * } + */ + export interface CardService { + ComposedEmailType: typeof ComposedEmailType; + ContentType: typeof ContentType; + Icon: typeof Icon; + ImageStyle: typeof ImageStyle; + LoadIndicator: typeof LoadIndicator; + NotificationType: typeof NotificationType; + OnClose: typeof OnClose; + OpenAs: typeof OpenAs; + SelectionInputType: typeof SelectionInputType; + TextButtonStyle: typeof TextButtonStyle; + UpdateDraftBodyType: typeof UpdateDraftBodyType; + newAction(): Action; + newActionResponseBuilder(): ActionResponseBuilder; + newAuthorizationAction(): AuthorizationAction; + newAuthorizationException(): AuthorizationException; + newButtonSet(): ButtonSet; + newCardAction(): CardAction; + newCardBuilder(): CardBuilder; + newCardHeader(): CardHeader; + newCardSection(): CardSection; + newComposeActionResponseBuilder(): ComposeActionResponseBuilder; + newImage(): Image; + newImageButton(): ImageButton; + newKeyValue(): KeyValue; + newNavigation(): Navigation; + newNotification(): Notification; + newOpenLink(): OpenLink; + newSelectionInput(): SelectionInput; + newSuggestions(): Suggestions; + newSuggestionsResponseBuilder(): SuggestionsResponseBuilder; + newSwitch(): Switch; + newTextButton(): TextButton; + newTextInput(): TextInput; + newTextParagraph(): TextParagraph; + newUniversalActionResponseBuilder(): UniversalActionResponseBuilder; + newUpdateDraftActionResponseBuilder(): UpdateDraftActionResponseBuilder; + newUpdateDraftBodyAction(): UpdateDraftBodyAction; + } + + /** + * The response object that may be returned from a callback method for compose action in a Gmail add-on. + * + * Note: This object isn't related to compose actions that are + * used to extend the compose UI. Rather, + * this object is a response to an Action that composes draft messages when a specific UI element is + * selected. + * + * var composeActionResponse = CardService.newComposeActionResponseBuilder() + * .setGmailDraft(GmailApp.createDraft("recipient", "subject", "body")) + * .build(); + */ + export interface ComposeActionResponse { + printJson(): string; + } + + /** + * A builder for ComposeActionResponse objects. + * + * Note: This object isn't related to compose actions that are + * used to extend the compose UI. Rather, + * this builder creates responses to an Action that composes draft messages when a specific + * UI element is selected. + */ + export interface ComposeActionResponseBuilder { + build(): ComposeActionResponse; + setGmailDraft(draft: Gmail.GmailDraft): ComposeActionResponseBuilder; + } + + /** + * An enum value that specifies whether the composed email is a standalone or reply draft. + */ + export enum ComposedEmailType { REPLY_AS_DRAFT, STANDALONE_DRAFT } + + /** + * An enum value that specifies the content type of the content generated by a UpdateDraftActionResponse. + */ + export enum ContentType { TEXT, MUTABLE_HTML, IMMUTABLE_HTML } + + /** + * Predefined icons that can be used in various UI objects, such as ImageButton or KeyValue widgets. + */ + export enum Icon { NONE, AIRPLANE, BOOKMARK, BUS, CAR, CLOCK, CONFIRMATION_NUMBER_ICON, DOLLAR, DESCRIPTION, EMAIL, EVENT_PERFORMER, EVENT_SEAT, FLIGHT_ARRIVAL, FLIGHT_DEPARTURE, HOTEL, HOTEL_ROOM_TYPE, INVITE, MAP_PIN, MEMBERSHIP, MULTIPLE_PEOPLE, OFFER, PERSON, PHONE, RESTAURANT_ICON, SHOPPING_CART, STAR, STORE, TICKET, TRAIN, VIDEO_CAMERA, VIDEO_PLAY } + + /** + * A widget that shows a single image. + * + * var image = CardService.newImage().setAltText("A nice image").setImageUrl("https://image.png"); + */ + export interface Image { + setAltText(altText: string): Image; + setAuthorizationAction(action: AuthorizationAction): Image; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): Image; + setImageUrl(url: string): Image; + setOnClickAction(action: Action): Image; + setOnClickOpenLinkAction(action: Action): Image; + setOpenLink(openLink: OpenLink): Image; + } + + /** + * A ImageButton with an image displayed on it. + * + * var imageButton = CardService.newImageButton() + * .setAltText("An image button with an airplane icon.") + * .setIcon(CardService.Icon.AIRPLANE) + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://airplane.com")); + */ + export interface ImageButton { + setAltText(altText: string): ImageButton; + setAuthorizationAction(action: AuthorizationAction): ImageButton; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): ImageButton; + setIcon(icon: Icon): ImageButton; + setIconUrl(url: string): ImageButton; + setOnClickAction(action: Action): ImageButton; + setOnClickOpenLinkAction(action: Action): ImageButton; + setOpenLink(openLink: OpenLink): ImageButton; + } + + /** + * An enum that defines an image cropping style. + */ + export enum ImageStyle { SQUARE, CIRCLE } + + /** + * A widget that displays one or more "keys" around a text "value". The possible keys include an + * icon, a label above and a label below. Setting the text content and one of the keys is required + * using setContent(text) and one of setIcon(icon), setIconUrl(url), setTopLabel(text), + * or setBottomLabel(text). + * + * var imageKeyValue = CardService.newKeyValue() + * .setIconUrl("https://icon.png") + * .setContent("KeyValue widget with an image on the left and text on the right"); + * + * var textKeyValue = CardService.newKeyValue() + * .setTopLabel("Text key") + * .setContent("KeyValue widget with text key on top and cotent below"); + * + * var multilineKeyValue = CardService.newKeyValue() + * .setTopLabel("Top label - single line)") + * .setContent("Content can be multiple lines") + * .setMultiline(true) + * .setBottomLabel("Bottom label - single line"); + */ + export interface KeyValue { + setAuthorizationAction(action: AuthorizationAction): KeyValue; + setBottomLabel(text: string): KeyValue; + setButton(button: Button): KeyValue; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): KeyValue; + setContent(text: string): KeyValue; + setIcon(icon: Icon): KeyValue; + setIconAltText(altText: string): KeyValue; + setIconUrl(url: string): KeyValue; + setMultiline(multiline: boolean): KeyValue; + setOnClickAction(action: Action): KeyValue; + setOnClickOpenLinkAction(action: Action): KeyValue; + setOpenLink(openLink: OpenLink): KeyValue; + setSwitch(switchToSet: Switch): KeyValue; + setTopLabel(text: string): KeyValue; + } + + /** + * An enum type that specifies the type of loading or progress indicator to display while an Action is being processed. + */ + export enum LoadIndicator { SPINNER, NONE } + + /** + * A helper object that controls card navigation. See the card navigation guide for more details. + */ + export interface Navigation { + popCard(): Navigation; + popToNamedCard(cardName: string): Navigation; + popToRoot(): Navigation; + printJson(): string; + pushCard(card: Card): Navigation; + updateCard(card: Card): Navigation; + } + + /** + * A notification shown to the user as a response to interacting with a UI element. + * + * var action = CardService.newAction().setFunctionName("notificationCallback"); + * CardService.newTextButton().setText('Save').setOnClickAction(action); + * + * // ... + * + * function notificationCallback() { + * return CardService.newActionResponseBuilder() + * .setNotification(CardService.newNotification() + * .setType(CardService.NotificationType.WARNING) + * .setText("Some info to display to user")) + * .build(); + * } + */ + export interface Notification { + setText(text: string): Notification; + setType(type: NotificationType): Notification; + } + + /** + * Type of notification to show. + */ + export enum NotificationType { INFO, ERROR, WARNING } + + /** + * An enum that specifies what to do when a URL opened through an OpenLink is closed. + * + * When a link is opened, the client either forgets about it or waits until the window is closed. + * The implementation depends on the client platform capabilities. OnClose may cause OpenAs to be ignored; if the client platform cannot support both selected values together, + * OnClose takes precedence. + */ + export enum OnClose { NOTHING, RELOAD_ADD_ON } + + /** + * An enum that specifies how to open a URL. + * + * The client can open a URL as either a full size window (if that is the frame used by the + * client), or an overlay (such as a pop-up). The implementation depends on the client platform + * capabilities, and the value selected may be ignored if the client does not support it. FULL_SIZE is supported by all clients. + * + * Using OnClose may cause OpenAs to be ignored; if the client platform cannot + * support both selected values together, OnClose takes precedence. + */ + export enum OpenAs { FULL_SIZE, OVERLAY } + + /** + * Represents an action to open a link with some options. + * + * // A button that opens as a link in an overlay and + * // requires a reload when closed. + * var button = CardService.newTextButton() + * .setText("This button opens a link in an overlay window") + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://www.google.com") + * .setOpenAs(CardService.OpenAs.OVERLAY) + * .setOnClose(CardService.OnClose.RELOAD_ADD_ON)); + * + * // An action response that opens a link in full screen and + * // requires no action when closed. + * var actionResponse = CardService.newActionResponseBuilder() + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://www.google.com") + * .setOpenAs(CardService.OpenAs.FULL_SIZE) + * .setOnClose(CardService.OnClose.NOTHING)); + * .build(); + */ + export interface OpenLink { + setOnClose(onClose: OnClose): OpenLink; + setOpenAs(openAs: OpenAs): OpenLink; + setUrl(url: string): OpenLink; + } + + /** + * An input field that allows choosing between a set of predefined options. + * + * var checkboxGroup = CardService.newSelectionInput() + * .setType(CardService.SelectionInputType.CHECK_BOX) + * .setTitle("A group of checkboxes. Multiple selections are allowed.") + * .setFieldName("checkbox_field") + * .addItem("checkbox one title", "checkbox_one_value", false) + * .addItem("checkbox two title", "checkbox_two_value", true) + * .addItem("checkbox three title", "checkbox_three_value", false) + * .setOnChangeAction(CardService.newAction() + * .setFunctionName("handleCheckboxChange")); + * + * var radioGroup = CardService.newSelectionInput() + * .setType(CardService.SelectionInputType.RADIO_BUTTON) + * .setTitle("A group of radio buttons. Only a single selection is allowed.") + * .setFieldName("checkbox_field") + * .addItem("radio button one title", "radio_one_value", true) + * .addItem("radio button two title", "radio_two_value", true) + * .addItem("radio button three title", "radio_three_value", false); + */ + export interface SelectionInput { + addItem(text: Object, value: Object, selected: boolean): SelectionInput; + setFieldName(fieldName: string): SelectionInput; + setOnChangeAction(action: Action): SelectionInput; + setTitle(title: string): SelectionInput; + setType(type: SelectionInputType): SelectionInput; + } + + /** + * Type of selection input. + */ + export enum SelectionInputType { CHECK_BOX, RADIO_BUTTON, DROPDOWN } + + /** + * Autocomplete suggestions to supplement a TextInput widget. + * + * var textInput = CardService.newTextInput() + * .setSuggestions(CardService.newSuggestions() + * .addSuggestion("First suggestion") + * .addSuggestion("Second suggestion")) + */ + export interface Suggestions { + addSuggestion(suggestion: string): Suggestions; + addSuggestions(suggestions: Object[]): Suggestions; + } + + /** + * A response object that can be returned from a suggestions callback function. This is used with + * TextInput widgets that implement autocomplete. + * + * var suggestionsResponse = CardService.newSuggestionsResponseBuilder() + * .setSuggestions(CardService.newSuggestions() + * .addSuggestion("First suggestion") + * .addSuggestion("Second suggestion")) + * .build(); + */ + export interface SuggestionsResponse { + printJson(): string; + } + + /** + * A builder for SuggestionsResponse objects. + */ + export interface SuggestionsResponseBuilder { + build(): SuggestionsResponse; + setSuggestions(suggestions: Suggestions): SuggestionsResponseBuilder; + } + + /** + * A UI element that supports being toggled on or off. This can only be used within a KeyValue widget. + * + * var switchKeyValue = CardService.newKeyValue() + * .setTopLabel("Switch key value widget label") + * .setContent("This is a key value widget with a switch on the right") + * .setSwitch(CardService.newSwitch() + * .setFieldName("form_input_switch_key") + * .setValue("form_input_switch_value") + * .setOnChangeAction(CardService.newAction() + * .setFunctionName("handleSwitchChange"))); + */ + export interface Switch { + setFieldName(fieldName: string): Switch; + setOnChangeAction(action: Action): Switch; + setSelected(selected: boolean): Switch; + setValue(value: string): Switch; + } + + /** + * A TextButton with a text label. + * + * var textButton = CardService.newTextButton() + * .setText("Open Link") + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://www.google.com")); + */ + export interface TextButton { + setAuthorizationAction(action: AuthorizationAction): TextButton; + setBackgroundColor(backgroundColor: string): TextButton; + setComposeAction(action: Action, composedEmailType: ComposedEmailType): TextButton; + setDisabled(disabled: boolean): TextButton; + setOnClickAction(action: Action): TextButton; + setOnClickOpenLinkAction(action: Action): TextButton; + setOpenLink(openLink: OpenLink): TextButton; + setText(text: string): TextButton; + setTextButtonStyle(textButtonStyle: TextButtonStyle): TextButton; + } + + /** + * An enum that specifies the style for TextButton. + * + * TEXT is the default; it renders a simple text button with clear background. + * FILLED buttons have a background color you can set with + * TextButton.setBackgroundColor(backgroundColor). + */ + export enum TextButtonStyle { TEXT, FILLED } + + /** + * A input field widget that accepts text input. + * + * var textInput = CardService.newTextInput() + * .setFieldName("text_input_form_input_key") + * .setTitle("Text input title") + * .setHint("Text input hint"); + */ + export interface TextInput { + setFieldName(fieldName: string): TextInput; + setHint(hint: string): TextInput; + setMultiline(multiline: boolean): TextInput; + setOnChangeAction(action: Action): TextInput; + setSuggestions(suggestions: Suggestions): TextInput; + setSuggestionsAction(suggestionsAction: Action): TextInput; + setTitle(title: string): TextInput; + setValue(value: string): TextInput; + } + + /** + * A widget that displays text and supports basic HTML formatting. + * + * var textParagraph = CardService.newTextParagraph() + * .setText("This is a text paragraph widget. Multiple lines are allowed if needed."); + */ + export interface TextParagraph { + setText(text: string): TextParagraph; + } + + /** + * The response object that may be returned from a method that creates universal action. + * + * // A universal action that opens a link. + * var openLinkUniversalAction = CardService.newUniversalActionResponseBuilder() + * .setOpenLink(CardService.newOpenLink() + * .setUrl("https://www.google.com")) + * .build(); + * + * var cardBuilder1 = CardService.newCardBuilder(); + * var cardBuilder2 = CardService.newCardBuilder(); + * // Finish building the cards ... + * + * // A universal action that shows two static cards. + * var cardsUniversalAction = CardService.newUniversalActionResponseBuilder() + * .displayAddOnCards([ + * cardBuilder1.build(); + * cardBuilder2.build(); + * ]).build(); + */ + export interface UniversalActionResponse { + printJson(): string; + } + + /** + * A builder for the UniversalActionResponse objects. + */ + export interface UniversalActionResponseBuilder { + build(): UniversalActionResponse; + displayAddOnCards(cardObjects: Object[]): UniversalActionResponseBuilder; + setOpenLink(openLink: OpenLink): UniversalActionResponseBuilder; + } + + /** + * Represents an action that updates the email draft that the user is currently editing. + * + * // A UpdateDraftActionResponse that inserts non-editable content (a link in this case) into an + * // email draft. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.IMMUTABLE_HTML) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + * + * // A UpdateDraftActionResponse that inserts a link into an email draft. The added content can be + * // edited further. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.MUTABLE_HTML) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + * + * // A UpdateDraftActionResponse that inserts multiple values of different types. + * // The example action response inserts two lines next to each other in the email + * // draft, at the cursor position. Each line contains the content added by + * // {@link UpdateDraftActionResponseBuilder#addUpdateContent}. + * var updateDraftActionResponse = CardService.newUpdateDraftActionResponseBuilder() + * .setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction() + * .addUpdateContent( + * "Google", + * ContentType.MUTABLE_HTML) + * .addUpdateContent("Above is a google link.", ContentType.PLAIN_TEXT) + * .setUpdateType(UpdateDraftBodyType.IN_PLACE_INSERT)) + * .build(); + */ + export interface UpdateDraftActionResponse { + printJson(): string; + } + + /** + * A builder for UpdateDraftActionResponse objects. + */ + export interface UpdateDraftActionResponseBuilder { + build(): UpdateDraftActionResponse; + setUpdateDraftBodyAction(updateDraftBodyAction: UpdateDraftBodyAction): UpdateDraftActionResponseBuilder; + } + + /** + * Represents an action that updates the email draft body. + */ + export interface UpdateDraftBodyAction { + addUpdateContent(content: string, contentType: ContentType): UpdateDraftBodyAction; + setUpdateType(updateType: UpdateDraftBodyType): UpdateDraftBodyAction; + } + + /** + * An enum value that specifies the type of an UpdateDraftBodyAction. + */ + export enum UpdateDraftBodyType { IN_PLACE_INSERT } + + /** + * Base class for all widgets that can be added to a Card. + */ + export interface Widget { + } + + } +} + +declare var CardService: GoogleAppsScript.Card_Service.CardService; diff --git a/types/google-apps-script/google-apps-script.charts.d.ts b/types/google-apps-script/google-apps-script.charts.d.ts index 50013a36d0..5898092bb4 100644 --- a/types/google-apps-script/google-apps-script.charts.d.ts +++ b/types/google-apps-script/google-apps-script.charts.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -536,7 +536,7 @@ declare namespace GoogleAppsScript { * function doGet() { * // This example creates two table charts side by side. One uses a data view definition to * // restrict the number of displayed columns. - * var app = UiApp.createApplication(); + * * // Get sample data from a spreadsheet. * var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' + * '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1'; @@ -555,9 +555,17 @@ declare namespace GoogleAppsScript { * .setDataViewDefinition(dataViewDefinition) * .build(); * - * var panel = app.createHorizontalPanel().setSpacing(15); - * panel.add(originalChart).add(limitedChart); - * return app.add(panel); + * var htmlOutput = HtmlService.createHtmlOutput(); + * var originalChartData = Utilities.base64Encode(originalChart.getAs('image/png').getBytes()); + * var originalChartUrl = "data:image/png;base64," + encodeURI(originalChartData); + * var limitedChartData = Utilities.base64Encode(limitedChart.getAs('image/png').getBytes()); + * var limitedChartUrl = "data:image/png;base64," + encodeURI(limitedChartData); + * htmlOutput.append("
"); + * htmlOutput.append(""); + * htmlOutput.append(""); + * htmlOutput.append(""); + * htmlOutput.append("
"); + * return htmlOutput; * } */ export interface DataViewDefinitionBuilder { diff --git a/types/google-apps-script/google-apps-script.data-studio.d.ts b/types/google-apps-script/google-apps-script.data-studio.d.ts new file mode 100644 index 0000000000..572e4284e1 --- /dev/null +++ b/types/google-apps-script/google-apps-script.data-studio.d.ts @@ -0,0 +1,301 @@ +// Type definitions for Google Apps Script 2018-12-26 +// Project: https://developers.google.com/apps-script/ +// Definitions by: motemen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace GoogleAppsScript { + export module Data_Studio { + /** + * An enum that defines the aggregation types that can be set for a Field. + */ + export enum AggregationType { NO_AGGREGATION, AVG, COUNT, COUNT_DISTINCT, MAX, MIN, SUM } + + /** + * Contains checkbox information for the config. Its properties determine how the checkbox is + * displayed in Data Studio. + * + * var checkbox = config.newCheckbox() + * .setId("use_https") + * .setName("Use Https?") + * .setHelpText("Whether or not https should be used.") + * .setAllowOverride(true); + */ + export interface Checkbox { + setAllowOverride(allowOverride: boolean): Checkbox; + setHelpText(helpText: string): Checkbox; + setId(id: string): Checkbox; + setName(name: string): Checkbox; + } + + /** + * CommunityConnector enables scripts to access builders and utilities to help with development of + * Community Connectors for Data Studio. Use this class to get a reference to the Fields + * object and the FieldType and AggregationType enums so they can be used in the + * construction of Fields. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fieldType = cc.FieldType; + * var aggregationType = cc.AggregationType; + * + * var fields = cc.getFields(); + * + * fields.newMetric() + * .setAggregation(aggregationType.AVG) + * .setFieldType(fieldType.CURRENCY_USD); + */ + export interface CommunityConnector { + AggregationType: typeof AggregationType; + FieldType: typeof FieldType; + getConfig(): Config; + getFields(): Fields; + } + + /** + * Contains the configuration entries for a connector. These configuration entries define what + * questions are asked when adding a new connector. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info_entry = config.newInfo() + * .setId("info_id") + * .setHelpText("This connector can connect to multiple data endpoints."); + */ + export interface Config { + build(): Object; + newCheckbox(): Checkbox; + newInfo(): Info; + newOptionBuilder(): OptionBuilder; + newSelectMultiple(): SelectMultiple; + newSelectSingle(): SelectSingle; + newTextArea(): TextArea; + newTextInput(): TextInput; + printJson(): string; + setDateRangeRequired(dateRangeRequired: boolean): Config; + } + + /** + * DataStudioApp allows scripts to interact with developer-oriented features for Data Studio. + */ + export interface DataStudioApp { + createCommunityConnector(): CommunityConnector; + } + + /** + * Contains field-related data. Its properties determine how the field is used in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fields = cc.getFields(); + * var types = cc.FieldType; + * + * var field1 = fields.newDimension() + * .setId('field1_id') + * .setName('Field 1 ID') + * .setDescription('The first field.') + * .setType(types.YEAR_MONTH) + * .setGroup('DATETIME'); + */ + export interface Field { + getAggregation(): AggregationType; + getDescription(): string; + getFormula(): string; + getGroup(): string; + getId(): string; + getName(): string; + getType(): FieldType; + isDefault(): boolean; + isDimension(): boolean; + isHidden(): boolean; + isMetric(): boolean; + setAggregation(aggregation: AggregationType): Field; + setDescription(description: string): Field; + setFormula(formula: string): Field; + setGroup(group: string): Field; + setId(id: string): Field; + setIsHidden(isHidden: boolean): Field; + setName(name: string): Field; + setType(type: FieldType): Field; + } + + /** + * An enum that defines the types that can be set for a Field. + */ + export enum FieldType { YEAR, YEAR_QUARTER, YEAR_MONTH, YEAR_WEEK, YEAR_MONTH_DAY, YEAR_MONTH_DAY_HOUR, QUARTER, MONTH, WEEK, MONTH_DAY, DAY_OF_WEEK, DAY, HOUR, MINUTE, DURATION, COUNTRY, COUNTRY_CODE, CONTINENT, CONTINENT_CODE, SUB_CONTINENT, SUB_CONTINENT_CODE, REGION, REGION_CODE, CITY, CITY_CODE, METRO, METRO_CODE, LATITUDE_LONGITUDE, NUMBER, PERCENT, TEXT, BOOLEAN, URL, CURRENCY_AED, CURRENCY_ALL, CURRENCY_ARS, CURRENCY_AUD, CURRENCY_BDT, CURRENCY_BGN, CURRENCY_BOB, CURRENCY_BRL, CURRENCY_CAD, CURRENCY_CDF, CURRENCY_CHF, CURRENCY_CLP, CURRENCY_CNY, CURRENCY_COP, CURRENCY_CRC, CURRENCY_CZK, CURRENCY_DKK, CURRENCY_DOP, CURRENCY_EGP, CURRENCY_ETB, CURRENCY_EUR, CURRENCY_GBP, CURRENCY_HKD, CURRENCY_HRK, CURRENCY_HUF, CURRENCY_IDR, CURRENCY_ILS, CURRENCY_INR, CURRENCY_IRR, CURRENCY_ISK, CURRENCY_JMD, CURRENCY_JPY, CURRENCY_KRW, CURRENCY_LKR, CURRENCY_LTL, CURRENCY_MNT, CURRENCY_MVR, CURRENCY_MXN, CURRENCY_MYR, CURRENCY_NOK, CURRENCY_NZD, CURRENCY_PAB, CURRENCY_PEN, CURRENCY_PHP, CURRENCY_PKR, CURRENCY_PLN, CURRENCY_RON, CURRENCY_RSD, CURRENCY_RUB, CURRENCY_SAR, CURRENCY_SEK, CURRENCY_SGD, CURRENCY_THB, CURRENCY_TRY, CURRENCY_TWD, CURRENCY_TZS, CURRENCY_UAH, CURRENCY_USD, CURRENCY_UYU, CURRENCY_VEF, CURRENCY_VND, CURRENCY_YER, CURRENCY_ZAR } + + /** + * Contains a set of Fields for a community connector. This set of fields define which + * dimensions and metrics can be used in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var fields = cc.getFields(); + * var types = cc.FieldType; + * + * var field1 = fields.newDimension() + * // Set other properties as needed. + * .setId('field1_id'); + */ + export interface Fields { + asArray(): Field[]; + build(): Object[]; + forIds(ids: string[]): Fields; + getDefaultDimension(): Field; + getDefaultMetric(): Field; + getFieldById(fieldId: string): Field; + newDimension(): Field; + newMetric(): Field; + setDefaultDimension(fieldId: string): void; + setDefaultMetric(fieldId: string): void; + } + + /** + * Contains info data for the config. Its properties determine how the info is displayed in Data + * Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info1 = config.newInfo() + * .setName("info1") + * .setText("This text gives some context on the configuration."); + */ + export interface Info { + setId(id: string): Info; + setText(text: string): Info; + } + + /** + * A builder for creating options for SelectSingles and SelectMultiples. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectSingle() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .addOption(option1) + * .addOption(option2); + */ + export interface OptionBuilder { + setLabel(label: string): OptionBuilder; + setValue(value: string): OptionBuilder; + } + + /** + * Contains select multiple information for the config. Its properties determine how the select + * multiple is displayed in Data Studio. + * + * Usage: + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectMultiple() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .setAllowOverride(true) + * .addOption(option1) + * .addOption(option2); + */ + export interface SelectMultiple { + addOption(optionBuilder: OptionBuilder): SelectMultiple; + setAllowOverride(allowOverride: boolean): SelectMultiple; + setHelpText(helpText: string): SelectMultiple; + setId(id: string): SelectMultiple; + setName(name: string): SelectMultiple; + } + + /** + * Contains select single information for the config. Its properties determine how the select single + * is displayed in Data Studio. + * + * var option1 = config.newOptionBuilder() + * .setLabel("option label") + * .setValue("option_value"); + * + * var option2 = config.newOptionBuilder() + * .setLabel("second option label") + * .setValue("option_value_2"); + * + * var info1 = config.newSelectMultiple() + * .setId("api_endpoint") + * .setName("Data Type") + * .setHelpText("Select the data type you're interested in.") + * .setAllowOverride(true) + * .addOption(option1) + * .addOption(option2); + */ + export interface SelectSingle { + addOption(optionBuilder: OptionBuilder): SelectSingle; + setAllowOverride(allowOverride: boolean): SelectSingle; + setHelpText(helpText: string): SelectSingle; + setId(id: string): SelectSingle; + setName(name: string): SelectSingle; + } + + /** + * Contains text area information for the config. Its properties determine how the text input is + * displayed in Data Studio. + * + * Usage: + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var textArea1 = config.newTextArea() + * .setId("textArea1") + * .setName("Search") + * .setHelpText("for example, Coldplay") + * .setAllowOverride(true) + * .setPlaceholder("Search for an artist for all songs."); + */ + export interface TextArea { + setAllowOverride(allowOverride: boolean): TextArea; + setHelpText(helpText: string): TextArea; + setId(id: string): TextArea; + setName(name: string): TextArea; + setPlaceholder(placeholder: string): TextArea; + } + + /** + * Contains text input information for the config. Its properties determine how the text input is + * displayed in Data Studio. + * + * var cc = DataStudioApp.createCommunityConnector(); + * var config = cc.getConfig(); + * + * var info1 = config.newTextInput() + * .setId("info1") + * .setName("Search") + * .setHelpText("for example, Coldplay") + * .setAllowOverride(true) + * .setPlaceholder("Search for an artist for all songs."); + */ + export interface TextInput { + setAllowOverride(allowOverride: boolean): TextInput; + setHelpText(helpText: string): TextInput; + setId(id: string): TextInput; + setName(name: string): TextInput; + setPlaceholder(placeholder: string): TextInput; + } + + } +} + +declare var DataStudioApp: GoogleAppsScript.Data_Studio.DataStudioApp; diff --git a/types/google-apps-script/google-apps-script.forms.d.ts b/types/google-apps-script/google-apps-script.forms.d.ts index df08002505..33df1975c7 100644 --- a/types/google-apps-script/google-apps-script.forms.d.ts +++ b/types/google-apps-script/google-apps-script.forms.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -151,9 +151,6 @@ declare namespace GoogleAppsScript { * checkBoxItem.setValidation(checkBoxValidation); */ export interface CheckboxValidation { - requireSelectAtLeast(number: Integer): CheckboxValidation; - requireSelectAtMost(number: Integer): CheckboxValidation; - requireSelectExactly(number: Integer): CheckboxValidation; } /** @@ -671,7 +668,7 @@ declare namespace GoogleAppsScript { * item.setHelpText('Description of new section.'); * } */ - export enum ItemType { CHECKBOX, CHECKBOX_GRID, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME } + export enum ItemType { CHECKBOX, CHECKBOX_GRID, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME, VIDEO } /** * A question item that allows the respondent to select one choice from a drop-down list. Items can diff --git a/types/google-apps-script/google-apps-script.gmail.d.ts b/types/google-apps-script/google-apps-script.gmail.d.ts index db8e6ecc52..b71a7226b6 100644 --- a/types/google-apps-script/google-apps-script.gmail.d.ts +++ b/types/google-apps-script/google-apps-script.gmail.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -103,6 +103,7 @@ declare namespace GoogleAppsScript { getContentType(): string; getDataAsString(): string; getDataAsString(charset: string): string; + getHash(): string; getName(): string; getSize(): Integer; isGoogleType(): boolean; diff --git a/types/google-apps-script/google-apps-script.groups.d.ts b/types/google-apps-script/google-apps-script.groups.d.ts index 757029f044..958838de57 100644 --- a/types/google-apps-script/google-apps-script.groups.d.ts +++ b/types/google-apps-script/google-apps-script.groups.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,13 +16,13 @@ declare namespace GoogleAppsScript { * * function listGroupMembers() { * var group = GroupsApp.getGroupByEmail("example@googlegroups.com"); - * var s = group.getEmail() + ': '; + * var str = group.getEmail() + ': '; * var users = group.getUsers(); * for (var i = 0; i < users.length; i++) { * var user = users[i]; - * s = s + user.getEmail() + ", "; + * str = str + user.getEmail() + ", "; * } - * Logger.log(s); + * Logger.log(str); * } */ export interface Group { diff --git a/types/google-apps-script/google-apps-script.script.d.ts b/types/google-apps-script/google-apps-script.script.d.ts index fbe95deb8c..5130b54db9 100644 --- a/types/google-apps-script/google-apps-script.script.d.ts +++ b/types/google-apps-script/google-apps-script.script.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,8 +15,8 @@ declare namespace GoogleAppsScript { * An enumeration that identifies which categories of authorized services Apps Script is able to * execute through a triggered function. These values are exposed in triggered functions as the authMode * property of the event parameter, e. For - * more information, see the guide to the authorization - * lifecycle for add-ons. + * more information, see the guide to the + * authorization lifecycle for add-ons. * * function onOpen(e) { * var menu = SpreadsheetApp.getUi().createAddonMenu(); diff --git a/types/google-apps-script/google-apps-script.slides.d.ts b/types/google-apps-script/google-apps-script.slides.d.ts index 3d1aac9227..f1c3a6fdae 100644 --- a/types/google-apps-script/google-apps-script.slides.d.ts +++ b/types/google-apps-script/google-apps-script.slides.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -125,6 +125,14 @@ declare namespace GoogleAppsScript { */ export enum ColorType { UNSUPPORTED, RGB, THEME } + /** + * The connection site on a PageElement that can connect to a connector. + */ + export interface ConnectionSite { + getIndex(): Integer; + getPageElement(): PageElement; + } + /** * The content alignments for a Shape or TableCell. The supported alignments * correspond to predefined text anchoring types from the ECMA-376 standard. @@ -172,8 +180,11 @@ declare namespace GoogleAppsScript { */ export interface Group { alignOnPage(alignmentPosition: AlignmentPosition): Group; + bringForward(): Group; + bringToFront(): Group; duplicate(): PageElement; getChildren(): PageElement[]; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -194,9 +205,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Group; select(): void; select(replace: boolean): void; + sendBackward(): Group; + sendToBack(): Group; + setDescription(description: string): Group; setHeight(height: Number): Group; setLeft(left: Number): Group; setRotation(angle: Number): Group; + setTitle(title: string): Group; setTop(top: Number): Group; setTransform(transform: AffineTransform): Group; setWidth(width: Number): Group; @@ -208,10 +223,13 @@ declare namespace GoogleAppsScript { */ export interface Image { alignOnPage(alignmentPosition: AlignmentPosition): Image; + bringForward(): Image; + bringToFront(): Image; duplicate(): PageElement; getAs(contentType: string): Base.Blob; getBlob(): Base.Blob; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getContentUrl(): string; getDescription(): string; getHeight(): Number; @@ -240,6 +258,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Image; select(): void; select(replace: boolean): void; + sendBackward(): Image; + sendToBack(): Image; + setDescription(description: string): Image; setHeight(height: Number): Image; setLeft(left: Number): Image; setLinkSlide(slideIndex: Integer): Link; @@ -247,6 +268,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): Image; + setTitle(title: string): Image; setTop(top: Number): Image; setTransform(transform: AffineTransform): Image; setWidth(width: Number): Image; @@ -267,6 +289,7 @@ declare namespace GoogleAppsScript { getLines(): Line[]; getMaster(): Master; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -285,6 +308,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -313,15 +337,20 @@ declare namespace GoogleAppsScript { */ export interface Line { alignOnPage(alignmentPosition: AlignmentPosition): Line; + bringForward(): Line; + bringToFront(): Line; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDashStyle(): DashStyle; getDescription(): string; getEnd(): Point; getEndArrow(): ArrowStyle; + getEndConnection(): ConnectionSite; getHeight(): Number; getInherentHeight(): Number; getInherentWidth(): Number; getLeft(): Number; + getLineCategory(): LineCategory; getLineFill(): LineFill; getLineType(): LineType; getLink(): Link; @@ -332,24 +361,32 @@ declare namespace GoogleAppsScript { getRotation(): Number; getStart(): Point; getStartArrow(): ArrowStyle; + getStartConnection(): ConnectionSite; getTitle(): string; getTop(): Number; getTransform(): AffineTransform; getWeight(): Number; getWidth(): Number; + isConnector(): boolean; preconcatenateTransform(transform: AffineTransform): Line; remove(): void; removeLink(): void; + reroute(): Line; scaleHeight(ratio: Number): Line; scaleWidth(ratio: Number): Line; select(): void; select(replace: boolean): void; + sendBackward(): Line; + sendToBack(): Line; setDashStyle(style: DashStyle): Line; + setDescription(description: string): Line; setEnd(left: Number, top: Number): Line; setEnd(point: Point): Line; setEndArrow(style: ArrowStyle): Line; + setEndConnection(connectionSite: ConnectionSite): Line; setHeight(height: Number): Line; setLeft(left: Number): Line; + setLineCategory(lineCategory: LineCategory): Line; setLinkSlide(slideIndex: Integer): Link; setLinkSlide(slide: Slide): Link; setLinkSlide(slidePosition: SlidePosition): Link; @@ -358,6 +395,8 @@ declare namespace GoogleAppsScript { setStart(left: Number, top: Number): Line; setStart(point: Point): Line; setStartArrow(style: ArrowStyle): Line; + setStartConnection(connectionSite: ConnectionSite): Line; + setTitle(title: string): Line; setTop(top: Number): Line; setTransform(transform: AffineTransform): Line; setWeight(points: Number): Line; @@ -370,7 +409,7 @@ declare namespace GoogleAppsScript { * The exact LineType created is determined based on the category and how it's routed to * connect to other page elements. */ - export enum LineCategory { STRAIGHT, BENT, CURVED } + export enum LineCategory { UNSUPPORTED, STRAIGHT, BENT, CURVED } /** * Describes the fill of a line or outline @@ -504,6 +543,7 @@ declare namespace GoogleAppsScript { getLayouts(): Layout[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -522,6 +562,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -556,6 +597,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPlaceholder(placeholderType: PlaceholderType): PageElement; getPlaceholder(placeholderType: PlaceholderType, placeholderIndex: Integer): PageElement; @@ -579,6 +621,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPlaceholder(placeholderType: PlaceholderType): PageElement; getPlaceholder(placeholderType: PlaceholderType, placeholderIndex: Integer): PageElement; @@ -606,6 +649,7 @@ declare namespace GoogleAppsScript { getImages(): Image[]; getLines(): Line[]; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -624,6 +668,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -686,7 +731,10 @@ declare namespace GoogleAppsScript { asTable(): Table; asVideo(): Video; asWordArt(): WordArt; + bringForward(): PageElement; + bringToFront(): PageElement; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -707,9 +755,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): PageElement; select(): void; select(replace: boolean): void; + sendBackward(): PageElement; + sendToBack(): PageElement; + setDescription(description: string): PageElement; setHeight(height: Number): PageElement; setLeft(left: Number): PageElement; setRotation(angle: Number): PageElement; + setTitle(title: string): PageElement; setTop(top: Number): PageElement; setTransform(transform: AffineTransform): PageElement; setWidth(width: Number): PageElement; @@ -836,11 +888,11 @@ declare namespace GoogleAppsScript { getNotesMaster(): NotesMaster; getNotesPageHeight(): Number; getNotesPageWidth(): Number; - getPageElementById(id: string): PageElement; + getPageElementById(id: string): PageElement; getPageHeight(): Number; getPageWidth(): Number; getSelection(): Selection; - getSlideById(id: string): Slide; + getSlideById(id: string): Slide; getSlides(): Slide[]; getUrl(): string; getViewers(): Base.User[]; @@ -903,8 +955,11 @@ declare namespace GoogleAppsScript { */ export interface Shape { alignOnPage(alignmentPosition: AlignmentPosition): Shape; + bringForward(): Shape; + bringToFront(): Shape; duplicate(): PageElement; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getContentAlignment(): ContentAlignment; getDescription(): string; getFill(): Fill; @@ -940,7 +995,10 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Shape; select(): void; select(replace: boolean): void; + sendBackward(): Shape; + sendToBack(): Shape; setContentAlignment(contentAlignment: ContentAlignment): Shape; + setDescription(description: string): Shape; setHeight(height: Number): Shape; setLeft(left: Number): Shape; setLinkSlide(slideIndex: Integer): Link; @@ -948,6 +1006,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): Shape; + setTitle(title: string): Shape; setTop(top: Number): Shape; setTransform(transform: AffineTransform): Shape; setWidth(width: Number): Shape; @@ -968,8 +1027,11 @@ declare namespace GoogleAppsScript { export interface SheetsChart { alignOnPage(alignmentPosition: AlignmentPosition): SheetsChart; asImage(): Image; + bringForward(): SheetsChart; + bringToFront(): SheetsChart; duplicate(): PageElement; getChartId(): Integer; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getEmbedType(): SheetsChartEmbedType; getHeight(): Number; @@ -995,6 +1057,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): SheetsChart; select(): void; select(replace: boolean): void; + sendBackward(): SheetsChart; + sendToBack(): SheetsChart; + setDescription(description: string): SheetsChart; setHeight(height: Number): SheetsChart; setLeft(left: Number): SheetsChart; setLinkSlide(slideIndex: Integer): Link; @@ -1002,6 +1067,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): SheetsChart; + setTitle(title: string): SheetsChart; setTop(top: Number): SheetsChart; setTransform(transform: AffineTransform): SheetsChart; setWidth(width: Number): SheetsChart; @@ -1028,6 +1094,7 @@ declare namespace GoogleAppsScript { getLines(): Line[]; getNotesPage(): NotesPage; getObjectId(): string; + getPageElementById(id: string): PageElement; getPageElements(): PageElement[]; getPageType(): PageType; getPlaceholder(placeholderType: PlaceholderType): PageElement; @@ -1046,6 +1113,7 @@ declare namespace GoogleAppsScript { insertImage(imageUrl: string): Image; insertImage(imageUrl: string, left: Number, top: Number, width: Number, height: Number): Image; insertLine(line: Line): Line; + insertLine(lineCategory: LineCategory, startConnectionSite: ConnectionSite, endConnectionSite: ConnectionSite): Line; insertLine(lineCategory: LineCategory, startLeft: Number, startTop: Number, endLeft: Number, endTop: Number): Line; insertPageElement(pageElement: PageElement): PageElement; insertShape(shape: Shape): Shape; @@ -1144,9 +1212,12 @@ declare namespace GoogleAppsScript { alignOnPage(alignmentPosition: AlignmentPosition): Table; appendColumn(): TableColumn; appendRow(): TableRow; + bringForward(): Table; + bringToFront(): Table; duplicate(): PageElement; getCell(rowIndex: Integer, columnIndex: Integer): TableCell; getColumn(columnIndex: Integer): TableColumn; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1172,9 +1243,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Table; select(): void; select(replace: boolean): void; + sendBackward(): Table; + sendToBack(): Table; + setDescription(description: string): Table; setHeight(height: Number): Table; setLeft(left: Number): Table; setRotation(angle: Number): Table; + setTitle(title: string): Table; setTop(top: Number): Table; setTransform(transform: AffineTransform): Table; setWidth(width: Number): Table; @@ -1343,8 +1418,11 @@ declare namespace GoogleAppsScript { */ export interface Video { alignOnPage(alignmentPosition: AlignmentPosition): Video; + bringForward(): Video; + bringToFront(): Video; duplicate(): PageElement; getBorder(): Border; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1369,9 +1447,13 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): Video; select(): void; select(replace: boolean): void; + sendBackward(): Video; + sendToBack(): Video; + setDescription(description: string): Video; setHeight(height: Number): Video; setLeft(left: Number): Video; setRotation(angle: Number): Video; + setTitle(title: string): Video; setTop(top: Number): Video; setTransform(transform: AffineTransform): Video; setWidth(width: Number): Video; @@ -1387,7 +1469,10 @@ declare namespace GoogleAppsScript { */ export interface WordArt { alignOnPage(alignmentPosition: AlignmentPosition): WordArt; + bringForward(): WordArt; + bringToFront(): WordArt; duplicate(): PageElement; + getConnectionSites(): ConnectionSite[]; getDescription(): string; getHeight(): Number; getInherentHeight(): Number; @@ -1411,6 +1496,9 @@ declare namespace GoogleAppsScript { scaleWidth(ratio: Number): WordArt; select(): void; select(replace: boolean): void; + sendBackward(): WordArt; + sendToBack(): WordArt; + setDescription(description: string): WordArt; setHeight(height: Number): WordArt; setLeft(left: Number): WordArt; setLinkSlide(slideIndex: Integer): Link; @@ -1418,6 +1506,7 @@ declare namespace GoogleAppsScript { setLinkSlide(slidePosition: SlidePosition): Link; setLinkUrl(url: string): Link; setRotation(angle: Number): WordArt; + setTitle(title: string): WordArt; setTop(top: Number): WordArt; setTransform(transform: AffineTransform): WordArt; setWidth(width: Number): WordArt; diff --git a/types/google-apps-script/google-apps-script.spreadsheet.d.ts b/types/google-apps-script/google-apps-script.spreadsheet.d.ts index 4ac5c84d6b..76a5bd5f22 100644 --- a/types/google-apps-script/google-apps-script.spreadsheet.d.ts +++ b/types/google-apps-script/google-apps-script.spreadsheet.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -99,7 +99,7 @@ declare namespace GoogleAppsScript { * var range = sheet.getRange("A1:B3"); * var rule = SpreadsheetApp.newConditionalFormatRule() * .whenNumberBetween(1, 10) - * .setBackgroundColor("#FF0000") + * .setBackground("#FF0000") * .setRanges([range]) * .build(); * var rules = sheet.getConditionalFormatRules(); @@ -268,6 +268,61 @@ declare namespace GoogleAppsScript { */ export enum DataValidationCriteria { DATE_AFTER, DATE_BEFORE, DATE_BETWEEN, DATE_EQUAL_TO, DATE_IS_VALID_DATE, DATE_NOT_BETWEEN, DATE_ON_OR_AFTER, DATE_ON_OR_BEFORE, NUMBER_BETWEEN, NUMBER_EQUAL_TO, NUMBER_GREATER_THAN, NUMBER_GREATER_THAN_OR_EQUAL_TO, NUMBER_LESS_THAN, NUMBER_LESS_THAN_OR_EQUAL_TO, NUMBER_NOT_BETWEEN, NUMBER_NOT_EQUAL_TO, TEXT_CONTAINS, TEXT_DOES_NOT_CONTAIN, TEXT_EQUAL_TO, TEXT_IS_VALID_EMAIL, TEXT_IS_VALID_URL, VALUE_IN_LIST, VALUE_IN_RANGE, CUSTOM_FORMULA, CHECKBOX } + /** + * Access and modify developer metadata. To create new developer metadata use Range.addDeveloperMetadata(key), Sheet.addDeveloperMetadata(key), or Spreadsheet.addDeveloperMetadata(key). + */ + export interface DeveloperMetadata { + getId(): Integer; + getKey(): string; + getLocation(): DeveloperMetadataLocation; + getValue(): string; + getVisibility(): DeveloperMetadataVisibility; + moveToColumn(column: Range): DeveloperMetadata; + moveToRow(row: Range): DeveloperMetadata; + moveToSheet(sheet: Sheet): DeveloperMetadata; + moveToSpreadsheet(): DeveloperMetadata; + remove(): void; + setKey(key: string): DeveloperMetadata; + setValue(value: string): DeveloperMetadata; + setVisibility(visibility: DeveloperMetadataVisibility): DeveloperMetadata; + } + + /** + * Search for developer metadata in a spreadsheet. To create new developer metadata finder use + * Range.createDeveloperMetadataFinder(), Sheet.createDeveloperMetadataFinder(), + * or Spreadsheet.createDeveloperMetadataFinder(). + */ + export interface DeveloperMetadataFinder { + find(): DeveloperMetadata[]; + onIntersectingLocations(): DeveloperMetadataFinder; + withId(id: Integer): DeveloperMetadataFinder; + withKey(key: string): DeveloperMetadataFinder; + withLocationType(locationType: DeveloperMetadataLocationType): DeveloperMetadataFinder; + withValue(value: string): DeveloperMetadataFinder; + withVisibility(visibility: DeveloperMetadataVisibility): DeveloperMetadataFinder; + } + + /** + * Access developer metadata location information. + */ + export interface DeveloperMetadataLocation { + getColumn(): Range; + getLocationType(): DeveloperMetadataLocationType; + getRow(): Range; + getSheet(): Sheet; + getSpreadsheet(): Spreadsheet; + } + + /** + * An enumeration of the types of developer metadata location types. + */ + export enum DeveloperMetadataLocationType { SPREADSHEET, SHEET, ROW, COLUMN } + + /** + * An enumeration of the types of developer metadata visibility. + */ + export enum DeveloperMetadataVisibility { DOCUMENT, PROJECT } + /** * An enumeration of possible directions along which data can be stored in a spreadsheet. */ @@ -896,6 +951,36 @@ declare namespace GoogleAppsScript { setRange(range: Range): NamedRange; } + /** + * Represents an image over the grid in a spreadsheet. + */ + export interface OverGridImage { + assignScript(functionName: string): OverGridImage; + getAltTextDescription(): string; + getAltTextTitle(): string; + getAnchorCell(): Range; + getAnchorCellXOffset(): Integer; + getAnchorCellYOffset(): Integer; + getHeight(): Integer; + getInherentHeight(): Integer; + getInherentWidth(): Integer; + getScript(): string; + getSheet(): Sheet; + getUrl(): string; + getWidth(): Integer; + remove(): void; + replace(blob: Base.BlobSource): OverGridImage; + replace(url: string): OverGridImage; + resetSize(): OverGridImage; + setAltTextDescription(description: string): OverGridImage; + setAltTextTitle(title: string): OverGridImage; + setAnchorCell(cell: Range): OverGridImage; + setAnchorCellXOffset(offset: Integer): OverGridImage; + setAnchorCellYOffset(offset: Integer): OverGridImage; + setHeight(height: Integer): OverGridImage; + setWidth(width: Integer): OverGridImage; + } + /** * * Deprecated. For spreadsheets created in the newer version of Google Sheets, use the more powerful @@ -1091,6 +1176,10 @@ declare namespace GoogleAppsScript { export interface Range { activate(): Range; activateAsCurrentCell(): Range; + addDeveloperMetadata(key: string): Range; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Range; + addDeveloperMetadata(key: string, value: string): Range; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Range; applyColumnBanding(): Banding; applyColumnBanding(bandingTheme: BandingTheme): Banding; applyColumnBanding(bandingTheme: BandingTheme, showHeader: boolean, showFooter: boolean): Banding; @@ -1115,6 +1204,7 @@ declare namespace GoogleAppsScript { copyTo(destination: Range, options: Object): void; copyValuesToRange(gridId: Integer, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; copyValuesToRange(sheet: Sheet, column: Integer, columnEnd: Integer, row: Integer, rowEnd: Integer): void; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; createFilter(): Filter; createPivotTable(sourceData: Range): PivotTable; deleteCells(shiftDimension: Dimension): void; @@ -1130,6 +1220,7 @@ declare namespace GoogleAppsScript { getDataTable(firstRowIsHeader: boolean): Charts.DataTable; getDataValidation(): DataValidation; getDataValidations(): DataValidation[][]; + getDeveloperMetadata(): DeveloperMetadata[]; getDisplayValue(): string; getDisplayValues(): string[][]; getFilter(): Filter; @@ -1178,7 +1269,7 @@ declare namespace GoogleAppsScript { getWrap(): boolean; getWrapStrategies(): WrapStrategy[][]; getWrapStrategy(): WrapStrategy; - getWraps(): Boolean[][]; + getWraps(): boolean[][]; insertCells(shiftDimension: Dimension): Range; isBlank(): boolean; isEndColumnBounded(): boolean; @@ -1328,6 +1419,10 @@ declare namespace GoogleAppsScript { */ export interface Sheet { activate(): Sheet; + addDeveloperMetadata(key: string): Sheet; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Sheet; + addDeveloperMetadata(key: string, value: string): Sheet; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Sheet; appendRow(rowContents: Object[]): Sheet; autoResizeColumn(columnPosition: Integer): Sheet; autoResizeColumns(startColumn: Integer, numColumns: Integer): Sheet; @@ -1341,6 +1436,7 @@ declare namespace GoogleAppsScript { collapseAllColumnGroups(): Sheet; collapseAllRowGroups(): Sheet; copyTo(spreadsheet: Spreadsheet): Sheet; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; deleteColumn(columnPosition: Integer): Sheet; deleteColumns(columnPosition: Integer, howMany: Integer): void; deleteRow(rowPosition: Integer): Sheet; @@ -1361,10 +1457,12 @@ declare namespace GoogleAppsScript { getConditionalFormatRules(): ConditionalFormatRule[]; getCurrentCell(): Range; getDataRange(): Range; + getDeveloperMetadata(): DeveloperMetadata[]; getFilter(): Filter; getFormUrl(): string; getFrozenColumns(): Integer; getFrozenRows(): Integer; + getImages(): OverGridImage[]; getIndex(): Integer; getLastColumn(): Integer; getLastRow(): Integer; @@ -1404,17 +1502,20 @@ declare namespace GoogleAppsScript { insertColumns(columnIndex: Integer, numColumns: Integer): void; insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): void; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; - insertImage(url: string, column: Integer, row: Integer): void; - insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): OverGridImage; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; insertRowAfter(afterPosition: Integer): Sheet; insertRowBefore(beforePosition: Integer): Sheet; insertRows(rowIndex: Integer): void; insertRows(rowIndex: Integer, numRows: Integer): void; insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertRowsBefore(beforePosition: Integer, howMany: Integer): Sheet; + isColumnHiddenByUser(columnPosition: Integer): boolean; isRightToLeft(): boolean; + isRowHiddenByFilter(rowPosition: Integer): boolean; + isRowHiddenByUser(rowPosition: Integer): boolean; isSheetHidden(): boolean; moveColumns(columnSpec: Range, destinationIndex: Integer): void; moveRows(rowSpec: Range, destinationIndex: Integer): void; @@ -1458,6 +1559,10 @@ declare namespace GoogleAppsScript { * collaborators. */ export interface Spreadsheet { + addDeveloperMetadata(key: string): Spreadsheet; + addDeveloperMetadata(key: string, visibility: DeveloperMetadataVisibility): Spreadsheet; + addDeveloperMetadata(key: string, value: string): Spreadsheet; + addDeveloperMetadata(key: string, value: string, visibility: DeveloperMetadataVisibility): Spreadsheet; addEditor(emailAddress: string): Spreadsheet; addEditor(user: Base.User): Spreadsheet; addEditors(emailAddresses: string[]): Spreadsheet; @@ -1468,6 +1573,7 @@ declare namespace GoogleAppsScript { appendRow(rowContents: Object[]): Sheet; autoResizeColumn(columnPosition: Integer): Sheet; copy(name: string): Spreadsheet; + createDeveloperMetadataFinder(): DeveloperMetadataFinder; deleteActiveSheet(): Sheet; deleteColumn(columnPosition: Integer): Sheet; deleteColumns(columnPosition: Integer, howMany: Integer): void; @@ -1485,11 +1591,13 @@ declare namespace GoogleAppsScript { getColumnWidth(columnPosition: Integer): Integer; getCurrentCell(): Range; getDataRange(): Range; + getDeveloperMetadata(): DeveloperMetadata[]; getEditors(): Base.User[]; getFormUrl(): string; getFrozenColumns(): Integer; getFrozenRows(): Integer; getId(): string; + getImages(): OverGridImage[]; getLastColumn(): Integer; getLastRow(): Integer; getName(): string; @@ -1517,10 +1625,10 @@ declare namespace GoogleAppsScript { insertColumnBefore(beforePosition: Integer): Sheet; insertColumnsAfter(afterPosition: Integer, howMany: Integer): Sheet; insertColumnsBefore(beforePosition: Integer, howMany: Integer): Sheet; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): void; - insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; - insertImage(url: string, column: Integer, row: Integer): void; - insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): void; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer): OverGridImage; + insertImage(blobSource: Base.BlobSource, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer): OverGridImage; + insertImage(url: string, column: Integer, row: Integer, offsetX: Integer, offsetY: Integer): OverGridImage; insertRowAfter(afterPosition: Integer): Sheet; insertRowBefore(beforePosition: Integer): Sheet; insertRowsAfter(afterPosition: Integer, howMany: Integer): Sheet; @@ -1533,6 +1641,9 @@ declare namespace GoogleAppsScript { insertSheet(sheetName: string, sheetIndex: Integer): Sheet; insertSheet(sheetName: string, sheetIndex: Integer, options: Object): Sheet; insertSheet(sheetName: string, options: Object): Sheet; + isColumnHiddenByUser(columnPosition: Integer): boolean; + isRowHiddenByFilter(rowPosition: Integer): boolean; + isRowHiddenByUser(rowPosition: Integer): boolean; moveActiveSheet(pos: Integer): void; removeEditor(emailAddress: string): Spreadsheet; removeEditor(user: Base.User): Spreadsheet; @@ -1582,6 +1693,8 @@ declare namespace GoogleAppsScript { BorderStyle: typeof BorderStyle; CopyPasteType: typeof CopyPasteType; DataValidationCriteria: typeof DataValidationCriteria; + DeveloperMetadataLocationType: typeof DeveloperMetadataLocationType; + DeveloperMetadataVisibility: typeof DeveloperMetadataVisibility; Dimension: typeof Dimension; Direction: typeof Direction; GroupControlTogglePosition: typeof GroupControlTogglePosition; diff --git a/types/google-apps-script/google-apps-script.utilities.d.ts b/types/google-apps-script/google-apps-script.utilities.d.ts index 272c341b6c..922e31544a 100644 --- a/types/google-apps-script/google-apps-script.utilities.d.ts +++ b/types/google-apps-script/google-apps-script.utilities.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2018-07-11 +// Type definitions for Google Apps Script 2018-12-26 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,7 +14,7 @@ declare namespace GoogleAppsScript { export enum Charset { US_ASCII, UTF_8 } /** - * Selector of Digest algorithm + * Selector of Digest algorithm. */ export enum DigestAlgorithm { MD2, MD5, SHA_1, SHA_256, SHA_384, SHA_512 } @@ -23,6 +23,11 @@ declare namespace GoogleAppsScript { */ export enum MacAlgorithm { HMAC_MD5, HMAC_SHA_1, HMAC_SHA_256, HMAC_SHA_384, HMAC_SHA_512 } + /** + * Selector of RSA algorithm + */ + export enum RsaAlgorithm { RSA_SHA_1, RSA_SHA_256 } + /** * This service provides utilities for string encoding/decoding, date formatting, JSON manipulation, * and other miscellaneous tasks. @@ -31,6 +36,7 @@ declare namespace GoogleAppsScript { Charset: typeof Charset; DigestAlgorithm: typeof DigestAlgorithm; MacAlgorithm: typeof MacAlgorithm; + RsaAlgorithm: typeof RsaAlgorithm; base64Decode(encoded: string): Byte[]; base64Decode(encoded: string, charset: Charset): Byte[]; base64DecodeWebSafe(encoded: string): Byte[]; @@ -50,8 +56,12 @@ declare namespace GoogleAppsScript { computeHmacSignature(algorithm: MacAlgorithm, value: Byte[], key: Byte[]): Byte[]; computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string): Byte[]; computeHmacSignature(algorithm: MacAlgorithm, value: string, key: string, charset: Charset): Byte[]; + computeRsaSha1Signature(value: string, key: string): Byte[]; + computeRsaSha1Signature(value: string, key: string, charset: Charset): Byte[]; computeRsaSha256Signature(value: string, key: string): Byte[]; computeRsaSha256Signature(value: string, key: string, charset: Charset): Byte[]; + computeRsaSignature(algorithm: RsaAlgorithm, value: string, key: string): Byte[]; + computeRsaSignature(algorithm: RsaAlgorithm, value: string, key: string, charset: Charset): Byte[]; formatDate(date: Date, timeZone: string, format: string): string; formatString(template: string, ...args: Object[]): string; getUuid(): string; @@ -80,4 +90,5 @@ declare namespace GoogleAppsScript { declare var Charset: GoogleAppsScript.Utilities.Charset; declare var DigestAlgorithm: GoogleAppsScript.Utilities.DigestAlgorithm; declare var MacAlgorithm: GoogleAppsScript.Utilities.MacAlgorithm; +declare var RsaAlgorithm: GoogleAppsScript.Utilities.RsaAlgorithm; declare var Utilities: GoogleAppsScript.Utilities.Utilities; From 3db4c59326d5bebca83fa95ce623241222e1cb2f Mon Sep 17 00:00:00 2001 From: PopGoesTheWza <32041843+PopGoesTheWza@users.noreply.github.com> Date: Wed, 26 Dec 2018 16:35:26 +0100 Subject: [PATCH 007/139] Update google-apps-script.forms.d.ts --- types/google-apps-script/google-apps-script.forms.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/google-apps-script/google-apps-script.forms.d.ts b/types/google-apps-script/google-apps-script.forms.d.ts index 33df1975c7..2f4508a956 100644 --- a/types/google-apps-script/google-apps-script.forms.d.ts +++ b/types/google-apps-script/google-apps-script.forms.d.ts @@ -151,6 +151,9 @@ declare namespace GoogleAppsScript { * checkBoxItem.setValidation(checkBoxValidation); */ export interface CheckboxValidation { + requireSelectAtLeast(number: Integer): CheckboxValidation; + requireSelectAtMost(number: Integer): CheckboxValidation; + requireSelectExactly(number: Integer): CheckboxValidation; } /** From eaef39d87d42500ef33fe85c2c10ad7b8f8e6815 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Wed, 26 Dec 2018 17:08:18 +0100 Subject: [PATCH 008/139] add data-studio, rename card-service, order as per ref page --- .../google-apps-script.card.d.ts | 660 ------------------ types/google-apps-script/index.d.ts | 13 +- 2 files changed, 7 insertions(+), 666 deletions(-) delete mode 100644 types/google-apps-script/google-apps-script.card.d.ts diff --git a/types/google-apps-script/google-apps-script.card.d.ts b/types/google-apps-script/google-apps-script.card.d.ts deleted file mode 100644 index 60a8bb9d37..0000000000 --- a/types/google-apps-script/google-apps-script.card.d.ts +++ /dev/null @@ -1,660 +0,0 @@ -// Type definitions for Google Apps Script 2018-07-11 -// Project: https://developers.google.com/apps-script/ -// Definitions by: motemen -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace GoogleAppsScript { - export module Card { - /** - * An action that enables interactivity within UI elements. The action does not happen directly on - * the client but rather invokes an Apps Script callback function with optional parameters. - * - * var image = CardService.newImage() - * .setOnClickAction(CardService.newAction() - * .setFunctionName("handleImageClick") - * .setParameters({imageSrc: 'carImage'})); - */ - export interface Action { - setFunctionName(functionName: string): Action; - setLoadIndicator(loadIndicator: LoadIndicator): Action; - setParameters(parameters: Object): Action; - setMethodName(functionName: string): Action; - } - - /** - * The response object that may be returned from a callback function (e.g., a form response handler) - * to perform one or more actions on the client. Some combinations of actions are not supported. - * - * // An action that opens a link - * var actionResponse = CardService.newActionResponseBuilder() - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://www.google.com")) - * .build(); - * - * // An action that shows a notification. - * var actionResponse = CardService.newActionResponseBuilder() - * .setNotification(CardService.newNotification() - * .setType(CardService.Notification.INFO) - * .setText("Some info to display to user")) - * .build(); - * - * // An action that shows an additional card. It also sets a flag to indicate that the original - * // state data has changed. - * - * var cardBuilder = CardService.newCardBuilder(); - * // Build card ... - * var actionResponse = CardService.newActionResponseBuilder() - * .setNavigation(CardService.newNavigation() - * .pushCard(cardBuilder.build())) - * .setStateChanged(true) - * .build(); - */ - export interface ActionResponse { - printJson(): string; - } - - /** - * A builder for ActionResponse objects. - */ - export interface ActionResponseBuilder { - build(): ActionResponse; - setNavigation(navigation: Navigation): ActionResponseBuilder; - setNotification(notification: Notification): ActionResponseBuilder; - setOpenLink(openLink: OpenLink): ActionResponseBuilder; - setStateChanged(stateChanged: boolean): ActionResponseBuilder; - } - - /** - * An authorization action that will send the user to the AuthorizationUrl when clicked. - * - * CardService.newAuthorizationAction() - * .setAuthorizationUrl("http://google.com/"); - */ - export interface AuthorizationAction { - setAuthorizationUrl(authorizationUrl: string): AuthorizationAction; - } - - /** - * An error that can be returned to trigger an authorization card to be shown to the user. - * - * CardService.newAuthorizationException() - * .setAuthorizationUrl("http://auth.com/") - * .setResourceDisplayName("Example Resource") - * .throwException(); - */ - export interface AuthorizationException { - printJson(): string; - setAuthorizationUrl(authUrl: string): AuthorizationException; - setCustomUiCallback(callback: string): AuthorizationException; - setResourceDisplayName(name: string): AuthorizationException; - throwException(): void; - } - - /** - * A base class for all buttons. - */ - export interface Button { - setAuthorizationAction(action: AuthorizationAction): Button; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): Button; - setOnClickAction(action: Action): Button; - setOnClickOpenLinkAction(action: Action): Button; - setOpenLink(openLink: OpenLink): Button; - } - - /** - * Holds a set of Button objects that are displayed in a row. - * - * var textButton = CardService.newTextButton(); - * // Finish building the text button... - * - * var imageButton = CardService.newImageButton(); - * // Finish building the image button... - * - * var buttonSet = CardService.newButtonSet() - * .addButton(textButton) - * .addButton(imageButton); - */ - export interface ButtonSet { - addButton(button: Button): ButtonSet; - } - - /** - * A context card that represents a single view in the - * UI. - * - * var cardSection = CardService.newCardSection(); - * // Finish building the card section ... - * - * var card = CardService.newCardBuilder() - * .setName("Card name") - * .setHeader(CardService.newCardHeader().setTitle("Card title")) - * .addSection(cardSection) - * .build(); - */ - export interface Card { - printJson(): string; - } - - /** - * A clickable menu item that is added to the card header menu. - * - * var action = CardService.newAction(); - * // Finish building the action... - * - * var cardAction = CardService.newCardAction() - * .setText("Card action") - * .setOnClickAction(action); - */ - export interface CardAction { - setAuthorizationAction(action: AuthorizationAction): CardAction; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): CardAction; - setOnClickAction(action: Action): CardAction; - setOnClickOpenLinkAction(action: Action): CardAction; - setOpenLink(openLink: OpenLink): CardAction; - setText(text: string): CardAction; - } - - /** - * A builder for Card objects. - */ - export interface CardBuilder { - addCardAction(cardAction: CardAction): CardBuilder; - addSection(section: CardSection): CardBuilder; - build(): Card; - setHeader(cardHeader: CardHeader): CardBuilder; - setName(name: string): CardBuilder; - } - - /** - * The header of a Card. - * - * var cardHeader = CardService.newCardHeader() - * .setTitle("Card header title") - * .setSubtitle("Card header subtitle") - * .setImageStyle(CardService.ImageStyle.CIRCLE) - * .setImageUrl("https://image.png"); - */ - export interface CardHeader { - setImageAltText(imageAltText: string): CardHeader; - setImageStyle(imageStyle: ImageStyle): CardHeader; - setImageUrl(imageUrl: string): CardHeader; - setSubtitle(subtitle: string): CardHeader; - setTitle(title: string): CardHeader; - } - - /** - * A card section holds groups of widgets and provides visual separation between them. - * - * var image = CardService.newImage(); - * // Build image ... - * var textParagraph = CardService.newTextParagraph(); - * // Build text paragraph ... - * - * var cardSection = CardService.newCardSection() - * .setHeader("Section header") - * .addWidget(image) - * .addWidget(textParagraph); - */ - export interface CardSection { - addWidget(widget: Widget): CardSection; - setCollapsible(collapsible: boolean): CardSection; - setHeader(header: string): CardSection; - setNumUncollapsibleWidgets(numUncollapsibleWidgets: Integer): CardSection; - } - - /** - * CardService provides the ability to create generic cards used across different Google - * extensibility products, such as Gmail add-ons. - * - * Currently you can only use this service to construct Gmail add-ons. - * - * return CardService.newCardBuilder() - * .setHeader(CardService.newCardHeader().setTitle("CardTitle")) - * .build(); - * - * Or you can return multiple Cards like so: - * - * return [ - * CardService.newCardBuilder().build(), - * CardService.newCardBuilder().build(), - * CardService.newCardBuilder().build() - * ] - * - * The following shows how you could define a card with a header, text, an image and a menu item: - * - * function createWidgetDemoCard() { - * return CardService - * .newCardBuilder() - * .setHeader( - * CardService.newCardHeader() - * .setTitle('Widget demonstration') - * .setSubtitle('Check out these widgets') - * .setImageStyle(CardService.ImageStyle.SQUARE) - * .setImageUrl( - * 'https://www.example.com/images/headerImage.png')) - * .addSection( - * CardService.newCardSection() - * .setHeader('Simple widgets') // optional - * .addWidget(CardService.newTextParagraph().setText( - * 'These widgets are display-only. ' + - * 'A text paragraph can have multiple lines and ' + - * 'formatting.')) - * .addWidget(CardService.newImage().setImageUrl( - * 'https://www.example.com/images/mapsImage.png'))) - * .addCardAction(CardService.newCardAction().setText('Gmail').setOpenLink( - * CardService.newOpenLink().setUrl('https://mail.google.com/mail'))) - * .build(); - * } - */ - export interface CardService { - ComposedEmailType: typeof ComposedEmailType; - Icon: typeof Icon; - ImageStyle: typeof ImageStyle; - LoadIndicator: typeof LoadIndicator; - NotificationType: typeof NotificationType; - OnClose: typeof OnClose; - OpenAs: typeof OpenAs; - SelectionInputType: typeof SelectionInputType; - newAction(): Action; - newActionResponseBuilder(): ActionResponseBuilder; - newAuthorizationAction(): AuthorizationAction; - newAuthorizationException(): AuthorizationException; - newButtonSet(): ButtonSet; - newCardAction(): CardAction; - newCardBuilder(): CardBuilder; - newCardHeader(): CardHeader; - newCardSection(): CardSection; - newComposeActionResponseBuilder(): ComposeActionResponseBuilder; - newImage(): Image; - newImageButton(): ImageButton; - newKeyValue(): KeyValue; - newNavigation(): Navigation; - newNotification(): Notification; - newOpenLink(): OpenLink; - newSelectionInput(): SelectionInput; - newSuggestions(): Suggestions; - newSuggestionsResponseBuilder(): SuggestionsResponseBuilder; - newSwitch(): Switch; - newTextButton(): TextButton; - newTextInput(): TextInput; - newTextParagraph(): TextParagraph; - newUniversalActionResponseBuilder(): UniversalActionResponseBuilder; - } - - /** - * The response object that may be returned from a callback method for compose action in a Gmail add-on. - * - * var composeActionResponse = CardService.newComposeActionResponseBuilder() - * .setGmailDraft(GmailApp.createDraft("recipient", "subject", "body")) - * .build(); - */ - export interface ComposeActionResponse { - printJson(): string; - } - - /** - * A builder for ComposeActionResponse objects. - */ - export interface ComposeActionResponseBuilder { - build(): ComposeActionResponse; - setGmailDraft(draft: Gmail.GmailDraft): ComposeActionResponseBuilder; - } - - /** - * An enum value that specifies whether the composed email is a standalone or reply draft. - */ - export enum ComposedEmailType { REPLY_AS_DRAFT, STANDALONE_DRAFT } - - /** - * Predefined icons that can be used in various UI objects, such as ImageButton or KeyValue widgets. - */ - export enum Icon { NONE, AIRPLANE, BOOKMARK, BUS, CAR, CLOCK, CONFIRMATION_NUMBER_ICON, DOLLAR, DESCRIPTION, EMAIL, EVENT_PERFORMER, EVENT_SEAT, FLIGHT_ARRIVAL, FLIGHT_DEPARTURE, HOTEL, HOTEL_ROOM_TYPE, INVITE, MAP_PIN, MEMBERSHIP, MULTIPLE_PEOPLE, OFFER, PERSON, PHONE, RESTAURANT_ICON, SHOPPING_CART, STAR, STORE, TICKET, TRAIN, VIDEO_CAMERA, VIDEO_PLAY } - - /** - * A widget that shows a single image. - * - * var image = CardService.newImage().setAltText("A nice image").setImageUrl("https://image.png"); - */ - export interface Image { - setAltText(altText: string): Image; - setAuthorizationAction(action: AuthorizationAction): Image; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): Image; - setImageUrl(url: string): Image; - setOnClickAction(action: Action): Image; - setOnClickOpenLinkAction(action: Action): Image; - setOpenLink(openLink: OpenLink): Image; - } - - /** - * A ImageButton with an image displayed on it. - * - * var imageButton = CardService.newImageButton() - * .setAltText("An image button with an airplane icon.") - * .setIcon(CardService.Icon.AIRPLANE) - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://airplane.com")); - */ - export interface ImageButton { - setAltText(altText: string): ImageButton; - setAuthorizationAction(action: AuthorizationAction): ImageButton; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): ImageButton; - setIcon(icon: Icon): ImageButton; - setIconUrl(url: string): ImageButton; - setOnClickAction(action: Action): ImageButton; - setOnClickOpenLinkAction(action: Action): ImageButton; - setOpenLink(openLink: OpenLink): ImageButton; - } - - /** - * An enum that defines an image cropping style. - */ - export enum ImageStyle { SQUARE, CIRCLE } - - /** - * A widget that displays one or more "keys" around a text "value". The possible keys include an - * icon, a label above and a label below. Setting the text content and one of the keys is required - * using setContent(text) and one of setIcon(icon), setIconUrl(url), setTopLabel(text), - * or setBottomLabel(text). - * - * var imageKeyValue = CardService.newKeyValue() - * .setIconUrl("https://icon.png") - * .setContent("KeyValue widget with an image on the left and text on the right"); - * - * var textKeyValue = CardService.newKeyValue() - * .setTopLabel("Text key") - * .setContent("KeyValue widget with text key on top and cotent below"); - * - * var multilineKeyValue = CardService.newKeyValue() - * .setTopLabel("Top label - single line)") - * .setContent("Content can be multiple lines") - * .setMultiline(true) - * .setBottomLabel("Bottom label - single line"); - */ - export interface KeyValue { - setAuthorizationAction(action: AuthorizationAction): KeyValue; - setBottomLabel(text: string): KeyValue; - setButton(button: Button): KeyValue; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): KeyValue; - setContent(text: string): KeyValue; - setIcon(icon: Icon): KeyValue; - setIconAltText(altText: string): KeyValue; - setIconUrl(url: string): KeyValue; - setMultiline(multiline: boolean): KeyValue; - setOnClickAction(action: Action): KeyValue; - setOnClickOpenLinkAction(action: Action): KeyValue; - setOpenLink(openLink: OpenLink): KeyValue; - setSwitch(switchToSet: Switch): KeyValue; - setTopLabel(text: string): KeyValue; - } - - /** - * An enum type that specifies the type of loading or progress indicator to display while an Action is being processed. - */ - export enum LoadIndicator { SPINNER, NONE } - - /** - * A helper object that controls card navigation. See the card navigation guide for more details. - */ - export interface Navigation { - popCard(): Navigation; - popToNamedCard(cardName: string): Navigation; - popToRoot(): Navigation; - printJson(): string; - pushCard(card: Card): Navigation; - updateCard(card: Card): Navigation; - } - - /** - * A notification shown to the user as a response to interacting with a UI element. - * - * var action = CardService.newAction().setFunctionName("notificationCallback"); - * CardService.newTextButton().setText('Save').setOnClickAction(action); - * - * // ... - * - * function notificationCallback() { - * return CardService.newActionResponseBuilder() - * .setNotification(CardService.newNotification() - * .setType(CardService.NotificationType.WARNING) - * .setText("Some info to display to user")) - * .build(); - * } - */ - export interface Notification { - setText(text: string): Notification; - setType(type: NotificationType): Notification; - } - - /** - * Type of notification to show. - */ - export enum NotificationType { INFO, ERROR, WARNING } - - /** - * An enum that specifies what to do when a URL opened through an OpenLink is closed. - * - * When a link is opened, the client either forgets about it or waits until the window is closed. - * The implementation depends on the client platform capabilities. OnClose may cause OpenAs to be ignored; if the client platform cannot support both selected values together, - * OnClose takes precedence. - */ - export enum OnClose { NOTHING, RELOAD_ADD_ON } - - /** - * An enum that specifies how to open a URL. - * - * The client can open a URL as either a full size window (if that is the frame used by the - * client), or an overlay (such as a pop-up). The implementation depends on the client platform - * capabilities, and the value selected may be ignored if the client does not support it. FULL_SIZE is supported by all clients. - * - * Using OnClose may cause OpenAs to be ignored; if the client platform cannot - * support both selected values together, OnClose takes precedence. - */ - export enum OpenAs { FULL_SIZE, OVERLAY } - - /** - * Represents an action to open a link with some options. - * - * // A button that opens as a link in an overlay and - * // requires a reload when closed. - * var button = CardService.newTextButton() - * .setText("This button opens a link in an overlay window") - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://www.google.com") - * .setOpenAs(CardService.OpenAs.OVERLAY) - * .setOnClose(CardService.OnClose.RELOAD_ADD_ON)); - * - * // An action response that opens a link in full screen and - * // requires no action when closed. - * var actionResponse = CardService.newActionResponseBuilder() - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://www.google.com") - * .setOpenAs(CardService.OpenAs.FULL_SIZE) - * .setOnClose(CardService.OnClose.NOTHING)); - * .build(); - */ - export interface OpenLink { - setOnClose(onClose: OnClose): OpenLink; - setOpenAs(openAs: OpenAs): OpenLink; - setUrl(url: string): OpenLink; - } - - /** - * An input field that allows choosing between a set of predefined options. - * - * var checkboxGroup = CardService.newSelectionInput() - * .setType(CardService.SelectionInputType.CHECK_BOX) - * .setTitle("A group of checkboxes. Multiple selections are allowed.") - * .setFieldName("checkbox_field") - * .addItem("checkbox one title", "checkbox_one_value", false) - * .addItem("checkbox two title", "checkbox_two_value", true) - * .addItem("checkbox three title", "checkbox_three_value", false) - * .setOnChangeAction(CardService.newAction() - * .setFunctionName("handleCheckboxChange")); - * - * var radioGroup = CardService.newSelectionInput() - * .setType(CardService.SelectionInputType.RADIO_BUTTON) - * .setTitle("A group of radio buttons. Only a single selection is allowed.") - * .setFieldName("checkbox_field") - * .addItem("radio button one title", "radio_one_value", true) - * .addItem("radio button two title", "radio_two_value", true) - * .addItem("radio button three title", "radio_three_value", false); - */ - export interface SelectionInput { - addItem(text: Object, value: Object, selected: boolean): SelectionInput; - setFieldName(fieldName: string): SelectionInput; - setOnChangeAction(action: Action): SelectionInput; - setTitle(title: string): SelectionInput; - setType(type: SelectionInputType): SelectionInput; - } - - /** - * Type of selection input. - */ - export enum SelectionInputType { CHECK_BOX, RADIO_BUTTON, DROPDOWN } - - /** - * Autocomplete suggestions to supplement a TextInput widget. - * - * var textInput = CardService.newTextInput() - * .setSuggestions(CardService.newSuggestions() - * .addSuggestion("First suggestion") - * .addSuggestion("Second suggestion")) - */ - export interface Suggestions { - addSuggestion(suggestion: string): Suggestions; - addSuggestions(suggestions: Object[]): Suggestions; - } - - /** - * A response object that can be returned from a suggestions callback function. This is used with - * TextInput widgets that implement autocomplete. - * - * var suggestionsResponse = CardService.newSuggestionsResponseBuilder() - * .setSuggestions(CardService.newSuggestions() - * .addSuggestion("First suggestion") - * .addSuggestion("Second suggestion")) - * .build(); - */ - export interface SuggestionsResponse { - printJson(): string; - } - - /** - * A builder for SuggestionsResponse objects. - */ - export interface SuggestionsResponseBuilder { - build(): SuggestionsResponse; - setSuggestions(suggestions: Suggestions): SuggestionsResponseBuilder; - } - - /** - * A UI element that supports being toggled on or off. This can only be used within a KeyValue widget. - * - * var switchKeyValue = CardService.newKeyValue() - * .setTopLabel("Switch key value widget label") - * .setContent("This is a key value widget with a switch on the right") - * .setSwitch(CardService.newSwitch() - * .setFieldName("form_input_switch_key") - * .setValue("form_input_switch_value") - * .setOnChangeAction(CardService.newAction() - * .setFunctionName("handleSwitchChange"))); - */ - export interface Switch { - setFieldName(fieldName: string): Switch; - setOnChangeAction(action: Action): Switch; - setSelected(selected: boolean): Switch; - setValue(value: string): Switch; - } - - /** - * A TextButton with a text label. - * - * var textButton = CardService.newTextButton() - * .setText("Open Link") - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://www.google.com")); - */ - export interface TextButton { - setAuthorizationAction(action: AuthorizationAction): TextButton; - setComposeAction(action: Action, composedEmailType: ComposedEmailType): TextButton; - setOnClickAction(action: Action): TextButton; - setOnClickOpenLinkAction(action: Action): TextButton; - setOpenLink(openLink: OpenLink): TextButton; - setText(text: string): TextButton; - } - - /** - * A input field widget that accepts text input. - * - * var textInput = CardService.newTextInput() - * .setFieldName("text_input_form_input_key") - * .setTitle("Text input title") - * .setHint("Text input hint"); - */ - export interface TextInput { - setFieldName(fieldName: string): TextInput; - setHint(hint: string): TextInput; - setMultiline(multiline: boolean): TextInput; - setOnChangeAction(action: Action): TextInput; - setSuggestions(suggestions: Suggestions): TextInput; - setSuggestionsAction(suggestionsAction: Action): TextInput; - setTitle(title: string): TextInput; - setValue(value: string): TextInput; - } - - /** - * A widget that displays text and supports basic HTML formatting. - * - * var textParagraph = CardService.newTextParagraph() - * .setText("This is a text paragraph widget. Multiple lines are allowed if needed."); - */ - export interface TextParagraph { - setText(text: string): TextParagraph; - } - - /** - * The response object that may be returned from a method that creates universal action. - * - * // A universal action that opens a link. - * var openLinkUniversalAction = CardService.newUniversalActionResponseBuilder() - * .setOpenLink(CardService.newOpenLink() - * .setUrl("https://www.google.com")) - * .build(); - * - * var cardBuilder1 = CardService.newCardBuilder(); - * var cardBuilder2 = CardService.newCardBuilder(); - * // Finish building the cards ... - * - * // A universal action that shows two static cards. - * var cardsUniversalAction = CardService.newUniversalActionResponseBuilder() - * .displayAddOnCards([ - * cardBuilder1.build(); - * cardBuilder2.build(); - * ]).build(); - */ - export interface UniversalActionResponse { - printJson(): string; - } - - /** - * A builder for the UniversalActionResponse objects. - */ - export interface UniversalActionResponseBuilder { - build(): UniversalActionResponse; - displayAddOnCards(cardObjects: Object[]): UniversalActionResponseBuilder; - setOpenLink(openLink: OpenLink): UniversalActionResponseBuilder; - } - - /** - * Base class for all widgets that can be added to a Card. - */ - export interface Widget { - } - - } -} - -declare var CardService: GoogleAppsScript.Card.CardService; diff --git a/types/google-apps-script/index.d.ts b/types/google-apps-script/index.d.ts index ae463c738b..8e565f334f 100644 --- a/types/google-apps-script/index.d.ts +++ b/types/google-apps-script/index.d.ts @@ -11,28 +11,29 @@ // Google Services (Google APIs) /// -/// -/// /// -/// +/// /// /// /// /// /// -/// +/// /// /// /// /// // Script Services (Other *App / *Service) +/// +/// +/// /// /// -/// /// -/// +/// /// +/// /// /// /// From e7ed9763dfab6e80d4b4c1410318e1ce69df428e Mon Sep 17 00:00:00 2001 From: Oskar Lindgren Date: Sat, 29 Dec 2018 15:32:38 +0900 Subject: [PATCH 009/139] add webdriverio appium desired capabilities --- types/webdriverio/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/webdriverio/index.d.ts b/types/webdriverio/index.d.ts index 48fb31af47..4a1f585808 100644 --- a/types/webdriverio/index.d.ts +++ b/types/webdriverio/index.d.ts @@ -6,6 +6,7 @@ // Tanvir ul Islam // Dave Parslow // Phil Leger +// Oskar Lindgren // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -273,6 +274,11 @@ declare namespace WebdriverIO { [name: string]: any; }; + // Appium specific + platformVersion?: string; + automationName?: string; + app?: string; + cleanSession?: boolean; // Chrome specific From 6ae5225037c41b3ffd3d90dd1e0ede947b932cc9 Mon Sep 17 00:00:00 2001 From: Oskar Lindgren Date: Sat, 29 Dec 2018 15:35:36 +0900 Subject: [PATCH 010/139] refactor webdriverio tests --- types/webdriverio/webdriverio-tests.ts | 162 ++++++++++++++----------- 1 file changed, 89 insertions(+), 73 deletions(-) diff --git a/types/webdriverio/webdriverio-tests.ts b/types/webdriverio/webdriverio-tests.ts index 11b473066b..f5e33e776e 100644 --- a/types/webdriverio/webdriverio-tests.ts +++ b/types/webdriverio/webdriverio-tests.ts @@ -2,11 +2,18 @@ import * as webdriverio from "webdriverio"; import { assert } from "chai"; // Stub mocha functions -const {describe, it, before, after, beforeEach, afterEach} = null as any as { - [s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any}; +const { describe, it, before, after, beforeEach, afterEach } = null as any as { + [s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & { only: any, skip: any }; }; -describe("webdriver.io page", () => { +describe("my webdriverio tests", () => { + let client: webdriverio.Client; + + before(async () => { + client = webdriverio.remote({ deprecationWarnings: true, desiredCapabilities: { browserName: "phantomjs" } }); + await client.init(); + }); + it("should have the right title - the good old callback way", () => { assert.equal( browser @@ -23,15 +30,6 @@ describe("webdriver.io page", () => { assert.equal(title, "WebdriverIO - Selenium 2.0 javascript bindings for nodejs"); }); }); -}); - -describe.only("my webdriverio tests", () => { - let client: webdriverio.Client; - - before(async () => { - client = webdriverio.remote({ deprecationWarnings: true, desiredCapabilities: { browserName: "phantomjs" } }); - await client.init(); - }); it("Github test", async () => { await client.url("https://github.com/"); @@ -57,76 +55,94 @@ describe.only("my webdriverio tests", () => { }); }); -const matrix = webdriverio.multiremote({ - browserA: { - desiredCapabilities: { - browserName: "chrome", - chromeOptions: { - args: [ - "use-fake-device-for-media-stream", - "use-fake-ui-for-media-stream", - ] - } - } - }, - browserB: { - desiredCapabilities: { - browserName: "chrome", - chromeOptions: { - args: [ - "use-fake-device-for-media-stream", - "use-fake-ui-for-media-stream", - ] - } - } - } +describe("multiremote test", () => { + let matrix: webdriverio.Client; + + before(async () => { + matrix = webdriverio.multiremote({ + browserA: { + desiredCapabilities: { + browserName: "chrome", + chromeOptions: { + args: [ + "use-fake-device-for-media-stream", + "use-fake-ui-for-media-stream", + ], + }, + }, + }, + browserB: { + desiredCapabilities: { + browserName: "chrome", + chromeOptions: { + args: [ + "use-fake-device-for-media-stream", + "use-fake-ui-for-media-stream", + ], + }, + }, + }, + }); }); -const channel = Math.round(Math.random() * 100000000000); + it("clicks a button in a random channel at apprtc", () => { + const channel = Math.round(Math.random() * 100000000000); -matrix - .init() - .url("https://apprtc.appspot.com/r/" + channel) - .click("#confirm-join-button") - .pause(5000) - .end(); + matrix + .init() + .url("https://apprtc.appspot.com/r/" + channel) + .click("#confirm-join-button") + .pause(5000) + .end(); + }); -const options = { - desiredCapabilities: { - browserName: "chrome" - } -}; + after(async () => { + await matrix.end(); + }); +}); -webdriverio - .remote(options) - .init() - .url("https://news.ycombinator.com/") - .selectorExecute("//div", (inputs: HTMLElement[], message: string) => { - return `${inputs.length} ${message}`; - }, "divs on the page") - .then((res: string) => { - console.log(res); - }) - .end(); +describe("testing feaures with chrome", () => { + const options = { + desiredCapabilities: { + browserName: "chrome", + }, + }; -webdriverio - .remote(options) - .init() - .url("http://www.google.com/") - .waitForVisible("//input[@type='submit']", 5000) - .then((visible) => { - console.log(visible); // Should return true - }) - .end(); + it("can use selectorExecute", () => { + webdriverio + .remote(options) + .init() + .url("https://news.ycombinator.com/") + .selectorExecute("//div", (inputs: HTMLElement[], message: string) => { + return `${inputs.length} ${message}`; + }, "divs on the page") + .then((res: string) => { + console.log(res); + }) + .end(); + }); -let hooks: webdriverio.Hooks = {}; + it("can waitForVisible", () => { + webdriverio + .remote(options) + .init() + .url("http://www.google.com/") + .waitForVisible("//input[@type='submit']", 5000) + .then((visible) => { + console.log(visible); // Should return true + }) + .end(); + }); +}); + +let hooks: webdriverio.Hooks = {}; hooks = { - // Hooks can be a noop function - onPrepare: () => undefined, - onError() { - // Hooks don't have to return a value - } + // Hooks can be a noop function + onPrepare: () => undefined, + onError() { + // Hooks don't have to return a value + } }; hooks.onComplete = async () => { From 8414c3f8bea09cdc33d340326f3b4f6b02f8cbd3 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sat, 29 Dec 2018 11:33:05 +0100 Subject: [PATCH 011/139] [retry] Update types to v0.12 --- types/retry/index.d.ts | 176 +++++++++++++++---------------------- types/retry/retry-tests.ts | 45 +++++----- types/retry/tsconfig.json | 4 +- types/retry/tslint.json | 6 +- 4 files changed, 96 insertions(+), 135 deletions(-) diff --git a/types/retry/index.d.ts b/types/retry/index.d.ts index 97729cec2d..543f3e13af 100644 --- a/types/retry/index.d.ts +++ b/types/retry/index.d.ts @@ -1,57 +1,68 @@ -// Type definitions for retry 0.10 +// Type definitions for retry 0.12 // Project: https://github.com/tim-kos/node-retry // Definitions by: Stan Goldmann +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 export interface RetryOperation { - /** - * Defines the function that is to be retried and executes it for the first time right away. - * - * @param callback The function that is to be retried - * @param callback.current Number of attempts callback has been executed so far. - * @param [options.timeout] A timeout in milliseconds. - * @param [options.callback] Callback to execute when the operation takes longer than the timeout. - * - */ - attempt(callback: (current: number) => void, options?: AttemptOptions): void; + /** + * Returns an array of all errors that have been passed to `retryOperation.retry()` so far. + * The returning array has the errors ordered chronologically based on when they were passed to + * `retryOperation.retry()`, which means the first passed error is at index zero and the last is at the last index. + */ + errors(): Error[]; - /** - * Returns false when no error value is given, or the maximum amount of retries has been reached. - * Otherwise it returns true, and retries the operation after the timeout for the current attempt number. - * - * - */ - retry(err?: Error): boolean; + /** + * A reference to the error object that occured most frequently. + * Errors are compared using the `error.message` property. + * If multiple error messages occured the same amount of time, the last error object with that message is returned. + * + * @return If no errors occured so far the value will be `null`. + */ + mainError(): Error | null; - /** - * The number of attempts it took to call the retrying function before it was successful. - * - */ - attempts(): number; + /** + * Defines the function that is to be retried and executes it for the first time right away. + * + * @param fn The function that is to be retried. `currentAttempt` represents the number of attempts + * callback has been executed so far. + * @param [timeoutOps.timeout] A timeout in milliseconds. + * @param [timeoutOps.callback] Callback to execute when the operation takes longer than the timeout. + */ + attempt(fn: (currentAttempt: number) => void, timeoutOps?: AttemptTimeoutOptions): void; - /** - * A reference to the error object that occured most frequently. - * Errors are compared using the error.message property. - * - * @return If no errors occured so far the value will be null. - */ - mainError(): Error | null; + /** + * Returns `false` when no `error` value is given, or the maximum amount of retries has been reached. + * Otherwise it returns `true`, and retries the operation after the timeout for the current attempt number. + */ + retry(err?: Error): boolean; - /** - * Returns an array of all errors that have been passed to RetryOperation.retry() so far. - * - */ - errors(): Error[]; + /** + * Stops the operation being retried. Useful for aborting the operation on a fatal error etc. + */ + stop(): void; - /** - * Stops the operation being retried. Useful for aborting the operation on a fatal error etc. - */ - stop(): void; + /** + * Resets the internal state of the operation object, so that you can call `attempt()` again as if + * this was a new operation object. + */ + reset(): void; + + /** + * Returns an int representing the number of attempts it took to call `fn` before it was successful. + */ + attempts(): number; } -export interface AttemptOptions { +export interface AttemptTimeoutOptions { + /** + * A timeout in milliseconds. + */ timeout?: number; + /** + * Callback to execute when the operation takes longer than the timeout. + */ callback?(): void; } @@ -69,45 +80,33 @@ export interface AttemptOptions { */ export function operation(options?: OperationOptions): RetryOperation; -export interface OperationOptions { +export interface OperationOptions extends TimeoutsOptions { /** - * The maximum amount of times to retry the operation. - * @default 10 - */ - retries?: number; - /** - * The exponential factor to use. - * @default 2 - */ - factor?: number; - /** - * The number of milliseconds before starting the first retry. - * @default 1000 - */ - minTimeout?: number; - /** - * The maximum number of milliseconds between two retries. - * @default Infinity - */ - maxTimeout?: number; - /** - * Randomizes the timeouts by multiplying a factor between 1-2. + * Whether to retry forever. * @default false */ - randomize?: boolean; forever?: boolean; + /** + * Whether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's. + * @default false + */ unref?: boolean; + /** + * The maximum time (in milliseconds) that the retried operation is allowed to run. + * @default Infinity + */ + maxRetryTime?: number; } /** Get an array with timeouts and their return values in milliseconds. */ export function timeouts(options?: TimeoutsOptions): number[]; -export interface TimeoutsOptions { +export interface TimeoutsOptions extends CreateTimeoutOptions { + /** + * The maximum amount of times to retry the operation. + * @default 10 + */ retries?: number; - factor?: number; - minTimeout?: number; - maxTimeout?: number; - randomize?: boolean; } /** @@ -148,42 +147,5 @@ export interface CreateTimeoutOptions { * @param methods Methods which need to be wrapped * */ -export function wrap(object: object, options?: WrapOptions, methods?: string[]): void; - -export interface WrapOptions { - /** - * The maximum amount of times to retry the operation. - * @default 10 - */ - retries?: number; - /** - * The exponential factor to use. - * @default 2 - */ - factor?: number; - /** - * The number of milliseconds before starting the first retry. - * @default 1000 - */ - minTimeout?: number; - /** - * The maximum number of milliseconds between two retries. - * @default Infinity - */ - maxTimeout?: number; - /** - * Randomizes the timeouts by multiplying a factor between 1-2. - * @default false - */ - randomize?: boolean; - /** - * Whether to retry forever. - * @default false - */ - forever?: boolean; - /** - * Whether to unref the setTimeout's. - * @default false - */ - unref?: boolean; -} +export function wrap(object: object, methods?: string[]): void; +export function wrap(object: object, options?: OperationOptions, methods?: string[]): void; diff --git a/types/retry/retry-tests.ts b/types/retry/retry-tests.ts index bb5eb35976..a68d6c635a 100644 --- a/types/retry/retry-tests.ts +++ b/types/retry/retry-tests.ts @@ -11,7 +11,7 @@ const evr = false; const unr = false; // Options themselves -const operationOptions = { +const operationOptions: retry.OperationOptions = { retries: ret, factor: fac, minTimeout: min, @@ -19,17 +19,18 @@ const operationOptions = { randomize: rnd, forever: evr, unref: unr, + maxRetryTime: max, }; -const timeoutOptions = { +const timeoutsOptions: retry.TimeoutsOptions = { + retries: ret, factor: fac, minTimeout: min, maxTimeout: max, randomize: rnd, }; -const timeoutsOptions = { - retries: ret, +const createTimeoutOptions: retry.CreateTimeoutOptions = { factor: fac, minTimeout: min, maxTimeout: max, @@ -49,24 +50,26 @@ class Foo { const operation = retry.operation(operationOptions); -operation.attempt((current) => { - const err = Math.random() >= 0.5 ? new Error('Happens to the best of us') : undefined; - - const retry = operation.retry(err); - - if (retry) { - const after = operation.attempts(); - } else { - const errors = operation.errors(); - - const main = operation.mainError(); - } - - operation.stop(); +operation.errors(); // $ExpectType Error[] +operation.mainError(); // $ExpectType Error | null +operation.attempt(current => { + current; // $ExpectType number }); +operation.attempt(current => {}, { timeout: 10 }); +operation.attempt(current => {}, { callback: () => {} }); +operation.retry(); // $ExpectType boolean +operation.retry(new Error()); // $ExpectType boolean +operation.stop(); +operation.reset(); +operation.attempts(); // $ExpectType number -const timeout = retry.createTimeout(att, timeoutOptions); +retry.createTimeout(att); // $ExpectType number +retry.createTimeout(att, createTimeoutOptions); // $ExpectType number -const timeouts = retry.timeouts(timeoutsOptions); +retry.timeouts(); // $ExpectType number[] +retry.timeouts(timeoutsOptions); // $ExpectType number[] -const wrap = retry.wrap(new Foo(), operationOptions, ['bar']); +retry.wrap(new Foo()); +retry.wrap(new Foo(), ['bar']); +retry.wrap(new Foo(), operationOptions, ['bar']); +retry.wrap(new Foo(), operationOptions); diff --git a/types/retry/tsconfig.json b/types/retry/tsconfig.json index 6e2c5d42d2..268dbcfff3 100644 --- a/types/retry/tsconfig.json +++ b/types/retry/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es5" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, @@ -20,4 +20,4 @@ "index.d.ts", "retry-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/retry/tslint.json b/types/retry/tslint.json index 26a0c302a8..f93cf8562a 100644 --- a/types/retry/tslint.json +++ b/types/retry/tslint.json @@ -1,7 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODO - "no-void-expression": false - } + "extends": "dtslint/dt.json" } From 22f5bc8bb7971f4ceef8f98b305679f3bcdd31b1 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sat, 29 Dec 2018 15:22:34 +0100 Subject: [PATCH 012/139] [retry] Fix dependent package --- types/promise-retry/index.d.ts | 6 +++--- types/promise-retry/tsconfig.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/promise-retry/index.d.ts b/types/promise-retry/index.d.ts index f2d9ee5747..01fe6cb25b 100644 --- a/types/promise-retry/index.d.ts +++ b/types/promise-retry/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { WrapOptions } from "retry"; +import { OperationOptions } from "retry"; /** * A function that is retryable, by having implicitly-bound params for both an error handler and an attempt number. * @@ -22,6 +22,6 @@ type RetryableFn = ((retry: (error: any) => never, attempt: numb * @param options The options for how long/often to retry the function for. * @returns The Promise resolved by the input retryableFn, or rejected (if not retried) from its catch block. */ -declare function promiseRetry(retryableFn: RetryableFn, options?: WrapOptions): Promise; -declare function promiseRetry(options: WrapOptions, retryableFn: RetryableFn): Promise; +declare function promiseRetry(retryableFn: RetryableFn, options?: OperationOptions): Promise; +declare function promiseRetry(options: OperationOptions, retryableFn: RetryableFn): Promise; export = promiseRetry; diff --git a/types/promise-retry/tsconfig.json b/types/promise-retry/tsconfig.json index 660e112726..cd598fc1f4 100644 --- a/types/promise-retry/tsconfig.json +++ b/types/promise-retry/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "promise-retry-tests.ts" ] -} \ No newline at end of file +} From 6dc17a08ce2b29b15a63f82fe5069d2143fb2b79 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Sat, 29 Dec 2018 19:15:19 +0200 Subject: [PATCH 013/139] Add React plugin to linkifyjs declaration. --- types/linkifyjs/index.d.ts | 1 + types/linkifyjs/linkifyjs-tests.ts | 260 ++++++++++++++++------------- types/linkifyjs/react.d.ts | 12 ++ 3 files changed, 154 insertions(+), 119 deletions(-) create mode 100644 types/linkifyjs/react.d.ts diff --git a/types/linkifyjs/index.d.ts b/types/linkifyjs/index.d.ts index 9c095a41f3..14f618102b 100644 --- a/types/linkifyjs/index.d.ts +++ b/types/linkifyjs/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for linkifyjs 2.1 // Project: https://github.com/SoapBox/linkifyjs#readme // Definitions by: Sean Zhu +// Ovidiu Bute // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 diff --git a/types/linkifyjs/linkifyjs-tests.ts b/types/linkifyjs/linkifyjs-tests.ts index 5688f9f99f..52d46fb416 100644 --- a/types/linkifyjs/linkifyjs-tests.ts +++ b/types/linkifyjs/linkifyjs-tests.ts @@ -1,141 +1,163 @@ +import * as React from "react"; +import * as ReactDOM from "react-dom"; import linkifyHtml from "linkifyjs/html"; +import Linkify from "linkifyjs/react"; + +declare function describe(desc: string, f: () => void): void; +declare function it(desc: string, f: () => void): void; // From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html -/* attributes */ +describe("linkifyjs/html", () => { + /* attributes */ -linkifyHtml("github.com", { - attributes: { - rel: "nofollow" - } -}); - -/* className */ - -linkifyHtml("github.com", { - className: "new-link--url" -}); - -linkifyHtml("github.com", { - className(href, type) { - return "new-link--" + type; - } -}); - -linkifyHtml("github.com", { - className: { - url: "new-link--url", - email(href: string) { - return "new-link--email"; + linkifyHtml("github.com", { + attributes: { + rel: "nofollow" } - } -}); + }); -/* events */ + /* className */ -linkifyHtml("", { - events: { - click(e) { - alert("Link clicked!"); - }, - mouseover(e) { - alert("Link hovered!"); + linkifyHtml("github.com", { + className: "new-link--url" + }); + + linkifyHtml("github.com", { + className(href, type) { + return "new-link--" + type; } - } -}); + }); -/* defaultProtocol */ - -/* format */ - -linkifyHtml("", { - format(value, type) { - if (type === "url" && value.length > 50) { - value = value.slice(0, 50) + "…"; + linkifyHtml("github.com", { + className: { + url: "new-link--url", + email(href: string) { + return "new-link--email"; + } } - return value; - } -}); + }); -linkifyHtml("", { - format: { - url(value) { - return value.length > 50 ? value.slice(0, 50) + "…" : value; + /* events */ + + linkifyHtml("", { + events: { + click(e) { + alert("Link clicked!"); + }, + mouseover(e) { + alert("Link hovered!"); + } } - } -}); + }); -/* formatHref */ + /* defaultProtocol */ -linkifyHtml("This site is #rad", { - formatHref(href, type) { - if (type === "hashtag") { - href = "https://twitter.com/hashtag/" + href.substring(1); + /* format */ + + linkifyHtml("", { + format(value, type) { + if (type === "url" && value.length > 50) { + value = value.slice(0, 50) + "…"; + } + return value; } - return href; - } -}); + }); -linkifyHtml("Hey @dhh, check out issue #23", { - formatHref: { - mention(href) { - return "https://github.com" + href; - }, - ticket(href) { - return ( - "https://github.com/SoapBox/linkifyjs/issues/" + - href.substring(1) - ); + linkifyHtml("", { + format: { + url(value) { + return value.length > 50 ? value.slice(0, 50) + "…" : value; + } } - } -}); + }); -/* ignoreTags */ + /* formatHref */ -linkifyHtml( - // tslint:disable-next-line:prefer-template - 'Please ignore \n' + - "but do b.ca", - { - ignoreTags: ["script", "style"] - } -); - -/* nl2br */ - -/* tagName */ - -linkifyHtml("github.com", { - tagName: "span" -}); - -linkifyHtml("#swag", { - tagName: { - hashtag: "span" - } -}); - -/* target */ - -linkifyHtml("github.com", { - target: "_parent" -}); - -linkifyHtml("test-email@example.com", { - target: { - url: "_parent", - email: null - } -}); - -/* validate */ - -// Don't linkify links that don't begin in a protocol -// e.g., "http://google.com" will be linkified, but "google.com" will not. -linkifyHtml("www.google.com", { - validate: { - url(value) { - return /^(http|ftp)s?:\/\//.test(value); + linkifyHtml("This site is #rad", { + formatHref(href, type) { + if (type === "hashtag") { + href = "https://twitter.com/hashtag/" + href.substring(1); + } + return href; } - } + }); + + linkifyHtml("Hey @dhh, check out issue #23", { + formatHref: { + mention(href) { + return "https://github.com" + href; + }, + ticket(href) { + return ( + "https://github.com/SoapBox/linkifyjs/issues/" + + href.substring(1) + ); + } + } + }); + + /* ignoreTags */ + + linkifyHtml( + // tslint:disable-next-line:prefer-template + 'Please ignore \n' + + "but do b.ca", + { + ignoreTags: ["script", "style"] + } + ); + + /* nl2br */ + + /* tagName */ + + linkifyHtml("github.com", { + tagName: "span" + }); + + linkifyHtml("#swag", { + tagName: { + hashtag: "span" + } + }); + + /* target */ + + linkifyHtml("github.com", { + target: "_parent" + }); + + linkifyHtml("test-email@example.com", { + target: { + url: "_parent", + email: null + } + }); + + /* validate */ + + // Don't linkify links that don't begin in a protocol + // e.g., "http://google.com" will be linkified, but "google.com" will not. + linkifyHtml("www.google.com", { + validate: { + url(value) { + return /^(http|ftp)s?:\/\//.test(value); + } + } + }); +}); + +describe("linkifyjs/react", () => { + it("should render a Linkify component", () => { + const rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement(Linkify, { + options: { + className: "custom-class-name" + } + }), + rootElement + ); + }); }); diff --git a/types/linkifyjs/react.d.ts b/types/linkifyjs/react.d.ts new file mode 100644 index 0000000000..352e87bf77 --- /dev/null +++ b/types/linkifyjs/react.d.ts @@ -0,0 +1,12 @@ +import * as React from "react"; +import { LinkifyOptions } from "./index"; + +declare interface LinkifyProps { + options: LinkifyOptions; +} + +declare class Linkify extends React.Component {} + +export { LinkifyProps }; + +export default Linkify; From ff09198a0fecfb2eadd278c92e415396ae61059f Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Sat, 29 Dec 2018 19:19:24 +0200 Subject: [PATCH 014/139] Add new declaration file. --- types/linkifyjs/tsconfig.json | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/types/linkifyjs/tsconfig.json b/types/linkifyjs/tsconfig.json index 52b1940fcd..2ddde7ba4f 100644 --- a/types/linkifyjs/tsconfig.json +++ b/types/linkifyjs/tsconfig.json @@ -1,25 +1,16 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom" - ], + "lib": ["es6", "dom"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "index.d.ts", - "html.d.ts", - "linkifyjs-tests.ts" - ] + "files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.ts"] } From 4b21ebf8d887de0592e01e5363f045750939eb83 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Sat, 29 Dec 2018 19:21:56 +0200 Subject: [PATCH 015/139] Change minimum TypeScript version. --- types/linkifyjs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/linkifyjs/index.d.ts b/types/linkifyjs/index.d.ts index 14f618102b..5626288816 100644 --- a/types/linkifyjs/index.d.ts +++ b/types/linkifyjs/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Sean Zhu // Ovidiu Bute // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 export type PossiblyFuncOfHrefAndType = | T From 3778d7dce48c38b5ff0317bb43e01aec11911e2f Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Sat, 29 Dec 2018 19:27:02 +0200 Subject: [PATCH 016/139] Change minimum TypeScript version. --- types/linkifyjs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/linkifyjs/index.d.ts b/types/linkifyjs/index.d.ts index 5626288816..d41d7bc8c1 100644 --- a/types/linkifyjs/index.d.ts +++ b/types/linkifyjs/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Sean Zhu // Ovidiu Bute // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.8 export type PossiblyFuncOfHrefAndType = | T From d6059686990c0007d0c6c5de43e7465e5f122ad7 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Sat, 29 Dec 2018 19:29:46 +0200 Subject: [PATCH 017/139] Remove redundant declare. --- types/linkifyjs/react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/linkifyjs/react.d.ts b/types/linkifyjs/react.d.ts index 352e87bf77..cdf9d42900 100644 --- a/types/linkifyjs/react.d.ts +++ b/types/linkifyjs/react.d.ts @@ -1,7 +1,7 @@ import * as React from "react"; import { LinkifyOptions } from "./index"; -declare interface LinkifyProps { +interface LinkifyProps { options: LinkifyOptions; } From 7b72165601a8a83f120f5dd4348c6d2a8bd62827 Mon Sep 17 00:00:00 2001 From: Kevin Pennarun Date: Sat, 29 Dec 2018 20:08:04 +0100 Subject: [PATCH 018/139] fix(react-redux)-use-the-new-forwardRef-option --- types/react-redux/index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index bcbcced0bd..39d1a8d743 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -314,6 +314,13 @@ export interface Options boolean; + + /** + * If true, use React's forwardRef to expose a ref of the wrapped component + * + * @default false + */ + forwardRef?: boolean; } /** @@ -383,7 +390,7 @@ export interface ConnectOptions { */ storeKey?: string; /** - * If true, stores a ref to the wrapped component instance and makes it available via getWrappedInstance() method. + * @deprecated Use forwardRef * * @default false */ From 33dfeb9d34d7d1973871938222ec7d86ef52546a Mon Sep 17 00:00:00 2001 From: Yongbeen Im Date: Sun, 30 Dec 2018 17:12:38 +0900 Subject: [PATCH 019/139] classnames tsconfig file modified strictNullChecks option to true --- types/classnames/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/classnames/tsconfig.json b/types/classnames/tsconfig.json index f9b03432fc..0e8475e613 100644 --- a/types/classnames/tsconfig.json +++ b/types/classnames/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From d81e5b3218210620695c15c8aa2a853721c6e1bc Mon Sep 17 00:00:00 2001 From: Yongbeen Im Date: Sun, 30 Dec 2018 17:13:44 +0900 Subject: [PATCH 020/139] calssnames module bind error fixed --- types/classnames/bind.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/classnames/bind.d.ts b/types/classnames/bind.d.ts index 4af94d1835..9befbabd4c 100644 --- a/types/classnames/bind.d.ts +++ b/types/classnames/bind.d.ts @@ -1,3 +1,3 @@ -import * as cn from "./index"; +import classNames = require('./index'); -export function bind(styles: Record): typeof cn; +export function bind(styles: Record): typeof classNames; From fb0afa719b54852c66efedbef76df8c6a04fc99d Mon Sep 17 00:00:00 2001 From: freewind Date: Sun, 30 Dec 2018 21:32:52 +0800 Subject: [PATCH 021/139] superagent: cookie related headers has special types --- types/superagent/index.d.ts | 2 ++ types/superagent/superagent-tests.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 7c1898cdc2..7915277b37 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -100,6 +100,7 @@ declare namespace request { files: any; forbidden: boolean; get(header: string): string; + get(header: 'Set-Cookie'): string[]; header: any; info: boolean; links: object; @@ -148,6 +149,7 @@ declare namespace request { serialize(serializer: Serializer): this; set(field: object): this; set(field: string, val: string): this; + set(field: 'Cookie', val: string[]): this; timeout(ms: number | { deadline?: number, response?: number }): this; type(val: string): this; unset(field: string): this; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index 44ef7cf773..b261a551d7 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -83,6 +83,12 @@ request .set({ 'API-Key': 'foobar', Accept: 'application/json' }) .end(callback); +// Setting cookie header +request + .get('/search') + .set('Cookie', ['name1=value1; Domain=.test.com; Path=/', 'name2=value2; Domain=.test.com; Path=/']) + .end(callback); + // GET requests request .get('/search') @@ -198,6 +204,12 @@ request('/search') const charset: string = res.charset; }); +// Getting response 'Set-Cookie' +request('/search') + .end((res: request.Response) => { + const setCookie: string[] = res.get('Set-Cookie'); + }); + // Custom parsers request .post('/search') From 31af24a42694a2b2119a7b07320dcb1fc13eec25 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:30:18 +0200 Subject: [PATCH 022/139] Fix interface and add more unit-tests. --- types/linkifyjs/linkifyjs-tests.ts | 48 +++++++++++++++++++++++++----- types/linkifyjs/react.d.ts | 2 +- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.ts b/types/linkifyjs/linkifyjs-tests.ts index 52d46fb416..12d5b04dbf 100644 --- a/types/linkifyjs/linkifyjs-tests.ts +++ b/types/linkifyjs/linkifyjs-tests.ts @@ -6,9 +6,9 @@ import Linkify from "linkifyjs/react"; declare function describe(desc: string, f: () => void): void; declare function it(desc: string, f: () => void): void; -// From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html - describe("linkifyjs/html", () => { + // From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html + /* attributes */ linkifyHtml("github.com", { @@ -149,14 +149,48 @@ describe("linkifyjs/html", () => { }); describe("linkifyjs/react", () => { + // From the docs here: https://soapbox.github.io/linkifyjs/docs/linkify-react.html + it("should render a Linkify component", () => { const rootElement = document.createElement("div"); ReactDOM.render( - React.createElement(Linkify, { - options: { - className: "custom-class-name" - } - }), + React.createElement( + Linkify, + {}, + React.createElement("span", "Hello https://google.com") + ), + rootElement + ); + }); + + it("should render a Linkify component with a custom className", () => { + const rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + options: { + className: "custom-class-name" + } + }, + React.createElement("span", "Hello https://google.com") + ), + rootElement + ); + }); + + it("should render a Linkify component with a custom tagName", () => { + const rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + options: { + tagName: "p" + } + }, + React.createElement("span", "Hello https://google.com") + ), rootElement ); }); diff --git a/types/linkifyjs/react.d.ts b/types/linkifyjs/react.d.ts index cdf9d42900..13591b6a6a 100644 --- a/types/linkifyjs/react.d.ts +++ b/types/linkifyjs/react.d.ts @@ -2,7 +2,7 @@ import * as React from "react"; import { LinkifyOptions } from "./index"; interface LinkifyProps { - options: LinkifyOptions; + options?: LinkifyOptions; } declare class Linkify extends React.Component {} From 3b2f86cb424afcb361b8062aa49246ae624301d3 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:33:02 +0200 Subject: [PATCH 023/139] Remove it calls. --- types/linkifyjs/linkifyjs-tests.ts | 76 ++++++++++++++---------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.ts b/types/linkifyjs/linkifyjs-tests.ts index 12d5b04dbf..bd7f67ea51 100644 --- a/types/linkifyjs/linkifyjs-tests.ts +++ b/types/linkifyjs/linkifyjs-tests.ts @@ -151,47 +151,41 @@ describe("linkifyjs/html", () => { describe("linkifyjs/react", () => { // From the docs here: https://soapbox.github.io/linkifyjs/docs/linkify-react.html - it("should render a Linkify component", () => { - const rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - {}, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); - }); + let rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + {}, + React.createElement("span", "Hello https://google.com") + ), + rootElement + ); - it("should render a Linkify component with a custom className", () => { - const rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - options: { - className: "custom-class-name" - } - }, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); - }); + rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + options: { + className: "custom-class-name" + } + }, + React.createElement("span", "Hello https://google.com") + ), + rootElement + ); - it("should render a Linkify component with a custom tagName", () => { - const rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - options: { - tagName: "p" - } - }, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); - }); + rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + options: { + tagName: "p" + } + }, + React.createElement("span", "Hello https://google.com") + ), + rootElement + ); }); From 793383d2a415b91273a63aa9c4d94e45957c3659 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:34:21 +0200 Subject: [PATCH 024/139] Simplify export syntax. --- types/linkifyjs/react.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/linkifyjs/react.d.ts b/types/linkifyjs/react.d.ts index 13591b6a6a..ce5dc24896 100644 --- a/types/linkifyjs/react.d.ts +++ b/types/linkifyjs/react.d.ts @@ -1,12 +1,10 @@ import * as React from "react"; import { LinkifyOptions } from "./index"; -interface LinkifyProps { +export interface LinkifyProps { options?: LinkifyOptions; } declare class Linkify extends React.Component {} -export { LinkifyProps }; - export default Linkify; From f687d485ec0acd7df12e15fa95f43ac7671d7ca7 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:38:40 +0200 Subject: [PATCH 025/139] Add missing tagName prop. --- types/linkifyjs/linkifyjs-tests.ts | 5 +---- types/linkifyjs/react.d.ts | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.ts b/types/linkifyjs/linkifyjs-tests.ts index bd7f67ea51..0376960065 100644 --- a/types/linkifyjs/linkifyjs-tests.ts +++ b/types/linkifyjs/linkifyjs-tests.ts @@ -4,7 +4,6 @@ import linkifyHtml from "linkifyjs/html"; import Linkify from "linkifyjs/react"; declare function describe(desc: string, f: () => void): void; -declare function it(desc: string, f: () => void): void; describe("linkifyjs/html", () => { // From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html @@ -180,9 +179,7 @@ describe("linkifyjs/react", () => { React.createElement( Linkify, { - options: { - tagName: "p" - } + tagName: "p" }, React.createElement("span", "Hello https://google.com") ), diff --git a/types/linkifyjs/react.d.ts b/types/linkifyjs/react.d.ts index ce5dc24896..0631b6c460 100644 --- a/types/linkifyjs/react.d.ts +++ b/types/linkifyjs/react.d.ts @@ -3,6 +3,7 @@ import { LinkifyOptions } from "./index"; export interface LinkifyProps { options?: LinkifyOptions; + tagName?: string; } declare class Linkify extends React.Component {} From 84e169e5bfb182639ce79becc1718fcc129efff4 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:39:50 +0200 Subject: [PATCH 026/139] Rename tests file to tsx. --- types/linkifyjs/{linkifyjs-tests.ts => linkifyjs-tests.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename types/linkifyjs/{linkifyjs-tests.ts => linkifyjs-tests.tsx} (100%) diff --git a/types/linkifyjs/linkifyjs-tests.ts b/types/linkifyjs/linkifyjs-tests.tsx similarity index 100% rename from types/linkifyjs/linkifyjs-tests.ts rename to types/linkifyjs/linkifyjs-tests.tsx From 396cbe2709b3f7b930a7e5457bec0bb7092cc4e0 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 09:44:43 +0200 Subject: [PATCH 027/139] Fix path to renamed file. --- types/linkifyjs/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/linkifyjs/tsconfig.json b/types/linkifyjs/tsconfig.json index 2ddde7ba4f..7a19e25d0d 100644 --- a/types/linkifyjs/tsconfig.json +++ b/types/linkifyjs/tsconfig.json @@ -12,5 +12,5 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.ts"] + "files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.tsx"] } From 1845e3f9a525b1a408e1a07e200192659331a334 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 14:31:37 +0200 Subject: [PATCH 028/139] Broaden type for attributes to fix React example. --- types/linkifyjs/index.d.ts | 2 +- types/linkifyjs/linkifyjs-tests.tsx | 40 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/types/linkifyjs/index.d.ts b/types/linkifyjs/index.d.ts index d41d7bc8c1..71f6a59226 100644 --- a/types/linkifyjs/index.d.ts +++ b/types/linkifyjs/index.d.ts @@ -28,7 +28,7 @@ export interface LinkifyOptions { * (e.g., 'url', 'email', etc.) and returns the object. */ attributes?: PossiblyFuncOfHrefAndType<{ - [attrName: string]: string; + [attrName: string]: any; }> | null; /** diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 0376960065..23b9c1f20e 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; +import { LinkifyOptions } from "linkifyjs"; import linkifyHtml from "linkifyjs/html"; import Linkify from "linkifyjs/react"; @@ -150,7 +151,46 @@ describe("linkifyjs/html", () => { describe("linkifyjs/react", () => { // From the docs here: https://soapbox.github.io/linkifyjs/docs/linkify-react.html + /* Usage */ + + var options: LinkifyOptions = {}; + var content = "For help with GitHub.com, please email support@github.com"; let rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + tagName: "p", + options: options + }, + React.createElement("span", content) + ), + rootElement + ); + + /* Events */ + + let linkProps = { + onClick: (event: any) => { + if (!confirm("Are you sure you want to leave this page?")) { + event.preventDefault(); + } + } + }; + var content = "For help with GitHub.com, please email support@github.com"; + rootElement = document.createElement("div"); + ReactDOM.render( + React.createElement( + Linkify, + { + options: { attributes: linkProps } + }, + React.createElement("span", null) + ), + rootElement + ); + + rootElement = document.createElement("div"); ReactDOM.render( React.createElement( Linkify, From d8e17753b1627df32d8c140c4848c3389543b478 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 14:44:17 +0200 Subject: [PATCH 029/139] Solve linting issue. --- types/linkifyjs/linkifyjs-tests.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 23b9c1f20e..1681932176 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -153,8 +153,8 @@ describe("linkifyjs/react", () => { /* Usage */ - var options: LinkifyOptions = {}; - var content = "For help with GitHub.com, please email support@github.com"; + const options: LinkifyOptions = {}; + const content = "For help with GitHub.com, please email support@github.com"; let rootElement = document.createElement("div"); ReactDOM.render( React.createElement( @@ -170,14 +170,14 @@ describe("linkifyjs/react", () => { /* Events */ - let linkProps = { + const linkProps = { onClick: (event: any) => { if (!confirm("Are you sure you want to leave this page?")) { event.preventDefault(); } } }; - var content = "For help with GitHub.com, please email support@github.com"; + rootElement = document.createElement("div"); ReactDOM.render( React.createElement( From 7f01b3fef06e3ffe479629fc5b9c642aa1c006dc Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Mon, 31 Dec 2018 14:46:42 +0200 Subject: [PATCH 030/139] Fix object shorthand linting error. --- types/linkifyjs/linkifyjs-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 1681932176..2ec3979134 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -161,7 +161,7 @@ describe("linkifyjs/react", () => { Linkify, { tagName: "p", - options: options + options }, React.createElement("span", content) ), From fa697d0de0e6527d1a82710644caeeb405e67526 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sun, 23 Dec 2018 21:06:10 +0100 Subject: [PATCH 031/139] [@keyv/mysql] Add types --- types/keyv__mysql/index.d.ts | 33 ++++++++++++++++++++++++++ types/keyv__mysql/keyv__mysql-tests.ts | 12 ++++++++++ types/keyv__mysql/tsconfig.json | 28 ++++++++++++++++++++++ types/keyv__mysql/tslint.json | 1 + 4 files changed, 74 insertions(+) create mode 100644 types/keyv__mysql/index.d.ts create mode 100644 types/keyv__mysql/keyv__mysql-tests.ts create mode 100644 types/keyv__mysql/tsconfig.json create mode 100644 types/keyv__mysql/tslint.json diff --git a/types/keyv__mysql/index.d.ts b/types/keyv__mysql/index.d.ts new file mode 100644 index 0000000000..4aef9d06e0 --- /dev/null +++ b/types/keyv__mysql/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for @keyv/mysql 1.1 +// Project: https://github.com/lukechilds/keyv-mysql +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import { Store } from 'keyv'; +import { EventEmitter } from 'events'; + +export = KeyvMysql; + +declare class KeyvMysql extends EventEmitter implements Store { + readonly ttlSupport: false; + namespace?: string; + + constructor(uri?: string); + constructor(options?: KeyvMysql.Options); // tslint:disable-line:unified-signatures + + get(key: string): Promise; + set(key: string, value: string | undefined): Promise; + delete(key: string): Promise; + clear(): Promise; +} + +declare namespace KeyvMysql { + interface Options { + uri?: string; + table?: string; + keySize?: number; + } +} diff --git a/types/keyv__mysql/keyv__mysql-tests.ts b/types/keyv__mysql/keyv__mysql-tests.ts new file mode 100644 index 0000000000..5a1947710d --- /dev/null +++ b/types/keyv__mysql/keyv__mysql-tests.ts @@ -0,0 +1,12 @@ +import Keyv = require('keyv'); +import KeyvMysql = require('@keyv/mysql'); + +new Keyv('mysql://user:pass@localhost:3306/dbname', { table: 'cache' }); + +new KeyvMysql('mysql://user:pass@localhost:3306/dbname'); +new KeyvMysql({ uri: 'mysql://user:pass@localhost:3306/dbname' }); +new KeyvMysql({ table: 'cache' }); +new KeyvMysql({ keySize: 100 }); + +const mysql = new KeyvMysql({ uri: 'mysql://user:pass@localhost:3306/dbname' }); +new Keyv({ store: mysql }); diff --git a/types/keyv__mysql/tsconfig.json b/types/keyv__mysql/tsconfig.json new file mode 100644 index 0000000000..e50e632d7c --- /dev/null +++ b/types/keyv__mysql/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@keyv/mysql": [ + "keyv__mysql" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "keyv__mysql-tests.ts" + ] +} diff --git a/types/keyv__mysql/tslint.json b/types/keyv__mysql/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/keyv__mysql/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 15a42cb90767d65bed9c7a10a1e5a8515cae9286 Mon Sep 17 00:00:00 2001 From: Rishi Sharma <5098873+rthreei@users.noreply.github.com> Date: Mon, 31 Dec 2018 16:49:43 -0500 Subject: [PATCH 032/139] Adds ensure to API interface --- types/xmlpoke/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/xmlpoke/index.d.ts b/types/xmlpoke/index.d.ts index d8566d4364..68bde4f9ab 100644 --- a/types/xmlpoke/index.d.ts +++ b/types/xmlpoke/index.d.ts @@ -25,6 +25,7 @@ declare module XmlPoke { // ghost module withBasePath(xpath: string): API; addNamespace(prefix: string, uri: string): API; errorOnNoMatches(): API; + ensure(xpath: string): API; } interface CDataValue { value: string; From a85ec9001a6a77c53fe59f84aa7b4a1a3fb0580e Mon Sep 17 00:00:00 2001 From: Rishi Sharma <5098873+rthreei@users.noreply.github.com> Date: Mon, 31 Dec 2018 16:54:26 -0500 Subject: [PATCH 033/139] Add a test --- types/xmlpoke/xmlpoke-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/xmlpoke/xmlpoke-tests.ts b/types/xmlpoke/xmlpoke-tests.ts index 1079d19756..04cab2aa1f 100644 --- a/types/xmlpoke/xmlpoke-tests.ts +++ b/types/xmlpoke/xmlpoke-tests.ts @@ -76,3 +76,7 @@ result = xmlpoke('', xml => return 'y'; })); assert.equal(result, 'y'); + +// ensure +result = xmlpoke('', xml => xml.ensure('a/b')); +assert.equal(result, ''); From b5bb7b09f84bffe6a229f0349c4565c717ba6656 Mon Sep 17 00:00:00 2001 From: Ivan Ha Date: Tue, 1 Jan 2019 09:51:17 +0800 Subject: [PATCH 034/139] [randomcolor] support for setting hue from a hex color --- types/randomcolor/index.d.ts | 4 ++-- types/randomcolor/randomcolor-tests.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/types/randomcolor/index.d.ts b/types/randomcolor/index.d.ts index 8a95bf6d65..d0d36297b8 100644 --- a/types/randomcolor/index.d.ts +++ b/types/randomcolor/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for randomColor 0.5.0 +// Type definitions for randomColor 0.5.2 // Project: https://github.com/davidmerfield/randomColor // Definitions by: Mathias Feitzinger , Brady Liles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,7 +6,7 @@ declare function randomColor(options?: RandomColorOptions): string; interface RandomColorOptions { - hue?: number | "red" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "monochrome" | "random"; + hue?: number | string; luminosity?: "bright" | "light" | "dark" | "random"; count?: number; seed?: number | string; diff --git a/types/randomcolor/randomcolor-tests.ts b/types/randomcolor/randomcolor-tests.ts index 5bd36b7eb4..595ea0781f 100644 --- a/types/randomcolor/randomcolor-tests.ts +++ b/types/randomcolor/randomcolor-tests.ts @@ -35,4 +35,16 @@ randomColor({ randomColor({ luminosity: 'light', format: 'hsla' // e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)' -}); \ No newline at end of file +}); + +// Returns a dark RGB color with specified alpha +randomColor({ + luminosity: 'dark', + format: 'rgba', + alpha: 0.5 // e.g. 'rgba(9, 1, 107, 0.5)', +}); + +// Support for setting hue from a hex color +randomColor({ + hue: "#00FFFF" +}); From db92425c03e131bd52307806f1b32e36974c7967 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Tue, 1 Jan 2019 09:12:24 +0200 Subject: [PATCH 035/139] Use a narrower type. --- types/linkifyjs/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/linkifyjs/index.d.ts b/types/linkifyjs/index.d.ts index 71f6a59226..a036ab52c1 100644 --- a/types/linkifyjs/index.d.ts +++ b/types/linkifyjs/index.d.ts @@ -5,6 +5,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 +import * as React from "react"; + export type PossiblyFuncOfHrefAndType = | T | ((href: string, type: string) => T); @@ -27,9 +29,9 @@ export interface LinkifyOptions { * Also accepts a function that takes the unformatted href, the link type * (e.g., 'url', 'email', etc.) and returns the object. */ - attributes?: PossiblyFuncOfHrefAndType<{ - [attrName: string]: any; - }> | null; + attributes?: PossiblyFuncOfHrefAndType< + React.AnchorHTMLAttributes + > | null; /** * className From a051a8341db5f319eb3d4fb661a6dcd898859087 Mon Sep 17 00:00:00 2001 From: Hamed Baatour Date: Tue, 1 Jan 2019 15:41:27 +0300 Subject: [PATCH 036/139] types(showdown): add missing showdown types for v1.9.0 --- types/showdown/index.d.ts | 70 ++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index 21075fd6c7..df2f17ab52 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Showdown 1.9.0 -// Project: https://github.com/coreyti/showdown -// Definitions by: cbowdon , Pei-Tang Huang , Ariel-Saldana +// Project: https://github.com/showdownjs/showdown +// Definitions by: Hamed Baatour, cbowdon , Pei-Tang Huang , Ariel-Saldana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = Showdown; @@ -64,6 +64,10 @@ declare namespace Showdown { output: ShowdownExtension[]; } + interface Metadata { + [meta: string]: string; + } + interface ShowdownOptions { /** * Omit the trailing newline in a code block. Ex: @@ -279,6 +283,43 @@ declare namespace Showdown { * @default false */ backslashEscapesHTMLTags?: boolean; + + /** + * Enable emoji support. Ex: `this is a :smile: emoji. + * + * @default false + */ + emoji?: boolean; + + /** + * Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, + * underscores no longer parses into `` and `` + * + * @default false + */ + underline?: boolean; + + /** + * Outputs a complete html document, including ``, `` and `` tags + * + * @default false + */ + completeHTMLDocument?: boolean; + + /** + * Outputs a complete html document, including ``, `` and `` tags + * + * @default false + */ + metadata?: boolean; + + /** + * Split adjacent blockquote blocks + * + * @default false + */ + splitAdjacentBlockquotes?: boolean; + } @@ -296,11 +337,11 @@ declare namespace Showdown { /** * Converts an HTML string into a markdown string - * - * @param src The input text (HTML) - * @returns The output markdown + * @param src + * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used. + * @returns {string} */ - makeMarkdown(src: string): string; + makeMarkdown(src: string, HTMLParser?: any): string; /** * Setting a "local" option only affects the specified Converter object. @@ -360,7 +401,20 @@ declare namespace Showdown { * * @param flavor name */ - setFlavor(name: string): void; + setFlavor(name: 'github' | 'original' | 'ghost' | 'vanilla' | 'allOn'): void; + + /** + * Get the metadata of the previously parsed document + * @param raw + * @returns {string|{}} + */ + getMetadata(raw?: boolean): string | Metadata + + /** + * Get the metadata format of the previously parsed document + * @returns {string} + */ + getMetadataFormat(): string; } @@ -477,5 +531,5 @@ declare namespace Showdown { * * @param name */ - function setFlavor(name: string): void; + function setFlavor(name: 'github' | 'original' | 'ghost' | 'vanilla' | 'allOn'): void; } From 36fa54b6d15414e50c362bee7e1c07dfa98f5253 Mon Sep 17 00:00:00 2001 From: Hamed Baatour Date: Tue, 1 Jan 2019 16:31:52 +0300 Subject: [PATCH 037/139] types(showdown): fix header authors format --- types/showdown/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index df2f17ab52..c0f3134f77 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -1,6 +1,9 @@ -// Type definitions for Showdown 1.9.0 +// Type definitions for Showdown 1.9. // Project: https://github.com/showdownjs/showdown -// Definitions by: Hamed Baatour, cbowdon , Pei-Tang Huang , Ariel-Saldana +// Definitions by: Hamed Baatour , +// cbowdon , +// Pei-Tang Huang , +// Ariel-Saldana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = Showdown; From a270ca9e8570b70a8a0f083071600e46c573730f Mon Sep 17 00:00:00 2001 From: Hamed Baatour Date: Tue, 1 Jan 2019 16:49:42 +0300 Subject: [PATCH 038/139] types(showdown): fix missing version patch number --- types/showdown/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/showdown/index.d.ts b/types/showdown/index.d.ts index c0f3134f77..c058591d91 100644 --- a/types/showdown/index.d.ts +++ b/types/showdown/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Showdown 1.9. +// Type definitions for Showdown 1.9.0 // Project: https://github.com/showdownjs/showdown // Definitions by: Hamed Baatour , // cbowdon , From 80d3201a48fb41e96ecbd58246815132de68d2de Mon Sep 17 00:00:00 2001 From: Slobodan Kletnikov Date: Wed, 2 Jan 2019 00:00:10 +0100 Subject: [PATCH 039/139] Add UncontrolledCarousel type --- types/reactstrap/index.d.ts | 7 +++++-- types/reactstrap/lib/Carousel.d.ts | 20 ++++++++++++++++++++ types/reactstrap/lib/Uncontrolled.d.ts | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index 8197cf5bb1..d2779b4ab6 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -241,17 +241,20 @@ import { UncontrolledButtonDropdown as UncontrolledButtonDropdown_, UncontrolledDropdown as UncontrolledDropdown_, UncontrolledTooltip as UncontrolledTooltip_, - UncontrolledCollapse as UncontrolledCollapse_ + UncontrolledCollapse as UncontrolledCollapse_, + UncontrolledCarousel as UncontrolledCarousel_ } from './lib/Uncontrolled'; export class UncontrolledAlert extends UncontrolledAlert_ {} export class UncontrolledButtonDropdown extends UncontrolledButtonDropdown_ {} export class UncontrolledDropdown extends UncontrolledDropdown_ {} export class UncontrolledTooltip extends UncontrolledTooltip_ {} export class UncontrolledCollapse extends UncontrolledCollapse_ {} +export class UncontrolledCarousel extends UncontrolledCarousel_ {} export { UncontrolledButtonDropdownProps, UncontrolledAlertProps, UncontrolledDropdownProps, UncontrolledTooltipProps, - UncontrolledCollapseProps + UncontrolledCollapseProps, + UncontrolledCarouselProps } from './lib/Uncontrolled'; diff --git a/types/reactstrap/lib/Carousel.d.ts b/types/reactstrap/lib/Carousel.d.ts index 0f59105f77..69899eff34 100644 --- a/types/reactstrap/lib/Carousel.d.ts +++ b/types/reactstrap/lib/Carousel.d.ts @@ -15,5 +15,25 @@ export type CarouselProps = React.HTMLProps & { cssModule?: CSSModule } & T; +export type UncontrolledProps = React.HTMLProps & { + items: any[]; + activeIndex?: number; + next?: () => void; + previous?: () => void; + keyboard?: boolean; + pause?: "hover" | false; + ride?: "carousel"; + interval?: number | string | boolean; + mouseEnter?: () => void; + mouseExit?: () => void; + slide?: boolean; + cssModule?: CSSModule; + controls?: boolean; + indicators?: boolean; + autoPlay?: boolean; +} & T; + +export type UncontrolledCarouselProps = UncontrolledProps; + declare class Carousel extends React.Component> {} export default Carousel; diff --git a/types/reactstrap/lib/Uncontrolled.d.ts b/types/reactstrap/lib/Uncontrolled.d.ts index 118b76d0d1..3be770852f 100644 --- a/types/reactstrap/lib/Uncontrolled.d.ts +++ b/types/reactstrap/lib/Uncontrolled.d.ts @@ -5,15 +5,18 @@ import { UncontrolledButtonDropdownProps } from './ButtonDropdown'; import { UncontrolledDropdownProps } from './Dropdown'; import { UncontrolledTooltipProps } from './Tooltip'; import { UncontrolledCollapseProps } from './Collapse'; +import { UncontrolledCarouselProps } from "./Carousel"; export class UncontrolledAlert extends React.Component> {} export class UncontrolledButtonDropdown extends React.Component> {} export class UncontrolledDropdown extends React.Component> {} export class UncontrolledTooltip extends React.Component> {} export class UncontrolledCollapse extends React.Component> {} +export class UncontrolledCarousel extends React.Component> {} export { UncontrolledAlertProps } from './Alert'; export { UncontrolledButtonDropdownProps } from './ButtonDropdown'; export { UncontrolledDropdownProps } from './Dropdown'; export { UncontrolledTooltipProps } from './Tooltip'; export { UncontrolledCollapseProps } from './Collapse'; +export { UncontrolledCarouselProps } from "./Carousel"; From b9256feb46be0b27b5a304690a8db0d37d6bcb2d Mon Sep 17 00:00:00 2001 From: Slobodan Kletnikov Date: Wed, 2 Jan 2019 00:16:18 +0100 Subject: [PATCH 040/139] Add UncontrolledCarousel test --- types/reactstrap/reactstrap-tests.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/types/reactstrap/reactstrap-tests.tsx b/types/reactstrap/reactstrap-tests.tsx index 427c5ae19e..4c6d1a98db 100644 --- a/types/reactstrap/reactstrap-tests.tsx +++ b/types/reactstrap/reactstrap-tests.tsx @@ -75,6 +75,7 @@ import { UncontrolledDropdown, UncontrolledTooltip, UncontrolledCollapse, + UncontrolledCarousel, TabContent, Table, Tag, @@ -4297,3 +4298,28 @@ function Example123() { ); } + +function Example124() { + // https://reactstrap.github.io/components/carousel/ + const items = [ + { + src: 'data:image/svg+xml...', + altText: 'Slide 1', + caption: 'Slide 1' + }, + { + src: 'data:image/svg+xml...', + altText: 'Slide 2', + caption: 'Slide 2' + }, + { + src: 'data:image/svg+xml...', + altText: 'Slide 3', + caption: 'Slide 3' + } + ]; + + return ( + + ); +} From 1aa32163930520b27f50ae0e2c6528852d29d04f Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:30:07 +0200 Subject: [PATCH 041/139] Rewrite examples in JSX. --- types/linkifyjs/linkifyjs-tests.tsx | 58 +++++++++++++---------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 2ec3979134..467bd39f84 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -153,44 +153,38 @@ describe("linkifyjs/react", () => { /* Usage */ - const options: LinkifyOptions = {}; - const content = "For help with GitHub.com, please email support@github.com"; - let rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - tagName: "p", - options - }, - React.createElement("span", content) - ), - rootElement - ); + { + // render() + let options = { + /* … */ + }; + let content = + "For help with GitHub.com, please email support@github.com"; + return ( + + {content} + + ); + } /* Events */ - const linkProps = { - onClick: (event: any) => { - if (!confirm("Are you sure you want to leave this page?")) { - event.preventDefault(); + { + let content = + "For help with GitHub.com, please email support@github.com"; + let linkProps = { + onClick: (event: any) => { + if (!confirm("Are you sure you want to leave this page?")) { + event.preventDefault(); + } } - } - }; + }; + return {content}; + } - rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - options: { attributes: linkProps } - }, - React.createElement("span", null) - ), - rootElement - ); + /* A few more test cases */ - rootElement = document.createElement("div"); + let rootElement = document.createElement("div"); ReactDOM.render( React.createElement( Linkify, From ef10efccb376d5b862fc9b337ea8455d71c7d4e5 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:32:58 +0200 Subject: [PATCH 042/139] Add JSX support. --- types/linkifyjs/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/linkifyjs/tsconfig.json b/types/linkifyjs/tsconfig.json index 7a19e25d0d..16becbcf0a 100644 --- a/types/linkifyjs/tsconfig.json +++ b/types/linkifyjs/tsconfig.json @@ -10,7 +10,8 @@ "typeRoots": ["../"], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" }, "files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.tsx"] } From ee0f28a96629669e46ae627859d808b8adb0b69e Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:34:05 +0200 Subject: [PATCH 043/139] Fix linting issues. --- types/linkifyjs/linkifyjs-tests.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 467bd39f84..fb4b99a72a 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -155,31 +155,29 @@ describe("linkifyjs/react", () => { { // render() - let options = { + const options = { /* … */ }; - let content = + const content = "For help with GitHub.com, please email support@github.com"; - return ( - - {content} - - ); + + {content} + ; } /* Events */ { - let content = + const content = "For help with GitHub.com, please email support@github.com"; - let linkProps = { + const linkProps = { onClick: (event: any) => { if (!confirm("Are you sure you want to leave this page?")) { event.preventDefault(); } } }; - return {content}; + {content}; } /* A few more test cases */ From f2777515136f394de5fb96ff092ae10db0536e4b Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:39:00 +0200 Subject: [PATCH 044/139] Use JSX in all tests. --- types/linkifyjs/linkifyjs-tests.tsx | 57 ++++++++++++----------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index fb4b99a72a..6b28d20528 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -182,39 +182,30 @@ describe("linkifyjs/react", () => { /* A few more test cases */ - let rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - {}, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); + /* Default values for all props */ + { + + Hello https://google.com + + } + + /* Custom class name */ - rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - options: { - className: "custom-class-name" - } - }, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); + { + + Hello https://google.com + + } - rootElement = document.createElement("div"); - ReactDOM.render( - React.createElement( - Linkify, - { - tagName: "p" - }, - React.createElement("span", "Hello https://google.com") - ), - rootElement - ); + /* Custom tag name */ + + { + + Hello https://google.com + + } }); From 627f354d1d7dbf8fc615bace43ba24bb25747cb7 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:39:46 +0200 Subject: [PATCH 045/139] Remove unused imports. --- types/linkifyjs/linkifyjs-tests.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 6b28d20528..57c91dae5a 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -1,6 +1,4 @@ import * as React from "react"; -import * as ReactDOM from "react-dom"; -import { LinkifyOptions } from "linkifyjs"; import linkifyHtml from "linkifyjs/html"; import Linkify from "linkifyjs/react"; From 5a2b7b2f0122df689f477f009d6450c0ad6b4944 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Wed, 2 Jan 2019 11:43:11 +0200 Subject: [PATCH 046/139] Work around prettier issue. --- types/linkifyjs/linkifyjs-tests.tsx | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 57c91dae5a..23ae8e3722 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -182,28 +182,38 @@ describe("linkifyjs/react", () => { /* Default values for all props */ { + const content = + "For help with GitHub.com, please email support@github.com"; - Hello https://google.com - + {content} + ; } - + /* Custom class name */ { - - Hello https://google.com - + const content = + "For help with GitHub.com, please email support@github.com"; + + {content} + ; } /* Custom tag name */ { - - Hello https://google.com - + const content = + "For help with GitHub.com, please email support@github.com"; + + {content} + ; } }); From 3cd60ea66fa5dd50ccdd7120342898285eebcc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalvis=20Kalni=C5=86=C5=A1?= Date: Wed, 2 Jan 2019 12:44:21 +0200 Subject: [PATCH 047/139] fix(SCServer): any wsEngine to handle modules --- types/socketcluster-server/scserver.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/socketcluster-server/scserver.d.ts b/types/socketcluster-server/scserver.d.ts index dd598f981a..751a646bbd 100644 --- a/types/socketcluster-server/scserver.d.ts +++ b/types/socketcluster-server/scserver.d.ts @@ -83,7 +83,7 @@ declare namespace SCServer { // This can be the name of an npm module or a path to a Node.js module // to use as the WebSocket server engine. // You can now set this to 'sc-uws' for a massive speedup of at least 2x! - wsEngine?: string; + wsEngine?: any; // An ID to associate with this specific instance of SC // this may be useful if you are running an SC app on multiple From 46251ff1179014cd38c842e6e031286e2c5bb138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalvis=20Kalni=C5=86=C5=A1?= Date: Wed, 2 Jan 2019 12:44:35 +0200 Subject: [PATCH 048/139] fix(SCServer): add missing events --- types/socketcluster-server/scserver.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/types/socketcluster-server/scserver.d.ts b/types/socketcluster-server/scserver.d.ts index 751a646bbd..cef90acfed 100644 --- a/types/socketcluster-server/scserver.d.ts +++ b/types/socketcluster-server/scserver.d.ts @@ -33,6 +33,13 @@ declare class SCServer extends EventEmitter { constructor(options?: SCServer.SCServerOptions); on(event: "connection", listener: SCServer.connectionListenerFunction): this; + on(event: "ready", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "disconnection" | "connectionAbort" | "closure", listener: SCServer.disconnectionListenerFunction): this; + on(event: "subscription", listener: SCServer.subscriptionListenerFunction): this; + on(event: "unsubscription", listener: SCServer.unsubscriptionListenerFunction): this; + on(event: "handshake", listener: SCServer.handshakeListenerFunction): this; + on(event: "badSocketAuthToken", listener: SCServer.badSocketAuthTokenListenerFunction): this; addMiddleware(type: "handshakeWS", middlewareFn: (req: IncomingMessage, next: SCServer.nextMiddlewareFunction) => void): void; addMiddleware(type: "handshakeSC", middlewareFn: (req: SCServer.HandshakeSCRequest, next: SCServer.nextHandshakeSCMiddlewareFunction) => void): void; @@ -305,10 +312,20 @@ declare namespace SCServer { data?: any; } + interface badAuthStatus { + authError: Error; + signedAuthToken: string; + } + type nextMiddlewareFunction = (error?: true | string | Error) => void; type nextHandshakeSCMiddlewareFunction = (error?: true | string | Error | null, statusCode?: number) => void; type nextAuthenticateMiddlewareFunction = (error?: true | string | Error | null, isBadToken?: boolean) => void; type connectionListenerFunction = (scSocket: SCServerSocket, serverSocketStatus: SCServerSocketStatus) => void; + type disconnectionListenerFunction = (scSocket: SCServerSocket, code: number, data: any) => void; + type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: {channel: string}) => void; + type unsubscriptionListenerFunction = (scSocket: SCServerSocket, name: string, channel: string) => void; + type handshakeListenerFunction = (scSocket: SCServerSocket) => void; + type badSocketAuthTokenListenerFunction = (scSocket: SCServerSocket, status: badAuthStatus) => void; interface SCCodecEngine { decode: (input: any) => any; From b94e246170fbd182788f258a590beb445320bc91 Mon Sep 17 00:00:00 2001 From: Henri Lahtinen Date: Wed, 2 Jan 2019 13:08:42 +0200 Subject: [PATCH 049/139] [react-native] Action types for Android date and time pickers --- types/react-native/index.d.ts | 42 ++++++++++++++++++++++--------- types/react-native/test/index.tsx | 19 +++++++++++++- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 865a46eefa..eecd4cd148 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7226,13 +7226,19 @@ export interface DatePickerAndroidOpenOptions { } // Deduced from DatePickerAndroid.android.js -export interface DatePickerAndroidOpenReturn { - action: string; // "dateSetAction" | "dismissedAction" - year?: number; - month?: number; - day?: number; +export interface DatePickerAndroidDateSetAction { + action: 'dateSetAction'; + year: number; + month: number; + day: number; } +export interface DatePickerAndroidDismissedAction { + action: 'dismissedAction'; +} + +export type DatePickerAndroidOpenReturn = DatePickerAndroidDateSetAction | DatePickerAndroidDismissedAction + export interface DatePickerAndroidStatic { /** * Opens the standard Android date picker dialog. @@ -7257,12 +7263,12 @@ export interface DatePickerAndroidStatic { /** * A date has been selected. */ - dateSetAction: string; + dateSetAction: 'dateSetAction'; /** * The dialog has been dismissed. */ - dismissedAction: string; + dismissedAction: 'dismissedAction'; } export interface IntentAndroidStatic { @@ -8002,12 +8008,24 @@ export class StatusBar extends React.Component { */ export interface StatusBarIOSStatic extends NativeEventEmitter {} -type TimePickerAndroidOpenOptions = { +export interface TimePickerAndroidOpenOptions { hour?: number; minute?: number; is24Hour?: boolean; mode?: "clock" | "spinner" | "default"; -}; +} + +export interface TimePickerAndroidTimeSetAction { + action: 'timeSetAction'; + hour: number; + minute: number; +} + +export interface TimePickerAndroidDismissedAction { + action: 'dismissedAction'; +} + +export type TimePickerAndroidOpenReturn = TimePickerAndroidTimeSetAction | TimePickerAndroidDismissedAction; /** * Opens the standard Android time picker dialog. @@ -8049,17 +8067,17 @@ export interface TimePickerAndroidStatic { * still be resolved with action being `TimePickerAndroid.dismissedAction` and all the other keys * being undefined. **Always** check whether the `action` before reading the values. */ - open(options: TimePickerAndroidOpenOptions): Promise<{ action: string; hour: number; minute: number }>; + open(options: TimePickerAndroidOpenOptions): Promise; /** * A time has been selected. */ - timeSetAction: string; + timeSetAction: 'timeSetAction'; /** * The dialog has been dismissed. */ - dismissedAction: string; + dismissedAction: 'dismissedAction'; } /** diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 842882cc29..4186b082fb 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -78,6 +78,7 @@ import { KeyboardAvoidingView, Modal, TimePickerAndroid, + DatePickerAndroid, ViewPropTypes, requireNativeComponent, } from "react-native"; @@ -762,13 +763,29 @@ const AlertIOSTest = () => { const ModalTest = () => ; -const TimePickerAndroidTest = () => +const TimePickerAndroidTest = () => { TimePickerAndroid.open({ hour: 8, minute: 15, is24Hour: true, mode: "spinner", + }).then(result => { + if (result.action === TimePickerAndroid.timeSetAction) { + console.log('Time', result.hour, result.minute) + } }); +} + +const DatePickerAndroidTest = () => { + DatePickerAndroid.open({ + date: new Date(), + mode: 'calendar' + }).then(result => { + if (result.action === DatePickerAndroid.dateSetAction) { + console.log('Date', result.year, result.month, result.day) + } + }); +} class BridgedComponentTest extends React.Component { static propTypes = { From cf569891f458d6bd00848d2f1ee929c02adecb53 Mon Sep 17 00:00:00 2001 From: Sameer KC Date: Wed, 2 Jan 2019 12:46:40 +0100 Subject: [PATCH 050/139] Type definitions for node-gettext --- node-gettext/index.d.ts | 26 +++++++++++++++++++++++++ node-gettext/node-gettext-tests.ts | 31 ++++++++++++++++++++++++++++++ node-gettext/tsconfig.json | 22 +++++++++++++++++++++ node-gettext/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 node-gettext/index.d.ts create mode 100644 node-gettext/node-gettext-tests.ts create mode 100644 node-gettext/tsconfig.json create mode 100644 node-gettext/tslint.json diff --git a/node-gettext/index.d.ts b/node-gettext/index.d.ts new file mode 100644 index 0000000000..4d0f760e99 --- /dev/null +++ b/node-gettext/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for node-gettext 2.0 +// Project: http://github.com/alexanderwallin/node-gettext +// Definitions by: Sameer K.C. +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default class GetText { + constructor(options?: { debug: boolean; }); + addTranslations(locale: string, domain: string, translations: object): void; + dgettext(domain: string, msgid: string): string; + dngettext(domain: string, msgid: string, msgidPlural: string, count: number): string; + dnpgettext(domain: string, msgctxt: string, msgid: string, msgidPlural: string, count: number): string; + dpgettext(domain: string, msgctxt: string, msgid: string): string; + emit(eventName: string, eventData: any): void; + getComment(domain: string, msgctxt: string, msgid: string): object | boolean; + gettext(msgid: string): string; + ngettext(msgid: string, msgidPlural: string, count: number): string; + npgettext(msgctxt: string, msgid: string, msgidPlural: string, count: number): string; + off(eventName: string, callback: (params: any) => void): string; + on(eventName: string, callback: (params: any) => void): void; + pgettext(msgctxt: string, msgid: string): string; + setLocale(locale: string): void; + setTextDomain(domain: string): void; + static getLanguageCode(locale: string): string; + textdomain(domain: string): void; + warn(message: string): void; +} diff --git a/node-gettext/node-gettext-tests.ts b/node-gettext/node-gettext-tests.ts new file mode 100644 index 0000000000..df01ae82c9 --- /dev/null +++ b/node-gettext/node-gettext-tests.ts @@ -0,0 +1,31 @@ +import Gettext from 'node-gettext'; + +const translations = {}; +const gt = new Gettext({ debug: true }); +const msgid = 'Get translation'; +const msgidPlural = 'Get translations'; +const domain = 'domain'; +const msgctxt = 'context'; +const count = 2; + +gt.addTranslations('en-US', 'messages', translations); +gt.setTextDomain(domain); +gt.textdomain(domain); +gt.setLocale('en-US'); +gt.gettext(msgid); +gt.dgettext('', msgid); +gt.dngettext(domain, msgid, msgidPlural, count); +gt.dnpgettext(domain, msgctxt, msgid, msgidPlural, count); +gt.dpgettext(domain, msgctxt, msgid); +gt.getComment(domain, msgctxt, msgid); +gt.ngettext(msgid, msgidPlural, count); +gt.npgettext(msgctxt, msgid, msgidPlural, count); +gt.pgettext(msgctxt, msgid); +Gettext.getLanguageCode('en-US'); +gt.warn('warning'); +const errorListener = (error: string) => { + // do something; +}; +gt.on('error', errorListener); +gt.emit('error', 'Error occurred'); +gt.off('error', errorListener); diff --git a/node-gettext/tsconfig.json b/node-gettext/tsconfig.json new file mode 100644 index 0000000000..fa6bede617 --- /dev/null +++ b/node-gettext/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-gettext-tests.ts" + ] +} diff --git a/node-gettext/tslint.json b/node-gettext/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/node-gettext/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From f17c61f5c6e5813399d11e68d4fa0df2063e8890 Mon Sep 17 00:00:00 2001 From: Sameer KC Date: Wed, 2 Jan 2019 15:56:33 +0100 Subject: [PATCH 051/139] CommonJS style import No default in npm module --- node-gettext/conf/tslint.json | 1 + node-gettext/index.d.ts | 3 ++- node-gettext/node-gettext-tests.ts | 3 +++ node-gettext/tsconfig.json | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 node-gettext/conf/tslint.json diff --git a/node-gettext/conf/tslint.json b/node-gettext/conf/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/node-gettext/conf/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/node-gettext/index.d.ts b/node-gettext/index.d.ts index 4d0f760e99..735f8db84b 100644 --- a/node-gettext/index.d.ts +++ b/node-gettext/index.d.ts @@ -3,7 +3,8 @@ // Definitions by: Sameer K.C. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default class GetText { +export = GetText; +declare class GetText { constructor(options?: { debug: boolean; }); addTranslations(locale: string, domain: string, translations: object): void; dgettext(domain: string, msgid: string): string; diff --git a/node-gettext/node-gettext-tests.ts b/node-gettext/node-gettext-tests.ts index df01ae82c9..e20e6aacac 100644 --- a/node-gettext/node-gettext-tests.ts +++ b/node-gettext/node-gettext-tests.ts @@ -1,4 +1,7 @@ +// with tsc v 2.7 & esModuleInterop & allowSyntheticDefaultImports enabled in tsconfig.json import Gettext from 'node-gettext'; +// or without +// import Gettext = require('node-getttext'); const translations = {}; const gt = new Gettext({ debug: true }); diff --git a/node-gettext/tsconfig.json b/node-gettext/tsconfig.json index fa6bede617..9306d23426 100644 --- a/node-gettext/tsconfig.json +++ b/node-gettext/tsconfig.json @@ -13,7 +13,9 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", From 6da80ae61a54c491e9e66c437a69f1544a64c952 Mon Sep 17 00:00:00 2001 From: Bryan Spears Date: Wed, 2 Jan 2019 18:34:28 -0700 Subject: [PATCH 052/139] [needle] Export all types --- types/needle/index.d.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/types/needle/index.d.ts b/types/needle/index.d.ts index b9c07b320b..fae0a01392 100644 --- a/types/needle/index.d.ts +++ b/types/needle/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for needle 2.0 // Project: https://github.com/tomas/needle -// Definitions by: San Chen , Niklas Mollenhauer , Matanel Sindilevich +// Definitions by: San Chen , +// Niklas Mollenhauer , +// Matanel Sindilevich , +// Bryan Spears // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -240,11 +243,11 @@ declare function needle(method: core.NeedleReadonlyHttpVerbs, url: string, optio declare function needle(method: core.NeedleHttpVerbs, url: string, data: core.BodyData, options?: core.NeedleOptions): Promise; declare namespace needle { - type BodyData = core.BodyData; - type NeedleCallback = core.NeedleCallback; - type NeedleHttpVerbs = core.NeedleHttpVerbs; + export type BodyData = core.BodyData; + export type NeedleCallback = core.NeedleCallback; + export type NeedleHttpVerbs = core.NeedleHttpVerbs; export type NeedleOptions = core.NeedleOptions; - type ReadableStream = core.ReadableStream; + export type ReadableStream = core.ReadableStream; /** * Lets override the defaults for all future requests. From 2129015369c3a0c29508ef69d1118935ceb54a23 Mon Sep 17 00:00:00 2001 From: Sindre Moen Date: Thu, 3 Jan 2019 07:57:28 +0100 Subject: [PATCH 053/139] Remove myself from Mongoose v4 contributors --- types/mongoose/v4/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongoose/v4/index.d.ts b/types/mongoose/v4/index.d.ts index d8a9feb085..e38317ae5d 100644 --- a/types/mongoose/v4/index.d.ts +++ b/types/mongoose/v4/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Mongoose 4.7.1 // Project: http://mongoosejs.com/ -// Definitions by: simonxca , horiuchi , sindrenm , lukasz-zak +// Definitions by: simonxca , horiuchi , lukasz-zak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 796d89f6d1fe1fb995180eb6e4ef053ebd0ad2bc Mon Sep 17 00:00:00 2001 From: Sindre Moen Date: Thu, 3 Jan 2019 07:59:32 +0100 Subject: [PATCH 054/139] Remove myself from Mongoose contributors --- types/mongoose/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index b588b4ecef..14e965dd5f 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for Mongoose 5.3.4 // Project: http://mongoosejs.com/ // Definitions by: horiuchi -// sindrenm // lukasz-zak // Alorel // jendrikw From 4ac28861b9c93da1f4a8e0a64c9412f302ce4d49 Mon Sep 17 00:00:00 2001 From: Mats Roshauw Date: Thu, 3 Jan 2019 10:12:19 +0100 Subject: [PATCH 055/139] Add closeOnBlur property to WrapperProps --- types/react-aria-menubutton/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-aria-menubutton/index.d.ts b/types/react-aria-menubutton/index.d.ts index 3bfc68259e..157fdff642 100644 --- a/types/react-aria-menubutton/index.d.ts +++ b/types/react-aria-menubutton/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for react-aria-menubutton 5.1 +// Type definitions for react-aria-menubutton 6.1 // Project: https://github.com/davidtheclark/react-aria-menubutton // Definitions by: Muhammad Fawwaz Orabi // Chris Rohlfs +// Mats Roshauw // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -33,6 +34,13 @@ export interface WrapperProps */ closeOnSelection?: boolean; + /** + * By default, it does automatically close. + * If false, the menu will not automatically close when it + * blurs. Default: `true`. + */ + closeOnBlur?: boolean; + isOpen?: boolean; tag?: T["tagName"]; From 26284942785bd43500772a29607fb2b4d6d53904 Mon Sep 17 00:00:00 2001 From: Sameer KC Date: Thu, 3 Jan 2019 10:13:21 +0100 Subject: [PATCH 056/139] Deleting unnecessary file --- node-gettext/conf/tslint.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 node-gettext/conf/tslint.json diff --git a/node-gettext/conf/tslint.json b/node-gettext/conf/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/node-gettext/conf/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 11ecd41a0be531c54b2f3fb44a53dc645d820d21 Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Thu, 3 Jan 2019 10:16:55 +0100 Subject: [PATCH 057/139] Improve type of message payload and sendTo return type --- types/iobroker/index.d.ts | 24 +++++++++-------- types/iobroker/iobroker-tests.ts | 45 +++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index 4cfbddc2a2..b83c89017f 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -828,10 +828,12 @@ declare global { ca: Array; } + type MessagePayload = string | Record; + /** Callback information for a passed message */ interface MessageCallbackInfo { /** The original message payload */ - message: string | object; + message: MessagePayload; /** ID of this callback */ id: number; // ??? @@ -839,14 +841,13 @@ declare global { /** Timestamp of this message */ time: number; } - type MessageCallback = (result?: any) => void; /** A message being passed between adapter instances */ interface Message { /** The command to be executed */ command: string; /** The message payload */ - message: string | object; + message: MessagePayload; /** The source of this message */ from: string; /** ID of this message */ @@ -1038,8 +1039,8 @@ declare global { * @param command (optional) Command name of the target instance. Default: "send" * @param message The message (e.g. params) to send. */ - sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendTo(instanceName: string, message: MessagePayload, callback?: MessageCallback | MessageCallbackInfo): void; + sendTo(instanceName: string, command: string, message: MessagePayload, callback?: MessageCallback | MessageCallbackInfo): void; /** * Sends a message to a specific instance or all instances of some specific adapter. * @param instanceName The instance to send this message to. @@ -1048,18 +1049,18 @@ declare global { * @param command (optional) Command name of the target instance. Default: "send" * @param message The message (e.g. params) to send. */ - sendToAsync(instanceName: string, message: string | object): Promise; - sendToAsync(instanceName: string, command: string, message: string | object): Promise; + sendToAsync(instanceName: string, message: MessagePayload): Promise; + sendToAsync(instanceName: string, command: string, message: MessagePayload): Promise; /** * Sends a message to a specific host or all hosts. */ - sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + sendToHost(hostName: string, message: MessagePayload, callback?: MessageCallback | MessageCallbackInfo): void; + sendToHost(hostName: string, command: string, message: MessagePayload, callback?: MessageCallback | MessageCallbackInfo): void; /** * Sends a message to a specific host or all hosts. */ - sendToHostAsync(hostName: string, message: string | object): Promise; - sendToHostAsync(hostName: string, command: string, message: string | object): Promise; + sendToHostAsync(hostName: string, message: MessagePayload): Promise; + sendToHostAsync(hostName: string, command: string, message: MessagePayload): Promise; /** Convert ID to {device: D, channel: C, state: S} */ idToDCS(id: string): { @@ -1584,6 +1585,7 @@ declare global { type ObjectChangeHandler = (id: string, obj: ioBroker.Object | null | undefined) => void; type StateChangeHandler = (id: string, obj: State | null | undefined) => void; type MessageHandler = (obj: Message) => void; + type MessageCallback = (response?: Message) => void; type UnloadHandler = (callback: EmptyCallback) => void; type EmptyCallback = () => void; diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 2ee7da83d5..f49eb34576 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -99,7 +99,8 @@ function messageHandler(msg: ioBroker.Message) { msg.callback.time.toFixed(); msg.command.toLowerCase(); msg.from.toLowerCase(); - msg.message.toString(); + typeof msg.message === "object" && msg.message.anything; + typeof msg.message === "string" && msg.message.toLowerCase(); } function unloadHandler(callback: ioBroker.EmptyCallback) { @@ -198,3 +199,45 @@ switch (adapter.log.level) { default: assertNever(adapter.log.level); } + +adapter.sendTo("foo.0", "command", "message"); +adapter.sendTo("foo.0", "message"); +adapter.sendTo("foo.0", "command", {msg: "message"}); +adapter.sendTo("foo.0", {msg: "message"}); + +function handleMessageResponse(response?: ioBroker.Message) { + if (!response) return; + response._id.toFixed(); + response.callback.ack.valueOf(); + response.callback.id.toFixed(); + response.callback.message.toString(); + response.callback.time.toFixed(); + response.command.toLowerCase(); + response.from.toLowerCase(); + typeof response.message === "object" && response.message.anything; + typeof response.message === "string" && response.message.toLowerCase(); +} +adapter.sendTo("foo.0", "command", "message", handleMessageResponse); +adapter.sendTo("foo.0", "message", handleMessageResponse); +adapter.sendTo("foo.0", "command", {msg: "message"}, handleMessageResponse); +adapter.sendTo("foo.0", {msg: "message"}, handleMessageResponse); + +adapter.sendToAsync("foo.0", "command", "message").then(handleMessageResponse); +adapter.sendToAsync("foo.0", "message").then(handleMessageResponse); +adapter.sendToAsync("foo.0", "command", {msg: "message"}).then(handleMessageResponse); +adapter.sendToAsync("foo.0", {msg: "message"}).then(handleMessageResponse); + +adapter.sendToHost("host-foo", "command", "message"); +adapter.sendToHost("host-foo", "message"); +adapter.sendToHost("host-foo", "command", {msg: "message"}); +adapter.sendToHost("host-foo", {msg: "message"}); + +adapter.sendToHost("host-foo", "command", "message", handleMessageResponse); +adapter.sendToHost("host-foo", "message", handleMessageResponse); +adapter.sendToHost("host-foo", "command", {msg: "message"}, handleMessageResponse); +adapter.sendToHost("host-foo", {msg: "message"}, handleMessageResponse); + +adapter.sendToHostAsync("host-foo", "command", "message").then(handleMessageResponse); +adapter.sendToHostAsync("host-foo", "message").then(handleMessageResponse); +adapter.sendToHostAsync("host-foo", "command", {msg: "message"}).then(handleMessageResponse); +adapter.sendToHostAsync("host-foo", {msg: "message"}).then(handleMessageResponse); From 3bdd3c10f378194e818b318b352b1418a1417488 Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Thu, 3 Jan 2019 10:31:31 +0100 Subject: [PATCH 058/139] MessageCallback should be where the other callbacks are --- types/iobroker/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index b83c89017f..81381d801d 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -1585,7 +1585,6 @@ declare global { type ObjectChangeHandler = (id: string, obj: ioBroker.Object | null | undefined) => void; type StateChangeHandler = (id: string, obj: State | null | undefined) => void; type MessageHandler = (obj: Message) => void; - type MessageCallback = (response?: Message) => void; type UnloadHandler = (callback: EmptyCallback) => void; type EmptyCallback = () => void; @@ -1593,6 +1592,8 @@ declare global { // TODO: Redefine callbacks as subclass of GenericCallback type GenericCallback = (err: string | null, result?: T) => void; + type MessageCallback = (response?: Message) => void; + type SetObjectCallback = (err: string | null, obj: { id: string }) => void; type GetObjectCallback = (err: string | null, obj: ioBroker.Object | null | undefined) => void; type GetEnumCallback = (err: string | null, enums: Record, requestedEnum: string) => void; From 5731953945ec2d03797a33cab0e8f32d79fa232b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalvis=20Kalni=C5=86=C5=A1?= Date: Thu, 3 Jan 2019 12:05:54 +0200 Subject: [PATCH 059/139] fix: review --- types/socketcluster-server/index.d.ts | 2 +- types/socketcluster-server/scserver.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/socketcluster-server/index.d.ts b/types/socketcluster-server/index.d.ts index 7466d1daed..17f138bf0f 100644 --- a/types/socketcluster-server/index.d.ts +++ b/types/socketcluster-server/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for socketcluster-server 13.1 +// Type definitions for socketcluster-server 14.2 // Project: https://github.com/SocketCluster/socketcluster-server // Definitions by: Daniel Rose // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/socketcluster-server/scserver.d.ts b/types/socketcluster-server/scserver.d.ts index cef90acfed..48952a8a8a 100644 --- a/types/socketcluster-server/scserver.d.ts +++ b/types/socketcluster-server/scserver.d.ts @@ -34,7 +34,7 @@ declare class SCServer extends EventEmitter { on(event: "connection", listener: SCServer.connectionListenerFunction): this; on(event: "ready", listener: () => void): this; - on(event: "error", listener: (error: Error) => void): this; + on(event: "warning" | "error", listener: (error: Error) => void): this; on(event: "disconnection" | "connectionAbort" | "closure", listener: SCServer.disconnectionListenerFunction): this; on(event: "subscription", listener: SCServer.subscriptionListenerFunction): this; on(event: "unsubscription", listener: SCServer.unsubscriptionListenerFunction): this; @@ -323,7 +323,7 @@ declare namespace SCServer { type connectionListenerFunction = (scSocket: SCServerSocket, serverSocketStatus: SCServerSocketStatus) => void; type disconnectionListenerFunction = (scSocket: SCServerSocket, code: number, data: any) => void; type subscriptionListenerFunction = (scSocket: SCServerSocket, name: string, options: {channel: string}) => void; - type unsubscriptionListenerFunction = (scSocket: SCServerSocket, name: string, channel: string) => void; + type unsubscriptionListenerFunction = (scSocket: SCServerSocket, channel: string) => void; type handshakeListenerFunction = (scSocket: SCServerSocket) => void; type badSocketAuthTokenListenerFunction = (scSocket: SCServerSocket, status: badAuthStatus) => void; From 9c1c7e78a9a2b4af8e2cda842c3693f67bb9e42d Mon Sep 17 00:00:00 2001 From: Cheng Wang Date: Thu, 3 Jan 2019 18:29:31 +0800 Subject: [PATCH 060/139] react-router fix (#31853) * [react-router] redirectLocation is not DOM Location type should use Location type from history package. see https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#match-routes-location-history-options--cb * [react-router] export argument types of match --- types/react-router/v3/index.d.ts | 2 +- types/react-router/v3/lib/match.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-router/v3/index.d.ts b/types/react-router/v3/index.d.ts index c21afeb049..2c624a63ab 100644 --- a/types/react-router/v3/index.d.ts +++ b/types/react-router/v3/index.d.ts @@ -55,7 +55,7 @@ export { default as Route } from "react-router/lib/Route"; export { createRoutes } from "react-router/lib/RouteUtils"; export { default as RouterContext } from "react-router/lib/RouterContext"; export { routerShape, locationShape } from "react-router/lib/PropTypes"; -export { default as match } from "react-router/lib/match"; +export { default as match, MatchHistoryArgs, MatchLocationArgs, MatchCallback } from "react-router/lib/match"; export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; export { formatPattern } from "react-router/lib/PatternUtils"; export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; diff --git a/types/react-router/v3/lib/match.d.ts b/types/react-router/v3/lib/match.d.ts index 77a35afafd..eb19888e0a 100644 --- a/types/react-router/v3/lib/match.d.ts +++ b/types/react-router/v3/lib/match.d.ts @@ -1,4 +1,4 @@ -import { Basename, History, LocationDescriptor } from "history"; +import { Basename, History, Location, LocationDescriptor } from "history"; import { ParseQueryString, RouteConfig, StringifyQuery } from "react-router"; export interface MatchArgs { From 4a45db244e4ae598bfc109da0697a652ec0e6a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=CC=81s=CC=8C=20Havli=CC=81c=CC=8Cek?= Date: Thu, 3 Jan 2019 13:42:25 +0100 Subject: [PATCH 061/139] React Native - added missing property (legacyImplementation) for SectionList --- types/react-native/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 865a46eefa..6a6db87b54 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -4269,6 +4269,8 @@ export interface SectionListProps extends VirtualizedListWithoutRenderIte * Only enabled by default on iOS because that is the platform standard there. */ stickySectionHeadersEnabled?: boolean; + + legacyImplementation?: boolean; } export interface SectionListScrollParams { From 2f2146a324a4667cd4f669caaf158b06a89bff30 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Thu, 3 Jan 2019 14:34:30 +0100 Subject: [PATCH 062/139] Remove tslint rule overrides and fix resulting issues. The 'ban-types' rule has not been removed because required changes conflict with other declarations (mongodb?). --- types/mongoose-paginate-v2/index.d.ts | 45 +++++------ .../mongoose-paginate-v2-tests.ts | 17 ++--- types/mongoose-paginate-v2/tslint.json | 75 +------------------ 3 files changed, 28 insertions(+), 109 deletions(-) diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index 3c178c5908..dfd70cc0cb 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for mongoose-paginate-v2 1.0.13 +// Type definitions for mongoose-paginate-v2 1.0 // Project: https://github.com/aravindnc/mongoose-paginate-v2 // Definitions by: Linus Brolin // simonxca @@ -8,25 +8,23 @@ // // Based on type declarations for mongoose-paginate 5.0.0. -/// - declare module 'mongoose' { - export interface CustomLabels { - totalDocs?: string, - limit?: string, - page?: string, - totalPages?: string, - docs?: string, - nextPage?: string, - prevPage?: string, + interface CustomLabels { + totalDocs?: string; + limit?: string; + page?: string; + totalPages?: string; + docs?: string; + nextPage?: string; + prevPage?: string; } - export interface PaginateOptions { + interface PaginateOptions { select?: Object | string; sort?: Object | string; - customLabels?: CustomLabels, - collation?: CollationOptions, - populate?: Array | Array | Object | string; + customLabels?: CustomLabels; + collation?: CollationOptions; + populate?: Object[] | string[] | Object | string; lean?: boolean; leanWithId?: boolean; offset?: number; @@ -34,29 +32,26 @@ declare module 'mongoose' { limit?: number; } - export interface PaginateResult { - docs: Array; + interface PaginateResult { + docs: T[]; total: number; limit: number; page?: number; pages?: number; offset?: number; - [customLabel: string]: Array | number | undefined; + [customLabel: string]: T[] | number | undefined; } interface PaginateModel extends Model { - paginate(query?: Object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; + paginate(query?: object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; } - export function model( + function model( name: string, schema?: Schema, collection?: string, skipInit?: boolean): PaginateModel; } -declare module 'mongoose-paginate-v2' { - import mongoose = require('mongoose'); - var _: (schema: mongoose.Schema) => void; - export = _; -} +import mongoose = require('mongoose'); +export function _(schema: mongoose.Schema): void; diff --git a/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts index 8410c740e5..200ca4e12a 100644 --- a/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts +++ b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts @@ -13,7 +13,6 @@ import { import mongoosePaginate = require('mongoose-paginate'); import { Router, Request, Response } from 'express'; - //#region Test Models interface User extends Document { email: string; @@ -29,20 +28,19 @@ const UserSchema: Schema = new Schema({ UserSchema.plugin(mongoosePaginate); -interface UserModel extends PaginateModel {}; +interface UserModel extends PaginateModel {} -let UserModel: UserModel = model('User', UserSchema) as UserModel; +const UserModel: UserModel = model('User', UserSchema) as UserModel; //#endregion - //#region Test Paginate -let router: Router = Router(); +const router: Router = Router(); -router.get('/users.json', function(req: Request, res: Response) { - let descending: boolean = true; - let options: PaginateOptions = {} as PaginateOptions; +router.get('/users.json', (req: Request, res: Response) => { + const descending = true; + const options: PaginateOptions = {}; options.select = 'email username'; - options.sort = { 'username': (descending ? -1 : 1) }; + options.sort = { username: (descending ? -1 : 1) }; options.collation = { locale: 'en_US', strength: 1 }; options.populate = ''; options.lean = true; @@ -78,6 +76,5 @@ router.get('/users.json', function(req: Request, res: Response) { console.dir(value.docsCustom); return res.json(value); }); - }); //#endregion diff --git a/types/mongoose-paginate-v2/tslint.json b/types/mongoose-paginate-v2/tslint.json index a41bf5d19a..a62d0d4e68 100644 --- a/types/mongoose-paginate-v2/tslint.json +++ b/types/mongoose-paginate-v2/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "ban-types": false } } From 581bcc1903f76eabd1f2ff5d2724b2f3fc03c1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=CC=81s=CC=8C=20Havli=CC=81c=CC=8Cek?= Date: Thu, 3 Jan 2019 14:40:12 +0100 Subject: [PATCH 063/139] React Native - added missing docs --- types/react-native/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 6a6db87b54..2c3922b89d 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3994,6 +3994,9 @@ export interface FlatListProps extends VirtualizedListProps { */ keyExtractor?: (item: ItemT, index: number) => string; + /** + * Uses legacy MetroListView instead of default VirtualizedSectionList + */ legacyImplementation?: boolean; /** @@ -4269,7 +4272,10 @@ export interface SectionListProps extends VirtualizedListWithoutRenderIte * Only enabled by default on iOS because that is the platform standard there. */ stickySectionHeadersEnabled?: boolean; - + + /** + * Uses legacy MetroListView instead of default VirtualizedSectionList + */ legacyImplementation?: boolean; } From dc1aa97bd1847f789f8bb7b21bc3526b8df35e88 Mon Sep 17 00:00:00 2001 From: Ovidiu Bute Date: Thu, 3 Jan 2019 15:49:40 +0200 Subject: [PATCH 064/139] Add better documentation blocks. --- types/linkifyjs/linkifyjs-tests.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/types/linkifyjs/linkifyjs-tests.tsx b/types/linkifyjs/linkifyjs-tests.tsx index 23ae8e3722..02d9d3b6d5 100644 --- a/types/linkifyjs/linkifyjs-tests.tsx +++ b/types/linkifyjs/linkifyjs-tests.tsx @@ -5,7 +5,10 @@ import Linkify from "linkifyjs/react"; declare function describe(desc: string, f: () => void): void; describe("linkifyjs/html", () => { - // From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html + /** + * The following tests were taken directly from the documentation: + * https://soapbox.github.io/linkifyjs/docs/options.html + */ /* attributes */ @@ -147,7 +150,10 @@ describe("linkifyjs/html", () => { }); describe("linkifyjs/react", () => { - // From the docs here: https://soapbox.github.io/linkifyjs/docs/linkify-react.html + /** + * The following tests were taken directly from the documentation: + * https://soapbox.github.io/linkifyjs/docs/linkify-react.html + */ /* Usage */ @@ -178,7 +184,9 @@ describe("linkifyjs/react", () => { {content}; } - /* A few more test cases */ + /** + * The following tests were made specifically for DefinitelyTyped. + */ /* Default values for all props */ { From 6637b2df5e2620fb4d0b39a77abec4cf09d17288 Mon Sep 17 00:00:00 2001 From: s8kggu_zlatkoa Date: Thu, 3 Jan 2019 15:33:07 +0100 Subject: [PATCH 065/139] Added type definitions for is-valid-path. --- types/is-valid-path/index.d.ts | 8 ++++++++ types/is-valid-path/is-valid-path-tests.ts | 18 +++++++++++++++++ types/is-valid-path/tsconfig.json | 23 ++++++++++++++++++++++ types/is-valid-path/tslint.json | 1 + 4 files changed, 50 insertions(+) create mode 100644 types/is-valid-path/index.d.ts create mode 100644 types/is-valid-path/is-valid-path-tests.ts create mode 100644 types/is-valid-path/tsconfig.json create mode 100644 types/is-valid-path/tslint.json diff --git a/types/is-valid-path/index.d.ts b/types/is-valid-path/index.d.ts new file mode 100644 index 0000000000..2aa54e3e99 --- /dev/null +++ b/types/is-valid-path/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-valid-path 0.1 +// Project: https://github.com/jonschlinkert/is-valid-path +// Definitions by: Zlatko Andonovski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function isValidPath(path?: string | null): boolean; + +export = isValidPath; diff --git a/types/is-valid-path/is-valid-path-tests.ts b/types/is-valid-path/is-valid-path-tests.ts new file mode 100644 index 0000000000..a0ca7ac1a9 --- /dev/null +++ b/types/is-valid-path/is-valid-path-tests.ts @@ -0,0 +1,18 @@ +// Tests are from the NPM README (https://www.npmjs.com/package/is-valid-path). + +import isValid = require('is-valid-path'); + +isValid('abc.js'); +isValid('abc/def/ghi.js'); +isValid('foo.js'); + +isValid(); +isValid(null); +isValid('!foo.js'); +isValid('*.js'); +isValid('**/abc.js'); +isValid('abc/*.js'); +isValid('abc/(aaa|bbb).js'); +isValid('abc/[a-z].js'); +isValid('abc/{a,b}.js'); +isValid('abc/?.js'); diff --git a/types/is-valid-path/tsconfig.json b/types/is-valid-path/tsconfig.json new file mode 100644 index 0000000000..da95d11317 --- /dev/null +++ b/types/is-valid-path/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-valid-path-tests.ts" + ] +} diff --git a/types/is-valid-path/tslint.json b/types/is-valid-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-valid-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 35a4efd52beb081a272fb2095f114a007a9cccf6 Mon Sep 17 00:00:00 2001 From: Simon VDB Date: Thu, 3 Jan 2019 16:29:08 +0100 Subject: [PATCH 066/139] add `sort` to StringifyOptions Adds the sort option thats available in the query string package. --- types/query-string/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/query-string/index.d.ts b/types/query-string/index.d.ts index 6e560f57e9..81c10fb086 100644 --- a/types/query-string/index.d.ts +++ b/types/query-string/index.d.ts @@ -33,6 +33,7 @@ export interface StringifyOptions { strict?: boolean; encode?: boolean; arrayFormat?: 'bracket' | 'index' | 'none'; + sort?: ((m: string, n: string) => boolean) | boolean; } /** From 9284ed563bcac4f67cf23b7cf0b73935f18408a5 Mon Sep 17 00:00:00 2001 From: Simon VDB Date: Thu, 3 Jan 2019 16:35:10 +0100 Subject: [PATCH 067/139] Add to contributor list --- types/query-string/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/query-string/index.d.ts b/types/query-string/index.d.ts index 81c10fb086..3eaf34c159 100644 --- a/types/query-string/index.d.ts +++ b/types/query-string/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for query-string 6.1 +// Type definitions for query-string 6.2 // Project: https://github.com/sindresorhus/query-string // Definitions by: Sam Verschueren // Tanguy Krotoff // HuHuanming // Madara Uchiha // Josh Holmer +// Simon Van den Broeck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 From f18132f94b6a66f994666e584e5b34f15a488485 Mon Sep 17 00:00:00 2001 From: Jeremy Forsythe Date: Thu, 3 Jan 2019 11:47:08 -0500 Subject: [PATCH 068/139] [express-slow-down] Add types --- .../express-slow-down-tests.ts | 27 +++++++ types/express-slow-down/index.d.ts | 75 +++++++++++++++++++ types/express-slow-down/tsconfig.json | 23 ++++++ types/express-slow-down/tslint.json | 1 + 4 files changed, 126 insertions(+) create mode 100644 types/express-slow-down/express-slow-down-tests.ts create mode 100644 types/express-slow-down/index.d.ts create mode 100644 types/express-slow-down/tsconfig.json create mode 100644 types/express-slow-down/tslint.json diff --git a/types/express-slow-down/express-slow-down-tests.ts b/types/express-slow-down/express-slow-down-tests.ts new file mode 100644 index 0000000000..46ab215848 --- /dev/null +++ b/types/express-slow-down/express-slow-down-tests.ts @@ -0,0 +1,27 @@ +import SlowDown = require("express-slow-down"); + +const slowerAllDefaults = new SlowDown({}); + +const slowerWithOptions = new SlowDown({ + windowMs: 15 * 60 * 1000, // 15 minutes, + delayAfter: 1, + delayMs: 0, // disabled + skipFailedRequests: false, + skipSuccessfulRequests: true, +}); + +const slowerWithCallbacks = new SlowDown({ + keyGenerator: (req, res) => req.ip, + skip: (req, res) => false, + onLimitReached: (req, res, opts) => {}, +}); + +class MockStore implements SlowDown.Store { + incr(key: string, cb: SlowDown.StoreIncrementCallback) { } + decrement(key: string) { } + resetKey(key: string) { } +} + +const slowerWithStore = new SlowDown({ + store: new MockStore() +}); diff --git a/types/express-slow-down/index.d.ts b/types/express-slow-down/index.d.ts new file mode 100644 index 0000000000..a446ca4f11 --- /dev/null +++ b/types/express-slow-down/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for express-slow-down 1.1 +// Project: https://github.com/nfriedly/express-slow-down +// Definitions by: Jeremy Forsythe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import express = require("express"); + +declare namespace SlowDown { + type StoreIncrementCallback = (err?: {}, hits?: number) => void; + + interface Store { + incr(key: string, cb: StoreIncrementCallback): void; + decrement(key: string): void; + resetKey(key: string): void; + } + + /** + * express-slow-down options + */ + interface Options { + /** + * How long to keep records of requests in memory. Defaults to `60000` (1 minute) + */ + windowMs?: number; + + /** + * Max number of connections during `windowMs` before starting to delay responses. + * Defaults to `1`. Set to `0` to disable delaying. + */ + delayAfter?: number; + + /** + * How long to delay the response, multiplied by `(number recent hits - delayAfter)`. + * Defaults to `1000` (1 second). Set to `0` to disable delaying. + */ + delayMs?: number; + + /** + * When `true` failed requests (response status >= 400) won't be counted. Defaults to `false`. + */ + skipFailedRequests?: boolean; + + /** + * When `true` successful requests (response status < 400) won't be counted. Defaults to `false`. + */ + skipSuccessfulRequests?: boolean; + + /** + * Function used to generate keys. By default user IP address (`req.ip`) is used. + * Default: `(req, res) => req.ip` + */ + keyGenerator?(req: express.Request, res: express.Response): string; + + /** + * Function used to skip requests. Returning `true` from the function will skip delaying for that request. + * Default: `(req, res) => false` + */ + skip?(req: express.Request, res: express.Response): boolean; + + /** + * Function to execute the first time the limit is reached within `windowMs`. + * Default: `(req, res, opts) => {}` + */ + onLimitReached?(req: express.Request, res: express.Response, optionsUsed: Options): void; + + /** + * The storage to use when persisting request attempts. By default, the MemoryStore is used. + */ + store?: Store; + } +} + +declare var SlowDown: new (options: SlowDown.Options) => express.RequestHandler; +export = SlowDown; diff --git a/types/express-slow-down/tsconfig.json b/types/express-slow-down/tsconfig.json new file mode 100644 index 0000000000..9973398566 --- /dev/null +++ b/types/express-slow-down/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-slow-down-tests.ts" + ] +} diff --git a/types/express-slow-down/tslint.json b/types/express-slow-down/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-slow-down/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 35692888a460f7c431e3f754edfcbf1a7946423b Mon Sep 17 00:00:00 2001 From: Bryan Spears Date: Thu, 3 Jan 2019 09:56:34 -0700 Subject: [PATCH 069/139] error can also be `null` --- types/needle/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/needle/index.d.ts b/types/needle/index.d.ts index fae0a01392..509e212c6e 100644 --- a/types/needle/index.d.ts +++ b/types/needle/index.d.ts @@ -23,7 +23,7 @@ declare namespace core { type ReadableStream = NodeJS.ReadableStream; - type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void; + type NeedleCallback = (error: Error | null, response: NeedleResponse, body: any) => void; interface Cookies { [name: string]: any; From 0566178dc9a85249fe7bd9d1bdbcc8a4dac3f7ba Mon Sep 17 00:00:00 2001 From: David Gomes Date: Thu, 3 Jan 2019 17:03:19 +0000 Subject: [PATCH 070/139] Add sqlstring.raw to sqlstring type definitions. --- types/sqlstring/index.d.ts | 1 + types/sqlstring/sqlstring-tests.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/types/sqlstring/index.d.ts b/types/sqlstring/index.d.ts index bf774824e7..3e85850069 100644 --- a/types/sqlstring/index.d.ts +++ b/types/sqlstring/index.d.ts @@ -7,3 +7,4 @@ export function format(sql: string, args: object | any[]): string; export function escape(value: any): string; export function escapeId(value: any, dotQualifier?: boolean): string; +export function raw(sql: string): { toSqlString: () => string }; diff --git a/types/sqlstring/sqlstring-tests.ts b/types/sqlstring/sqlstring-tests.ts index 6d2ef471c7..d6303c3831 100644 --- a/types/sqlstring/sqlstring-tests.ts +++ b/types/sqlstring/sqlstring-tests.ts @@ -29,3 +29,10 @@ const sql6 = const userId4 = 1; const inserts = ["users", "id", userId4]; const sql7 = SqlString.format("SELECT * FROM ?? WHERE ?? = ?", inserts); + +const userId4 = 1; +const inserts = ["users", "id", userId4]; +const sql7 = SqlString.format("SELECT * FROM ?? WHERE ?? = ?", inserts); + +var CURRENT_TIMESTAMP = SqlString.raw('CURRENT_TIMESTAMP()'); +const sql8 = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]); From 9975a166869998b7d183e547b857f3dbee99c901 Mon Sep 17 00:00:00 2001 From: David Gomes Date: Thu, 3 Jan 2019 17:09:01 +0000 Subject: [PATCH 071/139] Add sqlstring.raw to sqlstring type definitions. --- types/sqlstring/sqlstring-tests.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/types/sqlstring/sqlstring-tests.ts b/types/sqlstring/sqlstring-tests.ts index d6303c3831..de6fe64a1d 100644 --- a/types/sqlstring/sqlstring-tests.ts +++ b/types/sqlstring/sqlstring-tests.ts @@ -30,9 +30,5 @@ const userId4 = 1; const inserts = ["users", "id", userId4]; const sql7 = SqlString.format("SELECT * FROM ?? WHERE ?? = ?", inserts); -const userId4 = 1; -const inserts = ["users", "id", userId4]; -const sql7 = SqlString.format("SELECT * FROM ?? WHERE ?? = ?", inserts); - -var CURRENT_TIMESTAMP = SqlString.raw('CURRENT_TIMESTAMP()'); +const CURRENT_TIMESTAMP = SqlString.raw('CURRENT_TIMESTAMP()'); const sql8 = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]); From 62adcee7586cb3e197336385fe5333175bc02997 Mon Sep 17 00:00:00 2001 From: Jeremy Forsythe Date: Thu, 3 Jan 2019 12:14:46 -0500 Subject: [PATCH 072/139] [express-rate-limit] Create definitions for v3 --- .../express-rate-limit-tests.ts | 16 +++- types/express-rate-limit/index.d.ts | 81 ++++++++++++++++--- .../v2/express-rate-limit-tests.ts | 39 +++++++++ types/express-rate-limit/v2/index.d.ts | 42 ++++++++++ types/express-rate-limit/v2/tsconfig.json | 26 ++++++ types/express-rate-limit/v2/tslint.json | 1 + 6 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 types/express-rate-limit/v2/express-rate-limit-tests.ts create mode 100644 types/express-rate-limit/v2/index.d.ts create mode 100644 types/express-rate-limit/v2/tsconfig.json create mode 100644 types/express-rate-limit/v2/tslint.json diff --git a/types/express-rate-limit/express-rate-limit-tests.ts b/types/express-rate-limit/express-rate-limit-tests.ts index aa5c51a016..4b94ef6b05 100644 --- a/types/express-rate-limit/express-rate-limit-tests.ts +++ b/types/express-rate-limit/express-rate-limit-tests.ts @@ -3,7 +3,19 @@ import RateLimit = require("express-rate-limit"); const apiLimiter = new RateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100, - delayMs: 0 // disabled + headers: false, + skipFailedRequests: false, + skipSuccessfulRequests: true, +}); + +const apiLimiterWithMaxFn = new RateLimit({ + windowMs: 15 * 60 * 1000, + max: () => 5, +}); + +const apiLimiterWithMaxPromiseFn = new RateLimit({ + windowMs: 15 * 60 * 1000, + max: () => Promise.resolve(5), }); const apiLimiterWithMessageObject = new RateLimit({ @@ -17,8 +29,6 @@ const apiLimiterWithMessageObject = new RateLimit({ const createAccountLimiter = new RateLimit({ windowMs: 60 * 60 * 1000, // 1 hour window - delayAfter: 1, // begin slowing down responses after the first request - delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request max: 5, // start blocking after 5 requests message: "Too many accounts created from this IP, please try again after an hour", handler: (req, _, next) => next(new Error(`TooManyRequests: ${req.ip}`)) diff --git a/types/express-rate-limit/index.d.ts b/types/express-rate-limit/index.d.ts index b3f074f28d..9d3459e21b 100644 --- a/types/express-rate-limit/index.d.ts +++ b/types/express-rate-limit/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for express-rate-limit 2.9 +// Type definitions for express-rate-limit 3.3 // Project: https://github.com/nfriedly/express-rate-limit -// Definitions by: Cyril Schumacher , makepost +// Definitions by: Cyril Schumacher +// makepost +// Jeremy Forsythe // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -21,19 +23,80 @@ declare namespace RateLimit { [key: string]: any; } + type MaxValueFn = () => number | Promise; + interface Options { - delayAfter?: number; - delayMs?: number; + /** + * The funciton to handle requests once `max` is exceeded. It receives the request and response objects. + * The "next" param is available if you need to pass to the next middleware. The `req.rateLimit` object + * has `limit`, `current`, and `remaining` number of requests, and if the store provides it, a `resetTime` + * Date object. + * Default: `(req, res, next) => res.status(options.statusCode).send(options.message)` + */ handler?(req: express.Request, res: express.Response, next: express.NextFunction): any; + + /** + * Enable headers for request limit (`X-RateLimit-Limit`) and current usage (`X-RateLimit-Remaining`) on all + * responses andtime to wait before retrying (`Retry-After`) when `max` is exceeded. Defaults to `true`. + */ headers?: boolean; + + /** + * Function used to generate keys. Defaults to using `req.ip`. + * Default: `(req, res) => req.ip` + */ keyGenerator?(req: express.Request, res: express.Response): string; - max?: number; + + /** + * Max number of connections during `windowMs` before sending a 429 response. May be a `number` or + * a function that returns a `number` or a `Promise`. Defaults to `5`. Set to `0` to disable. + */ + max?: number | MaxValueFn; + + /** + * Error message sent to user when `max` is exceeded. May be a `string`, JSON object, or any other value + * that Express's `req.send()` supports. Defaults to `'Too many requests, please try again later.'`. + */ message?: string | Buffer | Message; - skip?(req: express.Request, res: express.Response): boolean; - skipFailedRequests?: boolean; - statusCode?: number; - store?: Store; + + /** + * Function that is called the first time `max` is exceeded. The `req.rateLimit` object has `limit`, `current`, + * and `remaining` number of requests and, if the store provides it, a `resetTime` Date object. Default is + * an empty function. + * Default: `(req, res, opts) => {}` + */ onLimitReached?(req: express.Request, res: express.Response, optionsUsed: Options): void; + + /** + * Function used to skip requests. Returning `true` from the function will skip limiting for that request. Defaults to + * always `false` (count all requests). + * Default: `(req, res) => false` + */ + skip?(req: express.Request, res: express.Response): boolean; + + /** + * When set to `true`, failed requests (status >= 400, request canceled or errored) won't be counted. Defaults to `false`. + */ + skipFailedRequests?: boolean; + + /** + * When set to `true`, successful requests (status < 400) won't be counted. Defaults to `false`. + */ + skipSuccessfulRequests?: boolean; + + /** + * HTTP status code returned when `max` is exceeded. Defaults to `429`. + */ + statusCode?: number; + + /** + * The storage to use when persisting rate limit attempts. + */ + store?: Store; + + /** + * How long in milliseconds to keep records of requests in memory. Defaults to `60000` (1 minute). + */ windowMs?: number; } } diff --git a/types/express-rate-limit/v2/express-rate-limit-tests.ts b/types/express-rate-limit/v2/express-rate-limit-tests.ts new file mode 100644 index 0000000000..aa5c51a016 --- /dev/null +++ b/types/express-rate-limit/v2/express-rate-limit-tests.ts @@ -0,0 +1,39 @@ +import RateLimit = require("express-rate-limit"); + +const apiLimiter = new RateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 100, + delayMs: 0 // disabled +}); + +const apiLimiterWithMessageObject = new RateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 100, + message: { + status: 429, + message: 'To many requests, try again later' + } +}); + +const createAccountLimiter = new RateLimit({ + windowMs: 60 * 60 * 1000, // 1 hour window + delayAfter: 1, // begin slowing down responses after the first request + delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request + max: 5, // start blocking after 5 requests + message: "Too many accounts created from this IP, please try again after an hour", + handler: (req, _, next) => next(new Error(`TooManyRequests: ${req.ip}`)) +}); + +const callbackWithFewerParams = new RateLimit({ + handler: (req, res) => res.status(429).json(`TooManyRequests: ${req.ip}`) +}); + +class SomeStore implements RateLimit.Store { + incr(key: string, cb: RateLimit.StoreIncrementCallback) { } + decrement(key: string) { } + resetKey(key: string) { } +} + +const limiterWithStore = new RateLimit({ + store: new SomeStore() +}); diff --git a/types/express-rate-limit/v2/index.d.ts b/types/express-rate-limit/v2/index.d.ts new file mode 100644 index 0000000000..b3f074f28d --- /dev/null +++ b/types/express-rate-limit/v2/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for express-rate-limit 2.9 +// Project: https://github.com/nfriedly/express-rate-limit +// Definitions by: Cyril Schumacher , makepost +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import express = require("express"); + +declare namespace RateLimit { + type StoreIncrementCallback = (err?: {}, hits?: number) => void; + + interface Store { + incr(key: string, cb: StoreIncrementCallback): void; + decrement(key: string): void; + resetKey(key: string): void; + } + + interface Message { + status: number; + message: string; + [key: string]: any; + } + + interface Options { + delayAfter?: number; + delayMs?: number; + handler?(req: express.Request, res: express.Response, next: express.NextFunction): any; + headers?: boolean; + keyGenerator?(req: express.Request, res: express.Response): string; + max?: number; + message?: string | Buffer | Message; + skip?(req: express.Request, res: express.Response): boolean; + skipFailedRequests?: boolean; + statusCode?: number; + store?: Store; + onLimitReached?(req: express.Request, res: express.Response, optionsUsed: Options): void; + windowMs?: number; + } +} + +declare var RateLimit: new (options: RateLimit.Options) => express.RequestHandler; +export = RateLimit; diff --git a/types/express-rate-limit/v2/tsconfig.json b/types/express-rate-limit/v2/tsconfig.json new file mode 100644 index 0000000000..0e9b4d2ad4 --- /dev/null +++ b/types/express-rate-limit/v2/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "express-rate-limit": ["express-rate-limit/v2"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-rate-limit-tests.ts" + ] +} diff --git a/types/express-rate-limit/v2/tslint.json b/types/express-rate-limit/v2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-rate-limit/v2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4cace8f646c6c7173dbd2370f95296c06c2e4e2c Mon Sep 17 00:00:00 2001 From: Taku Shimosawa Date: Wed, 2 Jan 2019 17:51:25 -0800 Subject: [PATCH 073/139] [bytebuffer] Change to/add Buffer in the types for arguments and return types --- types/bytebuffer/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/bytebuffer/index.d.ts b/types/bytebuffer/index.d.ts index 4423d7872b..bafed6edf8 100644 --- a/types/bytebuffer/index.d.ts +++ b/types/bytebuffer/index.d.ts @@ -146,7 +146,7 @@ declare class ByteBuffer /** * Concatenates multiple ByteBuffers into one. */ - static concat( buffers: Array, encoding?: string | boolean, litteEndian?: boolean, noAssert?: boolean ): ByteBuffer; + static concat( buffers: Array, encoding?: string | boolean, litteEndian?: boolean, noAssert?: boolean ): ByteBuffer; /** * Decodes a base64 encoded string to a ByteBuffer. @@ -185,7 +185,7 @@ declare class ByteBuffer * @param littleEndian Whether to use little or big endian byte order. Defaults to ByteBuffer.DEFAULT_ENDIAN. * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteBuffer.DEFAULT_NOASSERT. */ - static wrap( buffer: ByteBuffer | ArrayBuffer | Uint8Array | string, enc?: string | boolean, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + static wrap( buffer: ByteBuffer | Buffer | ArrayBuffer | Uint8Array | string, enc?: string | boolean, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; /** * Decodes a zigzag encoded signed 32bit integer. @@ -220,7 +220,7 @@ declare class ByteBuffer /** * Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended data's length. */ - append( source: ByteBuffer | ArrayBuffer | Uint8Array | string, encoding?: string | number, offset?: number ): ByteBuffer; + append( source: ByteBuffer | Buffer | ArrayBuffer | Uint8Array | string, encoding?: string | number, offset?: number ): ByteBuffer; /** * Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents behind the specified offset up to the length of this ByteBuffer's data. @@ -291,7 +291,7 @@ declare class ByteBuffer /** * Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the prepended data's length. If there is not enough space available before the specified offset, the backing buffer will be resized and its contents moved accordingly. */ - prepend( source: ByteBuffer | string | ArrayBuffer, encoding?: string | number, offset?: number ): ByteBuffer; + prepend( source: ByteBuffer | string | ArrayBuffer | Buffer, encoding?: string | number, offset?: number ): ByteBuffer; /** * Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the prepended data's length. If there is not enough space available before the specified offset, the backing buffer will be resized and its contents moved accordingly. @@ -480,7 +480,7 @@ declare class ByteBuffer /** * Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. Will transparently ByteBuffer#flip this ByteBuffer if offset > limit but the actual offsets remain untouched. */ - toBuffer( forceCopy?: boolean ): ArrayBuffer; + toBuffer( forceCopy?: boolean ): Buffer; /** *Encodes this ByteBuffer to a hex encoded string with marked offsets. Offset symbols are: @@ -517,7 +517,7 @@ declare class ByteBuffer /** * Writes an array of bytes. This is an alias for append */ - writeBytes( source: ByteBuffer | ArrayBuffer | Uint8Array | string, encoding?: string | number, offset?: number ): ByteBuffer; + writeBytes( source: ByteBuffer | Buffer | ArrayBuffer | Uint8Array | string, encoding?: string | number, offset?: number ): ByteBuffer; /** * Writes a NULL-terminated UTF8 encoded string. For this to work the specified string must not contain any NULL characters itself. From e50421936ea216ae862fb88afe78a502900553da Mon Sep 17 00:00:00 2001 From: Wouter R Date: Thu, 3 Jan 2019 19:34:43 +0100 Subject: [PATCH 074/139] Remove tslint ban-types config override in favor of inline overrides. --- types/mongoose-paginate-v2/index.d.ts | 3 +++ types/mongoose-paginate-v2/tslint.json | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index dfd70cc0cb..ca8b7eac91 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -20,10 +20,13 @@ declare module 'mongoose' { } interface PaginateOptions { + /* tslint:disable-next-line: ban-types */ select?: Object | string; + /* tslint:disable-next-line: ban-types */ sort?: Object | string; customLabels?: CustomLabels; collation?: CollationOptions; + /* tslint:disable-next-line: ban-types */ populate?: Object[] | string[] | Object | string; lean?: boolean; leanWithId?: boolean; diff --git a/types/mongoose-paginate-v2/tslint.json b/types/mongoose-paginate-v2/tslint.json index a62d0d4e68..f93cf8562a 100644 --- a/types/mongoose-paginate-v2/tslint.json +++ b/types/mongoose-paginate-v2/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "ban-types": false - } + "extends": "dtslint/dt.json" } From 45f849476129c3f383ecc59742c3b9f19cbea55a Mon Sep 17 00:00:00 2001 From: Jeremy Forsythe Date: Thu, 3 Jan 2019 13:53:52 -0500 Subject: [PATCH 075/139] fix function call and handle augmented Request --- .../express-slow-down-tests.ts | 20 ++++++---- types/express-slow-down/index.d.ts | 38 ++++++++++++++++++- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/types/express-slow-down/express-slow-down-tests.ts b/types/express-slow-down/express-slow-down-tests.ts index 46ab215848..e7d049bd7d 100644 --- a/types/express-slow-down/express-slow-down-tests.ts +++ b/types/express-slow-down/express-slow-down-tests.ts @@ -1,8 +1,8 @@ -import SlowDown = require("express-slow-down"); +import slowDown = require("express-slow-down"); -const slowerAllDefaults = new SlowDown({}); +const slowerAllDefaults = slowDown({}); -const slowerWithOptions = new SlowDown({ +const slowerWithOptions = slowDown({ windowMs: 15 * 60 * 1000, // 15 minutes, delayAfter: 1, delayMs: 0, // disabled @@ -10,18 +10,22 @@ const slowerWithOptions = new SlowDown({ skipSuccessfulRequests: true, }); -const slowerWithCallbacks = new SlowDown({ +const slowerWithCallbacks = slowDown({ keyGenerator: (req, res) => req.ip, skip: (req, res) => false, - onLimitReached: (req, res, opts) => {}, + onLimitReached: (req, res, opts) => { + console.log(req.slowDown.current); + console.log(req.slowDown.remaining); + console.log(req.slowDown.limit); + }, }); -class MockStore implements SlowDown.Store { - incr(key: string, cb: SlowDown.StoreIncrementCallback) { } +class MockStore implements slowDown.Store { + incr(key: string, cb: slowDown.StoreIncrementCallback) { } decrement(key: string) { } resetKey(key: string) { } } -const slowerWithStore = new SlowDown({ +const slowerWithStore = slowDown({ store: new MockStore() }); diff --git a/types/express-slow-down/index.d.ts b/types/express-slow-down/index.d.ts index a446ca4f11..0ab76adb8f 100644 --- a/types/express-slow-down/index.d.ts +++ b/types/express-slow-down/index.d.ts @@ -9,6 +9,40 @@ import express = require("express"); declare namespace SlowDown { type StoreIncrementCallback = (err?: {}, hits?: number) => void; + interface SlowDownRequestAugmentation { + /** + * The `options.delayAfter` value + */ + limit: number; + + /** + * The number of requests in the current window + */ + current: number; + + /** + * the number of requests remaining before rate-limiting begins + */ + remaining: number; + + /** + * When the window will reset, `current` will return to `0`, and `remaining` will return + * to limit. Represents milliseconds since epoch (compare to `Date.now()`). This field + * depends on store support. It will be `undefined` if the store does not provide the value. + */ + resetTime?: number; + + /** + * Amount of delay imposed on current request in milliseconds + */ + delay: number; + } + + /** + * Express Request with the added `slowDown` property + */ + type RequestWithSlowDown = express.Request & { slowDown: SlowDownRequestAugmentation } + interface Store { incr(key: string, cb: StoreIncrementCallback): void; decrement(key: string): void; @@ -62,7 +96,7 @@ declare namespace SlowDown { * Function to execute the first time the limit is reached within `windowMs`. * Default: `(req, res, opts) => {}` */ - onLimitReached?(req: express.Request, res: express.Response, optionsUsed: Options): void; + onLimitReached?(req: RequestWithSlowDown, res: express.Response, optionsUsed: Options): void; /** * The storage to use when persisting request attempts. By default, the MemoryStore is used. @@ -71,5 +105,5 @@ declare namespace SlowDown { } } -declare var SlowDown: new (options: SlowDown.Options) => express.RequestHandler; +declare var SlowDown: (options: SlowDown.Options) => express.RequestHandler; export = SlowDown; From 59d63bd16121fe914f7e87e5a304fbc7b1e30597 Mon Sep 17 00:00:00 2001 From: Jeremy Forsythe Date: Thu, 3 Jan 2019 14:03:06 -0500 Subject: [PATCH 076/139] fix tests --- types/express-slow-down/index.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/types/express-slow-down/index.d.ts b/types/express-slow-down/index.d.ts index 0ab76adb8f..9e49f6ba64 100644 --- a/types/express-slow-down/index.d.ts +++ b/types/express-slow-down/index.d.ts @@ -41,7 +41,7 @@ declare namespace SlowDown { /** * Express Request with the added `slowDown` property */ - type RequestWithSlowDown = express.Request & { slowDown: SlowDownRequestAugmentation } + type RequestWithSlowDown = express.Request & { slowDown: SlowDownRequestAugmentation }; interface Store { incr(key: string, cb: StoreIncrementCallback): void; @@ -105,5 +105,4 @@ declare namespace SlowDown { } } -declare var SlowDown: (options: SlowDown.Options) => express.RequestHandler; -export = SlowDown; +export function SlowDown(options: SlowDown.Options): express.RequestHandler; From 6ca38e89115b17ce7b7b77bd64fe69bc1d18671c Mon Sep 17 00:00:00 2001 From: Jeremy Forsythe Date: Thu, 3 Jan 2019 14:26:39 -0500 Subject: [PATCH 077/139] fix lint and better interface definition --- types/express-slow-down/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/express-slow-down/index.d.ts b/types/express-slow-down/index.d.ts index 9e49f6ba64..f7aeab76fd 100644 --- a/types/express-slow-down/index.d.ts +++ b/types/express-slow-down/index.d.ts @@ -41,7 +41,9 @@ declare namespace SlowDown { /** * Express Request with the added `slowDown` property */ - type RequestWithSlowDown = express.Request & { slowDown: SlowDownRequestAugmentation }; + interface RequestWithSlowDown extends express.Request { + slowDown: SlowDownRequestAugmentation; + } interface Store { incr(key: string, cb: StoreIncrementCallback): void; @@ -105,4 +107,5 @@ declare namespace SlowDown { } } -export function SlowDown(options: SlowDown.Options): express.RequestHandler; +declare function SlowDown(options: SlowDown.Options): express.RequestHandler; +export = SlowDown; From 3d61a8f7b0b0477ea9b5b30da4f263b1782b46ec Mon Sep 17 00:00:00 2001 From: Akuukis Date: Fri, 4 Jan 2019 04:05:35 +0200 Subject: [PATCH 078/139] [stellar-sdk] Misc improvements 3 (#31857) * fix(operations): review props and options * feat(op): setOptions signer conditional type * fix: Server.ServerOptions -> Server.Options --- types/stellar-sdk/index.d.ts | 200 +++++++++++++------------ types/stellar-sdk/stellar-sdk-tests.ts | 12 ++ 2 files changed, 116 insertions(+), 96 deletions(-) diff --git a/types/stellar-sdk/index.d.ts b/types/stellar-sdk/index.d.ts index 89f534c629..82ee2f583e 100644 --- a/types/stellar-sdk/index.d.ts +++ b/types/stellar-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stellar-sdk 0.10 +// Type definitions for stellar-sdk 0.11 // Project: https://github.com/stellar/js-stellar-sdk // Definitions by: Carl Foster // Triston Jones @@ -154,98 +154,89 @@ export namespace StellarBase { } namespace Operation { - interface Operation { - type: OperationType; - source: string | null; - } - interface AccountMerge extends Operation { - type: OperationType.accountMerge; - destination: string; - } - interface AccountMergeOptions { - destination: string; + interface Operation { + type: T; source?: string; } + interface OperationOptions { + source?: string; + } + + interface AccountMerge extends Operation { + destination: string; + } + interface AccountMergeOptions extends OperationOptions { + destination: string; + } function accountMerge(options: AccountMergeOptions): xdr.Operation; - interface AllowTrust extends Operation { - type: OperationType.allowTrust; + interface AllowTrust extends Operation { trustor: string; assetCode: string; - authorize: boolean; + authorize: boolean | undefined; } - interface AllowTrustOptions { + interface AllowTrustOptions extends OperationOptions { trustor: string; assetCode: string; - authorize: boolean; - source?: string; + authorize?: boolean; } function allowTrust(options: AllowTrustOptions): xdr.Operation; - interface ChangeTrust extends Operation { - type: OperationType.changeTrust; + interface ChangeTrust extends Operation { line: Asset; - limit: string | number; + limit: string; } - interface ChangeTrustOptions { + interface ChangeTrustOptions extends OperationOptions { asset: Asset; limit?: string; - source?: string; } function changeTrust(options: ChangeTrustOptions): xdr.Operation; - interface CreateAccount extends Operation { - type: OperationType.createAccount; - source: string; + interface CreateAccount extends Operation { destination: string; - startingBalance: string | number; + startingBalance: string; } - interface CreateAccountOptions { + interface CreateAccountOptions extends OperationOptions { destination: string; startingBalance: string; - source?: string; } function createAccount(options: CreateAccountOptions): xdr.Operation; - interface CreatePassiveOffer extends Operation { - type: OperationType.createPassiveOffer; - selling: Asset; - buying: Asset; - amount: string | number; - price: string | number; - } - interface CreatePassiveOfferOptions { + interface CreatePassiveOffer extends Operation { selling: Asset; buying: Asset; amount: string; - price: number | string | object; - source?: string; + price: string; + } + interface CreatePassiveOfferOptions extends OperationOptions { + selling: Asset; + buying: Asset; + amount: string; + price: number | string | object /* bignumber.js */; } function createPassiveOffer(options: CreatePassiveOfferOptions): xdr.Operation; - interface Inflation extends Operation { - type: OperationType.inflation; + interface Inflation extends Operation { } - function inflation(options: { source?: string }): xdr.Operation; + interface InflationOptions extends OperationOptions { // tslint:disable-line + } + function inflation(options: InflationOptions): xdr.Operation; - interface ManageData extends Operation { - type: OperationType.manageData; + interface ManageData extends Operation { name: string; value: Buffer; } - interface ManageDataOptions { + interface ManageDataOptions extends OperationOptions { name: string; value: string | Buffer; - source?: string; } function manageData(options: ManageDataOptions): xdr.Operation; - interface ManageOffer extends Operation { - type: OperationType.manageOffer; + interface ManageOffer extends Operation { selling: Asset; buying: Asset; - amount: string | number; - price: string | number; + amount: string; + price: string; offerId: string; } interface ManageOfferOptions extends CreatePassiveOfferOptions { @@ -253,37 +244,33 @@ export namespace StellarBase { } function manageOffer(options: ManageOfferOptions): xdr.Operation; - interface PathPayment extends Operation { - type: OperationType.pathPayment; - sendAsset: Asset; - sendMax: string | number; - destination: string; - destAsset: Asset; - destAmount: string | number; - path: Asset[]; - } - interface PathPaymentOptions { + interface PathPayment extends Operation { sendAsset: Asset; sendMax: string; destination: string; destAsset: Asset; destAmount: string; path: Asset[]; - source?: string; + } + interface PathPaymentOptions extends OperationOptions { + sendAsset: Asset; + sendMax: string; + destination: string; + destAsset: Asset; + destAmount: string; + path?: Asset[]; } function pathPayment(options: PathPaymentOptions): xdr.Operation; - interface Payment extends Operation { - type: OperationType.payment; - destination: string; - asset: Asset; - amount: string | number; - } - interface PaymentOptions { - destination: string; - asset: Asset; + interface Payment extends Operation { amount: string; - source?: string; + asset: Asset; + destination: string; + } + interface PaymentOptions extends OperationOptions { + amount: string; + asset: Asset; + destination: string; } function payment(options: PaymentOptions): xdr.Operation; @@ -297,14 +284,49 @@ export namespace StellarBase { Revocable = 2, Immutable = 4, } - interface Signer { - ed25519PublicKey?: string; - sha256Hash?: Buffer | string; - preAuthTx?: Buffer | string; + interface SignerEd25519PublicKey { + ed25519PublicKey: string; + weight: number | undefined; + } + interface SignerSha256Hash { + sha256Hash: Buffer; + weight: number | undefined; + } + interface SignerPreAuthTx { + preAuthTx: Buffer; + weight: number | undefined; + } + type Signer = SignerEd25519PublicKey | SignerSha256Hash | SignerPreAuthTx; + interface SignerEd25519PublicKeyOptions { + ed25519PublicKey: string; weight?: number | string; } - interface SetOptions extends Operation { - type: OperationType.setOptions; + interface SignerSha256HashOptions { + sha256Hash: Buffer | string; + weight?: number | string; + } + interface SignerPreAuthTxOptions { + preAuthTx: Buffer | string; + weight?: number | string; + } + type SignerOptions = SignerEd25519PublicKeyOptions | SignerSha256HashOptions | SignerPreAuthTxOptions; + type SignerUnion = {ed25519PublicKey: any} | {sha256Hash: any} | {preAuthTx: any} | null; + interface SetOptions extends Operation { + inflationDest?: string; + clearFlags?: AuthFlags; + setFlags?: AuthFlags; + masterWeight?: number; + lowThreshold?: number; + medThreshold?: number; + highThreshold?: number; + homeDomain?: string; + signer: + T extends {ed25519PublicKey: any} ? SignerEd25519PublicKey : + T extends {sha256Hash: any} ? SignerSha256Hash : + T extends {preAuthTx: any} ? SignerPreAuthTx : + never; + } + interface SetOptionsOptions extends OperationOptions { inflationDest?: string; clearFlags?: AuthFlags; setFlags?: AuthFlags; @@ -313,29 +335,15 @@ export namespace StellarBase { medThreshold?: number | string; highThreshold?: number | string; homeDomain?: string; - signer?: Signer; + signer?: T; } - interface SetOptionsOptions { - inflationDest?: string; - clearFlags?: AuthFlags; - setFlags?: AuthFlags; - masterWeight?: number | string; - lowThreshold?: number | string; - medThreshold?: number | string; - highThreshold?: number | string; - signer?: Signer; - homeDomain?: string; - source?: string; - } - function setOptions(options: SetOptionsOptions): xdr.Operation; + function setOptions(options: SetOptionsOptions): xdr.Operation>; - interface BumpSequence extends Operation { - type: OperationType.bumpSequence; + interface BumpSequence extends Operation { bumpTo: string; } - interface BumpSequenceOptions { + interface BumpSequenceOptions extends OperationOptions { bumpTo: string; - source?: string; } function bumpSequence(options: BumpSequenceOptions): xdr.Operation; @@ -473,7 +481,7 @@ export namespace Config { } export class Server { - constructor(serverURL: string, options?: Server.ServerOptions) + constructor(serverURL: string, options?: Server.Options) accounts(): Server.AccountCallBuilder; assets(): Server.AssetsCallBuilder; effects(): Server.EffectCallBuilder; @@ -967,7 +975,7 @@ export namespace Server { forTransaction(transactionId: string): this; } - interface ServerOptions { + interface Options { allowHttp: boolean; } diff --git a/types/stellar-sdk/stellar-sdk-tests.ts b/types/stellar-sdk/stellar-sdk-tests.ts index bf991b4591..c4dcbda7c8 100644 --- a/types/stellar-sdk/stellar-sdk-tests.ts +++ b/types/stellar-sdk/stellar-sdk-tests.ts @@ -30,3 +30,15 @@ StellarSdk.Memo.hash('asdf').value; // $ExpectType Buffer // P.S. don't use Memo constructor (new StellarSdk.Memo(StellarSdk.MemoHash, 'asdf')).value; // $ExpectType AnyValue (new StellarSdk.Memo(StellarSdk.MemoHash, 'asdf')).type; // $ExpectType AnyType + +const noSignerXDR = StellarSdk.Operation.setOptions({lowThreshold: 1}); +StellarSdk.Operation.fromXDRObject(noSignerXDR).signer; // $ExpectType never + +const newSignerXDR1 = StellarSdk.Operation.setOptions({signer: {ed25519PublicKey: sourceKey.publicKey(), weight: '1'}}); +StellarSdk.Operation.fromXDRObject(newSignerXDR1).signer; // $ExpectType SignerEd25519PublicKey + +const newSignerXDR2 = StellarSdk.Operation.setOptions({signer: {sha256Hash: Buffer.from(''), weight: '1'}}); +StellarSdk.Operation.fromXDRObject(newSignerXDR2).signer; // $ExpectType SignerSha256Hash + +const newSignerXDR3 = StellarSdk.Operation.setOptions({signer: {preAuthTx: '', weight: 1}}); +StellarSdk.Operation.fromXDRObject(newSignerXDR3).signer; // $ExpectType SignerPreAuthTx From 34b631c6783abf448473a078b73e91feca87595e Mon Sep 17 00:00:00 2001 From: Taeheon Kim Date: Fri, 4 Jan 2019 11:06:38 +0900 Subject: [PATCH 079/139] Add "onBeforeDragStart" to the "DragDropContextProps" interface (#31865) --- types/react-beautiful-dnd/index.d.ts | 2 ++ types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index dfe6f21229..f917fc1a2d 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -5,6 +5,7 @@ // Austin Turner // Mark Nelissen // Enrico Boccadifuoco +// Taeheon Kim // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -85,6 +86,7 @@ export interface DropResult extends DragUpdate { } export interface DragDropContextProps { + onBeforeDragStart?(initial: DragStart): void; onDragStart?(initial: DragStart, provided: ResponderProvided): void; onDragUpdate?(initial: DragUpdate, provided: ResponderProvided): void; onDragEnd(result: DropResult, provided: ResponderProvided): void; diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index 93b7903818..ceb6757992 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -48,6 +48,10 @@ class App extends React.Component<{}, AppState> { this.onDragEnd = this.onDragEnd.bind(this); } + onBeforeDragStart(dragStart: DragStart) { + // + } + onDragStart(dragStart: DragStart, provided: ResponderProvided) { // } @@ -80,7 +84,7 @@ class App extends React.Component<{}, AppState> { render() { return ( - + {(provided, snapshot) => (
From 8d21ac9216f47c1a4739b5deb4df266a98fa2160 Mon Sep 17 00:00:00 2001 From: davidgoli Date: Thu, 3 Jan 2019 18:09:14 -0800 Subject: [PATCH 080/139] add extra parse signature --- types/url-parse/index.d.ts | 6 +++++- types/url-parse/url-parse-tests.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/url-parse/index.d.ts b/types/url-parse/index.d.ts index 58a14f3f4d..4d33354e9e 100644 --- a/types/url-parse/index.d.ts +++ b/types/url-parse/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for url-parse 1.4 // Project: https://github.com/unshiftio/url-parse -// Definitions by: Pavlo Chernenko , Hari Sivaramakrishnan , Dmitry Dushkin +// Definitions by: Pavlo Chernenko +// Hari Sivaramakrishnan +// Dmitry Dushkin +// David Golightly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -43,6 +46,7 @@ interface URLParse { declare const URLParse: { new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; + (address: string, parser?: boolean | URLParse.QueryParser): URLParse; extractProtocol(url: string): { slashes: boolean; diff --git a/types/url-parse/url-parse-tests.ts b/types/url-parse/url-parse-tests.ts index 87904b7f13..be8b8afe8c 100644 --- a/types/url-parse/url-parse-tests.ts +++ b/types/url-parse/url-parse-tests.ts @@ -5,6 +5,10 @@ new URL('foo/bar', 'https://github.com/'); new URL('foo/bar', 'https://github.com/', (query: string) => ({ query })); parse('foo/bar', 'https://github.com/'); parse('foo/bar', 'https://github.com/', (query: string) => ({ query })); +const result = parse('foo/bar?baz=quux', true); +if (result.query.baz !== 'quux') { + throw new Error('bad query parsing'); +} const url1: URL = new URL('https://github.com/foo/bar?baz=true'); url1.hash; From 305151cf2d4fdd0ce1ba36b4e0cd4e5ef381dddf Mon Sep 17 00:00:00 2001 From: paibamboo Date: Fri, 4 Jan 2019 10:22:41 +0700 Subject: [PATCH 081/139] Add onAfterClose prop to ReactModal --- types/react-modal/index.d.ts | 5 ++++- types/react-modal/react-modal-tests.tsx | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index d04a6b5c18..2daa2a1a6f 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal 3.6 +// Type definitions for react-modal 3.8.1 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov , // Drew Noakes , @@ -64,6 +64,9 @@ declare namespace ReactModal { /* Function that will be run after the modal has opened. */ onAfterOpen?(): void; + /* Function that will be run after the modal has closed. */ + onAfterClose?(): void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ onRequestClose?(event: (MouseEvent | KeyboardEvent)): void; diff --git a/types/react-modal/react-modal-tests.tsx b/types/react-modal/react-modal-tests.tsx index 8dfd6d35e3..96c18ea881 100644 --- a/types/react-modal/react-modal-tests.tsx +++ b/types/react-modal/react-modal-tests.tsx @@ -12,6 +12,7 @@ class ExampleOfUsingReactModal extends React.Component { overlayRef: HTMLDivElement; render() { const onAfterOpenFn = () => { }; + const onAfterCloseFn = () => { }; const onRequestCloseFn = () => { }; const customStyle = { overlay: { @@ -59,6 +60,7 @@ class ExampleOfUsingReactModal extends React.Component { Date: Fri, 4 Jan 2019 14:09:05 +0800 Subject: [PATCH 082/139] [opentype.js] add annotations for BoundingBox and some tests, finish prev todo --- types/opentype.js/index.d.ts | 15 +++++++++++++-- types/opentype.js/opentype.js-tests.ts | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/types/opentype.js/index.d.ts b/types/opentype.js/index.d.ts index 8dc449784d..5fdc257362 100644 --- a/types/opentype.js/index.d.ts +++ b/types/opentype.js/index.d.ts @@ -367,8 +367,19 @@ export interface PathCommand { * UTIL CLASSES ******************************************/ -export type BoundingBox = () => any; -// TODO add methods +export class BoundingBox { + x1: number; + y1: number; + x2: number; + y2: number; + + isEmpty(): boolean; + addPoint(x: number, y: number): void; + addX(x: number): void; + addY(y: number): void; + addBezier(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x: number, y: number): void; + addQuad(x0: number, y0: number, x1: number, y1: number, x: number, y: number): void; +} export interface Encoding { charset: string; diff --git a/types/opentype.js/opentype.js-tests.ts b/types/opentype.js/opentype.js-tests.ts index 04781d5415..e3695944db 100644 --- a/types/opentype.js/opentype.js-tests.ts +++ b/types/opentype.js/opentype.js-tests.ts @@ -113,6 +113,8 @@ aPath.extend(aPath); aPath.extend(aPath.commands); aPath.extend(aPath.getBoundingBox()); const pathBBox: opentype.BoundingBox = aPath.getBoundingBox(); +pathBBox.addQuad(1, 1, 1, 1, 1, 1); +const yDist = pathBBox.y2 - pathBBox.y1; aPath.draw(ctx); const pathData: string = aPath.toPathData(7); const pathSvg: string = aPath.toSVG(7); From f4417875ccd9964b8e64822b7dd8c582353178b8 Mon Sep 17 00:00:00 2001 From: paibamboo Date: Fri, 4 Jan 2019 13:26:08 +0700 Subject: [PATCH 083/139] Fix build error patch version not allowed --- types/react-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index 2daa2a1a6f..0117a69656 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal 3.8.1 +// Type definitions for react-modal 3.8 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov , // Drew Noakes , From c8aebb07540f5b9e66a5d80707594c6750e4fc65 Mon Sep 17 00:00:00 2001 From: Vince Varga Date: Thu, 3 Jan 2019 16:27:01 +0100 Subject: [PATCH 084/139] Add navigator.permissions API type definitions --- types/navigator-permissions/index.d.ts | 180 ++++++++++++++++++ .../navigator-permissions-tests.ts | 45 +++++ types/navigator-permissions/tsconfig.json | 24 +++ types/navigator-permissions/tslint.json | 1 + 4 files changed, 250 insertions(+) create mode 100644 types/navigator-permissions/index.d.ts create mode 100644 types/navigator-permissions/navigator-permissions-tests.ts create mode 100644 types/navigator-permissions/tsconfig.json create mode 100644 types/navigator-permissions/tslint.json diff --git a/types/navigator-permissions/index.d.ts b/types/navigator-permissions/index.d.ts new file mode 100644 index 0000000000..a62c7f77ef --- /dev/null +++ b/types/navigator-permissions/index.d.ts @@ -0,0 +1,180 @@ +// Type definitions for Navigator.Permissions 0.1 +// Project: https://developer.mozilla.org/en-US/docs/Web/API/Permissions +// Definitions by: Vince Varga , MindDoc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/** + * Namespace for `navigator.permissions` type definitions. + * + * As the Permissions API is only supported by Firefox and Chrome + * https://caniuse.com/#feat=permissions-api + * the TypeScript team has not yet added it to lib.dom.d.ts + * https://github.com/Microsoft/TypeScript/issues/24923 + * In the meantime, these type definitions can be used. + * + * The documentation is based on the MDN web docs + * https://developer.mozilla.org/en-US/docs/Web/API/Permissions + */ +declare namespace NavigatorPermissions { + /** + * Permission state values. + */ + type PermissionState = + 'granted' | + 'denied' | + 'prompt'; + + /** + * The `PermissionStatus` interface of the Permissions API provides the state + * of an object and an event handler for monitoring changes to said state. + * + * This is an experimental technology + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus} + */ + interface PermissionStatus extends EventTarget { + /** + * Returns the state of a requested permission. + */ + readonly state: PermissionState; + /** + * Returns the state of a requested permission. + * Later versions of the specification replace this with + * `PermissionStatus.state`. + * @deprecated + */ + readonly status: PermissionState; + /** + * An event called whenever `PermissionStatus.status` changes. + */ + onchange: ((this: this, event: Event) => any) | null; + } + + /** + * Permission name options. + */ + type PermissionName = + 'accelerometer' | + 'accessibility-events' | + 'ambient-light-sensor' | + 'background-sync' | + 'camera' | + 'clipboard-read' | + 'clipboard-write' | + 'geolocation' | + 'gyroscope' | + 'magnetometer' | + 'microphone' | + 'midi' | + 'notifications' | + 'payment-handler' | + 'persistent-storage' | + 'push'; + + /** + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query} + */ + interface PermissionDescriptor { + /** + * The name of the API whose permissions you want to query. + * + * Please, be aware, that not all of these are supported in every browser + * that supports the Permissions API. For example, in Firefox you can't query + * the `'microphone'` or `'camera'` and it'll throw `TypeError` + */ + name: N; + } + + interface PushPermissionDescriptor extends PermissionDescriptor<'push'> { + /** + * Indicates whether you want to show a notification for every message + * or be able to send silent push + * notifications. The default is `false`. Not supported in Firefox. + */ + userVisibleOnly?: boolean; + } + + interface MidiPermissionDescriptor extends PermissionDescriptor<'midi'> { + /** + * Indicates whether you need and/or receive system exclusive + * messages. The default is false. + */ + sysex?: boolean; + } + + // Map permission names to correctly typed descriptors. + interface NameDescriptorMap { + // ??? Question ???: + // Is there a better way to handle this case and remove repeated code, + // something like + // > { + // [n in N]: D; // this line to cover all basic cases + // // and the custom permission descriptors for midi and push + // } + 'accelerometer': PermissionDescriptor<'accelerometer'>; + 'accessibility-events': PermissionDescriptor<'accessibility-events'>; + 'ambient-light-sensor': PermissionDescriptor<'ambient-light-sensor'>; + 'background-sync': PermissionDescriptor<'background-sync'>; + 'camera': PermissionDescriptor<'camera'>; + 'clipboard-read': PermissionDescriptor<'clipboard-read'>; + 'clipboard-write': PermissionDescriptor<'clipboard-write'>; + 'geolocation': PermissionDescriptor<'geolocation'>; + 'gyroscope': PermissionDescriptor<'gyroscope'>; + 'magnetometer': PermissionDescriptor<'magnetometer'>; + 'microphone': PermissionDescriptor<'microphone'>; + 'notifications': PermissionDescriptor<'notifications'>; + 'payment-handler': PermissionDescriptor<'payment-handler'>; + 'persistent-storage': PermissionDescriptor<'persistent-storage'>; + // These permission descriptors support extra properties + 'midi': MidiPermissionDescriptor; + 'push': PushPermissionDescriptor; + } + + /** + * The `Permissions` interface of the Permissions API provides the core + * Permission API functionality, such as methods for querying and + * revoking permissions. + * + * This is an experimental technology. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions} + */ + interface Permissions { + /** + * The `Permissions.query()` method of the `Permissions` interface returns + * the state of a user permission on the global scope. + * @param permissionDescriptor object that sets + * options for the query operation consisting of a comma-separated list + * of name-value pairs. + * (Is comma-separated list really supported? It is mentioned in the docs, but does not work). + * @returns the user permission status for a given API. + * @throws `TypeError` Retrieving the `PermissionDescriptor` information + * failed in some way, or the permission doesn't exist or is currently + * unsupported (e.g. `midi`, or `push` with `userVisibleOnly`). + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query} + */ + query(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise; + /** + * The `Permissions.revoke()` method of the `Permissions` interface reverts a + * currently set permission back to its default state, which is usually `prompt`. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/revoke} + */ + revoke(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise; + } + + /** + * Navigator type definition with possible `permissions` API support. + * + * This interface adds the `permissions` property to the navigator. + */ + interface NavigatorPermissions extends Navigator { + /** + * Provides the core Permission API functionality, such as querying and revoking permissions. + * + * The typing takes into account that the feature is not widely supported, + * making code using this API more secure by forcing considering the `undefined` case. + */ + permissions?: Permissions; + } +} diff --git a/types/navigator-permissions/navigator-permissions-tests.ts b/types/navigator-permissions/navigator-permissions-tests.ts new file mode 100644 index 0000000000..918726b23d --- /dev/null +++ b/types/navigator-permissions/navigator-permissions-tests.ts @@ -0,0 +1,45 @@ +// Here are some examples for Navigator.Permissions types. +// Open it in your IDE with TypeScript support and observe the types and documentation help +// that this module provides + +// Navigator from lib.dom might have permissions +const nav = navigator as NavigatorPermissions.NavigatorPermissions; + +async function exampleQueryAndEventListeners() { + // Force users to check for undefined as the feature is not widely supported + if (typeof nav.permissions === 'undefined') { return; } + const permissionsStatus = await nav.permissions.query({ name: 'camera' }); + // Possible state values are known to users: + const isDenied = permissionsStatus.state === 'denied'; + // if compared to any non-valid value, it warns + // const tsShouldWarn = permissionsStatus.state === 'can you see the warning?'; + permissionsStatus.addEventListener('change', (event) => { + console.log('permission state changed'); + // I couldn't find a way to set the EventTarget's type to PermissionStatus + console.log('new PermissionStatus', event.target); + }); +} + +function exampleQueryOptions() { + // Force users to check for undefined as the feature is not widely supported + if (typeof nav.permissions === 'undefined') { return; } + // query method checks if the name is a valid permission name + nav.permissions.query({ name: 'camera' }); + // Other names would cause type errors + // nav.permissions.query({ name: 'invalid name' }); + + // When permission name is 'push', userVisibleOnly property is also supported + nav.permissions.query({ name: 'push', userVisibleOnly: true }); + // For other names, it would fail: + // nav.permissions.query({ name: 'camera', userVisibleOnly: true }); + + // When permission name is 'midi', sysex property is also supported + nav.permissions.query({ name: 'midi', sysex: true }); + // For other names, it would fail: + // nav.permissions.query({ name: 'camera', sysex: true }); +} + +function exampleIgnoreUndefinedCheck() { + // Using the ! after permissions will let you bypass the undefined-check + nav.permissions!.query({ name: 'microphone' }); +} diff --git a/types/navigator-permissions/tsconfig.json b/types/navigator-permissions/tsconfig.json new file mode 100644 index 0000000000..c072886b33 --- /dev/null +++ b/types/navigator-permissions/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "navigator-permissions-tests.ts" + ] +} diff --git a/types/navigator-permissions/tslint.json b/types/navigator-permissions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/navigator-permissions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5950b10aed88f4fc785a6e92158603f4d6713e41 Mon Sep 17 00:00:00 2001 From: Guillaume Mayer Date: Fri, 4 Jan 2019 11:48:30 -0300 Subject: [PATCH 085/139] failing test (sort of) --- types/koa-router/koa-router-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/koa-router/koa-router-tests.ts b/types/koa-router/koa-router-tests.ts index 51e95fb8a5..50e66509ea 100644 --- a/types/koa-router/koa-router-tests.ts +++ b/types/koa-router/koa-router-tests.ts @@ -49,6 +49,10 @@ const match = router.match('/users/:id', 'GET'); let layer: Router.Layer let layerOptions: Router.ILayerOptions +const mw: Router.IMiddleware = (ctx: Router.IRouterContext, next: () => Promise) => { + ctx.body = "Ok"; +}; + app.use(router.routes()); app.use(router.allowedMethods()); From 6e13e6088f3eab8874141412f27d23a6c6d4975a Mon Sep 17 00:00:00 2001 From: Guillaume Mayer Date: Fri, 4 Jan 2019 11:49:20 -0300 Subject: [PATCH 086/139] fix --- types/koa-router/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/koa-router/index.d.ts b/types/koa-router/index.d.ts index 81b0f697e6..b2163d09d1 100644 --- a/types/koa-router/index.d.ts +++ b/types/koa-router/index.d.ts @@ -43,7 +43,7 @@ declare namespace Router { strict?: boolean; } - export interface IRouterContext { + export interface IRouterContext extends Koa.Context { /** * url params */ From 8085094f30ad662b8226355079c3f75f4388ef3d Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 4 Jan 2019 17:27:19 +0100 Subject: [PATCH 087/139] Add terser-webpack-plugin (#31863) * Added terser plugin typings * add webpack chunk typing * added 'ExtractCommentOptions' instead of just 'object' --- types/terser-webpack-plugin/index.d.ts | 54 +++++++++++++++++++ .../terser-webpack-plugin-tests.ts | 36 +++++++++++++ types/terser-webpack-plugin/tsconfig.json | 23 ++++++++ types/terser-webpack-plugin/tslint.json | 1 + 4 files changed, 114 insertions(+) create mode 100644 types/terser-webpack-plugin/index.d.ts create mode 100644 types/terser-webpack-plugin/terser-webpack-plugin-tests.ts create mode 100644 types/terser-webpack-plugin/tsconfig.json create mode 100644 types/terser-webpack-plugin/tslint.json diff --git a/types/terser-webpack-plugin/index.d.ts b/types/terser-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..5d1afa1a52 --- /dev/null +++ b/types/terser-webpack-plugin/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for terser-webpack-plugin 1.2 +// Project: https://github.com/webpack-contrib/terser-webpack-plugin +// Definitions by: Daniel Schopf +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +import { Plugin } from 'webpack'; +import { MinifyOptions } from 'terser'; +import webpack = require('webpack'); + +export = TerserPlugin; + +declare class TerserPlugin extends Plugin { + constructor(opts?: TerserPlugin.TerserPluginOptions); +} + +declare namespace TerserPlugin { + interface MinifyResult { + error: any; + map: any; + code: any; + warnings: any; + extractedComments: any; + } + + interface ExtractCommentOptions { + condition: boolean | string | RegExp | ExtractCommentFn | object; + filename?: string | FormatFn; + banner?: boolean | string | FormatFn; + } + + type ExtractCommentFn = (node: any, comment: any) => (boolean | object); + + type FormatFn = (input: string) => string; + + interface TerserPluginOptions { + test?: string | RegExp | Array; + include?: string | RegExp | Array; + exclude?: string | RegExp | Array; + chunkFilter?: (chunk: webpack.compilation.Chunk) => boolean; + cache?: boolean | string; + cacheKeys?: (defaultCacheKeys: any, file: any) => object; + parallel?: boolean | number; + sourceMap?: boolean; + minify?: (file: any, sourceMap: any) => MinifyResult; + terserOptions?: MinifyOptions; + extractComments?: boolean + | string + | RegExp + | ExtractCommentFn + | ExtractCommentOptions; + warningsFilter?: (warning: any, source: any) => boolean; + } +} diff --git a/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts b/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts new file mode 100644 index 0000000000..5b0540a4ff --- /dev/null +++ b/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts @@ -0,0 +1,36 @@ +import * as webpack from 'webpack'; +import * as TerserPlugin from "terser-webpack-plugin"; + +const compiler = webpack({ + plugins: [ + new TerserPlugin(), + ], +}); + +const compilerOptions = webpack({ + plugins: [ + new TerserPlugin({ + // Uncomment lines below for cache invalidation correctly + cache: true, + cacheKeys: (defaultCacheKeys) => { + delete defaultCacheKeys.terser; + + return { + ...defaultCacheKeys, + 'uglify-js': require('uglify-js/package.json').version, + }; + }, + minify: (file, sourceMap) => { + // https://github.com/mishoo/UglifyJS2#minify-options + const uglifyJsOptions = { + /* your `uglify-js` package options */ + }; + return require('uglify-js').minify(file, uglifyJsOptions); + }, + include: /src\//, + exclude: /node_modules\//, + sourceMap: true, + terserOptions: { mangle: true } + }), + ], +}); diff --git a/types/terser-webpack-plugin/tsconfig.json b/types/terser-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..02669a9daa --- /dev/null +++ b/types/terser-webpack-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "terser-webpack-plugin-tests.ts" + ] +} diff --git a/types/terser-webpack-plugin/tslint.json b/types/terser-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/terser-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8a18392af3b5dd555cb920168668d15d11485e24 Mon Sep 17 00:00:00 2001 From: Nathan Fast Date: Fri, 4 Jan 2019 10:44:06 -0600 Subject: [PATCH 088/139] Add ignorePunctuation parameter to MarkOptions (#31873) --- types/mark.js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/mark.js/index.d.ts b/types/mark.js/index.d.ts index 7b410ad65e..8b214c3e15 100644 --- a/types/mark.js/index.d.ts +++ b/types/mark.js/index.d.ts @@ -24,6 +24,7 @@ declare namespace Mark { acrossElements?: boolean; caseSensitive?: boolean; ignoreJoiners?: boolean; + ignorePunctuation?: string[]; wildcards?: 'disabled' | 'enabled' | 'withSpaces'; each?(element: Element): void; From 62b167feca55ad8b5c865f76c6bc63d7eb5a0b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E4=B9=90?= Date: Sat, 5 Jan 2019 00:44:52 +0800 Subject: [PATCH 089/139] Update ACLType in index.d.ts@types/ali-oss (#31819) * Update ACLType in index.d.ts ### From ```ts type ACLType = "public-read-write" | "public-read" | "and private"; ``` ### Tto ```ts type ACLType = "public-read-write" | "public-read" | "private"; ``` * Update index.d.ts * Update index.d.ts * Update index.d.ts --- types/ali-oss/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/ali-oss/index.d.ts b/types/ali-oss/index.d.ts index 13f7f56ff9..e4f9e09e7c 100644 --- a/types/ali-oss/index.d.ts +++ b/types/ali-oss/index.d.ts @@ -18,6 +18,7 @@ declare namespace OSS { internal?: boolean; // access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money. secure?: boolean; // instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol. timeout?: string | number; // instance level timeout for all operations, default is 60s + cname?: boolean; // use custom domain name } interface Bucket { @@ -29,7 +30,7 @@ declare namespace OSS { type StorageType = "Standard" | "IA" | "Archive"; - type ACLType = "public-read-write" | "public-read" | "and private"; + type ACLType = "public-read-write" | "public-read" | "private"; type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT"; @@ -174,6 +175,7 @@ declare namespace OSS { mime?: string; // custom mime, will send with Content-Type entity header meta?: UserMeta; // user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 } callback: ObjectCallback; + headers?: object; } interface PutObjectResult { @@ -188,6 +190,7 @@ declare namespace OSS { mime: string; // custom mime, will send with Content-Type entity header meta: UserMeta; callback: ObjectCallback; + headers?: object; } interface AppendObjectOptions { From 0a779e312e545de2ab989d7eec72def644719a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Kadi=C5=A1a?= <8273932+martynaskadisa@users.noreply.github.com> Date: Fri, 4 Jan 2019 19:43:36 +0200 Subject: [PATCH 090/139] add typings for @loadable/component --- types/loadable__component/index.d.ts | 47 +++++++ .../loadable__component-tests.tsx | 117 ++++++++++++++++++ types/loadable__component/tsconfig.json | 29 +++++ types/loadable__component/tslint.json | 1 + 4 files changed, 194 insertions(+) create mode 100644 types/loadable__component/index.d.ts create mode 100644 types/loadable__component/loadable__component-tests.tsx create mode 100644 types/loadable__component/tsconfig.json create mode 100644 types/loadable__component/tslint.json diff --git a/types/loadable__component/index.d.ts b/types/loadable__component/index.d.ts new file mode 100644 index 0000000000..c4877bd8a9 --- /dev/null +++ b/types/loadable__component/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for @loadable/component 5.2 +// Project: https://github.com/smooth-code/loadable-components +// Definitions by: Martynas Kadiša +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface DefaultImportedComponent

{ + default: React.ComponentType

; +} + +export type DefaultComponent

= React.ComponentType

| DefaultImportedComponent

; + +export interface Options { + fallback?: JSX.Element; +} + +export type LoadableComponent = React.ComponentType; +export type LoadableLibrary = React.ComponentType<{ + fallback?: JSX.Element; + children?: (module: TModule) => React.ReactNode; + ref?: React.Ref; +}> & + TModule; + +declare function lib( + loadFn: (props: object) => Promise, + options?: Options +): LoadableLibrary; + +declare function loadableFunc( + loadFn: (props: T) => Promise>, + options?: Options +): LoadableComponent; + +declare const loadable: typeof loadableFunc & { lib: typeof lib }; + +export default loadable; + +export namespace lazy { + function lib(loadFn: (props: object) => Promise): LoadableLibrary; +} + +export function lazy(loadFn: (props: T) => Promise>): LoadableComponent; + +export function loadableReady(done?: () => any): Promise; diff --git a/types/loadable__component/loadable__component-tests.tsx b/types/loadable__component/loadable__component-tests.tsx new file mode 100644 index 0000000000..d286711be1 --- /dev/null +++ b/types/loadable__component/loadable__component-tests.tsx @@ -0,0 +1,117 @@ +import * as React from 'react'; +import loadable, { lazy, loadableReady } from '@loadable/component'; + +const TestComponent: React.SFC<{ foo: string }> = () => <>test; + +function defaultImportComponentLoader() { + return new Promise<{ default: typeof TestComponent }>(resolve => resolve({ default: TestComponent })); +} + +function importComponentLoader() { + return new Promise(resolve => resolve(TestComponent)); +} + +const lib = { + getTestObj: () => ({ bar: 'bar', foo: 'foo' }) +}; + +function defaultImportLibLoader() { + return new Promise<{ default: typeof lib }>(resolve => resolve(({ default: lib }))); +} + +function importLibLoader() { + return new Promise(resolve => resolve(lib)); +} + +// loadable +{ + // Should infer props from imported component with default export + const LoadableDefaultComponent = loadable(defaultImportComponentLoader); + ; + + // Should infer props from imported component without default export + const LoadableComponent = loadable(importComponentLoader); + ; + + // Should allow passing JSX element to fallback in options + loadable(defaultImportComponentLoader, { fallback:

loading...
}); + + // Should allow passing `fallback` prop to loadable component + loading...
} />; +} + +// lazy +{ + // Should infer props from imported component with default export + const LazyDefaultComponent = lazy(defaultImportComponentLoader); + ; + + // Should infer props from imported component without default export + const LazyComponent = lazy(importComponentLoader); + ; + + // Should allow passing fallback prop + loading...} />; +} + +// loadable.lib +{ + // Should infer types from module with default export and reflect them in children render prop + const LoadableDefaultLibrary = loadable.lib(defaultImportLibLoader); + + {({ default: { getTestObj } }) => getTestObj().foo} + ; + + // Should infer types from module without default export and reflect them in children render prop + const LoadableLibrary = loadable.lib(importLibLoader); + + {({ getTestObj }) => getTestObj().foo} + ; + + // Should allow passing fallback JSX element + loadable.lib(importLibLoader, { fallback:
loading lib...
}); + + // Should allow passing fallback prop + Loading library...}> + {({ getTestObj }) => getTestObj().foo} + ; + + // Should reflect inferred types from module in ref + const ref = React.createRef(); + ; + ref.current!.getTestObj().foo; +} + +// lazy.lib +{ + // Should infer types from module with default export and reflect them in children render prop + const LazyDefaultLibrary = lazy.lib(defaultImportLibLoader); + + {({ default: { getTestObj } }) => getTestObj().foo} + ; + + // Should infer types from module without default export and reflect them in children render prop + const LazyLibrary = lazy.lib(importLibLoader); + + {({ getTestObj }) => getTestObj().foo} + ; + + // Should allow passing fallback prop + Loading library...}> + {({ getTestObj }) => getTestObj().foo} + ; + + // Should reflect inferred types from module in ref + const ref = React.createRef(); + ; + ref.current!.getTestObj().foo; +} + +// loadableReady +{ + // Should allow passing callback argument + loadableReady(() => {}); + + // Should return a promise + loadableReady().then(() => {}); +} diff --git a/types/loadable__component/tsconfig.json b/types/loadable__component/tsconfig.json new file mode 100644 index 0000000000..440535e42b --- /dev/null +++ b/types/loadable__component/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@loadable/component": [ + "loadable__component" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "loadable__component-tests.tsx" + ] +} diff --git a/types/loadable__component/tslint.json b/types/loadable__component/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/loadable__component/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 742f59c19a984a3bbae16cb81e6f67113d99e635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Kadi=C5=A1a?= <8273932+martynaskadisa@users.noreply.github.com> Date: Fri, 4 Jan 2019 19:54:16 +0200 Subject: [PATCH 091/139] add typings for @loadable/server --- types/loadable__server/index.d.ts | 86 +++++++++++++++++++ .../loadable__server-tests.tsx | 74 ++++++++++++++++ types/loadable__server/tsconfig.json | 29 +++++++ types/loadable__server/tslint.json | 1 + 4 files changed, 190 insertions(+) create mode 100644 types/loadable__server/index.d.ts create mode 100644 types/loadable__server/loadable__server-tests.tsx create mode 100644 types/loadable__server/tsconfig.json create mode 100644 types/loadable__server/tslint.json diff --git a/types/loadable__server/index.d.ts b/types/loadable__server/index.d.ts new file mode 100644 index 0000000000..eafbd7eec7 --- /dev/null +++ b/types/loadable__server/index.d.ts @@ -0,0 +1,86 @@ +// Type definitions for @loadable/server 5.2 +// Project: https://github.com/smooth-code/loadable-components +// Definitions by: Martynas Kadiša +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { ComponentType, ReactElement, Component } from 'react'; + +export type ChunkExtractorOptions = { + /** + * Webpack entrypoints to load (default to `["main"]`) + */ + entrypoints?: string | string[]; + /** + * Optional output path (only for `requireEntrypoint`) + */ + outputPath?: string; +} & ({ + /** + * Stats file path generated using `@loadable/webpack-plugin` + */ + statsFile: string; + } | { + /** + * Stats generated using `@loadable/webpack-plugin`. + */ + stats: object; + }); + +/** + * Used to collect chunks server-side and get them as script tags or script elements + */ +export class ChunkExtractor { + constructor(options: ChunkExtractorOptions); + + /** + * Wrap your application in a `ChunkExtractorManager` + */ + collectChunks( + /** + * JSX element that will be wrapped in `ChunkExtractorManager` + */ + element: JSX.Element + ): JSX.Element; + + /** + * Require the entrypoint of your application as a commonjs module. + */ + requireEntrypoint(name?: string): { default: ComponentType }; + + /** + * Get scripts as a string of `