diff --git a/.travis.yml b/.travis.yml index acfc5176f9..0bad26ece1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,7 @@ language: node_js node_js: - "0.10" +sudo: false + notifications: email: false diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index da1fb51a1c..f5470fe4a9 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -5,6 +5,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](accounting/accounting.d.ts) [accounting.js](http://josscrowcroft.github.io/accounting.js) by [Sergey Gerasimov](https://github.com/gerich-home) * [:link:](ace/ace.d.ts) [Ace Ajax.org Cloud9 Editor](http://ace.ajax.org) by [Diullei Gomes](https://github.com/Diullei) * [:link:](add2home/add2home.d.ts) [add2home](http://cubiq.org/add-to-home-screen) by [James Wilkins](http://www.codeplex.com/site/users/view/jamesnw) +* [:link:](adm-zip/adm-zip.d.ts) [adm-zip](https://github.com/cthackers/adm-zip) by [John Vilk](https://github.com/jvilk) * [:link:](alertify/alertify.d.ts) [alertify](http://fabien-d.github.io/alertify.js) by [John Jeffery](http://github.com/jjeffery) * [:link:](amcharts/AmCharts.d.ts) [amCharts](http://www.amcharts.com) by [aleksey-bykov](https://github.com/aleksey-bykov) * [:link:](amplifyjs/amplifyjs.d.ts) [AmplifyJs](http://amplifyjs.com) by [Jonas Eriksson](https://github.com/joeriks) @@ -18,7 +19,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](angularjs/angular-sanitize.d.ts) [Angular JS (ngSanitize module)](http://angularjs.org) by [Diego Vilar](http://github.com/diegovilar) * [:link:](angular-ui/angular-ui-router.d.ts) [Angular JS (ui.router module)](https://github.com/angular-ui/ui-router) by [Michel Salib](https://github.com/michelsalib) * [:link:](angular-protractor/angular-protractor.d.ts) [Angular Protractor](https://github.com/angular/protractor) by [Bill Armstrong](https://github.com/BillArmstrong) -* [:link:](angularjs/angular-scenario.d.ts) [Angular Scenario Testing](http://angularjs.org) by [RomanoLindano](https://github.com/RomanoLindano) +* [:link:](angularjs/angular-scenario.d.ts) [Angular Scenario Testing (ngScenario module)](http://angularjs.org) by [RomanoLindano](https://github.com/RomanoLindano) * [:link:](angular-translate/angular-translate.d.ts) [Angular Translate (pascalprecht.translate module)](https://github.com/PascalPrecht/angular-translate) by [Michel Salib](https://github.com/michelsalib) * [:link:](angular-ui-bootstrap/angular-ui-bootstrap.d.ts) [Angular UI Bootstrap](https://github.com/angular-ui/bootstrap) by [Brian Surowiec](https://github.com/xt0rted) * [:link:](angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts) [angular-bootstrap-lightbox](https://github.com/compact/angular-bootstrap-lightbox) by [Roland Zwaga](https://github.com/rolandzwaga) @@ -102,6 +103,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](convert-source-map/convert-source-map.d.ts) [convert-source-map](https://github.com/thlorenz/convert-source-map) by [Andrew Gaspar](https://github.com/AndrewGaspar) * [:link:](cookie/cookie.d.ts) [cookie](https://github.com/jshttp/cookie) by [Pine Mizune](https://github.com/pine613) * [:link:](cookie-parser/cookie-parser.d.ts) [cookie-parser](https://github.com/expressjs/cookie-parser) by [Santi Albo](https://github.com/santialbo) +* [:link:](cookiejs/cookiejs.d.ts) [cookie.js](https://github.com/js-coder/cookie.js) by [Boltmade](https://github.com/Boltmade) * [:link:](threejs/three-copyshader.d.ts) [CopyShader.js](https://github.com/mrdoob/three.js/blob/r68/examples/js/shaders/CopyShader.js) by [Satoru Kimura](https://github.com/gyohk) * [:link:](cordova-ionic/plugins/keyboard.d.ts) [Cordova Keyboard plugin](https://github.com/driftyco/ionic-plugins-keyboard) by [Hendrik Maus](https://github.com/hendrikmaus) * [:link:](cordovarduino/cordovarduino.d.ts) [Cordovarduino plugin](https://github.com/stereolux/cordovarduino) by [Hendrik Maus](https://github.com/hendrikmaus) @@ -216,6 +218,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](handlebars/handlebars.d.ts) [Handlebars](http://handlebarsjs.com) by [Boris Yankov](https://github.com/borisyankov) * [:link:](hapi/hapi.d.ts) [hapi](http://github.com/spumko/hapi) by [Hakubo](http://github.com/hakubo) * [:link:](hashmap/hashmap.d.ts) [HashMap](https://github.com/flesler/hashmap) by [Rafał Wrzeszcz](http://wrzasq.pl) +* [:link:](Headroom/headroom.d.ts) [headroom.js](http://wicky.nillia.ms/headroom.js) by [Jakub Olek](https://github.com/hakubo) +* [:link:](heatmap.js/heatmap.d.ts) [heatmap.js](https://github.com/pa7/heatmap.js) by [Yang Guan](https://github.com/lookuptable) * [:link:](hellojs/hellojs.d.ts) [hello.js](http://adodson.com/hello.js) by [Pavel Zika](https://github.com/PavelPZ) * [:link:](highcharts/highcharts.d.ts) [Highcharts](http://www.highcharts.com) by [Damiano Gambarotto](http://github.com/damianog) * [:link:](highland/highland.d.ts) [Highland](http://highlandjs.org) by [Bart van der Schoor](https://github.com/Bartvds) @@ -268,6 +272,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jquery.base64/jquery.base64.d.ts) [jQuery Plugin - base64 codec](https://github.com/yatt/jquery.base64) by [Shinya Mochizuki](https://github.com/enrapt-mochizuki) * [:link:](jquery.postMessage/jquery.postMessage.d.ts) [jQuery postMessage](http://benalman.com/projects/jquery-postmessage-plugin) by [Junle Li](https://github.com/lijunle) * [:link:](jquery.prettyphoto/jquery.prettyphoto.d.ts) [jQuery prettyPhoto](https://github.com/scaron/prettyphoto) by [pgaske](https://github.com/pgaske) +* [:link:](jquery.rowGrid/jquery.rowGrid.d.ts) [jQuery rowGrid.js plugin (v1.0.2)](https://github.com/brunjo/rowGrid.js) by [Vinayak Garg](https://github.com/vinayak-garg) * [:link:](royalslider/royalslider.d.ts) [jQuery royal-slider](http://dimsemenov.com/plugins/royal-slider/documentation) by [Christiaan Rakowski](https://github.com/csrakowski) * [:link:](jquery.simplePagination/jquery.simplePagination.d.ts) [jQuery simplePagination.js](https://github.com/flaviusmatis/simplePagination.js) by [Natan Vivo](https://github.com/nvivo) * [:link:](jquery.tagsmanager/jquery.tagsmanager.d.ts) [jQuery Tags Manager](http://welldonethings.com/tags/manager) by [Vincent Bortone](https://github.com/vbortone) @@ -338,7 +343,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](keypress/keypress.d.ts) [Keypress](https://github.com/dmauro/Keypress) by [Roger Chen](https://github.com/rcchen) * [:link:](kineticjs/kineticjs.d.ts) [KineticJS](http://kineticjs.com) by [Basarat Ali Syed](http://www.github.com/basarat), [Ralph de Ruijter](http://www.superdopey.nl/techblog) * [:link:](knockback/knockback.d.ts) [Knockback.js](http://kmalakoff.github.io/knockback) by [Boris Yankov](https://github.com/borisyankov) -* [:link:](knockout/knockout.d.ts) [Knockout](http://knockoutjs.com) by [Boris Yankov](https://github.com/borisyankov), [Igor Oleinikov](https://github.com/Igorbek) +* [:link:](knockout/knockout.d.ts) [Knockout](http://knockoutjs.com) by [Boris Yankov](https://github.com/borisyankov), [Igor Oleinikov](https://github.com/Igorbek), [Clément Bourgeois](https://github.com/moonpyk) * [:link:](knockout.deferred.updates/knockout.deferred.updates.d.ts) [Knockout Deferred Updates](https://github.com/mbest/knockout-deferred-updates) by [Sebastián Galiano](https://github.com/sgaliano) * [:link:](knockout.validation/knockout.validation.d.ts) [Knockout Validation](https://github.com/ericmbarnard/Knockout-Validation) by [Dan Ludwig](https://github.com/danludwig) * [:link:](knockout.viewmodel/knockout.viewmodel.d.ts) [Knockout Viewmodel](http://coderenaissance.github.com/knockout.viewmodel) by [Oisin Grehan](https://github.com/oising) @@ -402,6 +407,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](mongoose/mongoose.d.ts) [Mongoose](http://mongoosejs.com) by [horiuchi](https://github.com/horiuchi) * [:link:](morgan/morgan.d.ts) [morgan](https://github.com/expressjs/morgan) by [James Roland Cabresos](https://github.com/staticfunction) * [:link:](mousetrap/mousetrap.d.ts) [Mousetrap](http://craig.is/killing/mice) by [Dániel Tar](https://github.com/qcz) +* [:link:](mousetrap/mousetrap-global-bind.d.ts) [Mousetrap 1.4.6's global-bind extension](http://craig.is/killing/mice#extensions.global) by [Andrew Bradley](https://github.com/cspotcode) * [:link:](moviedb/moviedb.d.ts) [MovieDB](https://github.com/danzajdband/moviedb) by [Basarat Ali Syed](https://github.com/basarat) * [:link:](firefox/firefox.d.ts) [Mozilla Web API](https://developer.mozilla.org/en-US/docs/Web/API) by [vvakame](https://github.com/vvakame) * [:link:](localForage/localForage.d.ts) [Mozilla's localForage](https://github.com/mozilla/localforage) by [david pichsenmeister](https://github.com/3x14159265) @@ -540,8 +546,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](slickgrid/slick.headerbuttons.d.ts) [SlickGrid HeaderButtons Plugin](https://github.com/mleibman/SlickGrid) by [Derek Cicerone](https://github.com/derekcicerone) * [:link:](slickgrid/slick.rowselectionmodel.d.ts) [SlickGrid RowSelectionModel Plugin](https://github.com/mleibman/SlickGrid) by [Derek Cicerone](https://github.com/derekcicerone) * [:link:](smoothie/smoothie.d.ts) [Smoothie Charts](https://github.com/joewalnes/smoothie) by [Drew Noakes](https://drewnoakes.com), [Mike H. Hawley](https://github.com/mikehhawley) -* [:link:](socket.io/socket.io.d.ts) [socket.io](http://socket.io) by [William Orr](https://github.com/worr) -* [:link:](socket.io-client/socket.io-client.d.ts) [socket.io nodejs client](http://socket.io) by [Maido Kaara](https://github.com/v3rm0n) +* [:link:](socket.io/socket.io.d.ts) [socket.io](http://socket.io) by [PROGRE](https://github.com/progre) +* [:link:](socket.io-client/socket.io-client.d.ts) [socket.io-client](http://socket.io) by [PROGRE](https://github.com/progre) * [:link:](sockjs/sockjs.d.ts) [SockJS 0.3.x](https://github.com/sockjs/sockjs-client) by [Emil Ivanov](https://github.com/vladev) * [:link:](sockjs-node/sockjs-node.d.ts) [sockjs-node 0.3.x](https://github.com/sockjs/sockjs-node) by [Phil McCloghry-Laing](https://github.com/pmccloghrylaing) * [:link:](soundjs/soundjs.d.ts) [SoundJS](http://www.createjs.com/#!/SoundJS) by [Pedro Ferreira](https://bitbucket.org/drk4) @@ -634,6 +640,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](xregexp/xregexp.d.ts) [XRegExp](http://xregexp.com) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](xsockets/XSockets.d.ts) [XSockets.NET](http://xsockets.net) by [Jeffery Grajkowski](https://github.com/pushplay) * [:link:](yargs/yargs.d.ts) [yargs](https://github.com/chevex/yargs) by [Martin Poelstra](https://github.com/poelstra) +* [:link:](yeoman-generator/yeoman-generator.d.ts) [yeoman-generator](https://github.com/yeoman/generator) by [Kentaro Okuno](http://github.com/armorik83) +* [:link:](yosay/yosay.d.ts) [yosay](https://github.com/yeoman/yosay) by [Kentaro Okuno](http://github.com/armorik83) * [:link:](youtube/youtube.d.ts) [YouTube](https://developers.google.com/youtube) by [Daz Wilkin](https://github.com/DazWilkin), [Ian Obermiller](http://ianobermiller.com) * [:link:](gapi.youtubeAnalytics/gapi.youtubeAnalytics.d.ts) [YouTube Analytics API](https://developers.google.com/youtube/analytics) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](gapi.youtube/gapi.youtube.d.ts) [YouTube Data API v3](https://developers.google.com/youtube/v3) by [Frank M](https://github.com/sgtfrankieboy) diff --git a/adm-zip/adm-zip-tests.ts b/adm-zip/adm-zip-tests.ts new file mode 100644 index 0000000000..f8583ae617 --- /dev/null +++ b/adm-zip/adm-zip-tests.ts @@ -0,0 +1,33 @@ +/// +import AdmZip = require("adm-zip"); + + +// reading archives +var zip = new AdmZip("./my_file.zip"); +var zipEntries = zip.getEntries(); // an array of ZipEntry records + +zipEntries.forEach(function (zipEntry) { + console.log(zipEntry.toString()); // outputs zip entries information + if (zipEntry.entryName == "my_file.txt") { + console.log(zipEntry.getData().toString('utf8')); + } +}); +// outputs the content of some_folder/my_file.txt +console.log(zip.readAsText("some_folder/my_file.txt")); +// extracts the specified file to the specified location +zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*overwrite*/true) +// extracts everything +zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true); + + +// creating archives +var zip = new AdmZip(); + +// add file directly +zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here"); +// add local file +zip.addLocalFile("/home/me/some_picture.png"); +// get everything as a buffer +var willSendthis = zip.toBuffer(); +// or write everything to disk +zip.writeZip(/*target file name*/"/home/me/files.zip"); diff --git a/adm-zip/adm-zip.d.ts b/adm-zip/adm-zip.d.ts new file mode 100644 index 0000000000..9f2eb7dfdb --- /dev/null +++ b/adm-zip/adm-zip.d.ts @@ -0,0 +1,300 @@ +// Type definitions for adm-zip v0.4.4 +// Project: https://github.com/cthackers/adm-zip +// Definitions by: John Vilk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module AdmZip { + class ZipFile { + /** + * Create a new, empty archive. + */ + constructor(); + /** + * Read an existing archive. + */ + constructor(fileName: string); + /** + * Extracts the given entry from the archive and returns the content as a + * Buffer object. + * @param entry String with the full path of the entry + * @return Buffer or Null in case of error + */ + readFile(entry: string): Buffer; + /** + * Extracts the given entry from the archive and returns the content as a + * Buffer object. + * @param entry ZipEntry object + * @return Buffer or Null in case of error + */ + readFile(entry: IZipEntry): Buffer; + /** + * Asynchronous readFile + * @param entry String with the full path of the entry + * @param callback Called with a Buffer or Null in case of error + */ + readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void; + /** + * Asynchronous readFile + * @param entry ZipEntry object + * @param callback Called with a Buffer or Null in case of error + * @return Buffer or Null in case of error + */ + readFileAsync(entry: IZipEntry, callback: (data: Buffer, err: string) => any): void; + /** + * Extracts the given entry from the archive and returns the content as + * plain text in the given encoding + * @param entry String with the full path of the entry + * @param encoding Optional. If no encoding is specified utf8 is used + * @return String + */ + readAsText(fileName: string, encoding?: string): string; + /** + * Extracts the given entry from the archive and returns the content as + * plain text in the given encoding + * @param entry ZipEntry object + * @param encoding Optional. If no encoding is specified utf8 is used + * @return String + */ + readAsText(fileName: IZipEntry, encoding?: string): string; + /** + * Asynchronous readAsText + * @param entry String with the full path of the entry + * @param callback Called with the resulting string. + * @param encoding Optional. If no encoding is specified utf8 is used + */ + readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void; + /** + * Asynchronous readAsText + * @param entry ZipEntry object + * @param callback Called with the resulting string. + * @param encoding Optional. If no encoding is specified utf8 is used + */ + readAsTextAsync(fileName: IZipEntry, callback: (data: string) => any, encoding?: string): void; + /** + * Remove the entry from the file or the entry and all its nested directories + * and files if the given entry is a directory + * @param entry String with the full path of the entry + */ + deleteFile(entry: string): void; + /** + * Remove the entry from the file or the entry and all its nested directories + * and files if the given entry is a directory + * @param entry A ZipEntry object. + */ + deleteFile(entry: IZipEntry): void; + /** + * Adds a comment to the zip. The zip must be rewritten after + * adding the comment. + * @param comment Content of the comment. + */ + addZipComment(comment: string): void; + /** + * Returns the zip comment + * @return The zip comment. + */ + getZipComment(): string; + /** + * Adds a comment to a specified zipEntry. The zip must be rewritten after + * adding the comment. + * The comment cannot exceed 65535 characters in length. + * @param entry String with the full path of the entry + * @param comment The comment to add to the entry. + */ + addZipEntryComment(entry: string, comment: string): void; + /** + * Adds a comment to a specified zipEntry. The zip must be rewritten after + * adding the comment. + * The comment cannot exceed 65535 characters in length. + * @param entry ZipEntry object. + * @param comment The comment to add to the entry. + */ + addZipEntryComment(entry: IZipEntry, comment: string): void; + /** + * Returns the comment of the specified entry. + * @param entry String with the full path of the entry. + * @return String The comment of the specified entry. + */ + getZipEntryComment(entry: string): string; + /** + * Returns the comment of the specified entry + * @param entry ZipEntry object. + * @return String The comment of the specified entry. + */ + getZipEntryComment(entry: IZipEntry): string; + /** + * Updates the content of an existing entry inside the archive. The zip + * must be rewritten after updating the content + * @param entry String with the full path of the entry. + * @param content The entry's new contents. + */ + updateFile(entry: string, content: Buffer): void; + /** + * Updates the content of an existing entry inside the archive. The zip + * must be rewritten after updating the content + * @param entry ZipEntry object. + * @param content The entry's new contents. + */ + updateFile(entry: IZipEntry, content: Buffer): void; + /** + * Adds a file from the disk to the archive. + * @param localPath Path to a file on disk. + * @param zipPath Path to a directory in the archive. Defaults to the empty + * string. + */ + addLocalFile(localPath: string, zipPath?: string): void; + /** + * Adds a local directory and all its nested files and directories to the + * archive. + * @param localPath Path to a folder on disk. + * @param zipPath Path to a folder in the archive. Defaults to an empty + * string. + */ + addLocalFolder(localPath: string, zipPath?: string): void; + /** + * Allows you to create a entry (file or directory) in the zip file. + * If you want to create a directory the entryName must end in / and a null + * buffer should be provided. + * @param entryName Entry path + * @param content Content to add to the entry; must be a 0-length buffer + * for a directory. + * @param comment Comment to add to the entry. + * @param attr Attribute to add to the entry. + */ + addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void; + /** + * Returns an array of ZipEntry objects representing the files and folders + * inside the archive + */ + getEntries(): IZipEntry[]; + /** + * Returns a ZipEntry object representing the file or folder specified by + * ``name``. + * @param name Name of the file or folder to retrieve. + * @return ZipEntry The entry corresponding to the name. + */ + getEntry(name: string): IZipEntry; + /** + * Extracts the given entry to the given targetPath. + * If the entry is a directory inside the archive, the entire directory and + * its subdirectories will be extracted. + * @param entry String with the full path of the entry + * @param targetPath Target folder where to write the file + * @param maintainEntryPath If maintainEntryPath is true and the entry is + * inside a folder, the entry folder will be created in targetPath as + * well. Default is TRUE + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is true. Default is FALSE + * + * @return Boolean + */ + extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean; + /** + * Extracts the given entry to the given targetPath. + * If the entry is a directory inside the archive, the entire directory and + * its subdirectories will be extracted. + * @param entry ZipEntry object + * @param targetPath Target folder where to write the file + * @param maintainEntryPath If maintainEntryPath is true and the entry is + * inside a folder, the entry folder will be created in targetPath as + * well. Default is TRUE + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is true. Default is FALSE + * @return Boolean + */ + extractEntryTo(entryPath: IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean; + /** + * Extracts the entire archive to the given location + * @param targetPath Target location + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is true. Default is FALSE + */ + extractAllTo(targetPath: string, overwrite?: boolean): void; + /** + * Writes the newly created zip file to disk at the specified location or + * if a zip was opened and no ``targetFileName`` is provided, it will + * overwrite the opened zip + * @param targetFileName + */ + writeZip(targetPath?: string): void; + /** + * Returns the content of the entire zip file as a Buffer object + * @return Buffer + */ + toBuffer(): Buffer; + } + + /** + * The ZipEntry is more than a structure representing the entry inside the + * zip file. Beside the normal attributes and headers a entry can have, the + * class contains a reference to the part of the file where the compressed + * data resides and decompresses it when requested. It also compresses the + * data and creates the headers required to write in the zip file. + */ + interface IZipEntry { + /** + * Represents the full name and path of the file + */ + entryName: string; + rawEntryName: Buffer; + /** + * Extra data associated with this entry. + */ + extra: Buffer; + /** + * Entry comment. + */ + comment: string; + name: string; + /** + * Read-Only property that indicates the type of the entry. + */ + isDirectory: boolean; + /** + * Get the header associated with this ZipEntry. + */ + header: Buffer; + /** + * Retrieve the compressed data for this entry. Note that this may trigger + * compression if any properties were modified. + */ + getCompressedData(): Buffer; + /** + * Asynchronously retrieve the compressed data for this entry. Note that + * this may trigger compression if any properties were modified. + */ + getCompressedDataAsync(callback: (data: Buffer) => void): void; + /** + * Set the (uncompressed) data to be associated with this entry. + */ + setData(value: string): void; + /** + * Set the (uncompressed) data to be associated with this entry. + */ + setData(value: Buffer): void; + /** + * Get the decompressed data associated with this entry. + */ + getData(): Buffer; + /** + * Asynchronously get the decompressed data associated with this entry. + */ + getDataAsync(callback: (data: Buffer) => void): void; + /** + * Returns the CEN Entry Header to be written to the output zip file, plus + * the extra data and the entry comment. + */ + packHeader(): Buffer; + /** + * Returns a nicely formatted string with the most important properties of + * the ZipEntry. + */ + toString(): string; + } +} + +declare module "adm-zip" { + import zipFile = AdmZip.ZipFile; + export = zipFile; +} diff --git a/angularfire/angularfire-tests.ts b/angularfire/angularfire-tests.ts index eced9d7fe7..7d39e4181d 100644 --- a/angularfire/angularfire-tests.ts +++ b/angularfire/angularfire-tests.ts @@ -3,53 +3,166 @@ var myapp = angular.module("myapp", ["firebase"]); interface AngularFireScope extends ng.IScope { - items: AngularFire; - remoteItems: RemoteItems; -} - -interface RemoteItems { - bar: string; + data: any; } var url = "https://myapp.firebaseio.com"; -myapp.controller("MyController", ["$scope", "$firebase", - function($scope: AngularFireScope, $firebase: AngularFireService) { - $scope.items = $firebase(new Firebase(url)); - $scope.items.$add({ foo: "bar" }); - $scope.items.$remove("foo"); - $scope.items.$remove(); - $scope.items.$save(); - var child = $scope.items.$child("foo"); - child.$remove(); - $scope.items.$set({ bar: "baz" }); - var keys = $scope.items.$getIndex(); - keys.forEach(function(key, i) { - console.log(i, ($scope.items)[key]); - }); - $scope.items.$on("loaded", function() { - console.log("Initial data received!"); - }); - $scope.items.$on("change", function() { - console.log("A remote change was applied locally!"); - }); - $scope.items.$off('loaded'); - function stopSync() { - $scope.items.$off(); +myapp.controller("MyController", ["$scope", "$firebase", '$FirebaseObject', '$FirebaseArray', + function ($scope: AngularFireScope, $firebase: AngularFireService, $FirebaseObject: AngularFireObjectService, $FirebaseArray: AngularFireArrayService) { + var ref = new Firebase(url); + var sync = $firebase(ref); + + // AngularFire + { + sync.$asArray(); + sync.$asObject(); + sync.$ref(); + sync.$remove(); + sync.$push({ foo: "foo data" }); + sync.$set("foo", 1); + sync.$set({ foo: 2 }); + sync.$update({ foo: 3 }); + sync.$update("foo", { bar: 1 }); + + // Increment the message count by 1 + sync.$transaction('count', function (currentCount) { + if (!currentCount) return 1; // Initial value for counter. + if (currentCount < 0) return; // Return undefined to abort transaction. + return currentCount + 1; // Increment the count by 1. + }).then(function (snapshot) { + if (!snapshot) { + // Handle aborted transaction. + } else { + // Do something. + console.log(snapshot.val()); + } + }, function (err) { + // Handle the error condition. + console.log(err.stack); + }); + } + + + // AngularFireObject + { + var obj = sync.$asObject(); + + // $id + if (obj.$id !== ref.name()) throw "error"; + + // $loaded() + obj.$loaded().then((data) => { + if (data !== obj) throw "error"; + // $priority + obj.$priority; + + // $value, $save() + obj.$value = "foobar"; + obj.$save(); + }); + + // $inst() + if (obj.$inst() !== sync) throw "error"; + + // $bindTo() + obj.$bindTo($scope, "data").then(function () { + console.log($scope.data); + $scope.data.foo = "baz"; // will be saved to Firebase + sync.$set({ foo: "baz" }); // this would update Firebase and $scope.data + }); + + // $watch() + var unwatch = obj.$watch(function () { + console.log("data changed!"); + }); + unwatch(); + + // $destroy() + obj.$destroy(); + + // $extendFactory() + var NewFactory = $FirebaseObject.$extendFactory({ + getMyFavoriteColor: function () { + return this.favoriteColor + ", no green!"; // obscure Monty Python reference + } + }); + var customObj = $firebase(ref, { objectFactory: NewFactory }).$asObject(); + } + + // AngularFireArray + { + var list = sync.$asArray(); + + // $inst() + if (list.$inst() !== sync) throw "error"; + + // $add() + list.$add({ foo: "foo value" }); + + // $keyAt() + var key = list.$keyAt(0); + + // $indexFor() + var index = list.$indexFor(key); + + // $getRecord() + var item = list.$getRecord(key); + + // $save() + item["bar"] = "bar value"; + list.$save(item); + + // $remove() + list.$remove(item); + + // $loaded() + list.$loaded().then(data => { + if (data !== list) throw "error"; + }); + + // $watch() + var unwatch = list.$watch((event, key, prevChild) => { + switch (event) { + case "child_added": + console.log(key + " added"); + break; + case "child_changed": + console.log(key + " changed"); + break; + case "child_moved": + console.log(key + " moved"); + break; + case "child_removed": + console.log(key + " removed"); + break; + default: + throw "error"; + } + }); + unwatch(); + + // $destroy() + list.$destroy(); + + // $extendFactory() + var ArrayWithSum = $FirebaseArray.$extendFactory({ + sum: function () { + var total = 0; + angular.forEach(this.$list, function (rec) { + total += rec.x; + }); + return total; + } + }); + var list = $firebase(ref, { arrayFactory: ArrayWithSum }).$asArray(); + list.$loaded().then(function () { + console.log("List has " + (list).sum() + " items"); + }); } - $scope.items.$bind($scope, "remoteItems"); - $scope.remoteItems.bar = "foo"; - $scope.items.$bind($scope, "remote").then(function(unbind) { - unbind(); - $scope.remoteItems.bar = "foo"; - }); } ]); -var foo: AngularFireObject = { - $priority: 0 -}; - interface AngularFireAuthScope extends ng.IScope { loginObj: AngularFireAuth; } diff --git a/angularfire/angularfire.d.ts b/angularfire/angularfire.d.ts index 3f2b0aa106..0bebb23c52 100644 --- a/angularfire/angularfire.d.ts +++ b/angularfire/angularfire.d.ts @@ -1,4 +1,4 @@ -// Type definitions for AngularFire 0.6.0 +// Type definitions for AngularFire 0.8.2 // Project: http://angularfire.com // Definitions by: Dénes Harmath // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -7,24 +7,65 @@ /// interface AngularFireService { - (firebase: Firebase): AngularFire; + (firebase: Firebase, config?: any): AngularFire; } interface AngularFire { - $add(value: any): void; - $remove(key?: string): void; - $save(key?: string): void; - $child(key: string): AngularFire; - $set(value: any): void; - $getIndex(): string[]; - $on(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; - $off(eventType?: string, callback?: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; - $bind($scope: ng.IScope, modelName: string): ng.IPromise; + $asArray(): AngularFireArray; + $asObject(): AngularFireObject; + $ref(): Firebase; + $push(data: any): ng.IPromise; + $set(key: string, data: any): ng.IPromise; + $set(data: any): ng.IPromise; + $remove(key?: string): ng.IPromise; + $update(key: string, data: Object): ng.IPromise; + $update(data: any): ng.IPromise; + $transaction(updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise; + $transaction(key:string, updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise; } -interface AngularFireObject { - $priority: number; +interface AngularFireObject extends AngularFireSimpleObject { + $id: string; + $priority: number; + $value: any; + $save(): ng.IPromise; + $loaded(resolve?: (x: AngularFireObject) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise; + $loaded(resolve?: (x: AngularFireObject) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise; + $loaded(resolve?: (x: AngularFireObject) => void, reject?: (err: any) => any): ng.IPromise; + $inst(): AngularFire; + $bindTo(scope: ng.IScope, varName: string): ng.IPromise; + $watch(callback: Function, context?: any): Function; + $destroy(): void; } +interface AngularFireObjectService { + $extendFactory(ChildClass: Object, methods?: Object): Object; +} + +interface AngularFireArray extends Array { + $add(newData: any): ng.IPromise; + $save(recordOrIndex: any): ng.IPromise; + $remove(recordOrIndex: any): ng.IPromise; + $getRecord(key: string): AngularFireSimpleObject; + $keyAt(recordOrIndex: any): string; + $indexFor(key: string): number; + $loaded(resolve?: (x: AngularFireArray) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise; + $loaded(resolve?: (x: AngularFireArray) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise; + $loaded(resolve?: (x: AngularFireArray) => void, reject?: (err: any) => any): ng.IPromise; + $inst(): AngularFire; + $watch(cb: (event: string, key: string, prevChild: string) => void, context?: any): Function; + $destroy(): void; +} +interface AngularFireArrayService { + $extendFactory(ChildClass: Object, methods?: Object): Object; +} + +interface AngularFireSimpleObject { + $id: string; + $priority: number; + $value: any; + [key: string]: any; +} + interface AngularFireAuthService { (firebase: Firebase): AngularFireAuth; @@ -34,7 +75,7 @@ interface AngularFireAuth { $getCurrentUser(): ng.IPromise; $login(provider: string, options?: Object): ng.IPromise; $logout(): void; - $createUser(email: string, password: string, noLogin?: boolean): ng.IPromise; + $createUser(email: string, password: string): ng.IPromise; $changePassword(email: string, oldPassword: string, newPassword: string): ng.IPromise; $removeUser(email: string, password: string): ng.IPromise; $sendPasswordResetEmail(email: string): ng.IPromise; diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index aa12399e5e..a01c93ef5b 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2+ (ngAnimate module) +// Type definitions for Angular JS 1.3 (ngAnimate module) // Project: http://angularjs.org // Definitions by: Michel Salib , Adi Dahiya // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts index 6222216750..dc0c449089 100644 --- a/angularjs/angular-cookies.d.ts +++ b/angularjs/angular-cookies.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2 (ngCookies module) +// Type definitions for Angular JS 1.3 (ngCookies module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index 2591c006e9..877071127f 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module) +// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 597a58e401..ed08c77dd9 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2 (ngResource module) +// Type definitions for Angular JS 1.3 (ngResource module) // Project: http://angularjs.org // Definitions by: Diego Vilar , Michael Jess // Definitions: https://github.com/daptiv/DefinitelyTyped @@ -11,6 +11,16 @@ /////////////////////////////////////////////////////////////////////////////// declare module ng.resource { + /** + * Currently supported options for the $resource factory options argument. + */ + interface IResourceOptions { + /** + * If true then the trailing slashes from any calculated URL will be stripped (defaults to true) + */ + stripTrailingSlashes?: boolean; + } + /////////////////////////////////////////////////////////////////////////// // ResourceService // see http://docs.angularjs.org/api/ngResource.$resource @@ -20,17 +30,17 @@ declare module ng.resource { /////////////////////////////////////////////////////////////////////////// interface IResourceService { (url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): IResourceClass>; + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass>; (url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): U; + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): U; (url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): IResourceClass; + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass; } // Just a reference to facilitate describing new actions diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index a71299e258..949680bf2d 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2 (ngRoute module) +// Type definitions for Angular JS 1.3 (ngRoute module) // Project: http://angularjs.org // Definitions by: Jonathan Park // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-sanitize.d.ts b/angularjs/angular-sanitize.d.ts index a28bdb0d77..6fde0baef9 100644 --- a/angularjs/angular-sanitize.d.ts +++ b/angularjs/angular-sanitize.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.2 (ngSanitize module) +// Type definitions for Angular JS 1.3 (ngSanitize module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-scenario.d.ts b/angularjs/angular-scenario.d.ts index ee71ffbea0..d1b7b19f61 100644 --- a/angularjs/angular-scenario.d.ts +++ b/angularjs/angular-scenario.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular Scenario Testing +// Type definitions for Angular Scenario Testing 1.3 (ngScenario module) // Project: http://angularjs.org // Definitions by: RomanoLindano // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/legacy/angular-1.2.d.ts b/angularjs/legacy/angular-1.2.d.ts index a1a4cb15be..fb21b030a6 100644 --- a/angularjs/legacy/angular-1.2.d.ts +++ b/angularjs/legacy/angular-1.2.d.ts @@ -410,6 +410,13 @@ declare module ng { cancel(promise: IPromise): boolean; } + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + /////////////////////////////////////////////////////////////////////////// // FilterService // see http://docs.angularjs.org/api/ng.$filter diff --git a/angularjs/legacy/angular-animate-1.2.d.ts b/angularjs/legacy/angular-animate-1.2.d.ts new file mode 100644 index 0000000000..307e50760c --- /dev/null +++ b/angularjs/legacy/angular-animate-1.2.d.ts @@ -0,0 +1,110 @@ +// Type definitions for Angular JS 1.2 (ngAnimate module) +// Project: http://angularjs.org +// Definitions by: Michel Salib , Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngAnimate module (angular-animate.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.animate { + + /////////////////////////////////////////////////////////////////////////// + // AnimateService + // see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/service/$animate + /////////////////////////////////////////////////////////////////////////// + interface IAnimateService extends ng.IAnimateService { + /** + * Globally enables / disables animations. + * + * @param value If provided then set the animation on or off. + * @param element If provided then the element will be used to represent the enable/disable operation. + * @returns current animation state + */ + enabled(value?: boolean, element?: JQuery): boolean; + + /** + * Appends the element to the parentElement element that resides in the document and then runs the enter animation. + * + * @param element the element that will be the focus of the enter animation + * @param parentElement the parent element of the element that will be the focus of the enter animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void; + + /** + * Runs the leave animation operation and, upon completion, removes the element from the DOM. + * + * @param element the element that will be the focus of the leave animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + leave(element: JQuery, doneCallback?: () => void): void; + + /** + * Fires the move DOM operation. Just before the animation starts, the animate service will either append + * it into the parentElement container or add the element directly after the afterElement element if present. + * Then the move animation will be run. + * + * @param element the element that will be the focus of the move animation + * @param parentElement the parent element of the element that will be the focus of the move animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void; + + /** + * Triggers a custom animation event based off the className variable and then attaches the className + * value to the element as a CSS class. + * + * @param element the element that will be animated + * @param className the CSS class that will be added to the element and then animated + * @param doneCallback the callback function that will be called once the animation is complete + */ + addClass(element: JQuery, className: string, doneCallback?: () => void): void; + + /** + * Triggers a custom animation event based off the className variable and then removes the CSS class + * provided by the className value from the element. + * + * @param element the element that will be animated + * @param className the CSS class that will be animated and then removed from the element + * @param doneCallback the callback function that will be called once the animation is complete + */ + removeClass(element: JQuery, className: string, doneCallback?: () => void): void; + + /** + * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback + * will be fired (if provided). + * + * @param element the element which will have its CSS classes changed removed from it + * @param add the CSS classes which will be added to the element + * @param remove the CSS class which will be removed from the element CSS classes have been set on the element + * @param doneCallback done the callback function (if provided) that will be fired after the CSS classes have been set on the element + */ + setClass(element: JQuery, add: string, remove: string, doneCallback?: () => void): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => ng.IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } +} diff --git a/angularjs/legacy/angular-cookies-1.2.d.ts b/angularjs/legacy/angular-cookies-1.2.d.ts new file mode 100644 index 0000000000..c5ff512e84 --- /dev/null +++ b/angularjs/legacy/angular-cookies-1.2.d.ts @@ -0,0 +1,43 @@ +// Type definitions for Angular JS 1.2 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService {} + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + /** + * Returns the value of given cookie key + * @param key Id to use for lookup + */ + get(key: string): any; + /** + * Sets a value for given cookie key + * @param key Id for the value + * @param value Value to be stored + */ + put(key: string, value: any): void; + /** + * Remove given cookie + * @param key Id of the key-value pair to delete + */ + remove(key: string): void; + } + +} diff --git a/angularjs/legacy/angular-mocks-1.2-tests.ts b/angularjs/legacy/angular-mocks-1.2-tests.ts new file mode 100644 index 0000000000..6f359a67c4 --- /dev/null +++ b/angularjs/legacy/angular-mocks-1.2-tests.ts @@ -0,0 +1,305 @@ +/// + +/////////////////////////////////////// +// IAngularStatic +/////////////////////////////////////// +var angular: ng.IAngularStatic; +var mock: ng.IMockStatic; + +mock = angular.mock; + + +/////////////////////////////////////// +// IMockStatic +/////////////////////////////////////// +var date: Date; + +mock.dump({ key: 'value' }); + +mock.inject( + function () { return 1; }, + function () { return 2; } + ); + +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]); + +// This overload is not documented on the website, but flows from +// how the injector works. +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }], + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]); + +mock.module('module1', 'module2'); +mock.module( + function () { return 1; }, + function () { return 2; } + ); +mock.module({ module1: function () { return 1; } }); + +date = mock.TzDate(-7, '2013-1-1T15:00:00Z'); +date = mock.TzDate(-8, 12345678); + + +/////////////////////////////////////// +// IExceptionHandlerProvider +/////////////////////////////////////// +var exceptionHandlerProvider: ng.IExceptionHandlerProvider; + +exceptionHandlerProvider.mode('log'); + + +/////////////////////////////////////// +// ITimeoutService +/////////////////////////////////////// +var timeoutService: ng.ITimeoutService; + +timeoutService.flush(); +timeoutService.flush(1234); +timeoutService.flushNext(); +timeoutService.flushNext(1234); +timeoutService.verifyNoPendingTasks(); + +//////////////////////////////////////// +// IIntervalService +//////////////////////////////////////// +var intervalService: ng.IIntervalService; +var intervalServiceTimeActuallyAdvanced: number; + +intervalServiceTimeActuallyAdvanced = intervalService.flush(); +intervalServiceTimeActuallyAdvanced = intervalService.flush(1234); + +/////////////////////////////////////// +// ILogService, ILogCall +/////////////////////////////////////// +var logService: ng.ILogService; +var logCall: ng.ILogCall; +var logs: string[]; + +logService.assertEmpty(); +logService.reset(); + +logCall = logService.debug; +logCall = logService.error; +logCall = logService.info; +logCall = logService.log; +logCall = logService.warn; + +logs = logCall.logs; + + +/////////////////////////////////////// +// IHttpBackendService +/////////////////////////////////////// +var httpBackendService: ng.IHttpBackendService; +var requestHandler: ng.mock.IRequestHandler; + +httpBackendService.flush(); +httpBackendService.flush(1234); +httpBackendService.resetExpectations(); +httpBackendService.verifyNoOutstandingExpectation(); +httpBackendService.verifyNoOutstandingRequest(); + +requestHandler = httpBackendService.expect('GET', 'http://test.local'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.expectDELETE('http://test.local'); +requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectGET('http://test.local'); +requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectHEAD('http://test.local'); +requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectJSONP('http://test.local'); +requestHandler = httpBackendService.expectJSONP(/test.local/); + +requestHandler = httpBackendService.expectPATCH('http://test.local'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPOST('http://test.local'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPUT('http://test.local'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.when('GET', 'http://test.local'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.whenDELETE('http://test.local'); +requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenGET('http://test.local'); +requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenHEAD('http://test.local'); +requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenJSONP('http://test.local'); +requestHandler = httpBackendService.whenJSONP(/test.local/); + +requestHandler = httpBackendService.whenPATCH('http://test.local'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPOST('http://test.local'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPUT('http://test.local'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' }); + + +/////////////////////////////////////// +// IRequestHandler +/////////////////////////////////////// +requestHandler.passThrough(); +requestHandler.respond(function () { }); +requestHandler.respond({ key: 'value' }); +requestHandler.respond({ key: 'value' }, { header: 'value' }); +requestHandler.respond(404); +requestHandler.respond(404, { key: 'value' }); +requestHandler.respond(404, { key: 'value' }, { header: 'value' }); diff --git a/angularjs/legacy/angular-mocks-1.2.d.ts b/angularjs/legacy/angular-mocks-1.2.d.ts new file mode 100644 index 0000000000..e9b0dc8d24 --- /dev/null +++ b/angularjs/legacy/angular-mocks-1.2.d.ts @@ -0,0 +1,226 @@ +// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.dump + dump(obj: any): string; + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.inject + inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.module + module(...modules: any[]): any; + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/type/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$exceptionHandler + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/provider/$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$interval + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + flush(millis?: number): number; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface ILogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/angularjs/legacy/angular-resource-1.2-tests.ts b/angularjs/legacy/angular-resource-1.2-tests.ts new file mode 100644 index 0000000000..ca970f5c40 --- /dev/null +++ b/angularjs/legacy/angular-resource-1.2-tests.ts @@ -0,0 +1,138 @@ +/// + +interface IMyResource extends ng.resource.IResource { }; +interface IMyResourceClass extends ng.resource.IResourceClass { }; + +/////////////////////////////////////// +// IActionDescriptor +/////////////////////////////////////// +var actionDescriptor: ng.resource.IActionDescriptor; + +actionDescriptor.headers = { header: 'value' }; +actionDescriptor.isArray = true; +actionDescriptor.method = 'method action'; +actionDescriptor.params = { key: 'value' }; + + +/////////////////////////////////////// +// IResourceClass +/////////////////////////////////////// +var resourceClass: IMyResourceClass; +var resource: IMyResource; +var resourceArray: ng.resource.IResourceArray; + +resource = resourceClass.delete(); +resource = resourceClass.delete({ key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, function () { }); +resource = resourceClass.delete(function () { }); +resource = resourceClass.delete(function () { }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resource.$promise.then(function(data: IMyResource) {}); + +resource = resourceClass.get(); +resource = resourceClass.get({ key: 'value' }); +resource = resourceClass.get({ key: 'value' }, function () { }); +resource = resourceClass.get(function () { }); +resource = resourceClass.get(function () { }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resourceArray = resourceClass.query(); +resourceArray = resourceClass.query({ key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, function () { }); +resourceArray = resourceClass.query(function () { }); +resourceArray = resourceClass.query(function () { }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resourceArray.push(resource); +resourceArray.$promise.then(function(data: ng.resource.IResourceArray) {}); + +resource = resourceClass.remove(); +resource = resourceClass.remove({ key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, function () { }); +resource = resourceClass.remove(function () { }); +resource = resourceClass.remove(function () { }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.save(); +resource = resourceClass.save({ key: 'value' }); +resource = resourceClass.save({ key: 'value' }, function () { }); +resource = resourceClass.save(function () { }); +resource = resourceClass.save(function () { }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// + +var promise : ng.IPromise; +var arrayPromise : ng.IPromise; + +promise = resource.$delete(); +promise = resource.$delete({ key: 'value' }); +promise = resource.$delete({ key: 'value' }, function () { }); +promise = resource.$delete(function () { }); +promise = resource.$delete(function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, function () { }, function () { }); +promise.then(function(data: IMyResource) {}); + +promise = resource.$get(); +promise = resource.$get({ key: 'value' }); +promise = resource.$get({ key: 'value' }, function () { }); +promise = resource.$get(function () { }); +promise = resource.$get(function () { }, function () { }); +promise = resource.$get({ key: 'value' }, function () { }, function () { }); + +arrayPromise = resourceArray[0].$query(); +arrayPromise = resourceArray[0].$query({ key: 'value' }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); +arrayPromise = resourceArray[0].$query(function () { }); +arrayPromise = resourceArray[0].$query(function () { }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { }); +arrayPromise.then(function(data: ng.resource.IResourceArray) {}); + +promise = resource.$remove(); +promise = resource.$remove({ key: 'value' }); +promise = resource.$remove({ key: 'value' }, function () { }); +promise = resource.$remove(function () { }); +promise = resource.$remove(function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, function () { }, function () { }); + +promise = resource.$save(); +promise = resource.$save({ key: 'value' }); +promise = resource.$save({ key: 'value' }, function () { }); +promise = resource.$save(function () { }); +promise = resource.$save(function () { }, function () { }); +promise = resource.$save({ key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResourceService +/////////////////////////////////////// +var resourceService: ng.resource.IResourceService; +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); + +/////////////////////////////////////// +// IModule +/////////////////////////////////////// +var mod: ng.IModule; +var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction; +var resourceService: ng.resource.IResourceService; + +resourceClass = resourceServiceFactoryFunction(resourceService); + +resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return resourceClass; }; +mod = mod.factory('factory name', resourceServiceFactoryFunction); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// \ No newline at end of file diff --git a/angularjs/legacy/angular-resource-1.2.d.ts b/angularjs/legacy/angular-resource-1.2.d.ts new file mode 100644 index 0000000000..f3c3fbe65c --- /dev/null +++ b/angularjs/legacy/angular-resource-1.2.d.ts @@ -0,0 +1,152 @@ +// Type definitions for Angular JS 1.2 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar , Michael Jess +// Definitions: https://github.com/daptiv/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see https://code.angularjs.org/1.2.26/docs/api/ngResource/service/$resource + // Most of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass>; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): U; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + // + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + // + // Only those methods with an HTTP body do have 'data' as first parameter: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // More specifically, those methods are POST, PUT and PATCH: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // + // Also, static calls always return the IResource (or IResourceArray) retrieved + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 + interface IResourceClass { + new(dataOrParams? : any) : T; + get(): T; + get(params: Object): T; + get(success: Function, error?: Function): T; + get(params: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function, error?: Function): T; + + query(): IResourceArray; + query(params: Object): IResourceArray; + query(success: Function, error?: Function): IResourceArray; + query(params: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray; + + save(): T; + save(data: Object): T; + save(success: Function, error?: Function): T; + save(data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function, error?: Function): T; + + remove(): T; + remove(params: Object): T; + remove(success: Function, error?: Function): T; + remove(params: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function, error?: Function): T; + + delete(): T; + delete(params: Object): T; + delete(success: Function, error?: Function): T; + delete(params: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function, error?: Function): T; + } + + // Instance calls always return the the promise of the request which retrieved the object + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 + interface IResource { + $get(): ng.IPromise; + $get(params?: Object, success?: Function, error?: Function): ng.IPromise; + $get(success: Function, error?: Function): ng.IPromise; + + $query(): ng.IPromise>; + $query(params?: Object, success?: Function, error?: Function): ng.IPromise>; + $query(success: Function, error?: Function): ng.IPromise>; + + $save(): ng.IPromise; + $save(params?: Object, success?: Function, error?: Function): ng.IPromise; + $save(success: Function, error?: Function): ng.IPromise; + + $remove(): ng.IPromise; + $remove(params?: Object, success?: Function, error?: Function): ng.IPromise; + $remove(success: Function, error?: Function): ng.IPromise; + + $delete(): ng.IPromise; + $delete(params?: Object, success?: Function, error?: Function): ng.IPromise; + $delete(success: Function, error?: Function): ng.IPromise; + + /** the promise of the original server interaction that created this instance. **/ + $promise : ng.IPromise; + $resolved : boolean; + } + + /** + * Really just a regular Array object with $promise and $resolve attached to it + */ + interface IResourceArray extends Array { + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): IResourceClass; + >($resource: ng.resource.IResourceService): U; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} + +interface Array +{ + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; +} diff --git a/angularjs/legacy/angular-route-1.2-tests.ts b/angularjs/legacy/angular-route-1.2-tests.ts new file mode 100644 index 0000000000..0b82110ef2 --- /dev/null +++ b/angularjs/legacy/angular-route-1.2-tests.ts @@ -0,0 +1,17 @@ +/// + +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2013 Jonathan Park @ Daptiv Solutions Inc + * License: MIT + */ + +declare var $routeProvider: ng.route.IRouteProvider; +$routeProvider + .when('/projects/:projectId/dashboard',{ + controller: '', + templateUrl: '', + caseInsensitiveMatch: true, + reloadOnSearch: false + }) + .otherwise({redirectTo: '/'}); diff --git a/angularjs/legacy/angular-route-1.2.d.ts b/angularjs/legacy/angular-route-1.2.d.ts new file mode 100644 index 0000000000..7afd4af5a5 --- /dev/null +++ b/angularjs/legacy/angular-route-1.2.d.ts @@ -0,0 +1,145 @@ +// Type definitions for Angular JS 1.2 (ngRoute module) +// Project: http://angularjs.org +// Definitions by: Jonathan Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngRoute module (angular-route.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.route { + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + /** + * Causes $route service to reload the current route even if $location hasn't changed. + * As a result of that, ngView creates new scope, reinstantiates the controller. + */ + reload(): void; + + /** + * Object with all route configuration Objects as its properties. + */ + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + + /** + * see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider#when for API documentation + */ + interface IRoute { + /** + * {(string|function()=} + * Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string. + */ + controller?: any; + /** + * A controller alias name. If present the controller will be published to scope under the controllerAs name. + */ + controllerAs?: string; + /** + * Undocumented? + */ + name?: string; + /** + * {string=|function()=} + * Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl. + * + * If template is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + template?: string; + /** + * {string=|function()=} + * Path or function that returns a path to an html template that should be used by ngView. + * + * If templateUrl is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + templateUrl?: any; + /** + * {Object.=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is: + * + * - key - {string}: a name of a dependency to be injected into the controller. + * - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead. + */ + resolve?: {[key: string]: any}; + /** + * {(string|function())=} + * Value to update $location path with and trigger route redirection. + * + * If redirectTo is a function, it will be called with the following parameters: + * + * - {Object.} - route parameters extracted from the current $location.path() by applying the current route templateUrl. + * - {string} - current $location.path() + * - {Object} - current $location.search() + * - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search(). + */ + redirectTo?: any; + /** + * Reload route when only $location.search() or $location.hash() changes. + * + * This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope. + */ + reloadOnSearch?: boolean; + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ + caseInsensitiveMatch?: boolean; + } + + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + /** + * Sets route definition that will be used on route change when no other route definition is matched. + * + * @params Mapping information to be assigned to $route.current. + */ + otherwise(params: IRoute): IRouteProvider; + /** + * Adds a new route definition to the $route service. + * + * @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition. + * + * - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches. + * - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches. + * - path can contain optional named groups with a question mark: e.g.:name?. + * + * For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes. + * + * @param route Mapping information to be assigned to $route.current on route match. + */ + when(path: string, route: IRoute): IRouteProvider; + } +} diff --git a/angularjs/legacy/angular-sanitize-1.2-tests.ts b/angularjs/legacy/angular-sanitize-1.2-tests.ts new file mode 100644 index 0000000000..853bbf3495 --- /dev/null +++ b/angularjs/legacy/angular-sanitize-1.2-tests.ts @@ -0,0 +1,10 @@ +/// + +var shouldBeString: string; + +declare var $sanitizeService: ng.sanitize.ISanitizeService; +shouldBeString = $sanitizeService(shouldBeString); + +declare var $linky: ng.sanitize.filter.ILinky; +shouldBeString = $linky(shouldBeString); +shouldBeString = $linky(shouldBeString, shouldBeString); diff --git a/angularjs/legacy/angular-sanitize-1.2.d.ts b/angularjs/legacy/angular-sanitize-1.2.d.ts new file mode 100644 index 0000000000..4c6805c9a4 --- /dev/null +++ b/angularjs/legacy/angular-sanitize-1.2.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Angular JS 1.2 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/service/$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + + /////////////////////////////////////////////////////////////////////////// + // Filters included with the ngSanitize + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter + /////////////////////////////////////////////////////////////////////////// + export module filter { + + // Finds links in text input and turns them into html links. + // Supports http/https/ftp/mailto and plain email address links. + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter/linky + interface ILinky { + (text: string, target?: string): string; + } + } +} diff --git a/angularjs/legacy/angular-scenario-1.0.d.ts b/angularjs/legacy/angular-scenario-1.0.d.ts index 8dd605f7d8..a44b79096c 100644 --- a/angularjs/legacy/angular-scenario-1.0.d.ts +++ b/angularjs/legacy/angular-scenario-1.0.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular Scenario Testing +// Type definitions for Angular Scenario Testing 1.0 (ngScenario module) // Project: [http://angularjs.org] // Definitions by: [RomanoLindano] // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/legacy/angular-scenario-1.2.d.ts b/angularjs/legacy/angular-scenario-1.2.d.ts new file mode 100644 index 0000000000..9e72db8956 --- /dev/null +++ b/angularjs/legacy/angular-scenario-1.2.d.ts @@ -0,0 +1,166 @@ +// Type definitions for Angular Scenario Testing 1.2 (ngScenario module) +// Project: http://angularjs.org +// Definitions by: RomanoLindano +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng { + export interface IAngularStatic { + scenario: any; + } +} + +declare module angularScenario { + + export interface RunFunction { + (functionToRun: any): any; + } + export interface RunFunctionWithDescription { + (description: string, functionToRun: any): any; + } + + export interface PauseFunction { + (): any; + } + + export interface SleepFunction { + (seconds: number): any; + } + + export interface Future { + } + + export interface testWindow { + href(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface testLocation { + url(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface Browser { + navigateTo(url: string): void; + navigateTo(urlDescription: string, urlFunction: () => string): void; + reload(): void; + window(): testWindow; + location(): testLocation; + } + + export interface Matchers { + toEqual(value: any): void; + toBe(value: any): void; + toBeDefined(): void; + toBeTruthy(): void; + toBeFalsy(): void; + toMatch(regularExpression: any): void; + toBeNull(): void; + toContain(value: any): void; + toBeLessThan(value: any): void; + toBeGreaterThan(value: any): void; + } + + export interface CustomMatchers extends Matchers { + } + + export interface Expect extends CustomMatchers { + not(): angularScenario.CustomMatchers; + } + + export interface UsingFunction { + (selector: string, selectorDescription?: string): void; + } + + export interface BindingFunction { + (bracketBindingExpression: string): Future; + } + + export interface Input { + enter(value: any): any; + check(): any; + select(radioButtonValue: any): any; + val(): Future; + } + + export interface Repeater { + count(): Future; + row(index: number): Future; + column(ngBindingExpression: string): Future; + } + + export interface Select { + option(value: any): any; + option(...listOfValues: any[]): any; + } + + export interface Element { + count(): Future; + click(): any; + dblclick(): any; + mouseover(): any; + mousedown(): any; + mouseup(): any; + query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any; + val(): Future; + text(): Future; + html(): Future; + height(): Future; + innerHeight(): Future; + outerHeight(): Future; + width(): Future; + innerWidth(): Future; + outerWidth(): Future; + position(): Future; + scrollLeft(): Future; + scrollTop(): Future; + offset(): Future; + + val(value: any): void; + text(value: any): void; + html(value: any): void; + height(value: any): void; + innerHeight(value: any): void; + outerHeight(value: any): void; + width(value: any): void; + innerWidth(value: any): void; + outerWidth(value: any): void; + position(value: any): void; + scrollLeft(value: any): void; + scrollTop(value: any): void; + offset(value: any): void; + + attr(key: any): Future; + prop(key: any): Future; + css(key: any): Future; + + attr(key: any, value: any): void; + prop(key: any, value: any): void; + css(key: any, value: any): void; + } +} + +declare var describe: angularScenario.RunFunctionWithDescription; +declare var ddescribe: angularScenario.RunFunctionWithDescription; +declare var xdescribe: angularScenario.RunFunctionWithDescription; +declare var beforeEach: angularScenario.RunFunction; +declare var afterEach: angularScenario.RunFunction; +declare var it: angularScenario.RunFunctionWithDescription; +declare var iit: angularScenario.RunFunctionWithDescription; +declare var xit: angularScenario.RunFunctionWithDescription; +declare var pause: angularScenario.PauseFunction; +declare var sleep: angularScenario.SleepFunction; +declare function browser(): angularScenario.Browser; +declare function expect(expectation: angularScenario.Future): angularScenario.Expect; +declare var using: angularScenario.UsingFunction; +declare var binding: angularScenario.BindingFunction; +declare function input(ngModelBinding: string): angularScenario.Input; +declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater; +declare function select(ngModelBinding: string): angularScenario.Select; +declare function element(selector: string, elementDescription?: string): angularScenario.Element; +declare var angular: ng.IAngularStatic; diff --git a/cookiejs/cookiejs-tests.ts b/cookiejs/cookiejs-tests.ts new file mode 100644 index 0000000000..b4dd6927b6 --- /dev/null +++ b/cookiejs/cookiejs-tests.ts @@ -0,0 +1,30 @@ +/// + +// Based on https://github.com/js-coder/cookie.js/blob/gh-pages/tests/spec.js + +cookie.set({a: '1', b: '2', c: '3'}); + +cookie; +cookie.enabled(); + +cookie.set('n', '5'); + +cookie.get('a'); +cookie.get('__undef__'); +cookie.get('__undef__', 'fallback'); +cookie.get(['a', 'b']); +cookie.get(['a', '__undef__'], 'fallback'); + +cookie('a'); +cookie('__undef__'); +cookie('__undef__', 'fallback'); +cookie(['a', 'b']); +cookie(['a', '__undef__'], 'fallback'); + +cookie.remove('a'); +cookie.remove('a', 'b'); +cookie.remove(['a', 'b']); + +cookie.empty(); + +cookie.all(); diff --git a/cookiejs/cookiejs.d.ts b/cookiejs/cookiejs.d.ts new file mode 100644 index 0000000000..bdd71f0219 --- /dev/null +++ b/cookiejs/cookiejs.d.ts @@ -0,0 +1,24 @@ +// Type definitions for cookie.js v1.0.0 +// Project: https://github.com/js-coder/cookie.js +// Definitions by: Boltmade +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare function cookie(key : string, fallback?: string) : string; +declare function cookie(keys : string[], fallback?: string) : string; + +declare module cookie { + export function set(key : string, value : string, options? : any) : void; + export function set(obj : any, options? : any) : void; + export function remove(key : string) : void; + export function remove(keys : string[]) : void; + export function remove(...args : string[]) : void; + export function empty() : void; + export function get(key : string, fallback?: string) : string; + export function get(keys : string[], fallback?: string) : string; + export function all() : any; + export function enabled() : boolean; +} + +declare module "cookiejs" { + export = cookie; +} diff --git a/hapi/hapi-tests.ts b/hapi/hapi-tests.ts index da28b97a37..586d3d29f8 100644 --- a/hapi/hapi-tests.ts +++ b/hapi/hapi-tests.ts @@ -25,6 +25,36 @@ server.pack.register([plugin], (err: Object) => { if (err) { throw err; } }); +// Add server method +var add = function (a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) { + next(null, a + b); +}; + +server.method('sum', add, { cache: { expiresIn: 2000 } }); + +server.methods.sum(4, 5, (err: any, result: any) => { + console.log(result); +}); + +var addArray = function (array: Array, next: (err: any, result?: any, ttl?: number) => void) { + var sum: number = 0; + array.forEach((item: number) => { + sum += item; + }); + next(null, sum); +}; + +server.method('sumObj', addArray, { + cache: { expiresIn: 2000 }, + generateKey: (array: Array) => { + return array.join(','); + } +}); + +server.methods.sumObj([5, 6], (err: any, result: any) => { + console.log(result); +}); + // Add the route server.route({ method: 'GET', diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 09453737ad..de65efcdc8 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -279,7 +279,7 @@ declare module Hapi { export class Server { app: any; - methods: Array<() => void>; + methods: any; info: { port: number; host?: string; @@ -336,7 +336,7 @@ declare module Hapi { }; ext(event: any, method: string, options?: any): void; method(method: Array<{name: string; fn: () => void; options: any}>): void; - method(name: string, fn: () => void, options: any): void; + method(name: string, fn: Function, options: any): void; inject(options: any, callback: any): void; handler(name: string, method: (name: string, options: any) => void): void; } diff --git a/heatmap.js/heatmap-tests.ts b/heatmap.js/heatmap-tests.ts new file mode 100644 index 0000000000..a90eb0aea4 --- /dev/null +++ b/heatmap.js/heatmap-tests.ts @@ -0,0 +1,42 @@ +/// + +var baseLayer = L.tileLayer( + 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', + maxZoom: 18 + }); + +var testData: HeatmapData = { + max: 8, + data: [ + { + lat: 24.6408, + lng:46.7728, + count: 3 + }, { + lat: 50.75, + lng: -1.55, + count: 1 + } + ] +}; + +var config : HeatmapConfiguration = { + radius: 2, + maxOpacity: .8, + scaleRadius: true, + useLocalExtrema: true, + latField: 'lat', + lngField: 'lng', + valueField: 'count' +}; + +var heatmapLayer = new HeatmapOverlay(config); + +var map = new L.Map('map-canvas', { + center: new L.LatLng(25.6586, -80.3568), + zoom: 4, + layers: [baseLayer, heatmapLayer] +}); + +heatmapLayer.setData(testData); diff --git a/heatmap.js/heatmap.d.ts b/heatmap.js/heatmap.d.ts new file mode 100644 index 0000000000..012e3f9d9f --- /dev/null +++ b/heatmap.js/heatmap.d.ts @@ -0,0 +1,134 @@ +// Type definitions for heatmap.js v2.0 +// Project: https://github.com/pa7/heatmap.js/ +// Definitions by: Yang Guan +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/* + * Configuration object of a heatmap + */ +interface HeatmapConfiguration { + + /* + * A background color string in form of hexcode, color name, or rgb(a) + */ + backgroundColor?: string; + + /* + * The blur factor that will be applied to all datapoints. The higher the + * blur factor is, the smoother the gradients will be + * Default value: 0.85 + */ + blur?: number; + + /* + * An object that represents the gradient + */ + gradient?: any; + + /* + * The property name of your latitude coordinate in a datapoint + * Default value: 'x' + */ + latField?: string; + + /* + * The property name of your longitude coordinate in a datapoint + * Default value: 'y' + */ + lngField?: string; + + /* + * The maximal opacity the highest value in the heatmap will have. (will be + * overridden if opacity set) + * Default value: 0.6 + */ + maxOpacity?: number; + + /* + * The minimum opacity the lowest value in the heatmap will have (will be + * overridden if opacity set) + */ + minOpacity?: number; + + /* + * A global opacity for the whole heatmap. This overrides maxOpacity and + * minOpacity if set + */ + opacity?: number; + + /* + * The radius each datapoint will have (if not specified on the datapoint + * itself) + */ + radius?: number; + + /* + * Indicate whether the heatmap should use a global extrema or a local + * extrema (the maximum and minimum of the currently displayed viewport) + */ + useLocalExtrema?: boolean; + + /* + * The property name of the value/weight in a datapoint + */ + valueField: string; +} + +/* + * A single data point on a heatmap. The keys are specified by + * HeatmapConfig.latField, HeatmapConfig.lngField and HeatmapConfig.valueField + */ +interface HeatmapDataPoint { + [index: string]: number; +} + +/* + * An object representing the set of data points on a heatmap + */ +interface HeatmapData { + + /* + * An array of HeatmapDataPoints + */ + data: HeatmapDataPoint[]; + + /* + * Max value of the valueField + */ + max?: number; + + /* + * Min value of the valueField + */ + min?: number; +} + +/* + * The overlay layer to be added onto leaflet map + */ +declare class HeatmapOverlay { + + /* + * Initialization function + */ + constructor(configuration: HeatmapConfiguration) + + /* + * Create DOM elements for an overlay, adding them to map panes and puts + * listeners on relevant map events + */ + onAdd(map: L.Map): void; + + /* + * Remove the overlay's elements from the DOM and remove listeners + * previously added by onAdd() + */ + onRemove(map: L.Map): void; + + /* + * Initialize a heatmap instance with the given dataset + */ + setData(data: HeatmapData): void; +} diff --git a/jquery.rowGrid/jquery.rowGrid-tests.ts b/jquery.rowGrid/jquery.rowGrid-tests.ts new file mode 100644 index 0000000000..cb11d65964 --- /dev/null +++ b/jquery.rowGrid/jquery.rowGrid-tests.ts @@ -0,0 +1,24 @@ +/// +/// + +/* + * Test different options + */ + +var options = { + minMargin: 10, + maxMargin: 35, + itemSelector: ".item" +}; + +$(".container").rowGrid(options); + + +/* + * Test endless scrolling + */ + +// append new items +$(".container").append("
"); +// arrange appended items +$(".container").rowGrid("appended"); \ No newline at end of file diff --git a/jquery.rowGrid/jquery.rowGrid.d.ts b/jquery.rowGrid/jquery.rowGrid.d.ts new file mode 100644 index 0000000000..4b136d2bac --- /dev/null +++ b/jquery.rowGrid/jquery.rowGrid.d.ts @@ -0,0 +1,17 @@ +// Type definitions for jQuery rowGrid.js plugin (v1.0.2) +// Project: https://github.com/brunjo/rowGrid.js +// Definitions by: Vinayak Garg +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQueryRowGridJSOptions { + minMargin?: number; + maxMargin?: number; + itemSelector: string; +} + +interface JQuery { + rowGrid(options?: JQueryRowGridJSOptions): JQuery; + rowGrid(appended: string): JQuery; +} \ No newline at end of file diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 861fc8fe30..5c9ab58f32 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -1,6 +1,6 @@ // Type definitions for Knockout v3.2.0-beta // Project: http://knockoutjs.com -// Definitions by: Boris Yankov , Igor Oleinikov +// Definitions by: Boris Yankov , Igor Oleinikov , Clément Bourgeois // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -38,6 +38,7 @@ interface KnockoutObservableArrayFunctions { removeAll(): T[]; destroy(item: T): void; + destroy(destroyFunction: (item: T) => boolean): void; destroyAll(items: T[]): void; destroyAll(): void; } diff --git a/mousetrap/mousetrap-global-bind-tests.ts b/mousetrap/mousetrap-global-bind-tests.ts new file mode 100644 index 0000000000..92374d862e --- /dev/null +++ b/mousetrap/mousetrap-global-bind-tests.ts @@ -0,0 +1,42 @@ +/// + +Mousetrap.globalBind('4', function() { console.log('4'); }); +Mousetrap.globalBind("?", function() { console.log('show shortcuts!'); }); +Mousetrap.globalBind('esc', function() { console.log('escape'); }, 'keyup'); + +// combinations +Mousetrap.globalBind('command+shift+K', function() { console.log('command shift k'); }); + +// map multiple combinations to the same callback +Mousetrap.globalBind(['command+k', 'ctrl+k'], function() { + console.log('command k or control k'); + + // return false to prevent default browser behavior + // and stop event from bubbling + return false; +}); + +// gmail style sequences +Mousetrap.globalBind('g i', function() { console.log('go to inbox'); }); +Mousetrap.globalBind('* a', function() { console.log('select all'); }); + +// konami code! +Mousetrap.globalBind('up up down down left right left right b a enter', function() { + console.log('konami code'); +}); + +Mousetrap.globalBind(['ctrl+s', 'meta+s'], (e, combo) => { + if (e.preventDefault) { + e.preventDefault(); + } else { + // internet explorer + e.returnValue = false; + } +}); + +Mousetrap.unbind('?'); + +Mousetrap.trigger('esc'); +Mousetrap.trigger('esc', 'keyup'); + +Mousetrap.reset(); diff --git a/mousetrap/mousetrap-global-bind.d.ts b/mousetrap/mousetrap-global-bind.d.ts new file mode 100644 index 0000000000..ecfdd2ff23 --- /dev/null +++ b/mousetrap/mousetrap-global-bind.d.ts @@ -0,0 +1,11 @@ +// Type definitions for Mousetrap 1.4.6's global-bind extension +// Project: http://craig.is/killing/mice#extensions.global +// Definitions by: Andrew Bradley +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface MousetrapStatic { + globalBind(keys: string, callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void; + globalBind(keyArray: string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void; +} diff --git a/mousetrap/mousetrap-tests.ts b/mousetrap/mousetrap-tests.ts index 3eac1eef16..d60d8278d3 100644 --- a/mousetrap/mousetrap-tests.ts +++ b/mousetrap/mousetrap-tests.ts @@ -41,3 +41,11 @@ Mousetrap.trigger('esc'); Mousetrap.trigger('esc', 'keyup'); Mousetrap.reset(); + +// Test that Mousetrap can be loaded as an external module. +// Assume that if the externally-loaded module can be assigned to a variable with the type of global Mousetrap, +// then everything is working correctly. + +import importedMousetrap = require('mousetrap'); +var mousetrapModuleReference: typeof Mousetrap = importedMousetrap; + diff --git a/mousetrap/mousetrap.d.ts b/mousetrap/mousetrap.d.ts index dee352b42b..846e1f3ce2 100644 --- a/mousetrap/mousetrap.d.ts +++ b/mousetrap/mousetrap.d.ts @@ -19,3 +19,7 @@ interface MousetrapStatic { } declare var Mousetrap: MousetrapStatic; + +declare module "mousetrap" { + export = Mousetrap; +} diff --git a/node-webkit/node-webkit-tests.ts b/node-webkit/node-webkit-tests.ts index da10f2901c..ba53c3fc4f 100644 --- a/node-webkit/node-webkit-tests.ts +++ b/node-webkit/node-webkit-tests.ts @@ -1,7 +1,9 @@ /// /// + // Load native UI library -var gui: typeof nw.gui; +// See docs: https://github.com/rogerwang/node-webkit/wiki/Shell +import gui = require("nw.gui"); /* WINDOW */ @@ -109,7 +111,7 @@ var gui: typeof nw.gui; /* MENU ITEM */ - var itemc:nw.gui.MenuItem; + var itemc:gui.MenuItem; // Create a separator itemc = new gui.MenuItem({ type: 'separator' }); diff --git a/node-webkit/node-webkit.d.ts b/node-webkit/node-webkit.d.ts index 92afbff2dd..78c9dd3f0f 100644 --- a/node-webkit/node-webkit.d.ts +++ b/node-webkit/node-webkit.d.ts @@ -3,7 +3,7 @@ // Definitions by: Pedro Casaubon // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module nw.gui { +declare module "nw.gui" { interface IEventEmitter { addListener(event: string, listener: Function): EventEmitter; diff --git a/q/Q.d.ts b/q/Q.d.ts index 3e7371ead2..59e891c527 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -248,43 +248,43 @@ declare module Q { * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected?: (reason: any) => IPromise): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason: any) => U): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected?: (reason: any) => U): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected?: (reason: any) => IPromise): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason: any) => U): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected?: (reason: any) => U): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected?: (reason: any) => IPromise): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason: any) => U): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected?: (reason: any) => U): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected?: (reason: any) => IPromise): Promise; /** * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. * This is especially useful in conjunction with all. */ - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason: any) => U): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected?: (reason: any) => U): Promise; /** * Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms". diff --git a/react-addons/react-addons-tests.ts b/react-addons/react-addons-tests.ts index 4834d6e23d..7a835dfebe 100644 --- a/react-addons/react-addons-tests.ts +++ b/react-addons/react-addons-tests.ts @@ -113,21 +113,27 @@ React.addons.TestUtils.Simulate.click(node); React.addons.TestUtils.Simulate.change(node); React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter"}); -var GoodbyeMessage = React.createClass({displayName: 'GoodbyeMessage', +var Greeting = React.createClass({displayName: 'Greeting', + getInitialState: function() { + return {morning: true}; + }, render: function() { - return React.DOM.div(null, "Goodbye ", (>this).props.name); + var me = >this; + return React.DOM.div(null, (me.state.morning ? "Hello" : "Goodbye "), me.props.name); } }); -React.addons.TestUtils.renderIntoDocument(GoodbyeMessage({name: "John"})); + +var root = React.addons.TestUtils.renderIntoDocument(Greeting({name: "John"})); +var greeting = React.addons.TestUtils.findRenderedComponentWithType(root, Greeting); +greeting.setState({ + morning: false +}); var isImportant: boolean; var isRead: boolean; var cx = React.addons.classSet; -var classes = cx({ +var classes: string = cx({ 'message': true, 'message-important': isImportant, 'message-read': isRead }); - - - diff --git a/react-addons/react-addons.d.ts b/react-addons/react-addons.d.ts index 35fc5f1fb9..686dd05632 100644 --- a/react-addons/react-addons.d.ts +++ b/react-addons/react-addons.d.ts @@ -93,8 +93,9 @@ declare module React { findRenderedDOMComponentWithClass(tree: ReactElement, className: string): ReactElement; scryRenderedDOMComponentsWithTag(tree: ReactElement, className: string): ReactElement[]; findRenderedDOMComponentWithTag(tree: ReactElement, tagName: string): ReactElement; - scryFindRenderedComponentsWithTag(tree: ReactElement, componentClass: Function): ReactElement[]; - findRenderedComponentWithType(tree: ReactElement, componentClass: Function): ReactElement; + scryRenderedComponentsWithTag(tree: ReactElement, componentClass: Function): ReactElement[]; + findRenderedComponentWithType

(tree: ReactElement, componentClass: ReactComponentFactory

): Component; + scryRenderedComponentsWithType

(tree: ReactElement, componentClass: ReactComponentFactory

): Component[]; } export interface SyntheticEventData { diff --git a/socket.io-client/socket.io-client-commonjs-tests.ts b/socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts similarity index 81% rename from socket.io-client/socket.io-client-commonjs-tests.ts rename to socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts index 7b5f967473..beb8f0fad5 100644 --- a/socket.io-client/socket.io-client-commonjs-tests.ts +++ b/socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts @@ -1,10 +1,10 @@ -import io = require('socket.io-client'); - -var socket = io.connect('http://localhost:80'); - -socket.on('connect', function () { - console.log('Connected!'); - socket.emit('event', 'some test data', function () { - console.log('Sent some data.'); - }); -}); +import io = require('socket.io-client-0.9'); + +var socket = io.connect('http://localhost:80'); + +socket.on('connect', function () { + console.log('Connected!'); + socket.emit('event', 'some test data', function () { + console.log('Sent some data.'); + }); +}); diff --git a/socket.io-client/legacy/socket.io-client-0.9-tests.ts b/socket.io-client/legacy/socket.io-client-0.9-tests.ts new file mode 100644 index 0000000000..7178306281 --- /dev/null +++ b/socket.io-client/legacy/socket.io-client-0.9-tests.ts @@ -0,0 +1,10 @@ +/// + +var socket = io.connect('http://localhost:80'); + +socket.on('connect', function () { + console.log('Connected!'); + socket.emit('event', 'some test data', function () { + console.log('Sent some data.'); + }); +}); diff --git a/socket.io-client/legacy/socket.io-client-0.9.d.ts b/socket.io-client/legacy/socket.io-client-0.9.d.ts new file mode 100644 index 0000000000..0b3626e420 --- /dev/null +++ b/socket.io-client/legacy/socket.io-client-0.9.d.ts @@ -0,0 +1,40 @@ +// Type definitions for socket.io nodejs client +// Project: http://socket.io/ +// Definitions by: Maido Kaara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "socket.io-client-0.9" { + export = io; +} + +declare var io: SocketIOStatic; + +interface SocketIOStatic { + connect(host: string, details?: any): SocketIOClient.Socket; +} + +declare module SocketIOClient { + interface EventEmitter { + emit(name: string, ...data: any[]): any; + on(ns: string, fn: Function): EventEmitter; + addListener(ns: string, fn: Function): EventEmitter; + removeListener(ns: string, fn: Function): EventEmitter; + removeAllListeners(ns: string): EventEmitter; + once(ns: string, fn: Function): EventEmitter; + listeners(ns: string): Function[]; + } + + interface SocketNamespace extends EventEmitter { + of(name: string): SocketNamespace; + send(data: any, fn: Function): SocketNamespace; + emit(name: string): SocketNamespace; + } + + interface Socket extends EventEmitter { + of(name: string): SocketNamespace; + connect(fn: Function): Socket; + packet(data: any): Socket; + flushBuffer(): void; + disconnect(): Socket; + } +} diff --git a/socket.io-client/socket.io-client-tests.ts b/socket.io-client/socket.io-client-tests.ts index e1022c61af..215932c460 100644 --- a/socket.io-client/socket.io-client-tests.ts +++ b/socket.io-client/socket.io-client-tests.ts @@ -1,10 +1,57 @@ /// -var socket = io.connect('http://localhost:80'); - -socket.on('connect', function () { - console.log('Connected!'); - socket.emit('event', 'some test data', function () { - console.log('Sent some data.'); +function testUsingWithNodeHTTPServer() { + var socket = io('http://localhost'); + socket.on('news', function (data: any) { + console.log(data); + socket.emit('my other event', { my: 'data' }); }); -}); +} + +function testUsingWithExpress() { + var socket = io.connect('http://localhost'); + socket.on('news', function (data: any) { + console.log(data); + socket.emit('my other event', { my: 'data' }); + }); +} + +function testUsingWithTheExpressFramework() { + var socket = io.connect('http://localhost'); + socket.on('news', function (data: any) { + console.log(data); + socket.emit('my other event', { my: 'data' }); + }); +} + +function testRestrictingYourselfToANamespace() { + var chat = io.connect('http://localhost/chat') + , news = io.connect('http://localhost/news'); + + chat.on('connect', function () { + chat.emit('hi!'); + }); + + news.on('news', function () { + news.emit('woot'); + }); +} + +function testSendingAndGettingData() { + var socket = io(); + socket.on('connect', function () { + socket.emit('ferret', 'tobi', function (data: any) { + console.log(data); + }); + }); +} + +function testUsingItJustAsACrossBrowserWebSocket() { + var socket = io('http://localhost/'); + socket.on('connect', function () { + socket.emit('hi'); + + socket.on('message', function (msg: any) { + }); + }); +} diff --git a/socket.io-client/socket.io-client.d.ts b/socket.io-client/socket.io-client.d.ts index 079ca7cbb8..b03cc830bc 100644 --- a/socket.io-client/socket.io-client.d.ts +++ b/socket.io-client/socket.io-client.d.ts @@ -1,40 +1,46 @@ -// Type definitions for socket.io nodejs client +// Type definitions for socket.io-client 1.2.0 // Project: http://socket.io/ -// Definitions by: Maido Kaara +// Definitions by: PROGRE // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "socket.io-client" { - export = io; +/// + +declare var io: SocketIOClientStatic; + +declare module 'socket.io-client' { + export = io; } -declare var io: SocketIOStatic; - -interface SocketIOStatic { +interface SocketIOClientStatic { + (host: string, details?: any): SocketIOClient.Socket; + (details?: any): SocketIOClient.Socket; connect(host: string, details?: any): SocketIOClient.Socket; + connect(details?: any): SocketIOClient.Socket; + protocol: number; + Socket: { new (...args: any[]): SocketIOClient.Socket }; + Manager: SocketIOClient.ManagerStatic; } declare module SocketIOClient { - interface EventEmitter { - emit(name: string, ...data: any[]): any; - on(ns: string, fn: Function): EventEmitter; - addListener(ns: string, fn: Function): EventEmitter; - removeListener(ns: string, fn: Function): EventEmitter; - removeAllListeners(ns: string): EventEmitter; - once(ns: string, fn: Function): EventEmitter; - listeners(ns: string): Function[]; + interface Socket { + on(event: string, fn: Function): Socket; + once(event: string, fn: Function): Socket; + off(event: string, fn: Function): Socket; + emit(event: string, ...args: any[]): Socket; + listeners(event: string): Function[]; + hasListeners(event: string): boolean; } - interface SocketNamespace extends EventEmitter { - of(name: string): SocketNamespace; - send(data: any, fn: Function): SocketNamespace; - emit(name: string): SocketNamespace; + interface ManagerStatic { + (url: string, opts: any): SocketIOClient.Manager; + new (url: string, opts: any): SocketIOClient.Manager; } - interface Socket extends EventEmitter { - of(name: string): SocketNamespace; - connect(fn: Function): Socket; - packet(data: any): Socket; - flushBuffer(): void; - disconnect(): Socket; + interface Manager { + reconnection(v: boolean): Manager; + reconnectionAttempts(v: boolean): Manager; + reconnectionDelay(v: boolean): Manager; + reconnectionDelayMax(v: boolean): Manager; + timeout(v: boolean): Manager; } } diff --git a/socket.io/legacy/socket.io-0.9-tests.ts b/socket.io/legacy/socket.io-0.9-tests.ts new file mode 100644 index 0000000000..0d7e12bb6d --- /dev/null +++ b/socket.io/legacy/socket.io-0.9-tests.ts @@ -0,0 +1,24 @@ +import io = require('socket.io-0.9'); + +var socketManager = io.listen(80); + +socketManager.sockets.on('connection', socket => { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', data => { + console.log(data); + }); +}); + +// Storing data Associated to a client. +// Server side sample +io.listen(80).sockets.on('connection', function (socket) { + socket.on('set nickname', function (name) { + socket.set('nickname', name, function () { socket.emit('ready'); }); + }); + + socket.on('msg', function () { + socket.get('nickname', function (err, name) { + console.log('Chat message by ', name); + }); + }); +}); \ No newline at end of file diff --git a/socket.io/socket.io-tests.ts.tscparams b/socket.io/legacy/socket.io-0.9-tests.ts.tscparams similarity index 50% rename from socket.io/socket.io-tests.ts.tscparams rename to socket.io/legacy/socket.io-0.9-tests.ts.tscparams index d3f5a12faa..8b13789179 100644 --- a/socket.io/socket.io-tests.ts.tscparams +++ b/socket.io/legacy/socket.io-0.9-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/socket.io/legacy/socket.io-0.9.d.ts b/socket.io/legacy/socket.io-0.9.d.ts new file mode 100644 index 0000000000..5ead4abde5 --- /dev/null +++ b/socket.io/legacy/socket.io-0.9.d.ts @@ -0,0 +1,70 @@ +// Type definitions for socket.io +// Project: http://socket.io/ +// Definitions by: William Orr +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare module "socket.io-0.9" { + import http = require('http'); + + export function listen(server: http.Server, options: any, fn: Function): SocketManager; + export function listen(server: http.Server, fn?: Function): SocketManager; + export function listen(port: Number): SocketManager; + + + interface Socket { + id: string; + json:any; + log: any; + volatile: any; + broadcast: any; + handshake: any; + in(room: string): Socket; + to(room: string): Socket; + join(name: string, fn: Function): Socket; + leave(name: string, fn: Function): Socket; + set(key: string, value: any, fn: Function): Socket; + get(key: string, fn: Function): Socket; + has(key: string, fn: Function): Socket; + del(key: string, fn: Function): Socket; + disconnect(): Socket; + send(data: any, fn: Function): Socket; + emit(ev: any, ...data:any[]): Socket; + on(ns: string, fn: Function): Socket; + } + + interface SocketNamespace { + clients(room: string): Socket[]; + log: any; + store: any; + json: any; + volatile: any; + in(room: string): SocketNamespace; + on(evt: string, fn: (socket: Socket) => void): SocketNamespace; + to(room: string): SocketNamespace; + except(id: any): SocketNamespace; + send(data: any): any; + emit(ev: any, ...data:any[]): Socket; + socket(sid: any, readable: boolean): Socket; + authorization(fn: Function): SocketNamespace; + } + + interface SocketManager { + get(key: any): any; + set(key: any, value: any): SocketManager; + enable(key: any): SocketManager; + disable(key: any): SocketManager; + enabled(key: any): boolean; + disabled(key: any): boolean; + configure(env: string, fn: Function): SocketManager; + configure(fn: Function): SocketManager; + of(nsp: string): SocketNamespace; + on(ns: string, fn: Function): SocketManager; + sockets: SocketNamespace; + } + + +} + diff --git a/socket.io/socket.io-tests.ts b/socket.io/socket.io-tests.ts index 0b29890ca1..442e677751 100644 --- a/socket.io/socket.io-tests.ts +++ b/socket.io/socket.io-tests.ts @@ -1,24 +1,145 @@ -import io = require('socket.io'); - -var socketManager = io.listen(80); - -socketManager.sockets.on('connection', socket => { - socket.emit('news', { hello: 'world' }); - socket.on('my other event', data => { - console.log(data); - }); -}); - -// Storing data Associated to a client. -// Server side sample -io.listen(80).sockets.on('connection', function (socket) { - socket.on('set nickname', function (name) { - socket.set('nickname', name, function () { socket.emit('ready'); }); - }); - - socket.on('msg', function () { - socket.get('nickname', function (err, name) { - console.log('Chat message by ', name); - }); - }); -}); \ No newline at end of file +import socketIO = require('socket.io'); + +function testUsingWithNodeHTTPServer() { + var app = require('http').createServer(handler); + var io = socketIO(app); + var fs = require('fs'); + + app.listen(80); + + function handler(req: any, res: any) { + fs.readFile(__dirname + '/index.html', + function (err: any, data: any) { + if (err) { + res.writeHead(500); + return res.end('Error loading index.html'); + } + + res.writeHead(200); + res.end(data); + }); + } + + io.on('connection', function (socket) { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', function (data: any) { + console.log(data); + }); + }); +} + +function testUsingWithExpress() { + var app = require('express')(); + var server = require('http').Server(app); + var io = socketIO(server); + + server.listen(80); + + app.get('/', function (req: any, res: any) { + res.sendfile(__dirname + '/index.html'); + }); + + io.on('connection', function (socket) { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', function (data: any) { + console.log(data); + }); + }); +} + +function testUsingWithTheExpressFramework() { + var app = require('express').createServer(); + var io = socketIO(app); + + app.listen(80); + + app.get('/', function (req: any, res: any) { + res.sendfile(__dirname + '/index.html'); + }); + + io.on('connection', function (socket) { + socket.emit('news', { hello: 'world' }); + socket.on('my other event', function (data: any) { + console.log(data); + }); + }); +} + +function testSendingAndReceivingEvents() { + var io = socketIO(80); + + io.on('connection', function (socket) { + io.emit('this', { will: 'be received by everyone' }); + + socket.on('private message', function (from: any, msg: any) { + console.log('I received a private message by ', from, ' saying ', msg); + }); + + socket.on('disconnect', function () { + io.sockets.emit('user disconnected'); + }); + }); +} + +function testRestrictingYourselfToANamespace() { + var io = socketIO.listen(80); + var chat = io + .of('/chat') + .on('connection', function (socket) { + socket.emit('a message', { + that: 'only' + , '/chat': 'will get' + }); + chat.emit('a message', { + everyone: 'in' + , '/chat': 'will get' + }); + }); + + var news = io + .of('/news') + .on('connection', function (socket) { + socket.emit('item', { news: 'item' }); + }); +} + +function testSendingVolatileMessages() { + var io = socketIO.listen(80); + + io.sockets.on('connection', function (socket) { + var tweets = setInterval(function () { + socket.volatile.emit('bieber tweet', {}); + }, 100); + + socket.on('disconnect', function () { + clearInterval(tweets); + }); + }); +} + +function testSendingAndGettingData() { + var io = socketIO.listen(80); + + io.sockets.on('connection', function (socket) { + socket.on('ferret', function (name: any, fn: any) { + fn('woot'); + }); + }); +} + +function testBroadcastingMessages() { + var io = socketIO.listen(80); + + io.sockets.on('connection', function (socket) { + socket.broadcast.emit('user connected'); + }); +} + +function testUsingItJustAsACrossBrowserWebSocket() { + var io = socketIO.listen(80); + + io.sockets.on('connection', function (socket) { + socket.on('message', function () { }); + socket.on('disconnect', function () { }); + }); +} diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index 184468b127..b6aad32931 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -1,70 +1,76 @@ -// Type definitions for socket.io -// Project: http://socket.io/ -// Definitions by: William Orr -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -/// - -declare module "socket.io" { - import http = require('http'); - - export function listen(server: http.Server, options: any, fn: Function): SocketManager; - export function listen(server: http.Server, fn?: Function): SocketManager; - export function listen(port: Number): SocketManager; - - - interface Socket { - id: string; - json:any; - log: any; - volatile: any; - broadcast: any; - handshake: any; - in(room: string): Socket; - to(room: string): Socket; - join(name: string, fn: Function): Socket; - leave(name: string, fn: Function): Socket; - set(key: string, value: any, fn: Function): Socket; - get(key: string, fn: Function): Socket; - has(key: string, fn: Function): Socket; - del(key: string, fn: Function): Socket; - disconnect(): Socket; - send(data: any, fn: Function): Socket; - emit(ev: any, ...data:any[]): Socket; - on(ns: string, fn: Function): Socket; - } - - interface SocketNamespace { - clients(room: string): Socket[]; - log: any; - store: any; - json: any; - volatile: any; - in(room: string): SocketNamespace; - on(evt: string, fn: (socket: Socket) => void): SocketNamespace; - to(room: string): SocketNamespace; - except(id: any): SocketNamespace; - send(data: any): any; - emit(ev: any, ...data:any[]): Socket; - socket(sid: any, readable: boolean): Socket; - authorization(fn: Function): SocketNamespace; - } - - interface SocketManager { - get(key: any): any; - set(key: any, value: any): SocketManager; - enable(key: any): SocketManager; - disable(key: any): SocketManager; - enabled(key: any): boolean; - disabled(key: any): boolean; - configure(env: string, fn: Function): SocketManager; - configure(fn: Function): SocketManager; - of(nsp: string): SocketNamespace; - on(ns: string, fn: Function): SocketManager; - sockets: SocketNamespace; - } - - -} - +// Type definitions for socket.io 1.2.0 +// Project: http://socket.io/ +// Definitions by: PROGRE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'socket.io' { + var server: SocketIOStatic; + + export = server; +} + +interface SocketIOStatic { + (): SocketIO.Server; + (srv: any, opts?: any): SocketIO.Server; + (port: number, opts?: any): SocketIO.Server; + (opts: any): SocketIO.Server; + + listen: SocketIOStatic; +} + +declare module SocketIO { + interface Server { + serveClient(v: boolean): Server; + path(v: string): Server; + adapter(v: any): Server; + origins(v: string): Server; + sockets: Namespace; + attach(srv: any, opts: any): Server; + attach(port: number, opts: any): Server; + listen(srv: any, opts: any): Server; + listen(port: number, opts: any): Server; + bind(srv: any): Server; + onconnection(socket: any): Server; + of(nsp: string): Namespace; + emit(name: string, ...args: any[]): Socket; + use(fn: Function): Namespace; + + on(event: 'connection', listener: (socket: Socket) => void): any; + on(event: 'connect', listener: (socket: Socket) => void): any; + on(event: string, listener: Function): any; + } + + interface Namespace extends NodeJS.EventEmitter { + name: string; + connected: { [id: number]: Socket }; + use(fn: Function): Namespace + + on(event: 'connection', listener: (socket: Socket) => void): any; + on(event: 'connect', listener: (socket: Socket) => void): any; + on(event: string, listener: Function): any; + } + + interface Socket { + rooms: string[]; + client: Client; + conn: Socket; + request: any; + id: string; + emit(name: string, ...args: any[]): Socket; + join(name: string, fn?: Function): Socket; + leave(name: string, fn?: Function): Socket; + to(room: string): Socket; + in(room: string): Socket; + + on(event: string, listener: Function): any; + broadcast: Socket; + volatile: Socket; + } + + interface Client { + conn: any; + request: any; + } +} diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index 9e6f9c4b5b..0abed74380 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -79,6 +79,8 @@ declare module "superagent" { subscribe(url: string, callback?: (err: Error, res: Response) => void): Request; unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Request; patch(url: string, callback?: (err: Error, res: Response) => void): Request; + search(url: string, callback?: (err: Error, res: Response) => void): Request; + connect(url: string, callback?: (err: Error, res: Response) => void): Request; parse(fn: Function): Request; saveCookies(res: Response): void; attachCookies(req: Request): void; diff --git a/supertest/supertest-tests.ts b/supertest/supertest-tests.ts index c4bdfb2711..120cb43c00 100644 --- a/supertest/supertest-tests.ts +++ b/supertest/supertest-tests.ts @@ -29,4 +29,31 @@ request req.expect(200, (err, res) => { if (err) throw err; }); - }); \ No newline at end of file + }); + +// cookie scenario, new version +var client = supertest.agent(app); +client + .post('/login') + .end((err, res) => { + if (err) throw err; + + client.get('/admin') + .expect(200, (err, res) => { + if (err) throw err; + }); + }); + +// functional expect +supertest(app) + .get('/') + .expect(hasPreviousAndNextKeys) + .end((err, res) => { + if (err) throw err; + }); + +function hasPreviousAndNextKeys(res: supertest.Response) { + if (!('next' in res.body)) return "missing next key"; + if (!('prev' in res.body)) throw new Error("missing prev key"); +} + diff --git a/supertest/supertest.d.ts b/supertest/supertest.d.ts index 9b60431f06..cb2bb78b30 100644 --- a/supertest/supertest.d.ts +++ b/supertest/supertest.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SuperTest 0.8.0 +// Type definitions for SuperTest 0.14.0 // Project: https://github.com/visionmedia/supertest // Definitions by: Alex Varju // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,19 +12,32 @@ declare module "supertest" { interface Test extends superagent.Request { url: string; serverAddress(app: any, path: string): string; - expect(status: number, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(status: number, body: string, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(body: string, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(body: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(body: Object, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(field: string, val: string, callback?: (err: Error, res: superagent.Response) => void): Test; - expect(field: string, val: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test; + expect(status: number, callback?: (err: Error, res: Response) => void): Test; + expect(status: number, body: string, callback?: (err: Error, res: Response) => void): Test; + expect(body: string, callback?: (err: Error, res: Response) => void): Test; + expect(body: RegExp, callback?: (err: Error, res: Response) => void): Test; + expect(body: Object, callback?: (err: Error, res: Response) => void): Test; + expect(field: string, val: string, callback?: (err: Error, res: Response) => void): Test; + expect(field: string, val: RegExp, callback?: (err: Error, res: Response) => void): Test; + expect(checker: (res: Response) => any): Test; + + attach(field: string, file: string, filename: string): Test; + redirects(n: number): Test; + part(): Test; set(field: string, val: string): Test; set(field: Object): Test; + type(val: string): Test; query(val: Object): Test; send(data: string): Test; send(data: Object): Test; + buffer(val: boolean): Test; + timeout(ms: number): Test; + clearTimeout(): Test; + auth(user: string, name: string): Test; + field(name: string, val: string): Test; + end(callback?: (err: Error, res: Response) => void): Test; } + interface Response extends superagent.Response {} interface SuperTest { get(url: string): Test; @@ -52,7 +65,34 @@ declare module "supertest" { patch(url: string): Test; } - function agent(): superagent.Agent; + interface TestAgent extends superagent.Agent { + get(url: string, callback?: (err: Error, res: Response) => void): Test; + post(url: string, callback?: (err: Error, res: Response) => void): Test; + put(url: string, callback?: (err: Error, res: Response) => void): Test; + head(url: string, callback?: (err: Error, res: Response) => void): Test; + del(url: string, callback?: (err: Error, res: Response) => void): Test; + options(url: string, callback?: (err: Error, res: Response) => void): Test; + trace(url: string, callback?: (err: Error, res: Response) => void): Test; + copy(url: string, callback?: (err: Error, res: Response) => void): Test; + lock(url: string, callback?: (err: Error, res: Response) => void): Test; + mkcol(url: string, callback?: (err: Error, res: Response) => void): Test; + move(url: string, callback?: (err: Error, res: Response) => void): Test; + propfind(url: string, callback?: (err: Error, res: Response) => void): Test; + proppatch(url: string, callback?: (err: Error, res: Response) => void): Test; + unlock(url: string, callback?: (err: Error, res: Response) => void): Test; + report(url: string, callback?: (err: Error, res: Response) => void): Test; + mkactivity(url: string, callback?: (err: Error, res: Response) => void): Test; + checkout(url: string, callback?: (err: Error, res: Response) => void): Test; + merge(url: string, callback?: (err: Error, res: Response) => void): Test; + //m-search(url: string, callback?: (err: Error, res: Response) => void): Test; + notify(url: string, callback?: (err: Error, res: Response) => void): Test; + subscribe(url: string, callback?: (err: Error, res: Response) => void): Test; + unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Test; + patch(url: string, callback?: (err: Error, res: Response) => void): Test; + search(url: string, callback?: (err: Error, res: Response) => void): Test; + connect(url: string, callback?: (err: Error, res: Response) => void): Test; + } + function agent(app?: any): supertest.TestAgent; } function supertest(app: any): supertest.SuperTest; diff --git a/tv4/tv4.d.ts b/tv4/tv4.d.ts index 702d3c3bc6..02b7ebba2f 100644 --- a/tv4/tv4.d.ts +++ b/tv4/tv4.d.ts @@ -43,5 +43,6 @@ interface TV4 { errorCodes:TV4ErrorCodes; } declare module "tv4" { -export = TV4; + var tv4: TV4 + export = tv4; } diff --git a/yeoman-generator/yeoman-generator-tests.ts b/yeoman-generator/yeoman-generator-tests.ts new file mode 100644 index 0000000000..84f0072065 --- /dev/null +++ b/yeoman-generator/yeoman-generator-tests.ts @@ -0,0 +1,114 @@ +/// +import yeoman = require('yeoman-generator'); + +var base = yeoman.generators.Base; +var namedBase = yeoman.generators.NamedBase; + +var generator = base.extend({ + initializing: function() { + return; + }, + writing: { + app: function() { + return; + }, + other: function() { + return; + } + }, + end: function() { + return; + } +}); + +generator.argument('name', { + desc: 'desc', + required: true, + optional: true, + type: 'any', + defaults: 'any', +}); + +var compose = generator.composeWith('namespace', 'any', { + local: 'local', + link: 'link' +}); + +compose.defaultFor('name'); +compose.destinationRoot('rootPath') === 'string'; +compose.determineAppname(); +compose.getCollisionFilter()('output'); +compose.hookFor('name', { + as: 'string', + args: 'any', + options: 'any' +}); +compose.option('name', { + alias: 'string', + defaults: 'any', + desc: 'string', + hide: true, + type: 'any' +}); +var returnString: boolean; +returnString = compose.rootGeneratorName() === 'string'; +compose.run('args'); +compose.run('args', () => { + return; +}); +compose.runHooks(() => { + return; +}); +returnString = compose.sourceRoot('rootPath') === 'string'; + +var assert = yeoman.assert; + +assert.file('path'); +assert.file(['paths', 'paths']); +assert.fileContent('file', /.*/); +assert.fileContent([ + ['string', /.*/], + ['string', /.*/], + ['string', /.*/] +]); +assert.files([ + ['string', /.*/], + 'string', + ['string', /.*/], + 'string' +]); +assert.implement('subject', 'methods'); +assert.noFile('file'); +assert.noFileContent('file', /.*/); +assert.noFileContent([ + ['string', /.*/], + ['string', /.*/], + ['string', /.*/] +]); +assert.noImplement('subject', 'methods'); +assert.textEqual('value', 'expected'); + +var test = yeoman.test; +var dummyGen = test.createDummyGenerator(); +dummyGen.determineAppname(); + +var createdGen = test.createGenerator('name', ['any', 'amy'], 'args', 'options'); +createdGen.determineAppname(); + +test.decorate('context', 'method', () => { + return; // replacement +}, 'options'); +test.gruntfile('options', () => { + return; // done +}); +test.mockPrompt(createdGen, 'answers'); +test.registerDependencies(['dependencies', 'dependencies']); +test.restore(); +var runContext = test.run('generator'); + +runContext.async()(); +runContext.inDir('dirPath') + .withArguments('args') + .withGenerators(['deps', 'deps']) + .withOptions('opts') + .withPrompts('answers'); diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts new file mode 100644 index 0000000000..aed7a8f034 --- /dev/null +++ b/yeoman-generator/yeoman-generator.d.ts @@ -0,0 +1,141 @@ +// Type definitions for yeoman-generator +// Project: https://github.com/yeoman/generator +// Definitions by: Kentaro Okuno +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module yo { + export interface IYeomanGenerator { + argument(name: string, config: IArgumentConfig): void; + composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; + defaultFor(name: string): void; + destinationRoot(rootPath: string): string; + determineAppname(): void; + getCollisionFilter(): (output: any) => void; + hookFor(name: string, config: IHookConfig): void; + option(name: string, config: IYeomanGeneratorOption): void; + rootGeneratorName(): string; + run(args?: any): void; + run(args: any, callback?: Function): void; + runHooks(callback?: Function): void; + sourceRoot(rootPath: string): string; + } + + export interface IArgumentConfig { + desc: string; + required: boolean; + optional: boolean; + type: any; + defaults: any; + } + + export interface IComposeSetting { + local?: string; + link?: string; + } + + export interface IHookConfig { + as: string; + args: any; + options: any; + } + + export interface IYeomanGeneratorOption { + alias: string; + defaults: any; + desc: string; + hide: boolean; + type: any; + } + + export interface IQueueProps { + initializing: () => void; + prompting?: () => void; + configuring?: () => void; + default?: () => void; + writing: { + [target: string]: () => void; + }; + conflicts?: () => void; + install?: () => void; + end: () => void; + } + + export interface IBase { + new(args: string, options: any): IYeomanGenerator; + new(args: string[], options: any): IYeomanGenerator; + extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } + + export interface INamedBase { + new(args: string, options: any): IYeomanGenerator; + new(args: string[], options: any): IYeomanGenerator; + } + + export interface IAssert { + file(path: string): void; + file(paths: string[]): void; + fileContent(file: string, reg: RegExp): void; + + /** @param {[String, RegExp][]} pairs */ + fileContent(pairs: any[][]): void; + + /** @param {[String, RegExp][]|String[]} pairs */ + files(pairs: any[]): void; + + /** + * @param {Object} subject + * @param {Object|Array} methods + */ + implement(subject: any, methods: any): void; + noFile(file: string): void; + noFileContent(file: string, reg: RegExp): void; + + /** @param {[String, RegExp][]} pairs */ + noFileContent(pairs: any[][]): void; + + /** + * @param {Object} subject + * @param {Object|Array} methods + */ + noImplement(subject: any, methods: any): void; + + textEqual(value: string, expected: string): void; + } + + export interface ITestHelper { + createDummyGenerator(): IYeomanGenerator; + createGenerator(name: string, dependencies: any[], args: any, options: any): IYeomanGenerator; + decorate(context: any, method: string, replacement: Function, options: any): void; + gruntfile(options: any, done: Function): void; + mockPrompt(generator: IYeomanGenerator, answers: any): void; + registerDependencies(dependencies: string[]): void; + restore(): void; + + /** @param {String|Function} generator */ + run(generator: any): IRunContext; + } + + export interface IRunContext { + async(): Function; + inDir(dirPath: string): IRunContext; + + /** @param {String|String[]} args */ + withArguments(args: any): IRunContext; + withGenerators(dependencies: string[]): IRunContext; + withOptions(options: any): IRunContext; + withPrompts(answers: any): IRunContext; + } + + /** @type file file-utils */ + var file: any; + var assert: IAssert; + var test: ITestHelper; + var generators: { + Base: IBase; + NamedBase: INamedBase; + }; +} + +declare module "yeoman-generator" { + export = yo; +} diff --git a/yosay/yosay-tests.ts b/yosay/yosay-tests.ts new file mode 100644 index 0000000000..257b546eae --- /dev/null +++ b/yosay/yosay-tests.ts @@ -0,0 +1,3 @@ +/// +import yosay = require('yosay'); +yosay('Welcome to the generator!', {maxLength: 20}); \ No newline at end of file diff --git a/yosay/yosay.d.ts b/yosay/yosay.d.ts new file mode 100644 index 0000000000..a46049e102 --- /dev/null +++ b/yosay/yosay.d.ts @@ -0,0 +1,9 @@ +// Type definitions for yosay +// Project: https://github.com/yeoman/yosay +// Definitions by: Kentaro Okuno +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'yosay' { + function yosay(message?: string, options?: {maxLength: number}): string; + export = yosay; +} \ No newline at end of file diff --git a/zepto/zepto.d.ts b/zepto/zepto.d.ts index aa497b03f9..b01df91739 100644 --- a/zepto/zepto.d.ts +++ b/zepto/zepto.d.ts @@ -1580,13 +1580,20 @@ interface ZeptoAjaxSettings { data?: any; processData?: boolean; contentType?: string; + mimeType?: string; dataType?: string; + jsonp?: string; + jsonpCallback?: any; // string or Function timeout?: number; headers?: { [key: string]: string }; async?: boolean; global?: boolean; context?: any; traditional?: boolean; + cache?: boolean; + xhrFields?: { [key: string]: any }; + username?: string; + password?: string; beforeSend?: (xhr: XMLHttpRequest, settings: ZeptoAjaxSettings) => boolean; success?: (data: any, status: string, xhr: XMLHttpRequest) => void; error?: (xhr: XMLHttpRequest, errorType: string, error: Error) => void;