diff --git a/types/ajv-errors/index.d.ts b/types/ajv-errors/index.d.ts index fed9e4585f..3b5c2d2322 100644 --- a/types/ajv-errors/index.d.ts +++ b/types/ajv-errors/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/epoberezkin/ajv-errors // Definitions by: Afshawn Lotfi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 import { Ajv } from "ajv"; diff --git a/types/amplitude-js/amplitude-js-tests.ts b/types/amplitude-js/amplitude-js-tests.ts index 4f3c2ea307..c5ffbe9898 100644 --- a/types/amplitude-js/amplitude-js-tests.ts +++ b/types/amplitude-js/amplitude-js-tests.ts @@ -1,85 +1,110 @@ // Tests for Amplitude SDK TypeScript definitions module Amplitude.Tests { + function all() { - amplitude.init('YOUR_API_KEY_HERE', null, { - // optional configuration options + var client: amplitude.AmplitudeClient = new amplitude.AmplitudeClient(); + var identify: amplitude.Identify = new amplitude.Identify(); + var revenue: amplitude.Revenue = new amplitude.Revenue(); + + client = amplitude.getInstance(); + client = amplitude.getInstance('some name'); + + amplitude.__VERSION__ === '1.2.3'; + amplitude.options.logLevel = 'WARN'; + + amplitude.init('API_KEY', 'USER_ID', { saveEvents: true, includeUtm: true, includeReferrer: true, batchEvents: true, eventUploadThreshold: 50 - }); - amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {}); + }, function () { }); + amplitude.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true }); + amplitude.init('API_KEY', 'USER_ID'); + amplitude.init('API_KEY'); - amplitude.logEvent('EVENT_IDENTIFIER_HERE'); - amplitude.setUserId('USER_ID_HERE'); - amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE'); - amplitude.setUserId(null); // not string 'null' - amplitude.setVersionName('VERSION_NAME_HERE'); - - amplitude.regenerateDeviceId(); - amplitude.setDeviceId('CUSTOM_DEVICE_ID'); - - amplitude.logEvent('EVENT_IDENTIFIER_HERE', { - 'color': 'blue', - 'age': 20, - 'key': 'value' - }); + amplitude.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 }); + amplitude.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' }); amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { }); + amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' }); + + amplitude.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0'); + amplitude.setDomain('.amplitude.com'); + amplitude.setGroup('orgId', '15'); + amplitude.setGroup('orgId', ['15', '16']); + amplitude.setUserId('joe@gmail.com'); + amplitude.setUserProperties({ 'gender': 'female', 'sign_up_complete': true }) + amplitude.setVersionName('1.12.3'); + amplitude.isNewSession(); + amplitude.getSessionId() === 123; - let identify = new amplitude.Identify().set('gender', 'female').set('age', 20); amplitude.identify(identify); + amplitude.logRevenue(3.99, 1, 'product_1234'); + amplitude.logRevenueV2(revenue); - identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015'); - amplitude.identify(identify); - identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015'); - amplitude.identify(identify); + client.init('API_KEY', 'USER_ID', { + saveEvents: true, + includeUtm: true, + includeReferrer: true, + batchEvents: true, + eventUploadThreshold: 50 + }, function () { }); + client.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true }); + client.init('API_KEY', 'USER_ID'); + client.init('API_KEY'); - identify = new amplitude.Identify().unset('gender').unset('age'); - amplitude.identify(identify); + client.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 }); + client.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' }); + client.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { }); + client.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' }); + client.logEventWithTimestamp('EVENT_IDENTIFIER_HERE', { 'key': 'value' }, 1505430378000, (httpCode, response) => { }); + + client.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0'); + client.setDomain('.amplitude.com'); + client.setUserId('joe@gmail.com'); + client.setOptOut(true); + client.setGroup('type', 'name'); + client.setGroup('type', ['name', 'name2']); + client.setUserProperties({ 'gender': 'female', 'sign_up_complete': true }); + client.setGlobalUserProperties({ 'gender': 'female', 'sign_up_complete': true }); + client.setVersionName('1.12.3'); + client.setSessionId(1505430378000); + + client.options.logLevel = 'WARN'; + client.getSessionId() === 123; + client.isNewSession() === true; + client.regenerateDeviceId(); + client.clearUserProperties(); + + client.identify(identify); + client.logRevenue(3.99, 1, 'product_1234'); + client.logRevenueV2(revenue); + + + identify = new amplitude.Identify().set('colors', ['rose', 'gold']).add('karma', 1).setOnce('sign_up_date', '2016-03-31'); identify = new amplitude.Identify().add('karma', 1).add('friends', 1); - amplitude.identify(identify); - - identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']); - amplitude.identify(identify); - - identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']); - amplitude.identify(identify); - - identify = new amplitude.Identify() - .set('karma', 10) - .add('karma', 1) - .unset('karma'); - amplitude.identify(identify); - + identify = new amplitude.Identify().set('karma', 10).add('karma', 1).unset('karma'); + identify = new amplitude.Identify().append('ab-tests', 'new-user-tests'); + identify.append('some_list', [1, 2, 3, 4, 'values']); + identify = new amplitude.Identify().prepend('ab-tests', 'new-user-tests'); + identify.prepend('some_list', [1, 2, 3, 4, 'values']); + identify = new amplitude.Identify().set('user_type', 'beta'); + identify.set('name', { 'first': 'John', 'last': 'Doe' }); + identify = new amplitude.Identify().setOnce('sign_up_date', '2016-04-01'); + identify = new amplitude.Identify().unset('user_type').unset('age'); identify = new amplitude.Identify() .set('colors', ['rose', 'gold']) .append('ab-tests', 'campaign_a') .append('existing_list', [4, 5]); - amplitude.identify(identify); - amplitude.setUserProperties({ - gender: 'female', - age: 20 - }); - amplitude.clearUserProperties(); - - amplitude.setOptOut(true); - amplitude.setOptOut(false); - - amplitude.setGroup('orgId', '15'); - amplitude.setGroup('sport', ['soccer', 'tennis']); - - // TODO: Implement those. - /* - var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3); - amplitude.logRevenueV2(revenue); - - amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' }); - */ + revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99); + revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setEventProperties({ 'city': 'San Francisco' }); + revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setQuantity(5); + revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setRevenueType('purchase'); } + } diff --git a/types/amplitude-js/index.d.ts b/types/amplitude-js/index.d.ts index 613f5ad5d8..1cdb843589 100644 --- a/types/amplitude-js/index.d.ts +++ b/types/amplitude-js/index.d.ts @@ -1,61 +1,146 @@ -// Type definitions for Amplitude SDK 2.12.1 +// Type definitions for Amplitude SDK 4.4.0 // Project: https://github.com/amplitude/Amplitude-Javascript // Definitions by: Arvydas Sidorenko -// Definitions: https://github.com/Asido/DefinitelyTyped +// Dan Manastireanu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module amplitude { + + type Callback = (responseCode: number, responseBody: string, details?: { reason: string; }) => void; + type LogReturn = number | void; + interface Config { + apiEndpoint?: string; batchEvents?: boolean; cookieExpiration?: number; cookieName?: string; + userId?: string; deviceId?: string; + deviceIdFromUrlParam?: boolean; domain?: string; eventUploadPeriodMillis?: number; eventUploadThreshold?: number; + forceHttps?: boolean; + includeGclid?: boolean; includeReferrer?: boolean; includeUtm?: boolean; language?: string; + logLevel?: 'DISABLE' | 'ERROR' | 'WARN' | 'INFO'; optOut?: boolean; platform?: string; saveEvents?: boolean; savedMaxCount?: number; + saveParamsReferrerOncePerSession?: boolean; sessionTimeout?: number; + trackingOptions?: { + city?: boolean; + country?: boolean; + device_model?: boolean; + dma?: boolean; + ip_address?: boolean; + language?: boolean; + os_name?: boolean; + os_version?: boolean; + platform?: boolean; + region?: boolean; + version_name?: boolean; + }, + unsentKey?: string; + unsentIdentifyKey?: string; uploadBatchSize?: number; } export class Identify { set(key: string, value: any): Identify; setOnce(key: string, value: any): Identify; - add(key: string, value: number): Identify; + add(key: string, value: number | string): Identify; append(key: string, value: any): Identify; prepend(key: string, value: any): Identify; unset(key: string): Identify; } - export function init(apiKey: string): void; - export function init(apiKey: string, userId: string): void; - export function init(apiKey: string, userId: string, options: Config): void; - export function init(apiKey: string, userId: string, options: Config, callback: () => void): void; + export class Revenue { + + setProductId(productId: string): Revenue; + setQuantity(quantity: number): Revenue; + setPrice(price: number): Revenue; + setRevenueType(revenueType: string): Revenue; + setEventProperties(eventProperties: any): Revenue; + } + + export class AmplitudeClient { + + constructor(instanceName?: string); + + options: Config; + + init(apiKey: string, userId?: string, config?: Config, callback?: (client: AmplitudeClient) => void): void; + + setVersionName(versionName: string): void; + + isNewSession(): boolean; + setSessionId(sessionId: number): void; + getSessionId(): number; + + setDomain(domain: string): void; + setUserId(userId: string): void; + + setDeviceId(id: string): void; + regenerateDeviceId(): void; + + identify(identify_obj: Identify, opt_callback?: Callback): void; + + setUserProperties(properties: any): void; + setGlobalUserProperties(properties: any): void; + clearUserProperties(): void; + + setOptOut(enable: boolean): void; + + setGroup(groupType: string, groupName: string | string[]): void; + + logEvent(event: string, data?: any, callback?: Callback): LogReturn; + logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn; + logRevenueV2(revenue_obj: Revenue): LogReturn; + logRevenue(pric: number, quantity: number, product: string): LogReturn; + logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn; + } + + // Proxy methods that get executed on the default AmplitudeClient instance (not all client methods are proxied) + + export function init(apiKey: string, userId?: string, options?: Config, callback?: (client: AmplitudeClient) => void): void; export function setVersionName(version: string): void; + + export function isNewSession(): boolean; + export function getSessionId(): number; + + export function setDomain(domain: string): void; + export function setUserId(userId: string): void; export function setDeviceId(id: string): void; export function regenerateDeviceId(): void; - export function identify(identify: Identify): void; + export function identify(identify: Identify, callback?: Callback): void; - export function setUserProperties(properties: Object): void; + export function setUserProperties(properties: any): void; + export function setGlobalUserProperties(properties: any): void; export function clearUserProperties(): void; export function setOptOut(optOut: boolean): void; export function setGroup(groupType: string, groupName: string | string[]): void; - export function logEvent(event: string): void; - export function logEvent(event: string, data: Object): void; - export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void; + export function logEvent(event: string, data?: any, callback?: Callback): LogReturn; + export function logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn; + export function logRevenueV2(revenue_obj: Revenue): LogReturn; + export function logRevenue(pric: number, quantity: number, product: string): LogReturn; + export function logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn; + + + export function getInstance(instanceName?: string): AmplitudeClient; + export const __VERSION__: string; export var options: Config; } diff --git a/types/ansi-styles/index.d.ts b/types/ansi-styles/index.d.ts index a07ac962ab..b67cdada41 100644 --- a/types/ansi-styles/index.d.ts +++ b/types/ansi-styles/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: bryn austin bellomy // plylrnsdy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +// TypeScript Version: 2.1 import { EscapeCode } from './escape-code'; diff --git a/types/apollo-upload-client/index.d.ts b/types/apollo-upload-client/index.d.ts index 7c1e3cb7b6..c6476f2ae9 100644 --- a/types/apollo-upload-client/index.d.ts +++ b/types/apollo-upload-client/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/jaydenseric/apollo-upload-client#readme // Definitions by: Edward Sammut Alessi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.6 import { ApolloLink } from "apollo-link"; import { HttpOptions } from "apollo-link-http-common"; diff --git a/types/apollo-upload-client/tsconfig.json b/types/apollo-upload-client/tsconfig.json index 2a023ff111..a78e75500c 100644 --- a/types/apollo-upload-client/tsconfig.json +++ b/types/apollo-upload-client/tsconfig.json @@ -2,7 +2,9 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", "dom" + "es6", + "dom", + "esnext.asynciterable" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/astring/index.d.ts b/types/astring/index.d.ts new file mode 100644 index 0000000000..c2768e7d5f --- /dev/null +++ b/types/astring/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for astring 1.3 +// Project: https://github.com/davidbonnet/astring +// Definitions by: Nikolaj Kappler +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as ESTree from 'estree'; +import 'node'; +import { Stream } from 'stream'; + +export interface Options { + /** string to use for indentation (defaults to " ") */ + indent?: string; + /** string to use for line endings (defaults to "\n") */ + lineEnd?: string; + /** indent level to start from (defaults to 0) */ + startingIndentLevel?: number; + /** generate comments if true (defaults to false) */ + comments?: boolean; + /** custom code generator (defaults to astring.baseGenerator) */ + generator?: object; + /** source map generator (defaults to null), see https://github.com/mozilla/source-map#sourcemapgenerator */ + sourceMap?: any; +} + +/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */ +export function generate(node: ESTree.Node, options?: Options): string; +/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */ +export function generate(node: ESTree.Node, options: Options & { + /** output stream to write the rendered code to (defaults to null) */ + output: Stream; +}): Stream; + +/** + * A code generator consists of a mapping of node names and functions that take two arguments: `node` and `state`. + * The `node` points to the node from which to generate the code and the `state` exposes the `write` method that takes generated code strings. + */ +export type Generator = { [key in ESTree.Node["type"]]: (node: Extract, state: { write(s: string): void }) => void }; + +/** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */ +export const baseGenerator: Generator; + +declare global { + interface astring { + generate: typeof generate; + /** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */ + baseGenerator: Generator; + } + const astring: astring; +} diff --git a/types/astring/test/astring-global.test.ts b/types/astring/test/astring-global.test.ts new file mode 100644 index 0000000000..c756c9c60e --- /dev/null +++ b/types/astring/test/astring-global.test.ts @@ -0,0 +1,5 @@ +// global scope function +astring.generate(null); + +// global scope function +astring.baseGenerator.Program(null, { write(s: string) { return; } }); diff --git a/types/astring/test/astring.test.ts b/types/astring/test/astring.test.ts new file mode 100644 index 0000000000..782af01017 --- /dev/null +++ b/types/astring/test/astring.test.ts @@ -0,0 +1,32 @@ +import { baseGenerator, generate } from "astring"; +import { FunctionExpression, MemberExpression, Program } from "estree"; +import { Stream } from "stream"; + +const ast: Program = null; +const functionE: FunctionExpression = null; +const memberE: MemberExpression = null; + +// should accept different nodes +generate(ast); +generate(functionE); +generate(memberE); + +// options without output option should generate string +const string: string = generate(ast, { + comments: true, + generator: baseGenerator, + indent: "\t", + lineEnd: "\n", + startingIndentLevel: 42, + sourceMap: null +}); + +// options with output option should return Stream +const stream: Stream = generate(ast, { + output: new Stream() +}); + +// Generator should map node types to functions whose first parameter is same node type +baseGenerator.Program(ast, { write(s: string) { return; } }); +baseGenerator.FunctionExpression(functionE, { write(s: string) { return; } }); +baseGenerator.MemberExpression(memberE, { write(s: string) { return; } }); diff --git a/types/astring/tsconfig.json b/types/astring/tsconfig.json new file mode 100644 index 0000000000..b00d44f643 --- /dev/null +++ b/types/astring/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/astring.test.ts", + "test/astring-global.test.ts" + ] +} \ No newline at end of file diff --git a/types/astring/tslint.json b/types/astring/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/astring/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 961dd73ebb..e6cfd3bcaa 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -2,34 +2,34 @@ // Project: https://github.com/caolan/async // Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman , Angus Fenying , Pascal Martin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 export as namespace async; export interface Dictionary { [key: string]: T; } export type IterableCollection = T[] | IterableIterator | Dictionary -export interface ErrorCallback { (err?: T): void; } -export interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } -export interface AsyncResultCallback { (err?: E, result?: T): void; } -export interface AsyncResultArrayCallback { (err?: E, results?: Array): void; } -export interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } +export interface ErrorCallback { (err?: E | null): void; } +export interface AsyncBooleanResultCallback { (err?: E | null, truthValue?: boolean): void; } +export interface AsyncResultCallback { (err?: E | null, result?: T): void; } +export interface AsyncResultArrayCallback { (err?: E | null, results?: Array): void; } +export interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -export interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } -export interface AsyncFunctionEx { (callback: (err?: E, ...results: T[]) => void): void; } -export interface AsyncIterator { (item: T, callback: ErrorCallback): void; } -export interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } -export interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } -export interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } -export interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } +export interface AsyncFunction { (callback: (err?: E | null, result?: T) => void): void; } +export interface AsyncFunctionEx { (callback: (err?: E | null, ...results: T[]) => void): void; } +export interface AsyncIterator { (item: T, callback: ErrorCallback): void; } +export interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } +export interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } +export interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } +export interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } -export interface AsyncWorker { (task: T, callback: ErrorCallback): void; } -export interface AsyncVoidFunction { (callback: ErrorCallback): void; } +export interface AsyncWorker { (task: T, callback: ErrorCallback): void; } +export interface AsyncVoidFunction { (callback: ErrorCallback): void; } export type AsyncAutoTasks, E> = { [K in keyof R]: AsyncAutoTask } export type AsyncAutoTask, E> = AsyncAutoTaskFunctionWithoutDependencies | (keyof R | AsyncAutoTaskFunction)[]; -export interface AsyncAutoTaskFunctionWithoutDependencies { (cb: AsyncResultCallback | ErrorCallback): void; } -export interface AsyncAutoTaskFunction, E> { (results: R, cb: AsyncResultCallback | ErrorCallback): void; } +export interface AsyncAutoTaskFunctionWithoutDependencies { (cb: AsyncResultCallback | ErrorCallback): void; } +export interface AsyncAutoTaskFunction, E = Error> { (results: R, cb: AsyncResultCallback | ErrorCallback): void; } export interface AsyncQueue { length(): number; @@ -37,9 +37,8 @@ export interface AsyncQueue { running(): number; idle(): boolean; concurrency: number; - push(task: T | T[], callback?: ErrorCallback): void; - push(task: T, callback?: AsyncResultCallback): void; - unshift(task: T | T[], callback?: ErrorCallback): void; + push(task: T | T[], callback?: AsyncResultCallback): void; + unshift(task: T | T[], callback?: ErrorCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -61,7 +60,7 @@ export interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T | T[], priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T | T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -94,112 +93,113 @@ export interface AsyncCargo { } // Collections -export function each(arr: IterableCollection, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function each(arr: IterableCollection, iterator: AsyncIterator, callback?: ErrorCallback): void; export const eachSeries: typeof each; -export function eachLimit(arr: IterableCollection, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function eachLimit(arr: IterableCollection, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; export const forEach: typeof each; export const forEachSeries: typeof each; export const forEachLimit: typeof eachLimit; -export function forEachOf(obj: IterableCollection, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOf(obj: IterableCollection, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; export const forEachOfSeries: typeof forEachOf; -export function forEachOfLimit(obj: IterableCollection, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOfLimit(obj: IterableCollection, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; export const eachOf: typeof forEachOf; export const eachOfSeries: typeof forEachOf; export const eachOfLimit: typeof forEachOfLimit; -export function map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export const mapSeries: typeof map; -export function mapLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; -export function mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; +export function mapLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; +export function mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; export const mapValuesSeries: typeof mapValues; -export function filter(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filter(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; export const filterSeries: typeof filter; -export function filterLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filterLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; export const select: typeof filter; export const selectSeries: typeof filter; export const selectLimit: typeof filterLimit; export const reject: typeof filter; export const rejectSeries: typeof filter; export const rejectLimit: typeof filterLimit; -export function reduce(arr: T[] | IterableIterator, memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; +export function reduce(arr: T[] | IterableIterator, memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; export const inject: typeof reduce; export const foldl: typeof reduce; export const reduceRight: typeof reduce; export const foldr: typeof reduce; -export function detect(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detect(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; export const detectSeries: typeof detect; -export function detectLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detectLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; export const find: typeof detect; export const findSeries: typeof detect; export const findLimit: typeof detectLimit; -export function sortBy(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function some(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function sortBy(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function some(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const someSeries: typeof some; -export function someLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function someLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const any: typeof some; export const anySeries: typeof someSeries; export const anyLimit: typeof someLimit; -export function every(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function every(arr: IterableCollection, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const everySeries: typeof every; -export function everyLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function everyLimit(arr: IterableCollection, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; export const all: typeof every; export const allSeries: typeof every; export const allLimit: typeof everyLimit; -export function concat(arr: IterableCollection, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function concatLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function concat(arr: IterableCollection, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function concatLimit(arr: IterableCollection, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export const concatSeries: typeof concat; // Control Flow -export function series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; -export function series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; -export function parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; -export function parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; -export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; -export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; -export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doWhilst(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; -export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doUntil(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; -export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; -export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; -export function waterfall(tasks: Function[], callback?: AsyncResultCallback): void; +export function series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; +export function series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; +export function parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; +export function parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; +export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; +export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; +export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doWhilst(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; +export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doUntil(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; +export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; +export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; +export function waterfall(tasks: Function[], callback?: AsyncResultCallback): void; export function compose(...fns: Function[]): Function; export function seq(...fns: Function[]): Function; export function applyEach(fns: Function[], ...argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. -export function queue(worker: AsyncWorker, concurrency?: number): AsyncQueue; -export function queue(worker: AsyncResultIterator, concurrency?: number): AsyncQueue; -export function priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; -export function cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; -export function auto, E>(tasks: AsyncAutoTasks, concurrency?: number, callback?: AsyncResultCallback): void; -export function autoInject(tasks: any, callback?: AsyncResultCallback): void; -export function retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; -export function retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; -export function retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; -export function apply(fn: Function, ...args: any[]): AsyncFunction; +export function queue(worker: AsyncWorker, concurrency?: number): AsyncQueue; +export function queue(worker: AsyncResultIterator, concurrency?: number): AsyncQueue; +export function priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; +export function cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; +export function auto, E = Error>(tasks: AsyncAutoTasks, concurrency?: number, callback?: AsyncResultCallback): void; +export function auto, E = Error>(tasks: AsyncAutoTasks, callback?: AsyncResultCallback): void; +export function autoInject(tasks: any, callback?: AsyncResultCallback): void; +export function retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; +export function retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; +export function retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; +export function apply(fn: Function, ...args: any[]): AsyncFunction; export function nextTick(callback: Function, ...args: any[]): void; export const setImmediate: typeof nextTick; -export function reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; -export function reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; +export function reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; +export function reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; -export function timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; -export function timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; +export function timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; +export function timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; export function times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; -export function timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; -export function timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; +export function timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; +export function timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; -export function transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; -export function transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; +export function transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; +export function transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; -export function transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; -export function transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; +export function transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; +export function transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; -export function race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; +export function race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; // Utils export function memoize(fn: Function, hasher?: Function): Function; diff --git a/types/async/test/index.ts b/types/async/test/index.ts index 3c6c2f5dfe..0081dd3dcd 100644 --- a/types/async/test/index.ts +++ b/types/async/test/index.ts @@ -114,7 +114,7 @@ async.series([ ], function (err, results) { }); -async.series([ +async.series([ function (callback) { callback(undefined, 'one'); }, @@ -138,7 +138,7 @@ async.series({ }, function (err, results) { }); -async.series({ +async.series({ one: function (callback) { setTimeout(function () { callback(undefined, 1); @@ -178,7 +178,7 @@ async.parallel([ ], function (err, results) { }); -async.parallel([ +async.parallel([ function (callback) { setTimeout(function () { callback(undefined, 'one'); @@ -207,7 +207,7 @@ async.parallel({ }, function (err, results) { }); -async.parallel({ +async.parallel({ one: function (callback) { setTimeout(function () { callback(undefined, 1); @@ -273,7 +273,7 @@ async.waterfall([ ], function (err, result) { }); -var q = async.queue(function (task: any, callback: (err?:Error,msg?:string) => void) { +var q = async.queue(function (task: any, callback: (err?:Error,msg?:string) => void) { console.log('hello ' + task.name); callback(undefined,'a message.'); }, 2); @@ -293,7 +293,7 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) { console.log('finished processing bar'); }); -q.push({name: 'foo'}, function (err,msg) { +q.push({name: 'foo'}, function (err, msg) { console.log('foo finished with a message "'+ msg! + '"'); }); @@ -330,7 +330,7 @@ q.resume(); q.kill(); // tests for strongly typed tasks -var q2 = async.queue(function (task: string, callback: () => void) { +var q2 = async.queue(function (task: string, callback: () => void) { console.log('Task: ' + task); callback(); }, 1); @@ -356,7 +356,7 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) { }); -var aq = async.queue(function (level: number, callback: (error?: Error, newLevel?: number) => void) { +var aq = async.queue(function (level: number, callback: (error?: Error, newLevel?: number) => void) { console.log('hello ' + level); callback(undefined, level+1); }); @@ -387,14 +387,47 @@ cargo.push({ name: 'baz' }, function (err: Error) { var filename = ''; async.auto({ - get_data: function (callback: any) { }, - make_folder: function (callback: any) { }, + get_data: function (callback: AsyncResultCallback) { }, + make_folder: function (callback: AsyncResultCallback) { }, //arrays with different types are not accepted by TypeScript. - write_file: ['get_data', 'make_folder', function (callback: any) { + write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback) { callback(null, filename); }], //arrays with different types are not accepted by TypeScript. - email_link: ['write_file', function (callback: any, results: any) { }] + email_link: ['write_file', function (callback: AsyncResultCallback, results: any) { }] +}); + +async.auto({ + get_data: function (callback: AsyncResultCallback) { }, + make_folder: function (callback: AsyncResultCallback) { }, + //arrays with different types are not accepted by TypeScript. + write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback) { + callback(null, filename); + }], + //arrays with different types are not accepted by TypeScript. + email_link: ['write_file', function (callback: AsyncResultCallback, results: any) { }] +}, function (err, results) { + console.log('finished auto'); +}); + +interface A { + get_data: any; + make_folder: any; + write_file: any; + email_link: any; +} + +async.auto({ + get_data: function (callback: AsyncResultCallback) { }, + make_folder: function (callback: AsyncResultCallback) { }, + //arrays with different types are not accepted by TypeScript. + write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback) { + callback(null, filename); + }], + //arrays with different types are not accepted by TypeScript. + email_link: ['write_file', function (callback: AsyncResultCallback, results: any) { }] +}, 1, function (err, results) { + console.log('finished auto'); }); async.retry(3, function (callback, results) { }, function (err, result) { }); @@ -459,10 +492,10 @@ async.dir(function (name: string, callback: any) { // each -async.each({ +async.each({ "a": 1, "b": 2 -}, function(val: number, next: ErrorCallback): void { +}, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -478,10 +511,10 @@ async.each({ }); -async.eachSeries({ +async.eachSeries({ "a": 1, "b": 2 -}, function(val: number, next: ErrorCallback): void { +}, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -497,14 +530,14 @@ async.eachSeries({ }); -async.eachLimit({ +async.eachLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, next: ErrorCallback): void { +}, 2, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -522,10 +555,10 @@ async.eachLimit({ // forEachOf/eachOf -async.eachOf({ +async.eachOf({ "a": 1, "b": 2 -}, function(val: number, key: string, next: ErrorCallback): void { +}, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -541,10 +574,10 @@ async.eachOf({ }); -async.forEachOfSeries({ +async.forEachOfSeries({ "a": 1, "b": 2 -}, function(val: number, key: string, next: ErrorCallback): void { +}, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -560,14 +593,14 @@ async.forEachOfSeries({ }); -async.forEachOfLimit({ +async.forEachOfLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, key: string, next: ErrorCallback): void { +}, 2, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -585,11 +618,11 @@ async.forEachOfLimit({ // map -async.map({ +async.map({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncResultCallback): void { +}, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -605,11 +638,11 @@ async.map({ }); -async.mapSeries({ +async.mapSeries({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncResultCallback): void { +}, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -625,14 +658,14 @@ async.mapSeries({ }); -async.mapLimit({ +async.mapLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, next: AsyncResultCallback): void { +}, 2, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -650,11 +683,11 @@ async.mapLimit({ // mapValues -async.mapValues({ +async.mapValues({ "a": 1, "b": 2, "c": 3 -}, function(val: number, key: string, next: AsyncResultCallback): void { +}, function(val: number, key: string, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -670,11 +703,11 @@ async.mapValues({ }); -async.mapValuesSeries({ +async.mapValuesSeries({ "a": 1, "b": 2, "c": 3 -}, function(val: number, key: string, next: AsyncResultCallback): void { +}, function(val: number, key: string, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -692,11 +725,11 @@ async.mapValuesSeries({ // filter/select/reject -async.filter({ +async.filter({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncBooleanResultCallback): void { +}, function(val: number, next: AsyncBooleanResultCallback): void { setTimeout(function(): void { @@ -712,11 +745,11 @@ async.filter({ }); -async.reject({ +async.reject({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncBooleanResultCallback): void { +}, function(val: number, next: AsyncBooleanResultCallback): void { setTimeout(function(): void { @@ -734,11 +767,11 @@ async.reject({ // concat -async.concat({ +async.concat({ "a": "1", "b": "2", "c": "3" -}, function(item: string, next: AsyncResultCallback): void { +}, function(item: string, next: AsyncResultCallback): void { console.log(`async.concat: ${item}`); @@ -752,11 +785,11 @@ async.concat({ // detect/find -async.detect({ +async.detect({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.detect/find: ${item}`); @@ -777,11 +810,11 @@ async.detect({ // every/all -async.every({ +async.every({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.every/all: ${item}`); @@ -795,11 +828,11 @@ async.every({ // some/any -async.some({ +async.some({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.some/any: ${item}`); diff --git a/types/atlassian-crowd-client/lib/models/session.d.ts b/types/atlassian-crowd-client/lib/models/session.d.ts index 2ef16a0814..2369f976bc 100644 --- a/types/atlassian-crowd-client/lib/models/session.d.ts +++ b/types/atlassian-crowd-client/lib/models/session.d.ts @@ -3,7 +3,7 @@ declare class Session { readonly token: string; readonly createdAt: Date; readonly expiresAt: Date; - + constructor(token: string, createdAt: Date, expiresAt: Date); toCrowd(): SessionObj; static fromCrowd(obj: SessionObj): Session; diff --git a/types/atlassian-crowd-client/settings.d.ts b/types/atlassian-crowd-client/settings.d.ts index 755c26038a..4c56a85e06 100644 --- a/types/atlassian-crowd-client/settings.d.ts +++ b/types/atlassian-crowd-client/settings.d.ts @@ -3,7 +3,7 @@ export interface Settings { readonly application: { readonly name: string; readonly password: string; - } + }; readonly nesting?: boolean; readonly sessionTimeout?: number; readonly debug?: boolean; diff --git a/types/auth-header/auth-header-tests.ts b/types/auth-header/auth-header-tests.ts new file mode 100644 index 0000000000..e8b510531c --- /dev/null +++ b/types/auth-header/auth-header-tests.ts @@ -0,0 +1,6 @@ +import * as auth from 'auth-header'; + +const basic: string = auth.format('Basic'); +const basic2: string = auth.format({scheme: 'Basic'}); + +const parsed: {scheme: string, token: null | string | string[]} = auth.parse(''); diff --git a/types/auth-header/index.d.ts b/types/auth-header/index.d.ts new file mode 100644 index 0000000000..fab462be9e --- /dev/null +++ b/types/auth-header/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for auth-header 1.0 +// Project: https://github.com/izaakschroeder/auth-header +// Definitions by: ForbesLindesay +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +type Params = + | Array<[string, string | ReadonlyArray]> + | {[key: string]: string | ReadonlyArray}; +export {Params}; + +export interface TokenOptions { + scheme: string; + token?: string; + params?: Params; +} + +export interface Token { + scheme: string; + params: {[key: string]: string | string[]}; + token: null | string | string[]; +} + +export function format(token: TokenOptions): string; +export function format(scheme: string, token?: string, params?: Params): string; + +export function parse(header: string): Token; diff --git a/types/auth-header/tsconfig.json b/types/auth-header/tsconfig.json new file mode 100644 index 0000000000..58c6fad6d7 --- /dev/null +++ b/types/auth-header/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "auth-header-tests.ts" + ] +} diff --git a/types/auth-header/tslint.json b/types/auth-header/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/auth-header/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/axe-webdriverjs/tsconfig.json b/types/axe-webdriverjs/tsconfig.json index d8637d03e4..4eaf433c1c 100644 --- a/types/axe-webdriverjs/tsconfig.json +++ b/types/axe-webdriverjs/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/axios-token-interceptor/index.d.ts b/types/axios-token-interceptor/index.d.ts index 85121f8165..a09fb7591b 100644 --- a/types/axios-token-interceptor/index.d.ts +++ b/types/axios-token-interceptor/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/sandrinodimattia/axios-token-interceptor#readme // Definitions by: Mike Dodge // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import { AxiosRequestConfig } from 'axios'; diff --git a/types/baidumap-web-sdk/tslint.json b/types/baidumap-web-sdk/tslint.json index aab43caa1d..eccb336643 100644 --- a/types/baidumap-web-sdk/tslint.json +++ b/types/baidumap-web-sdk/tslint.json @@ -2,14 +2,21 @@ "extends": "dtslint/dt.json", "rules": { // All are TODOs - "eofline": false, + "adjacent-overload-signatures": false, + "array-type": false, + "ban-types": false, "comment-format": false, "dt-header": false, + "eofline": false, "max-line-length": false, "member-access": false, + "no-consecutive-blank-lines": false, + "no-empty-interface": false, "no-namespace": false, + "no-unnecessary-class": false, "no-useless-files": false, "no-var": false, - "semicolon": false + "semicolon": false, + "space-before-function-paren": false } } diff --git a/types/basicauth-middleware/basicauth-middleware-tests.ts b/types/basicauth-middleware/basicauth-middleware-tests.ts new file mode 100644 index 0000000000..258f382807 --- /dev/null +++ b/types/basicauth-middleware/basicauth-middleware-tests.ts @@ -0,0 +1,21 @@ +import express = require('express'); +import basicAuth = require('basicauth-middleware'); + +const app = express(); + +app.use(basicAuth("username", "password", "realm")); +app.use(basicAuth([["username", "password"]])); + +function checkSync(username: string, password: string): boolean { + return username === "user" && password === "pass"; +} +function checkCallback(username: string, password: string, callback: (err: Error|null, authorized: boolean) => void): void { + callback(null, username === "user" && password === "pass"); +} +function checkPromise(username: string, password: string): Promise { + return Promise.resolve(true); +} + +app.use(basicAuth(checkSync)); +app.use(basicAuth(checkCallback)); +app.use(basicAuth(checkPromise)); diff --git a/types/basicauth-middleware/index.d.ts b/types/basicauth-middleware/index.d.ts new file mode 100644 index 0000000000..21e3a27ad8 --- /dev/null +++ b/types/basicauth-middleware/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for basicauth-middleware 3.1 +// Project: https://github.com/nchaulet/basicauth-middleware +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { RequestHandler } from "express"; +type checkFunctionSync = (username: string, password: string) => boolean; +type checkFunctionCallback = (username: string, password: string, callback: (err: Error|null, authorized: boolean) => void) => void; +type checkFunctionPromise = (username: string, password: string) => PromiseLike; +type CheckFunction = checkFunctionSync | checkFunctionPromise | checkFunctionCallback; + +declare function basicAuth(checkFnOrUsers: Array<[string, string]>|CheckFunction, realm?: string): RequestHandler; +declare function basicAuth(username: string, password: string, realm?: string): RequestHandler; + +export = basicAuth; diff --git a/types/basicauth-middleware/tsconfig.json b/types/basicauth-middleware/tsconfig.json new file mode 100644 index 0000000000..e31e940e70 --- /dev/null +++ b/types/basicauth-middleware/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + + }, + "files": [ + "index.d.ts", + "basicauth-middleware-tests.ts" + ] +} diff --git a/types/basicauth-middleware/tslint.json b/types/basicauth-middleware/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/basicauth-middleware/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bell/index.d.ts b/types/bell/index.d.ts index 058b7adcea..4b56a239a3 100644 --- a/types/bell/index.d.ts +++ b/types/bell/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/hapijs/bell // Definitions by: Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 +// TypeScript Version: 2.8 import { Server, Request, Plugin, AuthCredentials } from 'hapi'; diff --git a/types/boom/boom-tests.ts b/types/boom/boom-tests.ts index 5ffd808de4..2cae1aec29 100644 --- a/types/boom/boom-tests.ts +++ b/types/boom/boom-tests.ts @@ -144,12 +144,12 @@ const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, messag // isBoom -const isBoomError = new Boom('test') +const isBoomError = new Boom('test'); Boom.isBoom(isBoomError); -const maybeBoom = new Boom('test'); -if(Boom.isBoom(maybeBoom)) { +const maybeBoom = new Boom('test'); +if (Boom.isBoom(maybeBoom)) { // isBoom is a type guard that allows accessing these properties: maybeBoom.output.headers; } @@ -183,7 +183,8 @@ interface CustomPayload extends Boom.Payload { /** * Test assignment of custom error data: */ -const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1); +// tslint:disable-next-line:no-object-literal-type-assertion +const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true }); const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type const errorWithExplicitType: Boom = errorWithData; // can assign to union data type const errorWithConcreteCustomData: Boom = errorWithData; // can assign to concrete data type diff --git a/types/boom/index.d.ts b/types/boom/index.d.ts index b38dafe038..71a738a009 100644 --- a/types/boom/index.d.ts +++ b/types/boom/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for boom 7.2.0 +// Type definitions for boom 7.2 // Project: https://github.com/hapijs/boom // Definitions by: Igor Rogatty // AJP @@ -10,28 +10,31 @@ export = Boom; /** - * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: - * @see {@link https://github.com/hapijs/boom#boom} - */ + * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: + * @see {@link https://github.com/hapijs/boom#boom} + */ declare class Boom extends Error { - - /** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */ - constructor(message?: string | Error, options?: Boom.Options); - /** isBoom - if true, indicates this is a Boom object instance. */ - isBoom: boolean; - /** isServer - convenience bool indicating status code >= 500. */ - isServer: boolean; - /** message - the error message. */ - message: string; - /** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */ - output: Boom.Output; - /** reformat() - rebuilds error.output using the other object properties. */ - reformat: () => string; - /** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */ - isMissing?: boolean; - /** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */ - data: Data; - } + /** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */ + constructor(message?: string | Error, options?: Boom.Options); + /** isBoom - if true, indicates this is a Boom object instance. */ + isBoom: boolean; + /** isServer - convenience bool indicating status code >= 500. */ + isServer: boolean; + /** message - the error message. */ + message: string; + /** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */ + output: Boom.Output; + /** reformat() - rebuilds error.output using the other object properties. */ + reformat(): string; + /** + * "If message is unset, the 'error' segment of the header will not be present and + * isMissing will be true on the error object." mentioned in + * @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} + */ + isMissing?: boolean; + /** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */ + data: Data; +} declare namespace Boom { interface Options { /** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */ @@ -44,20 +47,32 @@ declare namespace Boom { ctor?: any; /** message - error message string. If the error already has a message, the provided message is added as a prefix. Defaults to no message. */ message?: string; - /** override - if false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored. Defaults to true (apply the provided statusCode and message options to the error regardless of its type, Error or Boom object). */ + /** + * override - if false, the err provided is a Boom object, and a statusCode or message are + * provided, the values are ignored. Defaults to true (apply the provided statusCode and + * message options to the error regardless of its type, Error or Boom object). + */ override?: boolean; } interface Output { /** statusCode - the HTTP status code (typically 4xx or 5xx). */ statusCode: number; - /** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */ + /** + * headers - an object containing any HTTP headers where each key is a header name and + * value is the header content. (Limited value type to string + * https://github.com/hapijs/boom/issues/151 ) + */ headers: {[index: string]: string}; - /** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */ + /** + * payload - the formatted object used as the response payload (stringified). + * Can be directly manipulated but any changes will be lost if reformat() is called. + * Any content allowed and by default includes the following content: + */ payload: Payload; } - interface Payload { + interface Payload { /** statusCode - the HTTP status code, derived from error.output.statusCode. */ statusCode: number; /** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */ @@ -79,13 +94,13 @@ declare namespace Boom { * @param options optional additional options * @see {@link https://github.com/hapijs/boom#boomifyerror-options} */ - function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom; + function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom; /** * Identifies whether an error is a Boom object. Same as calling instanceof Boom. * @param error the error object to identify. */ - function isBoom(error: Error): error is Boom + function isBoom(error: Error): error is Boom; // 4xx /** @@ -94,7 +109,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data} */ - function badRequest(message?: string, data?: Data): Boom; + function badRequest(message?: string, data?: Data): Boom; /** * Returns a 401 Unauthorized error @@ -102,13 +117,21 @@ declare namespace Boom { * @param scheme can be one of the following: * * an authentication scheme name * * an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header. - * @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object. + * @param attributes an object of values to use while setting the 'WWW-Authenticate' header. + * This value is only used when scheme is a string, otherwise it is ignored. + * Every key/value pair will be included in the 'WWW-Authenticate' in the format of + * 'key="value"' as well as in the response payload under the attributes key. + * Alternatively value can be a string which is use to set the value of the scheme, + * for example setting the token value for negotiate header. + * If string is used message parameter must be null. + * null and undefined will be replaced with an empty string. If attributes is set, + * message will be used as the 'error' segment of the 'WWW-Authenticate' header. + * If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object. * @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */ - function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom; - function unauthorized(message?: string, scheme?: string[]): Boom; - function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom; - function unauthorized(message?: null, scheme?: string[]): Boom; + function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom; + function unauthorized(message?: string, scheme?: string[]): Boom; + function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom; /** * Returns a 402 Payment Required error @@ -116,7 +139,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data} */ - function paymentRequired(message?: string, data?: Data): Boom; + function paymentRequired(message?: string, data?: Data): Boom; /** * Returns a 403 Forbidden error @@ -124,7 +147,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data} */ - function forbidden(message?: string, data?: Data): Boom; + function forbidden(message?: string, data?: Data): Boom; /** * Returns a 404 Not Found error @@ -132,7 +155,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data} */ - function notFound(message?: string, data?: Data): Boom; + function notFound(message?: string, data?: Data): Boom; /** * Returns a 405 Method Not Allowed error @@ -141,7 +164,7 @@ declare namespace Boom { * @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header. * @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow} */ - function methodNotAllowed(message?: string, data?: Data, allow?: string | string[]): Boom; + function methodNotAllowed(message?: string, data?: Data, allow?: string | string[]): Boom; /** * Returns a 406 Not Acceptable error @@ -149,7 +172,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data} */ - function notAcceptable(message?: string, data?: Data): Boom; + function notAcceptable(message?: string, data?: Data): Boom; /** * Returns a 407 Proxy Authentication Required error @@ -157,7 +180,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data} */ - function proxyAuthRequired(message?: string, data?: Data): Boom; + function proxyAuthRequired(message?: string, data?: Data): Boom; /** * Returns a 408 Request Time-out error @@ -165,7 +188,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data} */ - function clientTimeout(message?: string, data?: Data): Boom; + function clientTimeout(message?: string, data?: Data): Boom; /** * Returns a 409 Conflict error @@ -173,7 +196,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomconflictmessage-data} */ - function conflict(message?: string, data?: Data): Boom; + function conflict(message?: string, data?: Data): Boom; /** * Returns a 410 Gone error @@ -181,7 +204,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data} */ - function resourceGone(message?: string, data?: Data): Boom; + function resourceGone(message?: string, data?: Data): Boom; /** * Returns a 411 Length Required error @@ -189,7 +212,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data} */ - function lengthRequired(message?: string, data?: Data): Boom; + function lengthRequired(message?: string, data?: Data): Boom; /** * Returns a 412 Precondition Failed error @@ -197,7 +220,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data} */ - function preconditionFailed(message?: string, data?: Data): Boom; + function preconditionFailed(message?: string, data?: Data): Boom; /** * Returns a 413 Request Entity Too Large error @@ -205,7 +228,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data} */ - function entityTooLarge(message?: string, data?: Data): Boom; + function entityTooLarge(message?: string, data?: Data): Boom; /** * Returns a 414 Request-URI Too Large error @@ -213,7 +236,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data} */ - function uriTooLong(message?: string, data?: Data): Boom; + function uriTooLong(message?: string, data?: Data): Boom; /** * Returns a 415 Unsupported Media Type error @@ -221,7 +244,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data} */ - function unsupportedMediaType(message?: string, data?: Data): Boom; + function unsupportedMediaType(message?: string, data?: Data): Boom; /** * Returns a 416 Requested Range Not Satisfiable error @@ -229,7 +252,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data} */ - function rangeNotSatisfiable(message?: string, data?: Data): Boom; + function rangeNotSatisfiable(message?: string, data?: Data): Boom; /** * Returns a 417 Expectation Failed error @@ -237,7 +260,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data} */ - function expectationFailed(message?: string, data?: Data): Boom; + function expectationFailed(message?: string, data?: Data): Boom; /** * Returns a 418 I'm a Teapot error @@ -245,7 +268,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomteapotmessage-data} */ - function teapot(message?: string, data?: Data): Boom; + function teapot(message?: string, data?: Data): Boom; /** * Returns a 422 Unprocessable Entity error @@ -253,7 +276,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombaddatamessage-data} */ - function badData(message?: string, data?: Data): Boom; + function badData(message?: string, data?: Data): Boom; /** * Returns a 423 Locked error @@ -261,7 +284,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomlockedmessage-data} */ - function locked(message?: string, data?: Data): Boom; + function locked(message?: string, data?: Data): Boom; /** * Returns a 424 Failed Dependency error @@ -269,7 +292,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data} */ - function failedDependency(message?: string, data?: Data): Boom; + function failedDependency(message?: string, data?: Data): Boom; /** * Returns a 428 Precondition Required error @@ -277,7 +300,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data} */ - function preconditionRequired(message?: string, data?: Data): Boom; + function preconditionRequired(message?: string, data?: Data): Boom; /** * Returns a 429 Too Many Requests error @@ -285,7 +308,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data} */ - function tooManyRequests(message?: string, data?: Data): Boom; + function tooManyRequests(message?: string, data?: Data): Boom; /** * Returns a 451 Unavailable For Legal Reasons error @@ -293,7 +316,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomillegalmessage-data} */ - function illegal(message?: string, data?: Data): Boom; + function illegal(message?: string, data?: Data): Boom; // 5xx /** @@ -303,7 +326,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal} */ - function badImplementation(message?: string, data?: Data): Boom; + function badImplementation(message?: string, data?: Data): Boom; /** * Returns a 500 Internal Server Error error @@ -312,7 +335,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal} */ - function internal(message?: string, data?: Data): Boom; + function internal(message?: string, data?: Data): Boom; /** * Returns a 501 Not Implemented error with your error message to the user @@ -320,7 +343,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data} */ - function notImplemented(message?: string, data?: Data): Boom; + function notImplemented(message?: string, data?: Data): Boom; /** * Returns a 502 Bad Gateway error with your error message to the user @@ -328,7 +351,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data} */ - function badGateway(message?: string, data?: Data): Boom; + function badGateway(message?: string, data?: Data): Boom; /** * Returns a 503 Service Unavailable error with your error message to the user @@ -336,7 +359,7 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data} */ - function serverUnavailable(message?: string, data?: Data): Boom; + function serverUnavailable(message?: string, data?: Data): Boom; /** * Returns a 504 Gateway Time-out error with your error message to the user @@ -344,5 +367,5 @@ declare namespace Boom { * @param data optional additional error data. * @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data} */ - function gatewayTimeout(message?: string, data?: Data): Boom; + function gatewayTimeout(message?: string, data?: Data): Boom; } diff --git a/types/boom/tslint.json b/types/boom/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/boom/tslint.json +++ b/types/boom/tslint.json @@ -1,79 +1,3 @@ { - "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 - } + "extends": "dtslint/dt.json" } diff --git a/types/boom/v4/boom-tests.ts b/types/boom/v4/boom-tests.ts index 33e86699e8..ee2a8eefb8 100644 --- a/types/boom/v4/boom-tests.ts +++ b/types/boom/v4/boom-tests.ts @@ -1,5 +1,4 @@ import Boom = require('boom'); -import * as Hapi from 'hapi'; // 4xx and data type diff --git a/types/boom/v4/tsconfig.json b/types/boom/v4/tsconfig.json index f8f2968c34..58f1109eee 100644 --- a/types/boom/v4/tsconfig.json +++ b/types/boom/v4/tsconfig.json @@ -25,4 +25,4 @@ "index.d.ts", "boom-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/broccoli-plugin/broccoli-plugin-tests.ts b/types/broccoli-plugin/broccoli-plugin-tests.ts new file mode 100644 index 0000000000..4434fce10c --- /dev/null +++ b/types/broccoli-plugin/broccoli-plugin-tests.ts @@ -0,0 +1,46 @@ +import Plugin = require('broccoli-plugin'); + +declare function copySync(src: string, dest: string): void; +declare function setTimeout(callback: () => void, duration: number): void; + +class SlowItDown extends Plugin { + constructor(private readonly waitInMS: number) { + super([], { + annotation: `${waitInMS} ms`, + needsCache: false + }); + } + + async build() { + await new Promise(resolve => setTimeout(resolve, this.waitInMS)); + } +} + +class FileCopier extends Plugin { + constructor(inputNodes: Plugin.BroccoliNode[]) { + super(inputNodes, { + name: 'CopyFiles', + persistentOutput: true + }); + } + + build() { + for (const input of this.inputPaths) { + copySync(input, this.outputPath); + } + } + + getCallbackObject() { + return this; + } +} + +new FileCopier([ + new SlowItDown(5000), + 'src', + 'assets' +]); + +new Plugin(); // $ExpectError +new Plugin([{}]); // $ExpectError +new Plugin([], { foo: 'bar' }); // $ExpectError diff --git a/types/broccoli-plugin/index.d.ts b/types/broccoli-plugin/index.d.ts new file mode 100644 index 0000000000..36b1da65e2 --- /dev/null +++ b/types/broccoli-plugin/index.d.ts @@ -0,0 +1,78 @@ +// Type definitions for broccoli-plugin 1.3 +// Project: https://github.com/broccolijs/broccoli-plugin +// Definitions by: Dan Freeman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = BroccoliPlugin; + +declare namespace BroccoliPlugin { + type BroccoliNode = BroccoliPlugin | string; + + interface BroccoliPluginOptions { + /** + * The name of this plugin. Defaults to `this.constructor.name`. + */ + name?: string; + + /** + * A descriptive annotation. Useful for debugging, to tell multiple + * instances of the same plugin apart. + */ + annotation?: string; + + /** + * If `true`, the output directory is not automatically emptied between + * builds. Defaults to `false`. + */ + persistentOutput?: boolean; + + /** + * If `true`, a cache directory is created automatically and the path is + * set at `cachePath`. If `false`, a cache directory is not created and + * `this.cachePath` is `undefined`. Defaults to `true`. + */ + needsCache?: boolean; + } +} + +declare class BroccoliPlugin { + constructor(inputNodes: BroccoliPlugin.BroccoliNode[], options?: BroccoliPlugin.BroccoliPluginOptions); + + /** + * An array of paths on disk corresponding to each node in `inputNodes`. + * Your plugin will read files from these paths. + */ + readonly inputPaths: ReadonlyArray; + + /** + * The path on disk corresponding to this plugin instance (this node). + * Your plugin will write files to this path. This directory is emptied by + * Broccoli before each build, unless the `persistentOutput` options is + * `true`. + */ + readonly outputPath: string; + + /** + * The path on disk to an auxiliary cache directory. Use this to store + * files that you want preserved between builds. This directory will + * only be deleted when Broccoli exits. If a cache directory is not + * needed, set `needsCache` to false when calling `broccoli-plugin` + * constructor. + */ + readonly cachePath?: string; + + /** + * Override this method in your subclass. It will be called on each + * (re-)build. All paths stay the same between builds. + * To perform asynchronous work, return a promise. + */ + build(): void | Promise; + + /** + * Advanced usage only. + * Return the object on which Broccoli will call `obj.build()`. Called + * once after instantiation. By default, returns `this`. + */ + getCallbackObject(): { build(): void | Promise }; +} diff --git a/types/broccoli-plugin/tsconfig.json b/types/broccoli-plugin/tsconfig.json new file mode 100644 index 0000000000..0f36813dc1 --- /dev/null +++ b/types/broccoli-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", + "broccoli-plugin-tests.ts" + ] +} diff --git a/types/broccoli-plugin/tslint.json b/types/broccoli-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/broccoli-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bull/bull-tests.tsx b/types/bull/bull-tests.tsx index a8c7f403a7..7fd5a6a45d 100644 --- a/types/bull/bull-tests.tsx +++ b/types/bull/bull-tests.tsx @@ -125,6 +125,7 @@ videoQueue.add({ video: 'http://example.com/video1.mov' }, { jobId: 1 }) pdfQueue .on('error', (err: Error) => undefined) .on('active', (job: Queue.Job, jobPromise: Queue.JobPromise) => jobPromise.cancel()) +.on('waiting', (jobId: Queue.JobId) => undefined) .on('active', (job: Queue.Job) => undefined) .on('stalled', (job: Queue.Job) => undefined) .on('progress', (job: Queue.Job) => undefined) @@ -132,4 +133,53 @@ pdfQueue .on('failed', (job: Queue.Job) => undefined) .on('paused', () => undefined) .on('resumed', () => undefined) -.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined); +.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined) +.on('drained', () => undefined) +.on('removed', (job: Queue.Job) => undefined); + +// test different process methods + +const profileQueue = new Queue('profile'); +// Max concurrency for requestProfile is 100 +profileQueue.process('requestProfile', 100, () => {}); +profileQueue.process(100, () => {}); + +// other tests +const myQueue = new Queue('myQueue', { + settings: { + drainDelay: 5 + }, + defaultJobOptions: { + stackTraceLimit: 1, + } +}); + +myQueue.on('active', (job: Queue.Job) => { + job.moveToCompleted(); + job.moveToCompleted('done'); + job.moveToCompleted('done', true); + job.moveToCompleted('done', true).then(val => { + if (val) { + const nextJobData: any = val[0]; + const nextJobId: Queue.JobId = val[1]; + } + }); + + job.moveToFailed({ message: "Call to external service failed!" }, true); + job.moveToFailed(new Error('test error'), true); + job.moveToFailed(new Error('test error'), true).then(val => { + if (val) { + const nextJobData: any = val[0]; + const nextJobId: Queue.JobId = val[1]; + } + }); + + job.discard(); +}); + +// test all constructor options: + +new Queue('profile'); +new Queue('profile', 'url'); +new Queue('profile', { prefix: 'test' }); +new Queue('profile', 'url', { prefix: 'test' }); diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index ac820290f2..82b09928da 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for bull 3.3 +// Type definitions for bull 3.4 // Project: https://github.com/OptimalBits/bull // Definitions by: Bruno Grieder // Cameron Crothers @@ -10,6 +10,7 @@ // Bond Akinmade // Wuha Team // Alec Brunelle +// Dan Manastireanu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -23,9 +24,9 @@ import * as Promise from "bluebird"; */ declare const Bull: { (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; - (queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures + (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; - new (queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures + new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures }; declare namespace Bull { @@ -92,6 +93,12 @@ declare namespace Bull { backoffStrategies?: { [key: string]: (attemptsMade: number, err: typeof Error) => number; }; + + /** + * A timeout for when the queue is in `drained` state (empty waiting for jobs). + * It is used when calling `queue.getNextJob()`, which will pass it to `.brpoplpush` on the Redis client. + */ + drainDelay?: number; } type DoneCallback = (error?: Error | null, value?: any) => void; @@ -141,6 +148,11 @@ declare namespace Bull { */ retry(): Promise; + /** + * Ensure this job is never ran again even if attemptsMade is less than job.attempts. + */ + discard(): Promise; + /** * Returns a promise that resolves to the returned data when the job has been finished. * TODO: Add a watchdog to check if the job has finished periodically. @@ -148,6 +160,18 @@ declare namespace Bull { */ finished(): Promise; + /** + * Moves a job to the `completed` queue. Pulls a job from 'waiting' to 'active' + * and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null. + */ + moveToCompleted(returnValue?: string, ignoreLock?: boolean): Promise<[any, JobId] | null>; + + /** + * Moves a job to the `failed` queue. Pulls a job from 'waiting' to 'active' + * and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null. + */ + moveToFailed(errorInfo: { message: string; }, ignoreLock?: boolean): Promise<[any, JobId] | null>; + /** * Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible. */ @@ -205,6 +229,11 @@ declare namespace Bull { * Cron pattern specifying when the job should execute */ cron: string; + + /** + * Start date when the repeat job should start repeating (only with cron). + */ + startDate?: Date | string | number; } interface EveryRepeatOptions extends RepeatOptions { @@ -273,6 +302,11 @@ declare namespace Bull { * Default behavior is to keep the job in the completed set. */ removeOnFail?: boolean; + + /** + * Limits the amount of stack trace lines that will be recorded in the stacktrace. + */ + stackTraceLimit?: number; } interface JobCounts { @@ -618,6 +652,11 @@ declare namespace Bull { */ on(event: 'error', callback: ErrorEventCallback): this; + /** + * A Job is waiting to be processed as soon as a worker is idling. + */ + on(event: 'waiting', callback: WaitingEventCallback): this; + /** * A job has started. You can use `jobPromise.cancel()` to abort it */ @@ -654,6 +693,11 @@ declare namespace Bull { */ on(event: 'resumed', callback: EventCallback): this; // tslint:disable-line unified-signatures + /** + * A job successfully removed. + */ + on(event: 'removed', callback: RemovedEventCallback): this; + /** * Old jobs have been cleaned from the queue. * `jobs` is an array of jobs that were removed, and `type` is the type of those jobs. @@ -661,6 +705,12 @@ declare namespace Bull { * @see Queue#clean() for details */ on(event: 'cleaned', callback: CleanedEventCallback): this; + + /** + * Emitted every time the queue has processed all the waiting jobs + * (even if there can be some delayed jobs not yet processed) + */ + on(event: 'drained', callback: EventCallback): this; // tslint:disable-line unified-signatures } type EventCallback = () => void; @@ -685,6 +735,10 @@ declare namespace Bull { type FailedEventCallback = (job: Job, error: Error) => void; type CleanedEventCallback = (jobs: Array>, status: JobStatus) => void; + + type RemovedEventCallback = (job: Job) => void; + + type WaitingEventCallback = (jobId: JobId) => void; } export = Bull; diff --git a/types/bunyan-winston-adapter/index.d.ts b/types/bunyan-winston-adapter/index.d.ts index 718c9804e1..1ce6ae0a8b 100644 --- a/types/bunyan-winston-adapter/index.d.ts +++ b/types/bunyan-winston-adapter/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/gluwer/bunyan-winston-adapter // Definitions by: Steve Hipwell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 import * as bunyan from "bunyan"; import { Logger } from "winston"; diff --git a/types/catbox-redis/catbox-redis-tests.ts b/types/catbox-redis/catbox-redis-tests.ts index d7fb5eb701..91d86445b7 100644 --- a/types/catbox-redis/catbox-redis-tests.ts +++ b/types/catbox-redis/catbox-redis-tests.ts @@ -1,6 +1,6 @@ import * as CatbotRedis from 'catbox-redis'; -const cache = new CatbotRedis({ +const cache = new CatbotRedis({ host: 'localhost', partition: 'test', port: 2018, @@ -10,3 +10,8 @@ cache.get({ segment: 'test', id: 'test', }); + +cache.set({ + segment: 'test', + id: 'test', +}, 'test', 123); diff --git a/types/catbox-redis/index.d.ts b/types/catbox-redis/index.d.ts index a0d3590953..18972c6493 100644 --- a/types/catbox-redis/index.d.ts +++ b/types/catbox-redis/index.d.ts @@ -53,7 +53,7 @@ declare module 'catbox-redis' { sentinelName?: string; } } - class CatboxRedis extends Client { + class CatboxRedis extends Client { constructor(options: CatboxRedis.CatboxRedisOptions); } export = CatboxRedis; diff --git a/types/catbox/catbox-tests.ts b/types/catbox/catbox-tests.ts index 25d4826d25..e86d2a94af 100644 --- a/types/catbox/catbox-tests.ts +++ b/types/catbox/catbox-tests.ts @@ -1,16 +1,22 @@ -import { CacheItem, Client, Policy, EnginePrototypeOrObject } from "catbox"; +import { Client, Policy, EnginePrototypeOrObject, DecoratedResult, CachedObject } from "catbox"; const Memory: EnginePrototypeOrObject = { async start(): Promise {}, stop(): void {}, - async get(): Promise {}, + async get(): Promise> { + return { + item: 'asd', + stored: 12, + ttl: 123, + }; + }, async set(): Promise {}, async drop(): Promise {}, isReady(): boolean { return true; }, validateSegmentName(segment: string): null { return null; }, }; -const client = new Client(Memory, { partition: 'cache' }); +const client = new Client(Memory, { partition: 'cache' }); const cache = new Policy({ expiresIn: 5000, @@ -25,3 +31,11 @@ cache.drop('foo').then(() => {}); cache.isReady(); cache.stats(); + +const decoratedCache = new Policy({ + getDecoratedValue: true, +}, client, 'cache2'); + +decoratedCache.get('test').then((a: DecoratedResult) => { + const res: string = a.value; +}); diff --git a/types/catbox/index.d.ts b/types/catbox/index.d.ts index f6881b1aef..2a17490dd4 100644 --- a/types/catbox/index.d.ts +++ b/types/catbox/index.d.ts @@ -4,7 +4,7 @@ // AJP // Rodrigo Saboya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.8 /** * Client @@ -17,7 +17,7 @@ * the Riak bucket, or as a key prefix in Redis and Memcached. To share the cache across multiple clients, use the same partition name. * @see {@link https://github.com/hapijs/catbox#client} */ -export class Client implements ClientApi { +export class Client implements ClientApi { constructor(engine: EnginePrototypeOrObject, options: ClientOptions); /** start() - creates a connection to the cache server. Must be called before any other method is available. */ @@ -28,14 +28,14 @@ export class Client implements ClientApi { * get(key, callback) - retrieve an item from the cache engine if found where: * * key - a cache key object (see [ICacheKey]). */ - get(key: CacheKey): Promise; + get(key: CacheKey): Promise>; /** * set(key, value, ttl, callback) - store an item in the cache for a specified length of time, where: * * key - a cache key object (see [ICacheKey]). * * value - the string or object value to be stored. * * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid). */ - set(key: CacheKey, value: CacheItem, ttl: number): Promise; + set(key: CacheKey, value: T, ttl: number): Promise; /** * drop(key, callback) - remove an item from cache where: * * key - a cache key object (see [ICacheKey]). @@ -47,13 +47,13 @@ export class Client implements ClientApi { validateSegmentName(segment: string): null | Error; } -export type EnginePrototypeOrObject = EnginePrototype | ClientApi; +export type EnginePrototypeOrObject = EnginePrototype | ClientApi; /** * A prototype CatBox engine function */ -export interface EnginePrototype { - new(settings: ClientOptions): ClientApi; +export interface EnginePrototype { + new(settings: ClientOptions): ClientApi; } /** @@ -61,7 +61,7 @@ export interface EnginePrototype { * The Client object provides the following methods: * @see {@link https://github.com/hapijs/catbox#api} */ -export interface ClientApi { +export interface ClientApi { /** start() - creates a connection to the cache server. Must be called before any other method is available. */ start(): Promise; /** stop() - terminates the connection to the cache server. */ @@ -70,14 +70,14 @@ export interface ClientApi { * get(key, callback) - retrieve an item from the cache engine if found where: * * key - a cache key object (see [ICacheKey]). */ - get(key: CacheKey): Promise; + get(key: CacheKey): Promise>; /** * set(key, value, ttl) - store an item in the cache for a specified length of time, where: * * key - a cache key object (see [ICacheKey]). * * value - the string or object value to be stored. * * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid). */ - set(key: CacheKey, value: CacheItem, ttl: number): Promise; + set(key: CacheKey, value: T, ttl: number): Promise; /** * drop(key) - remove an item from cache where: * * key - a cache key object (see [ICacheKey]). @@ -100,17 +100,15 @@ export interface CacheKey { } /** Cached object contains the following: */ -export interface CachedObject { +export interface CachedObject { /** item - the value stored in the cache using set(). */ - item: any; + item: T; /** stored - the timestamp when the item was stored in the cache (in milliseconds). */ stored: number; /** ttl - the remaining time-to-live (not the original value used when storing the object). */ ttl: number; } -export type CacheItem = any; - export interface ClientOptions { /** * this will store items under keys that start with this value. @@ -118,89 +116,69 @@ export interface ClientOptions { partition: string; } +export type PolicyOptionVariants = PolicyOptions | DecoratedPolicyOptions; + /** - * The Policy object provides a convenient cache interface by setting a global policy which is automatically applied to every storage action. + * The Policy object provides a convenient cache interface by setting a + * global policy which is automatically applied to every storage action. * The object is constructed using new Policy(options, [cache, segment]) where: * * options - an object with the IPolicyOptions structure * * cache - a Client instance (which has already been started). - * * segment - required when cache is provided. The segment name used to isolate cached items within the cache partition. + * * segment - required when cache is provided. The segment name used to + * isolate cached items within the cache partition. * @see {@link https://github.com/hapijs/catbox#policy} */ -export class Policy implements PolicyAPI { - constructor(options: PolicyOptions, cache: Client, segment: string); +export class Policy> { + constructor(options: O, cache: Client, segment: string); /** - * get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided, - * a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are: - * * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key. + * retrieve an item from the cache. If the item is not + * found and the generateFunc method was provided, + * a new value is generated, stored in the cache, and returned. + * Multiple concurrent requests are queued and processed once. The method arguments are: + * @param id the unique item identifier (within the policy segment). + * Can be a string or an object with the required 'id' key. */ - get(id: string | { id: string }): Promise; + get(id: string | { id: string }): Promise ? DecoratedResult : T | null>; + /** - * set(id, value, ttl) - store an item in the cache where: - * * id - the unique item identifier (within the policy segment). - * * value - the string or object value to be stored. - * * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid). + * store an item in the cache where: + * @param id - the unique item identifier (within the policy segment). + * @param value - the string or object value to be stored. + * @param ttl - a time-to-live override value in milliseconds after which the item is automatically + * removed from the cache (or is marked invalid). * This should be set to 0 in order to use the caching rules configured when creating the Policy object. */ - set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise; + set(id: string | { id: string }, value: T, ttl?: number): Promise; /** - * drop(id) - remove the item from cache where: - * * id - the unique item identifier (within the policy segment). + * remove the item from cache where: + * @param id the unique item identifier (within the policy segment). */ drop(id: string | { id: string }): Promise; - /** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */ + /** + * given a created timestamp in milliseconds, returns the time-to-live left + * based on the configured rules. + */ ttl(created: number): number; - /** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */ - rules(options: PolicyOptions): void; - /** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */ + /** changes the policy rules after construction (note that items already stored will not be affected) */ + rules(options: PolicyOptions): void; + /** + * returns true if cache engine determines itself as ready, false if it is not ready or if + * here is no cache engine set. + */ isReady(): boolean; - /** stats - an object with cache statistics */ + /** an object with cache statistics */ stats(): CacheStatisticsObject; } -/** - * Policy API - * The Policy object provides the following methods: - * @see {@link https://github.com/hapijs/catbox#api-1} - */ -export interface PolicyAPI { - /** - * get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided, - * a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are: - * * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key. - */ - get(id: string | { id: string }): Promise; - /** - * set(id, value, ttl) - store an item in the cache where: - * * id - the unique item identifier (within the policy segment). - * * value - the string or object value to be stored. - * * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid). - * This should be set to 0 in order to use the caching rules configured when creating the Policy object. - */ - set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise; - /** - * drop(id) - remove the item from cache where: - * * id - the unique item identifier (within the policy segment). - */ - drop(id: string | { id: string }): Promise; - /** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */ - ttl(created: number): number; - /** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */ - rules(options: PolicyOptions): void; - /** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */ - isReady(): boolean; - /** stats - an object with cache statistics */ - stats(): CacheStatisticsObject; -} - -export interface PolicyGetPromiseResult { - value: CacheItem; - cached: PolicyGetCachedOptions; +export interface DecoratedResult { + value: T; + cached: PolicyGetCachedOptions; report: PolicyGetReportLog; } -export interface PolicyGetCachedOptions { +export interface PolicyGetCachedOptions { /** item - the cached value. */ - item: CacheItem; + item: T; /** stored - the timestamp when the item was stored in the cache. */ stored: number; /** ttl - the cache ttl value for the record. */ @@ -212,13 +190,13 @@ export interface PolicyGetCachedOptions { /** * @see {@link https://github.com/hapijs/catbox#policy} */ -export interface PolicyOptions { +export interface PolicyOptions { /** expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ expiresIn?: number; /** expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Uses local time. Cannot be used together with expiresIn. */ expiresAt?: string; /** generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is function(id, next) where: */ - generateFunc?: GenerateFunc; + generateFunc?: GenerateFunc; /** * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. * Must be less than expiresIn. Alternatively function that returns staleIn value in milliseconds. The function signature is function(stored, ttl) where: @@ -242,11 +220,18 @@ export interface PolicyOptions { generateIgnoreWriteError?: boolean; /** * pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed. - * Defaults to 0, no blocking of concurrent generateFunc calls beyond staleTimeout. + * @default 0, no blocking of concurrent generateFunc calls beyond staleTimeout. */ pendingGenerateTimeout?: number; } +export interface DecoratedPolicyOptions extends PolicyOptions { + /** + * @default false + */ + getDecoratedValue?: boolean; +} + export interface GenerateFuncFlags { ttl: number; } @@ -262,7 +247,7 @@ export interface GenerateFuncFlags { * * ttl - the cache ttl value in milliseconds. Set to 0 to skip storing in the cache. Defaults to the cache global policy. * @see {@link https://github.com/hapijs/catbox#policy} */ -export type GenerateFunc = (id: string, flags: GenerateFuncFlags) => Promise; +export type GenerateFunc = (id: string, flags: GenerateFuncFlags) => Promise; /** * An object with logging information about the generation operation containing the following keys (as relevant): diff --git a/types/chai-fs/index.d.ts b/types/chai-fs/index.d.ts index 144d7d6739..3b82eee078 100644 --- a/types/chai-fs/index.d.ts +++ b/types/chai-fs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for chai-fs 2.0 // Project: https://github.com/chaijs/chai-fs -// Definitions by: Dimitar Danailov +// Definitions by: Dimitar Danailov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 198b868f74..884ddaa760 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -10,7 +10,6 @@ // Guillaume Rodriguez // Simon Archer // Ken Elkabany -// Slavik Nychkalo // Francesco Benedetto // Alexandros Dorodoulis // Manuel Heidrich @@ -481,7 +480,12 @@ declare namespace Chart { fontStyle?: string; } - interface TickOptions { + interface TickOptions extends NestedTickOptions { + minor?: NestedTickOptions | false; + major?: NestedTickOptions | false; + } + + interface NestedTickOptions { autoSkip?: boolean; autoSkipPadding?: number; backdropColor?: ChartColor; diff --git a/types/chartist/chartist-tests.ts b/types/chartist/chartist-tests.ts index bd7006723e..cb7f884264 100644 --- a/types/chartist/chartist-tests.ts +++ b/types/chartist/chartist-tests.ts @@ -197,6 +197,7 @@ new Chartist.Bar('.ct-chart', { }, { // Default mobile configuration stackBars: true, + stackMode: 'accumulate', axisX: { labelInterpolationFnc: (value: string) => { return value.split(/\s+/).map((word: string) => { diff --git a/types/chartist/index.d.ts b/types/chartist/index.d.ts index 3d72210c73..9b096839cc 100644 --- a/types/chartist/index.d.ts +++ b/types/chartist/index.d.ts @@ -283,6 +283,7 @@ declare namespace Chartist { * If set to true this property will cause the series bars to be stacked and form a total for each series point. This will also influence the y-axis and the overall bounds of the chart. In stacked mode the seriesBarDistance property will have no effect. */ stackBars?: boolean; + stackMode?: 'overlap' | 'accumulate'; horizontalBars?: boolean; distributeSeries?: boolean; diff --git a/types/chartmogul-node/common.d.ts b/types/chartmogul-node/common.d.ts index ced10f98d7..d12587f090 100644 --- a/types/chartmogul-node/common.d.ts +++ b/types/chartmogul-node/common.d.ts @@ -1,5 +1,5 @@ export interface Map { - [key: string]: any + [key: string]: any; } export interface CursorParams { page?: number; @@ -15,9 +15,9 @@ export interface Cursor { total_pages?: number; } export interface Entries extends Cursor { - entries: T[] + entries: T[]; } -interface Summary { +export interface Summary { current: number; previous: number; ['percentage-change']: number; @@ -25,4 +25,4 @@ interface Summary { export interface EntriesSummary { entries: T[]; summary: Summary; -} \ No newline at end of file +} diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 2b49326e0b..c1ea6c99b9 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -260,16 +260,7 @@ declare namespace CodeMirror { line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. options, when given, should be an object that configures the behavior of the widget. Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */ - addLineWidget(line: any, node: HTMLElement, options?: { - /** Whether the widget should cover the gutter. */ - coverGutter?: boolean; - /** Whether the widget should stay fixed in the face of horizontal scrolling. */ - noHScroll?: boolean; - /** Causes the widget to be placed above instead of below the text of the line. */ - above?: boolean; - /** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */ - showIfHidden?: boolean; - }): CodeMirror.LineWidget; + addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget; /** Programatically set the size of the editor (overriding the applicable CSS rules). @@ -728,6 +719,17 @@ declare namespace CodeMirror { changed(): void; } + interface LineWidgetOptions { + /** Whether the widget should cover the gutter. */ + coverGutter?: boolean; + /** Whether the widget should stay fixed in the face of horizontal scrolling. */ + noHScroll?: boolean; + /** Causes the widget to be placed above instead of below the text of the line. */ + above?: boolean; + /** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */ + showIfHidden?: boolean; + } + interface EditorChange { /** Position (in the pre-change coordinate system) where the change started. */ from: CodeMirror.Position; diff --git a/types/consola/consola-tests.ts b/types/consola/consola-tests.ts new file mode 100644 index 0000000000..f6cc225346 --- /dev/null +++ b/types/consola/consola-tests.ts @@ -0,0 +1,15 @@ +import * as consola from 'consola'; + +consola.start('TEST'); +consola.info('TEST'); +consola.success('TEST'); +consola.error('TEST'); + +const logger = new consola.Consola({ + level: 30, +}); + +logger.start('TEST'); +logger.info('TEST'); +logger.success('TEST'); +logger.error('TEST'); diff --git a/types/consola/index.d.ts b/types/consola/index.d.ts new file mode 100644 index 0000000000..a17c0c5c8f --- /dev/null +++ b/types/consola/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for consola 1.x +// Project: https://github.com/nuxt/consola +// Definitions by: Jungwoo An +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export interface LevelType { + level: number; + color: string; + isError?: boolean; +} + +export interface Reporter { + log(logObj: any): void; +} + +export interface Option { + level?: number; + types?: LevelType; + reporters?: Reporter[]; +} + +export class Consola { + constructor(option?: Option); + + add(reporter: Reporter): Consola; + remove(reporter: Reporter): Consola; + clear(): Consola; + withScope(scope: string): void; + start(...arguments: string[]): void; + success(...arguments: string[]): void; + info(...arguments: string[]): void; + error(...arguments: Array): void; +} + +export function start(...arguments: string[]): void; +export function success(...arguments: string[]): void; +export function info(...arguments: string[]): void; +export function error(...arguments: Array): void; diff --git a/types/consola/tsconfig.json b/types/consola/tsconfig.json new file mode 100644 index 0000000000..aab34c3363 --- /dev/null +++ b/types/consola/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "consola-tests.ts"] +} diff --git a/types/consola/tslint.json b/types/consola/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/consola/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/critters-webpack-plugin/critters-webpack-plugin-tests.ts b/types/critters-webpack-plugin/critters-webpack-plugin-tests.ts new file mode 100644 index 0000000000..cb975b1cc0 --- /dev/null +++ b/types/critters-webpack-plugin/critters-webpack-plugin-tests.ts @@ -0,0 +1,10 @@ +import Critters from 'critters-webpack-plugin'; + +new Critters({ + compress: true, + external: true, + inlineFonts: false, + preloadFonts: true, + keyframes: 'critical', + noscriptFallback: true, +}); diff --git a/types/critters-webpack-plugin/index.d.ts b/types/critters-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..df758a42e7 --- /dev/null +++ b/types/critters-webpack-plugin/index.d.ts @@ -0,0 +1,65 @@ +// Type definitions for critters-webpack-plugin 1.3 +// Project: https://github.com/GoogleChromeLabs/critters +// Definitions by: Juan José González Giraldo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Plugin } from 'webpack'; + +export default Critters; +declare class Critters extends Plugin { + constructor(options?: Critters.CrittersOptions); +} + +declare namespace Critters { + interface CrittersOptions { + /** + * Inline styles from external stylesheets. + * @default true + */ + external?: boolean; + /** + * The mechanism to use for lazy-loading stylesheets. [JS] indicates that a strategy requires JavaScript (falls back to