diff --git a/.travis.yml b/.travis.yml index 4db6a14a5b..c8c468a417 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 6.9.1 + - 6.9.2 sudo: false diff --git a/babel-code-frame/babel-code-frame-tests.ts b/babel-code-frame/babel-code-frame-tests.ts index 875af43d3a..7047bf88d7 100644 --- a/babel-code-frame/babel-code-frame-tests.ts +++ b/babel-code-frame/babel-code-frame-tests.ts @@ -1,18 +1,14 @@ -import codeFrame from "babel-code-frame"; +import codeFrame = require("babel-code-frame"); -describe('babel-code-frame', () => { - it('frames given code', () => { - const code = ` - const number = 1; - var string = 'foo'; +const code = ` + const number = 1; + var string = 'foo'; - function print(name: string) { - console.log(string + name); - } - `; + function print(name: string) { + console.log(string + name); + } +`; - codeFrame(code, 5, 22); - codeFrame(code, 5, 22, { forceColor: true }); - codeFrame(code, 2, 2, { highlightCode: true }); - }); -}); +codeFrame(code, 5, 22); +codeFrame(code, 5, 22, { forceColor: true }); +codeFrame(code, 2, 2, { highlightCode: true }); diff --git a/babel-code-frame/index.d.ts b/babel-code-frame/index.d.ts index 935f39ea4e..ebfde63c4c 100644 --- a/babel-code-frame/index.d.ts +++ b/babel-code-frame/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for babel-code-frame 6.16 +// Type definitions for babel-code-frame 6.20 // Project: https://github.com/babel/babel/tree/master/packages // Definitions by: Mohsen Azimi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -28,9 +28,11 @@ interface BabelCodeFrameOptions { * * @returns Framed code */ -export default function babelCodeFrame( +declare function codeFrame( rawLines: string, lineNumber: number, colNumber: number, options?: BabelCodeFrameOptions ): string; + +export = codeFrame; diff --git a/babel-code-frame/tsconfig.json b/babel-code-frame/tsconfig.json index 25631aac91..76b559d0d8 100644 --- a/babel-code-frame/tsconfig.json +++ b/babel-code-frame/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "mocha" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/content-disposition/content-disposition-tests.ts b/content-disposition/content-disposition-tests.ts new file mode 100644 index 0000000000..4c4125fa2a --- /dev/null +++ b/content-disposition/content-disposition-tests.ts @@ -0,0 +1,10 @@ +import contentDisposition = require("content-disposition"); + +const noParams = contentDisposition(); +const withFilenameNoOptions = contentDisposition("EURO rates.txt"); +const withFilenameAndOptions = contentDisposition("€ rates.txt", { type: "attachment", fallback: "EURO rates.txt" }); +const noFilename = contentDisposition(undefined, { type: "attachment", fallback: true }); + +const res = contentDisposition.parse('attachment; filename="EURO rates.txt"'); +const type = res.type; +const parameters = res.parameters; diff --git a/content-disposition/index.d.ts b/content-disposition/index.d.ts new file mode 100644 index 0000000000..56ea66f8ca --- /dev/null +++ b/content-disposition/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for content-disposition 0.5 +// Project: https://github.com/jshttp/content-disposition +// Definitions by: Stefan Reichel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace contentDisposition { + export interface ContentDisposition { + type: string; + parameters: any; + } + + export interface Options { + type?: string; + fallback?: string | boolean; + } + + export function parse(contentDispositionHeader: string): ContentDisposition; +} + +declare function contentDisposition(): string; +declare function contentDisposition(filename: undefined, options: contentDisposition.Options): string; +declare function contentDisposition(filename: string, options?: contentDisposition.Options): string; + +export = contentDisposition; diff --git a/content-disposition/tsconfig.json b/content-disposition/tsconfig.json new file mode 100644 index 0000000000..179228e4d6 --- /dev/null +++ b/content-disposition/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "content-disposition-tests.ts" + ] +} diff --git a/content-disposition/tslint.json b/content-disposition/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/content-disposition/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/enzyme/enzyme-1.2.0.d.ts b/enzyme/enzyme-1.2.0.d.ts index c135267e95..865331529b 100644 --- a/enzyme/enzyme-1.2.0.d.ts +++ b/enzyme/enzyme-1.2.0.d.ts @@ -253,9 +253,9 @@ declare module "enzyme" { * * Returns itself. * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first - * argument, and will be run with a context of the original instance. + * argument, index as a second, and will be run with a context of the original instance. */ - forEach(fn: (wrapper: this) => any): this; + forEach(fn: (wrapper: this, index?: number) => any): this; /** * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map @@ -470,4 +470,4 @@ declare module "enzyme" { export function describeWithDOM(description: String, fn: Function): void; export function spyLifecycle(component: typeof Component): void; -} \ No newline at end of file +} diff --git a/fs-promise/fs-promise-tests.ts b/fs-promise/fs-promise-tests.ts new file mode 100644 index 0000000000..4469ea5c22 --- /dev/null +++ b/fs-promise/fs-promise-tests.ts @@ -0,0 +1,51 @@ +import * as fs from "fs-promise"; + +var src: string; +var dst: string; +var dir: string; +var path: string; +var data: any; +var writeOptions: fs.WriteOptions; +var writeJsonOptions: fs.WriteJsonOptions; +var readJsonOptions: fs.ReadJsonOptions; + +async function test() { + await fs.copy(src, dst); + await fs.emptyDir(dir); + await fs.emptydir(dir); + await fs.ensureFile(path); + await fs.createFile(path); + await fs.ensureDir(dir); + await fs.ensureLink(src, dst); + await fs.createLink(src, dst); + await fs.ensureSymlink(src, dst); + await fs.ensureSymlink(src, dst, "dir"); + await fs.ensureSymlink(src, dst, "file"); + await fs.ensureSymlink(src, dst, "junction"); + await fs.createSymlink(src, dst, "dir"); + await fs.mkdirs(dir); + await fs.mkdirp(dir); + await fs.move(src, dst); + await fs.outputFile(path, "test"); + await fs.outputFile(path, "test", writeOptions); + await fs.outputFile(path, new Buffer([1,2])); + await fs.outputFile(path, new Buffer([1,2]), writeOptions); + await fs.outputJson(path, data); + await fs.outputJson(path, data, writeJsonOptions); + await fs.outputJSON(path, data, writeJsonOptions); + let json = await fs.readJson(path); + json = await fs.readJson(path, readJsonOptions); + json = await fs.readJSON(path, readJsonOptions); + await fs.remove(path); + let dirs: string[] = await fs.walk(dir); + await fs.writeJson(path, data); + await fs.writeJson(path, data, writeJsonOptions); + await fs.writeJSON(path, data, writeJsonOptions); + return dirs; +} + +test().then((dirs: string[]) => { + console.log(dirs); +}).catch((err) => { + console.log(err); +}); diff --git a/fs-promise/index.d.ts b/fs-promise/index.d.ts new file mode 100644 index 0000000000..09b6ec4b9c --- /dev/null +++ b/fs-promise/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for fs-promise 1.0 +// Project: https://github.com/kevinbeaty/fs-promise#readme +// Definitions by: Thiago de Arruda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export * from "mz/fs"; + +export interface WriteOptions { + encoding?: string; + mode?: number; + flag?: string; +} + +type JsonReplacerArray = Array; + +type JsonReplacerFunction = (key: any, value: any) => any; + +type JsonReplacer = JsonReplacerArray | JsonReplacerFunction; + +export interface WriteJsonOptions extends WriteOptions { + spaces?: number; + replacer?: JsonReplacer; +} + +export interface ReadJsonOptions { + encoding: string; + flag?: string; + reviver: (key: any, value: any) => any; +} + +export function copy(src: string, dst: string): Promise; +export function emptyDir(dir: string): Promise; +export function ensureFile(file: string): Promise; +export function ensureDir(dir: string): Promise; +export function ensureLink(srcpath: string, dstpath: string): Promise; +export function ensureSymlink(srcpath: string, dstpath: string, type?: "dir" | "file" | "junction"): Promise; +export function mkdirs(dir: string): Promise; +export function move(src: string, dst: string): Promise; +export function outputFile(file: string, data: string | Buffer, options?: WriteOptions): Promise; +export function outputJson(file: string, data: any, options?: WriteJsonOptions): Promise; +export function readJson(file: string, options?: ReadJsonOptions): Promise; +export function remove(path: string): Promise; +export function walk(dir: string): Promise; +export function writeJson(file: string, data: any, options?: WriteJsonOptions): Promise; + +// aliases +export { + emptyDir as emptydir, + ensureFile as createFile, + ensureLink as createLink, + ensureSymlink as createSymlink, + mkdirs as mkdirp, + outputJson as outputJSON, + readJson as readJSON, + writeJson as writeJSON +}; diff --git a/fs-promise/tsconfig.json b/fs-promise/tsconfig.json new file mode 100644 index 0000000000..dcf9975c0d --- /dev/null +++ b/fs-promise/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fs-promise-tests.ts" + ] +} diff --git a/fs-promise/tslint.json b/fs-promise/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fs-promise/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/graphql-relay/tsconfig.json b/graphql-relay/tsconfig.json index bf46522ecc..1dcd8abe66 100644 --- a/graphql-relay/tsconfig.json +++ b/graphql-relay/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "graphql" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/iconv-lite/tsconfig.json b/iconv-lite/tsconfig.json index a9833e3458..5c0b70bff2 100644 --- a/iconv-lite/tsconfig.json +++ b/iconv-lite/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/incremental-dom/incremental-dom-tests.ts b/incremental-dom/incremental-dom-tests.ts index 19f39e235f..2e30297e57 100644 --- a/incremental-dom/incremental-dom-tests.ts +++ b/incremental-dom/incremental-dom-tests.ts @@ -1,3 +1,4 @@ +/// declare var expect: any; import id = require('incremental-dom'); diff --git a/incremental-dom/tsconfig.json b/incremental-dom/tsconfig.json index 9e2f677265..56ffdff383 100644 --- a/incremental-dom/tsconfig.json +++ b/incremental-dom/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "mocha" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/is-binary-path/index.d.ts b/is-binary-path/index.d.ts new file mode 100644 index 0000000000..9d825e6ae3 --- /dev/null +++ b/is-binary-path/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-binary-path 2.0 +// Project: https://github.com/sindresorhus/is-binary-path +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_binary_path; +declare function is_binary_path(filepath: string): boolean; diff --git a/is-binary-path/is-binary-path-tests.ts b/is-binary-path/is-binary-path-tests.ts new file mode 100644 index 0000000000..967346a35a --- /dev/null +++ b/is-binary-path/is-binary-path-tests.ts @@ -0,0 +1,5 @@ +import isBinaryPath = require("is-binary-path"); + +let a: boolean = isBinaryPath("src/unicorn.png"); + +let b: boolean = isBinaryPath("src/unicorn.txt"); \ No newline at end of file diff --git a/is-binary-path/tsconfig.json b/is-binary-path/tsconfig.json new file mode 100644 index 0000000000..4914ee401d --- /dev/null +++ b/is-binary-path/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-binary-path-tests.ts" + ] +} diff --git a/is-binary-path/tslint.json b/is-binary-path/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-binary-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/jcanvas/tsconfig.json b/jcanvas/tsconfig.json index 6f92aa9018..e2564f5a45 100644 --- a/jcanvas/tsconfig.json +++ b/jcanvas/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/koa-pug/index.d.ts b/koa-pug/index.d.ts new file mode 100644 index 0000000000..e25a5bc6bf --- /dev/null +++ b/koa-pug/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for koa-pug 3.0 +// Project: https://github.com/chrisyip/koa-pug +// Definitions by: Xavier Stouder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as koa from "koa"; + +export namespace Koa { + interface Context { + render(viewPath: string, locals?: Pug.PugLocals, overrideOpts?: Pug.PugCtxOptions, noCache?: boolean): void; + // tslint:disable-next-line:unified-signatures + render(pugStr: string, locals?: Pug.PugLocals, overrideOpts?: Pug.PugCtxOptions): void; + // tslint:disable-next-line:unified-signatures + render(pugStr: string, locals?: Pug.PugLocals, noCache?: boolean): void; + } +} +export class Pug { + constructor(options?: Pug.PugOptions); + use(app: koa): void; +} +export namespace Pug { + export interface PugOptions { + viewPath?: string; + pretty?: boolean; + compileDebug?: boolean; + debug?: boolean; + locals?: PugLocals; + noCache?: boolean; + helperPath?: string | Array; + basedir?: string; + app?: koa; + } + export interface PugCtxOptions extends PugOptions { + fromString: boolean; + } + export interface PugLocals { [str: string]: any; } +} diff --git a/koa-pug/koa-pug-tests.ts b/koa-pug/koa-pug-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/koa-pug/tsconfig.json b/koa-pug/tsconfig.json new file mode 100644 index 0000000000..21d8c4f990 --- /dev/null +++ b/koa-pug/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-pug-tests.ts" + ] +} diff --git a/koa-pug/tslint.json b/koa-pug/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/koa-pug/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/meow/index.d.ts b/meow/index.d.ts new file mode 100644 index 0000000000..d687f65611 --- /dev/null +++ b/meow/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for meow 3.6 +// Project: https://github.com/sindresorhus/meow +// Definitions by: KnisterPeter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as minimist from 'minimist'; + +declare function meow(options: string | string[] | meow.Options, minimistOptions?: minimist.Opts): meow.Result; +declare namespace meow { + + export interface Options { + description?: string | boolean; + help?: string | boolean; + version?: string | boolean; + pkg?: any; + argv?: string[]; + inferType?: boolean; + } + + export interface Result { + input: string[]; + flags: { [name: string]: any }; + pkg: any; + help: string; + showHelp(code: number): void; + } + +} + +export = meow; diff --git a/meow/meow-tests.ts b/meow/meow-tests.ts new file mode 100644 index 0000000000..cb2e1dc90a --- /dev/null +++ b/meow/meow-tests.ts @@ -0,0 +1,19 @@ +import meow = require('meow'); +import Options = meow.Options; + +var options: Options = {}; +options.description = true; +options.description = 'string'; +options.help = true; +options.help = 'string'; +options.version = true; +options.version = 'string'; +options.argv = ['string', 'string']; +options.inferType = true; + +meow(options); +meow('Usage text', { + alias: { + opt: 'opt' + } +}); diff --git a/meow/tsconfig.json b/meow/tsconfig.json new file mode 100644 index 0000000000..3e433b6c02 --- /dev/null +++ b/meow/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "meow-tests.ts" + ] +} diff --git a/meow/tslint.json b/meow/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/meow/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index e7446fccc3..a0508e7223 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -717,7 +717,7 @@ declare module "mongoose" { /** defaults to true */ validateBeforeSave?: boolean; /** defaults to "__v" */ - versionKey?: string; + versionKey?: string|boolean; /** * skipVersioning allows excluding paths from * versioning (the internal revision will not be diff --git a/n3/tsconfig.json b/n3/tsconfig.json index 53af13b215..10bad1929f 100644 --- a/n3/tsconfig.json +++ b/n3/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/node-hue-api/index.d.ts b/node-hue-api/index.d.ts new file mode 100644 index 0000000000..50467da2b1 --- /dev/null +++ b/node-hue-api/index.d.ts @@ -0,0 +1,1070 @@ +// Type definitions for node-hue-api 2.3.0 +// Project: https://github.com/peter-murray/node-hue-api +// Definitions by: wind-rider , Frederic Morel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + + //Not documented because it says it's broken + //export function connect(config) : HueApi; + + //TODO: document lightState, scheduledEvent, scene, timer + //export lightState: lightState, + //export scheduledEvent: scheduledEvent, + //export scene: scene, + //export timer: timer, + + /** + * Will locate the Philips Hue Devices on the network. Depending upon the speed and size of the network the timeout + * may need to be adjusted to locate the Hue Bridge. + * + * @param timeout The maximum time to wait for Hue Devices to be located. If not specified will use the default of 5 seconds. + * @return A promise that will resolve the Hue Bridges as an Array of {"id": {String}, "ipaddress": {String}} objects. + */ + export function upnpSearch(timeout: number): IUpnpSearchResultItem[]; + //Not documented because it's deprecated + //export function searchForBridges(timeout: number): IUpnpSearchResultItem[]; + + /** + * Uses the http://www.meethue.com/api/nupnp call to search for any bridges locally on the network. This lookup can be + * significantly faster than issuing search requests in the {locateBridges} function. + * + * @param cb An option callback function that will be informed of results. + * @returns {Q.promise} A promise that will resolve the addresses of the bridges, or {null} if a callback was provided. + */ + export function nupnpSearch(): Promise; + //Not documented because it's deprecated + //export function locateBridges(): Promise; + + /* An Error Type for API related errors when calling the Philips Hue API. + + * @param error The error object returned from the request. + * @constructor + */ + export class ApiError extends Error { + + name: string; + message: string; + type: any; + address: string; + + constructor(error: Object); + } + + export class HueApi { + + /* + * Constructor used for searching for bridges and registering users + */ + constructor(); + + /** + * Creates an instance of HueApi. + * @param {string} host Address of Hue bridge + * @param {string} username Application username for Hue bridge + * @param {number} [timeout] + * @param {number} [port] + */ + constructor(host: string, username: string, timeout?: number, port?: number); + + /** + * Gets the version data for the Philips Hue Bridge. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @returns {Q.promise} A promise will be provided that will resolve to the version data for the bridge, or {null} if a + * callback was provided. + */ + getVersion(): Promise; + //getVersion(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void; + version(): Promise; + //version(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void; + + /** + * Loads the description for the Philips Hue. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @return {Q.promise} A promise that will be provided with a description object, or {null} if a callback was provided. + */ + description(): Promise; + //description(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void; + getDescription(): Promise; + //getDescription(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void; + + /** + * Reads the bridge configuration and returns it as a JSON object. + * + * @param cb An optional callback function to use if you do not want to use the promise for results. + * @return {Q.promise} A promise with the result, or if a callback function was provided. + */ + config(): Promise; + //config(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void; + getConfig(): Promise; + //getConfig(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void; + + /** + * Obtains the complete state for the Bridge. This is considered to be a very expensive operation and should not be invoked + * frequently. The results detail all config, users, groups, schedules and lights for the system. + * + * @param cb An optional callback function if you don't want to be informed via a promise. + * @returns {Q.promise} A promise with the result, or {null} if a callback function was provided + */ + getFullState(): Promise; + //getFullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void; + fullState(): Promise; + //fullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void; + + /** + * Allows a new user/device to be registered with the Philips Hue Bridge. This will return the name of the user that was + * created by the function call. + * + * This function does not require the HueApi to have been initialized with a host or username. It does however require + * the end user to have pressed the link button on the bridge, before invoking this function. + * + * @param host The hostname or IP Address of the Hue Bridge. + * @param deviceDescription The description for the user/device that is being registered. This is a human readable + * description of the user/device. If one is not provided then a default will be set. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return {Q.promise} A promise with the result, or if a callback was provided. + */ + registerUser(host: string, deviceDescription?: string): Promise; + //registerUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + createUser(host: string, deviceDescription?: string): Promise; + //createUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Presses the Link Button on the Bridge (without the user actually having to do it). If successful then {true} will be + * returned as the result. + * + * @param cb An optional callback function to use if you do not want to use the promise returned. + * @return {Q.promise} A promise with the result, or if a callback was provided. + */ + pressLinkButton(): Promise; + //pressLinkButton(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Deletes an existing user from the Phillips Hue Bridge. + * + * @param username The username of the user to delete. + * @param cb An optional callback function to use if you do not want to get the result via a promise chain. + * @returns {Q.promise} A promise with the result of the deletion, or if a callback was provided. + */ + deleteUser(username: string): Promise; + //deleteUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + unregisterUser(username: string): Promise; + //unregisterUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void + + + /** + * Obtain a list of registered "users" or "devices" that can interact with the Philips Hue. + * + * @param cb An optional callback function if you do not want to use the promise to obtain the results. + * @return A promise that will provide the results of registered users, or if a callback was provided. + */ + registeredUsers(): Promise; + //registeredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void; + getRegisteredUsers(): Promise; + //getRegisteredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void; + + + /** + * Obtains the details of the individual sensors that are attached to the Philips Hue. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the lights object, or {null} if a callback function was provided. + */ + sensors(): Promise; + //sensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void; + getSensors(): Promise; + //getSensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void; + + /** + * Obtains the details of the individual lights that are attached to the Philips Hue. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the lights object, or {null} if a callback function was provided. + */ + lights(): Promise; + //lights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void; + getLights(): Promise; + //getLights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void; + + + /** + * Obtains the status of the specified light. + * + * @param id The id of the light as an integer, this value will be parsed into an integer value so can be a {String} or + * {Number} value. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the light status, or {null} if a callback function was provided. + */ + lightStatus(id: string | number): Promise; + //lightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + getLightStatus(id: string | number): Promise; + //getLightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + + lightStatusWithRGB(id: string | number): Promise; + //lightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + getLightStatusWithRGB(id: string | number): Promise; + //getLightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void; + + + /** + * Obtains the new lights found by the bridge, dependant upon the last search. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the new lights search result, or {null} if a callback function was provided. + */ + newLights(): Promise; + //newLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void; + getNewLights(): Promise; + //getNewLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void; + + + /** + * Starts a search for new lights. + * + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the new lights, or {null} if a callback function was provided. + */ + searchForNewLights(): Promise; + //searchForNewLights(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Sets the name of a light on the Bridge. + * + * @param id The ID of the light to set the name for. + * @param name The name to apply to the light. + * @param cb An optional callback function to use if you do not want a promise returned. + * @return A promise that will be provided with the results of setting the name, or {null} if a callback function was provided. + */ + setLightName(id: string | number, name: string): Promise; + //setLightName(id: string|number, name: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Sets the light state to the provided values. + * + * @param id The id of the light which is an integer or a value that can be parsed into an integer value. + * @param stateValues {lightState.State} containing the properties and values to set on the light. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set the specified state on the light, or {null} if a callback was provided. + */ + setLightState(id: string | number, stateValues: lightState.State | Object): Promise; + //setLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Sets the light state to the provided values for an entire group. + * + * @param id The id of the group which is an integer or a value that can be parsed into an integer value. + * @param stateValues {lightState.State} containing the properties and values to set on the light. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {Q.promise} A promise that will set the specified state on the group, or {null} if a callback was provided. + */ + setGroupLightState(id: string | number, stateValues: lightState.State | Object): Promise; + //setGroupLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + + /** + * Obtains all the groups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the groups, or {null} if a callback was provided. + */ + groups(): Promise; + //groups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getGroups(): Promise; + //getGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getAllGroups(): Promise; + //getAllGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + + /** + * Obtains all the Luminaires from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the luminaires, or {null} if a callback was provided. + */ + luminaires(): Promise; + //luminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLuminaires(): Promise; + //getLuminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + /** + * Obtains all the LightSources from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the lightsources, or {null} if a callback was provided. + */ + lightSources(): Promise; + //lightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLightSources(): Promise; + //getLightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + /** + * Obtains all the LightGroups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will obtain the LightGroups, or {null} if a callback was provided. + */ + lightGroups(): Promise; + //lightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + getLightGroups(): Promise; + //getLightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void; + + + /** + * Obtains the details for a specified group in a format of {id: {*}, name: {*}, lights: [], lastAction: {*}}. + * + * @param id {Number} or {String} which is the id of the group to get the details for. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set the specified state on the light, or {null} if a callback was provided. + */ + getGroup(id: string | number): Promise; + group(id: string | number): Promise; + + /** + * Updates a light group to the specified name and/or lights ids. The name and light ids can be specified independently or + * together when calling this function. + * + * @param id The id of the group to update the name and/or light ids associated with it. + * @param name {String} The name of the group + * @param lightIds {Array} An array of light ids to be assigned to the group. If any of the ids are not present in the + * bridge the creation will fail with an error being produced. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise with a result of if the update was successful, or null if a callback was provided. + */ + + updateGroup(id: string | number, name: string, lightIds: string[]): Promise; + updateGroup(id: string | number, name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Creates a new light Group. + * + * @param name The name of the group that we are creating, limited to 16 characters. + * @param lightIds {Array} of ids for the lights to be included in the group. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the group that was created, or null if a callback was provided. + */ + createGroup(name: string, lightIds: string[]): Promise; + //createGroup(name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Deletes a group with the specified id, returning if the action was successful. + * + * @param id The id of the group to delete. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return if the deletion was successful, or null if a callback was provided. + */ + deleteGroup(id: string | number): Promise; + //deleteGroup(id: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Gets the schedules on the Bridge, as an array of {"id": {String}, "name": {String}} objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the results or if a callback was provided. + */ + schedules(): Promise; + //schedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void; + getSchedules(): Promise; + //getSchedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void; + + /** + * Gets the specified schedule by id, which is in an identical format the the Hue API documentation, with the addition + * of an "id" value for the schedule. + * + * @param id The id of the schedule to retrieve. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @returns A promise that will return the results or if a callback was provided. + */ + schedule(id: string | number): Promise; + //schedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + getSchedule(id: string | number): Promise; + //getSchedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + + /** + * Creates a one time scheduled event. The results from this function is the id of the created schedule. The bridge only + * supports 100 schedules, so once they are triggered, they are removed from the bridge. + * + * @param schedule {ScheduledEvent} + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the id value of the schedule that was created, or if a callback was provided. + */ + scheduleEvent(schedule: ISchedule): Promise; + //scheduleEvent(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + createSchedule(schedule: ISchedule): Promise; + //createSchedule(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void; + + /** + * Deletes a schedule by id, returning {true} if the deletion was successful. + * + * @param id of the schedule + * @param cb An option callback function to use if you do not want to use a promise for the results. + * @return {Q.promise} A promise that will return the result of the deletion, or if a callback was provided. + */ + deleteSchedule(id: string | number): Promise; + //deleteSchedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: Object) => void): void; + + /** + * Updates an existing schedule event with the provided details. + * + * @param id The id of the schedule being updated. + * @param schedule The object containing the details to update for the existing schedule event. + * @param cb An optional callback function to use if you do not want to deal with a promise for the results. + * @return {Q.promise} A promise that will return the result, or if a callback was provided. + */ + updateSchedule(id: string | number, schedule: ISchedule): Promise; + //updateSchedule(id: string | number, schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void; + + /** + * Gets the scenes on the Bridge, as an array of {"id": {String}, "name": {String}, "lights": {Array}, "active": {Boolean}} + * objects. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the results or if a callback was provided. + */ + scenes(): Promise; + getScenes(): Promise; + + /** + * Obtains a scene by a given id. + * @param sceneId {String} The id of the scene to obtain. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the scene or if a callback was provided. + */ + scene(id: string | number): Promise; + //scene(id: string | number, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + getScene(id: string | number): Promise; + //getScene(id: string | number, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Deletes a Scene (that is stored inside the bridge, not in the lights). + * @param sceneId The ID for the scene to delete + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @returns {*} A promise that will return the result from deleting the scene or null if a callback was provided. + */ + deleteScene(id: string | number): Promise; + //deleteScene(id: string | number, cb: (err: NodeJS.ErrnoException, data: Object) => void): void; + + /** + * Creates a new Scene. + * When the scene is created, it will store the current state of the lights and will use those "current" settings + * when the scene is recalled/activated later. + * + * There are two variants to this function, one that accepts lightIds and a name and another that takes a Scene object. + * The former is to maintain backwards compatibility with the 1.2.x version of this library. + * + * @param scene Scene configuration to create + * @param lightIds {Array} of ids for the lights to be included in the scene. + * @param name {String} The name of the scene to be created. If one is not provided, then the id of the scene will become the name. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createScene(scene: IScene): Promise; + createScene(lightIds: string[] | number[], name: string): Promise; + //createScene(scene: IScene, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + //createScene(lightIds: string[] | number[], cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Provides backwards compatibility for < 1.11.x versions of the Hue Bridge Firmware. + * @param lightIds Lights to include in the scene + * @param name Name to use for the scene + * @param cb An optional callback function to use if you do not want to use a promise chain for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createBasicScene(lightIds: string[] | number[], name: string): Promise; + //createBasicScene(lightIds: string[] | number[], name: string, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Provides scene creation for >= 1.11.x firmware versions of the Hue Bridge. + * @param scene The Scene object containing the details of the scene to be created. + * @param cb An optional callback function to use if you do not want to use a promise chain for the results. + * @return {*} A promise that will return the id of the scene that was created (as well as the values that make up the scene), + * or null if a callback was provided. + */ + createAdvancedScene(scene: IScene): Promise; + //createAdvancedScene(scene: IScene, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Update the lights and/or name associated with a scene (or will create a new one if the + * sceneId is not present in the bridge). + * + * @param sceneId {String} The id for the scene in the bridge + * @param scene The configuration of the scene with the details to modify, which can be either a name or an array of + * light ids. + * @param storeLightState {Boolean} flag to save the current light state of the lights in the scene. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was updated and the light ids that are now set, + * or null if a callback was provided. + */ + updateScene(sceneId: string | number, scene: IScene, storeLightState: boolean): Promise; + //updateScene(sceneId: string | number, scene: IScene, storeLightState: boolean, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + modifyScene(sceneId: string | number, scene: IScene, storeLightState: boolean): Promise; + //modifyScene(sceneId: string | number, scene: IScene, storeLightState: boolean, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Modifies the light state of one of the lights in a scene. + * + * @param sceneId The scene id, which if it does not exist a new scene will be created. + * @param lightId integer The id of light that is having the state values set. + * @param stateValues {IState} containing the properties and values to set on the light. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will return the state values on the light, or {null} if a callback was provided. + */ + setSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //setSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + updateSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //updateSceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + modifySceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object): Promise; + //modifySceneLightState(sceneId: string | number, lightId: string | number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: IScene) => void): void; + + /** + * Helper-function that recalls a scene for a group using setGroupLightState. Reason for existence is simplicity for + * user. + * + * @param sceneId The id of the scene to activate, which is an integer or a value that can be parsed into an integer value. + * @param groupIdFilter An optional group filter to apply to the scene, to select a sub set of the lights in the scene. This can + * be {null} or {undefined} to not apply a filter. + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return A promise that will set activate the scene, or {null} if a callback was provided. + */ + activateScene(sceneId: string | number, groupIdFilter?: string | number): Promise; + //activateScene(sceneId: string|number, groupIdFilter: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + recallScene(sceneId: string | number, groupIdFilter?: string | number): Promise; + //recallScene(sceneId: string|number, groupIdFilter: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void; + + /** + * Obtains all the allowed timezones from the bridge. + * + * @param cb An optional callback function to use if you do not want to use a promise for the results. + * @return {*} A promise that will return the id of the scene that was created, or null if a callback was provided. + */ + getTimezones(): Promise; + //getTimezones(cb: (err: NodeJS.ErrnoException, data: string[]) => void): void; + timezones(): Promise; + //timezones(cb: (err: NodeJS.ErrnoException, data: string[]) => void): void; + + } + + /** + * Alias for HueApi + */ + export type BridgeApi = HueApi; + + /** + * Alias for HueApi + */ + export type api = HueApi; + + /* + * Interface declarations + */ + + export interface IBridgeVersion { + name: string, + version: { + api: string, + software: string + } + } + + export interface IUpnpSearchResultItem { + id: string, + ipaddress: string + } + + export interface IBridgeIcon { + mimetype: string, + height: string, + width: string, + depth: string, + url: string + } + + export interface IBridgeDescription { + version: { + major: string, + minor: string + }, + url: string, + name: string, + manufacturer: string, + model: { + name: string, + description: string, + number: string, + serial: string, + udn: string + }, + icons?: IBridgeIcon[] + } + + export type BackupStatus = "idle" | "startmigration" | "fileready_disabled" | "prepare_restore" | "restoring"; + + export interface IBridgeConfig { + name: string, + zigbeechannel: number, + bridgeid: string, + mac: string, + dhcp: boolean, + ipaddress: string, + netmask: string, + gateway: string, + proxyaddress: string, + proxyport: number, + UTC: Date, + localtime: Date, + timezone: string, + modelid: string, + swversion: string, + apiversion: string, + swupdate: { + updatestate: number, + checkforupdate: boolean, + devicetypes: { + bridge: boolean, + lights: string[], + sensors: string[] + }, + url: string, + text: string, + notify: boolean + }, + linkbutton: boolean, + portalservices: boolean, + portalconnection: string, + portalstate: { + signedon: boolean, + incoming: boolean, + outgoing: boolean, + communication: string + }, + factorynew: boolean, + replacesbridgeid?: string, + backup: { + status: BackupStatus, + errorcode: number + }, + whitelist: { + [key: string]: { + "last use date": Date, + "create date": Date, + name: string + } + } + } + + /** + * 3 methods to set color of light, in order of precedence if multiple are set + * + * xy: Coordinates in CIE color space, + * ct: Color Temperature, + * hs: Hue and Saturation + */ + export type ColorMode = "xy" | "ct" | "hs"; + + /** + * Alert command + * + * none = stop, + * select = flash once, + * lselect = flash for 15 seconds + */ + export type LightAlert = "none" | "select" | "lselect"; + + export type LightEffect = "none" | "colorloop"; + + /** + * If not set when creating a group, default is LightGroup + */ + export type LightGroupType = "LightGroup" | "Room" | "Luminaire" | "LightSource"; + + /** + * If not set when creating a group, default is Other + */ + export type RoomType = + "Living room" | "Kitchen" | "Dining" | + "Bedroom" | "Kids bedroom" | "Bathroom" | + "Nursery" | "Recreation" | "Office" | + "Gym" | "Hallway" | "Toilet" | + "Front door" | "Garage Terrace" | "Garden" | + "Driveway" | "Carport" | "Other"; + + export interface IScene { + id: string; + name: string; + lights: number[]; + } + + export interface ILightGroup { + id: string, + name: string, + type: LightGroupType, + class?: RoomType, + action?: { + on: boolean, + bri: number, + hue: number, + sat: number, + xy: [number, number], + ct: number, + effect: LightEffect, + colormode: ColorMode + }, + lights?: string[] + + } + + export interface ILight { + id?: string, + manufacturername: string, + uniqueid: string, + state: { + rgb?: number[], + on: boolean, + bri: number, + hue?: number, + sat?: number, + xy?: [number, number], + ct?: number, + alert: LightAlert, + effect?: LightEffect, + colormode?: ColorMode, + reachable: boolean + }, + type: string, + name: string, + modelid: string, + swversion: string, + pointsymbol?: { + "1": string, + "2": string, + "3": string, + "4": string, + "5": string, + "6": string, + "7": string, + "8": string + } + } + + export interface ILightsApiResponse { + lights: ILight[] + } + + //State and config depend on sensor type + //TODO: definitions for different sensor types + export interface ISensor { + id?: string, + manufacturername: string, + uniqueid?: string, + state: { + [key: string]: number | string; + lastupdated: string; + }; + config: { + [key: string]: number | string; + }; + type: string, + name: string, + modelid: string, + swversion: string, + } + + export interface ISensorsApiResponse { + sensors: ISensor[] + } + + export interface ISchedule { + name: string, + description: string, + command: { + address: string, + body: { + on: boolean + }, + method: string + }, + time: Date + } + + export interface IState { + lights: { + [key: string]: ILight + }, + groups: { + [key: string]: ILightGroup + }, + config: IBridgeConfig, + schedules: { + [key: string]: ISchedule + } + } + + export interface IRegisteredUser { + name: string, + username: string, + created: Date, + accessed: Date + } + + export interface INewLightsResponse { + lastscan: string, + [key: string]: string | { name: string } + } + + /* + * lightState part + */ + + export module lightState { + + class State { + payload(): Object; + + /** + * Resets/Clears the properties that have been set in the light state object. + * @returns {State} + */ + reset(): State; + clear(): State; + + /** + * Creates a copy of the state object + * @returns {State} + */ + copy(): State; + + /** + * Sets the strict state for setting parameters for the light state. + * @param strict + * @returns {State} + */ + strict(): State; + + isStrict(): boolean; + + /** + * Sets the on state + * @param on The state (true for on, false for off). If this parameter is not specified, it is assumed to be true. + * @returns {State} + */ + on(on?: boolean): State; + + /** + * Adds the bri state + * @param value The hue bri value, 0 to 254. + * @return {State} + */ + bri(value: number): State; + + /** + * Adds the hue for the color desired. + * @param hue The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue. + * @returns {State} + */ + hue(hue: number): State; + + /** + * The saturation of the color for the bulb, 0 being the least saturated i.e. white. + * @param saturation The saturation value 0 to 255 + * @returns {State} + */ + sat(saturation: number): State; + + /** + * Adds the xy values + * @param x The x value ranged from 0 to 1, or an Array of [x, y] values + * @param y The y value ranged from 0 to 1 + * @return {State} + */ + xy(x: number, y: number): State; + + /** + * Adds the Mired Color Temperature + * @param colorTemp The Color Temperature between 153 to 500 inclusive. + * @returns {State} + */ + ct(colorTemp: number): State; + + /** + * Adds the alert state + * @param value A String value representing the alert state, "none", "select", "lselect". + * @return {State} + */ + alert(value: LightAlert): State; + + /** + * Adds an effect for the bulb. + * @param value The type of effect, currently supports "none" and "colorloop". + * @returns {State} + */ + effect(value: LightEffect): State; + + /** + * Adds a transition to the desired state. + * @param value This is given as a multiple of 100ms and defaults to 4 (400ms). + * @return {State} + */ + transitiontime(value: number): State; + + /** + * Increments/Decrements the brightness value for the lights. + * @param value An amount to change the current brightness by, -254 to 254. + * @returns {State} + */ + bri_inc(value: number): State; + + /** + * Increments/Decrements the saturation value for the lights. + * @param value An amount to change the current saturation by, -254 to 254. + * @returns {State} + */ + sat_inc(value: number): State; + + /** + * Increments/Decrements the Hue value for the lights. + * @param value An amount to change the current hue by, -65534 to 65534. + * @returns {State} + */ + hue_inc(value: number): State; + + /** + * Increments/Decrements the color temperature value for the lights. + * @param value An amount to change the current color temperature by, -65534 to 65534. + * @returns {State} + */ + ct_inc(value: number): State; + + /** + * Increments/Decrements the XY value for the lights. + * @param value An amount to change the current XY by, -0.5 to 0.5. + * @returns {State} + */ + xy_inc(value: number): State; + + scene(value: string): State; + + + /////////////////////////////////////////////////////////////////////// + // Convenience functions + + turnOn(): State; + + off(): State; + turnOff(): State; + + /** + * Set the brightness as a percent value + * @param percentage The brightness percentage value between 0 and 100. + * @returns {State} + */ + brightness(percentage: number): State; + + incrementBrightness(value: number): State; + + colorTemperature(value: number): State; + colourTemperature(value: number): State; + colorTemp(value: number): State; + colourTemp(value: number): State; + + incrementColorTemp(value: number): State; + incrementColorTemperature(value: number): State; + incrementColourTemp(value: number): State; + incrementColourTemperature(value: number): State; + + incrementHue(value: number): State; + + incrementXY(value: number): State; + + saturation(percentage: number): State; + + incrementSaturation(value: number): State; + + shortAlert(): State; + alertShort(): State; + + longAlert(): State; + alertLong(): State; + + transitionTime(value: number): State; + /** + * Sets the transition time in milliseconds. + * @param milliseconds The number of milliseconds for the transition + * @returns {State} + */ + transition(milliseconds: number): State; + + transitionSlow(): State; + + transitionFast(): State; + + transitionInstant(): State; + + transitionDefault(): State; + + /** + * Builds the White state for a lamp + * @param colorTemp The temperature, a value of 153-500 + * @param brightPercentage The percentage of brightness 0-100 + * @return {State} + */ + white(colorTemp: number, brightPercentage: number): State; + + /** + * Adds the HSL values + * @param hue The hue value in degrees 0-360 + * @param saturation The saturation percentage 0-100 + * @param luminosity The luminosity percentage 0-100 + * @return {State} + */ + hsl(hue: number, saturation: number, luminosity: number): State; + + /** + * Adds the HSB values + * @param hue The hue value in degrees 0-360 + * @param saturation The saturation percentage 0-100 + * @param brightness The brightness percentage 0-100 + * @return {State} + */ + hsb(hue: number, saturation: number, brightness: number): State; + + /** + * Adds the rgb color to the state. This requires knowledge of the light type to be able to convert it into + * an actual color that the map can display. + * + * @param r The amount of Red 0-255, or an {Array} or r, g, b values. + * @param g The amount of Green 0-255 + * @param b The amount of Blue 0-255 + * @return {State} + */ + rgb(r: number, g: number, b: number): State; + + hasRGB(): boolean; + + colorLoop(): State; + colourLoop(): State; + effectColorLoop(): State; + effectColourLoop(): State; + + /** + * Creates a copy of the State if there is an RGB value set. + * + * @param modelid The model ID of the light(s) to convert the rgb value for. + * + * @returns {State} If there is an RGB value set, then a copy of the state, with the rgb value applied based on the + * lamp model provided. If there is no RGB value set, then {null} will be returned. + */ + applyRGB(modelid: string): State; + } + + function create(values?: Object): State; + function isLightState(obj: Object): obj is State; + } \ No newline at end of file diff --git a/node-hue-api/node-hue-api-tests.ts b/node-hue-api/node-hue-api-tests.ts new file mode 100644 index 0000000000..44903fa4da --- /dev/null +++ b/node-hue-api/node-hue-api-tests.ts @@ -0,0 +1,22 @@ +/// + +import hue = require('node-hue-api'); + +hue.nupnpSearch().then(function (bridges) { + if (!bridges || !bridges[0]) { + throw "No bridge found"; + } + let ip = bridges[0].ipaddress; + //First load username from file. Register if there's no file. + let api = new hue.HueApi(); + api.registerUser(ip).then(newUser => { + console.log("Created Hue user: " + JSON.stringify(newUser)); + }).then(listScenes.bind(this, api)); +}) + + +function listScenes(api: hue.HueApi) { + return api.getScenes().then(function (scenes) { + return console.log(scenes.map(s => s.name).join(", ")); + }); +} \ No newline at end of file diff --git a/node-hue-api/tsconfig.json b/node-hue-api/tsconfig.json new file mode 100644 index 0000000000..519af60856 --- /dev/null +++ b/node-hue-api/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-hue-api-tests.ts" + ] +} \ No newline at end of file diff --git a/passport-twitter/index.d.ts b/passport-twitter/index.d.ts index ee0ad9ea4b..387fa7ab44 100644 --- a/passport-twitter/index.d.ts +++ b/passport-twitter/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for passport-facebook 1.0.3 -// Project: https://github.com/jaredhanson/passport-facebook +// Type definitions for passport-twitter 1.0.4 +// Project: https://github.com/jaredhanson/passport-twitter // Definitions by: James Roland Cabresos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -24,6 +24,9 @@ interface IStrategyOption { consumerSecret: string; callbackURL: string; + passReqToCallback?: true; + includeEmail?: true; + reguestTokenURL?: string; accessTokenURL?: string; userAuthorizationURL?: string; diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts index 815d490610..66355a2f31 100644 --- a/passport-twitter/passport-twitter-tests.ts +++ b/passport-twitter/passport-twitter-tests.ts @@ -15,7 +15,9 @@ var User = { passport.use(new twitter.Strategy({ consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY, consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET, - callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL + callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL, + passReqToCallback : true, + includeEmail: true }, function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { User.findOrCreate(profile.id, profile.provider, function(err, user) { diff --git a/protractor-helpers/index.d.ts b/protractor-helpers/index.d.ts index 80314e8aa7..3ab4691778 100644 --- a/protractor-helpers/index.d.ts +++ b/protractor-helpers/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: John Cant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// /// // ElementArrayFinder diff --git a/protractor-helpers/protractor-helpers-tests.ts b/protractor-helpers/protractor-helpers-tests.ts index 269390080e..9b03e43005 100644 --- a/protractor-helpers/protractor-helpers-tests.ts +++ b/protractor-helpers/protractor-helpers-tests.ts @@ -1,4 +1,4 @@ - +/// import helpers = require('protractor-helpers'); diff --git a/protractor-helpers/tsconfig.json b/protractor-helpers/tsconfig.json index 897492ad71..83c6364510 100644 --- a/protractor-helpers/tsconfig.json +++ b/protractor-helpers/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", - "types": ["jasmine", "selenium-webdriver"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/protractor-http-mock/tsconfig.json b/protractor-http-mock/tsconfig.json index bad3dc76e2..e08b9ae838 100644 --- a/protractor-http-mock/tsconfig.json +++ b/protractor-http-mock/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", - "types": ["selenium-webdriver"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/react-daterange-picker/tsconfig.json b/react-daterange-picker/tsconfig.json index 658e569c10..483eb047c1 100644 --- a/react-daterange-picker/tsconfig.json +++ b/react-daterange-picker/tsconfig.json @@ -11,7 +11,7 @@ "paths": { "*": ["*", "react-daterange-picker/node_modules/*"] }, - "types": ["moment-range", "react"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, "jsx": "react" diff --git a/react-easy-chart/tsconfig.json b/react-easy-chart/tsconfig.json index fa7efaac28..36fff7f006 100644 --- a/react-easy-chart/tsconfig.json +++ b/react-easy-chart/tsconfig.json @@ -9,7 +9,7 @@ "typeRoots": [ "../" ], - "types": ["react"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 3731f9ca5d..5aedbf914f 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -103,8 +103,31 @@ declare module "react-relay" { renderFailure?(error: Error, retry: Function): JSX.Element } + type ReadyStateEvent = + 'ABORT' | + 'CACHE_RESTORED_REQUIRED' | + 'CACHE_RESTORE_FAILED' | + 'CACHE_RESTORE_START' | + 'NETWORK_QUERY_ERROR' | + 'NETWORK_QUERY_RECEIVED_ALL' | + 'NETWORK_QUERY_RECEIVED_REQUIRED' | + 'NETWORK_QUERY_START' | + 'STORE_FOUND_ALL' | + 'STORE_FOUND_REQUIRED'; + + interface OnReadyStateChange { + (readyState: { + ready: boolean, + done: boolean, + stale: boolean, + error?: Error, + events: Array, + aborted: boolean + }): void + } + interface RelayProp { - variables: any - setVariables(variables: Object): void + variables: any + setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void } } diff --git a/react-test-renderer/tsconfig.json b/react-test-renderer/tsconfig.json index b6bc79303e..e5ac05f506 100644 --- a/react-test-renderer/tsconfig.json +++ b/react-test-renderer/tsconfig.json @@ -8,9 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "react" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/react/index.d.ts b/react/index.d.ts index c600dfcc39..467af23d9f 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2179,7 +2179,8 @@ declare namespace React { stopColor?: string; stopOpacity?: number | string; stroke?: string; - strokeDasharray?: string; + strokeDasharray?: string | number; + strokeDashoffset?: string | number; strokeLinecap?: "butt" | "round" | "square" | "inherit"; strokeLinejoin?: "miter" | "round" | "bevel" | "inherit"; strokeMiterlimit?: string; diff --git a/react/react-tests.ts b/react/react-tests.ts index c2d80d0dd0..ab23c65532 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -341,13 +341,17 @@ React.DOM.svg({ x: 22, y: 10, width: 4, - height: 28 + height: 28, + strokeDasharray: '30%', + strokeDashoffset: '20%' }), React.DOM.rect({ x: 10, y: 22, width: 28, - height: 4 + height: 4, + strokeDasharray: 30, + strokeDashoffset: 20 }), React.DOM.path({ d: "M0,0V3H3V0ZM1,1V2H2V1Z", diff --git a/waterline/index.d.ts b/waterline/index.d.ts index 15c88ec8cf..6525e699b6 100644 --- a/waterline/index.d.ts +++ b/waterline/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Alexandro Libertino // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + import BluebirdPromise = require("bluebird"); declare namespace Waterline { type Adapter = Object; diff --git a/waterline/tsconfig.json b/waterline/tsconfig.json index d53e4133d4..bc53759038 100644 --- a/waterline/tsconfig.json +++ b/waterline/tsconfig.json @@ -8,10 +8,7 @@ "typeRoots": [ "../" ], - "types": [ - "node", - "bluebird" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/xml/index.d.ts b/xml/index.d.ts new file mode 100644 index 0000000000..8c5d5179ca --- /dev/null +++ b/xml/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for xml 1.0 +// Project: http://github.com/dylang/node-xml +// Definitions by: Jianrong Yu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface Option { + /** + * String used for tab, defaults to no tabs (compressed) + */ + indent?: string; + /** + * Return the result as a `stream` (default false) + */ + stream?: boolean; + /** + * Add default xml declaration (default false) + */ + declaration?: boolean | { + encoding?: string; + standalone?: string; + }; +} + +interface XmlAttrs { + [attr: string]: string; +} +interface XmlDescArray { + [index: number]: { _attr: XmlAttrs } | XmlObject; +} +interface ElementObject { + push(xmlObject: XmlObject): void; + close(xmlObject?: XmlObject): void; +} + +type XmlAtom = string | number | boolean; +type XmlDesc = { _attr: XmlAttrs } | { _cdata: string } | { _attr: XmlAttrs, _cdata: string } | XmlAtom | XmlAtom[] | XmlDescArray; +type XmlObject = { [tag: string]: ElementObject | XmlDesc } | XmlDesc; + +declare namespace xml { + function element(...xmlObjects: XmlObject[]): ElementObject; + function Element(...xmlObjects: XmlObject[]): ElementObject; +} + +declare function xml(xmlObject: XmlObject | XmlObject[], options: { stream: true, indent?: string }): NodeJS.ReadableStream; +declare function xml(xmlObject?: XmlObject | XmlObject[], options?: boolean | string | Option): string; + +export = xml; diff --git a/xml/tsconfig.json b/xml/tsconfig.json new file mode 100644 index 0000000000..48e5377f30 --- /dev/null +++ b/xml/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "xml-tests.ts" + ] +} diff --git a/xml/tslint.json b/xml/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/xml/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/xml/xml-tests.ts b/xml/xml-tests.ts new file mode 100644 index 0000000000..df8acf6ef9 --- /dev/null +++ b/xml/xml-tests.ts @@ -0,0 +1,163 @@ +// Code get from the test file of http://github.com/dylang/node-xml + +import * as xml from "xml"; + +interface Tester { + is(a: any, b: any): void; + same(a: any, b: any): void; + plan(id: number): void; + ok(a: any): void; +}; + +function test(c: string, f: (t: Tester) => void) { + return; +} + + +test('no elements', t => { + t.is(xml(), ''); + t.is(xml([]), ''); + t.is(xml('test'), 'test'); + t.is(xml('scotch & whisky'), 'scotch & whisky'); + t.is(xml('bob\'s escape character'), 'bob's escape character'); +}); + +test('simple options', t => { + t.is(xml([{a: {}}]), ''); + t.is(xml([{a: null}]), ''); + t.is(xml([{a: []}]), ''); + t.is(xml([{a: -1}]), '-1'); + t.is(xml([{a: false}]), 'false'); + t.is(xml([{a: 'test'}]), 'test'); + t.is(xml({a: {}}), ''); + t.is(xml({a: null}), ''); + t.is(xml({a: []}), ''); + t.is(xml({a: -1}), '-1'); + t.is(xml({a: false}), 'false'); + t.is(xml({a: 'test'}), 'test'); + t.is(xml([{a: 'test'}, {b: 123}, {c: -0.5}]), 'test123-0.5'); +}); + +test('deeply nested objects', t => { + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}]), '123'); +}); + +test('indents property', t => { + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], true), '\n \n 1\n 2\n 3\n \n'); + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], ' '), '\n \n 1\n 2\n 3\n \n'); + t.is(xml([{a: [{b: [{c: 1}, {c: 2}, {c: 3}]}]}], '\t'), '\n\t\n\t\t1\n\t\t2\n\t\t3\n\t\n'); + t.is(xml({guid: [{_attr: {premalink: true}}, 'content']}, true), 'content'); +}); + +test('supports xml attributes', t => { + t.is(xml([{b: {_attr: {}}}]), ''); + t.is(xml([{ + a: { + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + } + }]), ''); + t.is(xml([{ + a: [{ + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + }] + }]), ''); + t.is(xml([{ + a: [{ + _attr: { + attribute1: 'some value', + attribute2: 12345 + } + }, 'content'] + }]), 'content'); +}); + +test('supports cdata', t => { + t.is(xml([{a: {_cdata: 'This is some CDATA'}}]), 'CDATA]]>'); + t.is(xml([{ + a: { + _attr: {attribute1: 'some value', attribute2: 12345}, + _cdata: 'This is some CDATA' + } + }]), 'CDATA]]>'); + t.is(xml([{a: {_cdata: 'This is some CDATA with ]]> and then again ]]>'}}]), 'CDATA with ]]]]> and then again ]]]]>]]>'); +}); + +test('supports encoding', t => { + t.is(xml([{ + a: [{ + _attr: { + anglebrackets: 'this is strong', + url: 'http://google.com?s=opower&y=fun' + } + }, 'text'] + }]), 'text'); +}); + +test('supports stream interface', t => { + const elem = xml.element({_attr: {decade: '80s', locale: 'US'}}); + const xmlStream = xml({toys: elem}, {stream: true}); + const results = ['', 'Transformers', 'He-man', 'GI Joe', '']; + + elem.push({toy: 'Transformers'}); + elem.push({toy: [{name: 'He-man'}]}); + elem.push({toy: 'GI Joe'}); + elem.close(); + + xmlStream.on('data', (stanza: any[]) => { + t.is(stanza, results.shift()); + }); + + return new Promise( (resolve, reject) => { + xmlStream.on('close', () => { + t.same(results, []); + resolve(); + }); + xmlStream.on('error', reject); + }); +}); + +test('streams end properly', t => { + const elem = xml.element({ _attr: { decade: '80s', locale: 'US'} }); + const xmlStream = xml({ toys: elem }, { stream: true }); + + let gotData = false; + + t.plan(7); + + elem.push({ toy: 'Transformers' }); + elem.push({ toy: 'GI Joe' }); + elem.push({ toy: [{name:'He-man'}] }); + elem.close(); + + xmlStream.on('data', (data: any) => { + t.ok(data); + gotData = true; + }); + + xmlStream.on('end', () => { + t.ok(gotData); + }); + + return new Promise( (resolve, reject) => { + xmlStream.on('close', () => { + t.ok(gotData); + resolve(); + }); + xmlStream.on('error', reject); + }); +}); + +test('xml declaration options', t => { + t.is(xml([{a: 'test'}], {declaration: true}), 'test'); + t.is(xml([{a: 'test'}], {declaration: {encoding: 'foo'}}), 'test'); + t.is(xml([{a: 'test'}], {declaration: {standalone: 'yes'}}), 'test'); + t.is(xml([{a: 'test'}], {declaration: false}), 'test'); + t.is(xml([{a: 'test'}], {declaration: true, indent: '\n'}), '\ntest'); + t.is(xml([{a: 'test'}], {}), 'test'); +}); \ No newline at end of file