diff --git a/.gitattributes b/.gitattributes index c6b70b78d..412eeda78 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ # Auto detect text files and perform LF normalization -* text=none +* text=auto # Custom for Visual Studio *.cs diff=csharp diff --git a/.gitignore b/.gitignore index 2a52c95e0..35dd5a667 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,37 @@ -*.dll -*.exe -*.cmd -*.pdb -*.suo -*.js -*.user -*.cache -*.cs -*.sln -*.csproj -*.txt -*.map -*.swp -.DS_Store -npm-debug.log - -_Resharper.DefinitelyTyped -bin -obj -Properties - -# VIM backup files -*~ - -# test folder -_infrastructure/tests/build - -.idea -*.iml -*.js.map -!*.js/ - -node_modules - -.sublimets -.settings/launch.json +*.dll +*.exe +*.cmd +*.pdb +*.suo +*.js +*.user +*.cache +*.cs +*.sln +*.csproj +*.txt +*.map +*.swp +.DS_Store +npm-debug.log + +_Resharper.DefinitelyTyped +bin +obj +Properties + +# VIM backup files +*~ + +# test folder +_infrastructure/tests/build + +.idea +*.iml +*.js.map +!*.js/ + +node_modules + +.sublimets +.settings/launch.json diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 2c07fac20..9e71af53a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1596,4 +1596,5 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](scroller/scroller.d.ts) [Zynga Scroller](https://github.com/zynga/scroller) by [Boris Yankov](https://github.com/borisyankov) * [:link:](zynga-scroller/zynga-scroller.d.ts) [Zynga Scroller](http://zynga.github.com/scroller) by [Marcelo Haskell Camargo](https://github.com/haskellcamargo) * [:link:](viewporter/viewporter.d.ts) [Zynga Viewporter](https://github.com/zynga/viewporter) by [Boris Yankov](https://github.com/borisyankov) +* [:link:](flickity/flickity.d.ts) [Flickity](https://github.com/metafizzy/flickity) by [Chris McGrath](https://github.com/clmcgrath) diff --git a/Finch/Finch-tests.ts b/Finch/Finch-tests.ts index 28aeb6b66..ec15bcb88 100644 --- a/Finch/Finch-tests.ts +++ b/Finch/Finch-tests.ts @@ -1,368 +1,368 @@ -/// - -function test_Finch() { - - - Finch.route("Hello/Route", function() { - return console.log("Well hello there! How you doin'?!"); - }); - - Finch.route("Hello/Route/:someId", function(bindings) { - return console.log("Hey! Here's Some Id: " + bindings.someId); - }); - - Finch.route("Hello/Route/:someId", function(bindings, childCallback) { - console.log("Hey! Here's Some Id: " + bindings.someId); - return childCallback(); - }); - - Finch.route("some/route", { - setup: function(bindings) { - return console.log("Some Route has been setup! :)"); - }, - load: function(bindings) { - return console.log("Some Route has been loaed! :D"); - }, - unload: function(bindings) { - return console.log("Some Route has been loaed! :("); - }, - teardown: function(bindings) { - return console.log("Some Route has been torndown! :'("); - } - }); - - Finch.route("some/route", { - setup: function(bindings, childCallback) { - console.log("Some Route has been setup! :)"); - return childCallback(); - }, - load: function(bindings, childCallback) { - console.log("Some Route has been loaed! :D"); - return childCallback(); - }, - unload: function(bindings, childCallback) { - console.log("Some Route has been loaed! :("); - return childCallback(); - }, - teardown: function(bindings, childCallback) { - console.log("Some Route has been torndown! :'("); - return childCallback(); - } - }); - - Finch.call("Some/Route"); - - Finch.route("Some/Route", function() { - return Finch.observe("hello", "foo", function(hello: any, foo: string) { - return console.log("" + hello + " and " + foo); - }); - }); - - Finch.route("Some/Route", function() { - return Finch.observe(["hello", "foo"], function(hello: any, foo: any) { - return console.log("" + hello + " and " + foo); - }); - }); - - Finch.route("Some/Route", function(bindings) { - return Finch.observe(function(params) { - }); - }); - - Finch.navigate("Some/Route"); - - Finch.navigate("Some/Route", { - hello: 'world', - foo: 'bar' - }); - - Finch.navigate("Some/Route", { - foo: 'bar' - }, true); - - Finch.navigate("Some/Route", true); - - Finch.navigate({ - hello: 'world2', - wow: 'wee' - }); - - Finch.navigate({ - foo: 'bar', - wow: 'wee!!!' - }); - - Finch.navigate({ - hello: 'world2' - }, true); - - Finch.listen(); - Finch.ignore(); - Finch.abort(); - - - //test from Finch - Finch.call("/foo/bar"); - Finch.call("/foo/bar/123"); - Finch.call("/foo/bar/123"); - Finch.call("/foo/bar/123?x=Hello&y=World"); - Finch.call("/foo/baz/456"); - Finch.call("/quux/789?band=Sunn O)))&genre=Post-Progressive Fridgecore"); - Finch.call("/foo/bar/baz"); - Finch.call("/foo/bar/quux"); - Finch.call("/foo"); - Finch.call("/foo/bar"); - Finch.call("/foo"); - Finch.call("/foo"); - Finch.call("/"); - Finch.call("/"); - Finch.call("/foo"); - Finch.call("/foo/bar"); - Finch.call("/foo/bar?baz=quux"); - Finch.call("/foo/bar?baz=xyzzy"); - - var cb: any; - Finch.route("foo", { - setup: cb.setup_foo = this.stub(), - load: cb.load_foo = this.stub(), - unload: cb.unload_foo = this.stub(), - teardown: cb.teardown_foo = this.stub() - }); - Finch.route("[foo]/bar", { - setup: cb.setup_foo_bar = this.stub(), - load: cb.load_foo_bar = this.stub(), - unload: cb.unload_foo_bar = this.stub(), - teardown: cb.teardown_foo_bar = this.stub() - }); - Finch.route("[foo/bar]/:id", { - setup: cb.setup_foo_bar_id = this.stub(), - load: cb.load_foo_bar_id = this.stub(), - unload: cb.unload_foo_bar_id = this.stub(), - teardown: cb.teardown_foo_bar_id = this.stub() - }); - Finch.route("[foo]/baz", { - setup: cb.setup_foo_baz = this.stub(), - load: cb.load_foo_baz = this.stub(), - unload: cb.unload_foo_baz = this.stub(), - teardown: cb.teardown_foo_baz = this.stub() - }); - Finch.route("[foo/baz]/:id", { - setup: cb.setup_foo_baz_id = this.stub(), - load: cb.load_foo_baz_id = this.stub(), - unload: cb.unload_foo_baz_id = this.stub(), - teardown: cb.teardown_foo_baz_id = this.stub() - }); - Finch.call("/foo"); - Finch.call("/foo/bar"); - Finch.call("/foo"); - Finch.call("/foo/bar/123?x=abc"); - Finch.call("/foo/bar/456?x=aaa&y=zzz"); - Finch.call("/foo/bar/456?x=bbb&y=zzz"); - Finch.call("/foo/bar/456?y=zzz&x=bbb"); - Finch.call("/foo/baz/789"); - Finch.call("/foo/baz/abc?term=Hello"); - Finch.call("/foo/baz/abc?term=World"); - Finch.route("bar", this.stub()); - Finch.call("/foo"); - Finch.call("/bar"); - Finch.route("/", function() { - }); - Finch.route("[/]home", function() { - }); - Finch.route("[/home]/news", { - setup: function() { - }, - load: function() { - }, - unload: function() { - return true; - }, - teardown: function() { - return false; - } - }); - Finch.route("/foo", { - setup: function() { - return true; - }, - load: function() { - return true; - }, - unload: function() { - }, - teardown: function() { - } - }); - Finch.route("[/]bar", { - setup: function() { - }, - load: function() { - }, - unload: function() { - }, - teardown: function() { - } - }); - Finch.call("/bar"); - Finch.call("/home/news"); - Finch.call("/foo"); - Finch.call("/home/news"); - Finch.call("/bar"); - Finch.route("baz", this.stub()); - Finch.call("/foo"); - Finch.call("/foo/bar"); - Finch.call("/baz"); - Finch.route("/home", { - setup: function(bindings, next) { - return next(); - }, - load: function(bindings, next) { - return next(); - }, - unload: function(bindings, next) { - return next(); - }, - teardown: function(bindings, next) { - return next(); - } - }); - Finch.route("[/home]/news", { - setup: function(bindings, next) { - return next(); - }, - load: function(bindings, next) { - return next(); - }, - unload: function(bindings, next) { - return next(); - }, - teardown: function(bindings, next) { - return next(); - } - }); - Finch.call("/home"); - Finch.call("/home/news"); - Finch.call("/foo"); - - Finch.route("/", function(bindings) { - return Finch.observe(["x"], function(x) { - }); - }); - Finch.call("/?x=123"); - Finch.call("/?x=123.456"); - Finch.call("/?x=true"); - Finch.call("/?x=false"); - Finch.call("/?x=stuff"); - Finch.options({ - CoerceParameterTypes: true - }); - Finch.call("/?x=123"); - Finch.call("/?x=123.456"); - Finch.call("/?x=true"); - Finch.call("/?x=false"); - Finch.call("/?x=stuff"); - Finch.route("/:x", function(_arg) { - }); - Finch.call("/123"); - Finch.call("/123.456"); - Finch.call("/true"); - Finch.call("/false"); - Finch.call("/stuff"); - Finch.options({ - CoerceParameterTypes: true - }); - Finch.call("/123"); - Finch.call("/123.456"); - Finch.call("/true"); - Finch.call("/false"); - Finch.call("/stuff"); - - Finch.navigate("/home"); - Finch.navigate("/home/news"); - Finch.navigate("/home"); - Finch.navigate("/home", { - foo: "bar" - }); - Finch.navigate("/home", { - hello: "world" - }); - Finch.navigate({ - foos: "bars" - }); - Finch.navigate({ - foos: "baz" - }); - Finch.navigate({ - hello: "world" - }, true); - Finch.navigate({ - foos: null - }, true); - Finch.navigate("/home/news", true); - Finch.navigate("/hello world", {}); - Finch.navigate("/hello world", { - foo: "bar bar" - }); - Finch.navigate({ - foo: "baz baz" - }); - Finch.navigate({ - hello: 'world world' - }, true); - Finch.navigate("/home?foo=bar", { - hello: "world" - }); - Finch.navigate("/home?foo=bar", { - hello: "world", - foo: "baz" - }); - Finch.navigate("/home?foo=bar", { - hello: "world", - free: "bird" - }); - Finch.navigate("#/home", true); - Finch.navigate("#/home"); - Finch.navigate("#/home/news", { - free: "birds", - hello: "worlds" - }); - Finch.navigate("#/home/news", { - foo: "bar" - }, true); - Finch.navigate("/home/news"); - Finch.navigate("../"); - Finch.navigate("./"); - Finch.navigate("./news"); - Finch.navigate("/home/news/article"); - Finch.navigate("../../account"); - - Finch.listen(); - Finch.ignore(); - Finch.route("/home", function(bindings, continuation) { - }); - Finch.route("/foo", function(bindings, continuation) { - }); - Finch.call("home"); - Finch.call("foo"); - Finch.abort(); - Finch.call("foo"); - Finch.route("/", { - 'setup': cb.slash_setup = this.stub(), - 'load': cb.slash_load = this.stub(), - 'unload': cb.slash_unload = this.stub(), - 'teardown': cb.slash_teardown = this.stub() - }); - Finch.route("[/]users/profile", { - 'setup': cb.profile_setup = this.stub(), - 'load': cb.profile_load = this.stub(), - 'unload': cb.profile_unload = this.stub(), - 'teardown': cb.profile_teardown = this.stub() - }); - Finch.route("[/]:page", { - 'setup': cb.page_setup = this.stub(), - 'load': cb.page_load = this.stub(), - 'unload': cb.page_unload = this.stub(), - 'teardown': cb.page_teardown = this.stub() - }); - Finch.call("/users"); -} +/// + +function test_Finch() { + + + Finch.route("Hello/Route", function() { + return console.log("Well hello there! How you doin'?!"); + }); + + Finch.route("Hello/Route/:someId", function(bindings) { + return console.log("Hey! Here's Some Id: " + bindings.someId); + }); + + Finch.route("Hello/Route/:someId", function(bindings, childCallback) { + console.log("Hey! Here's Some Id: " + bindings.someId); + return childCallback(); + }); + + Finch.route("some/route", { + setup: function(bindings) { + return console.log("Some Route has been setup! :)"); + }, + load: function(bindings) { + return console.log("Some Route has been loaed! :D"); + }, + unload: function(bindings) { + return console.log("Some Route has been loaed! :("); + }, + teardown: function(bindings) { + return console.log("Some Route has been torndown! :'("); + } + }); + + Finch.route("some/route", { + setup: function(bindings, childCallback) { + console.log("Some Route has been setup! :)"); + return childCallback(); + }, + load: function(bindings, childCallback) { + console.log("Some Route has been loaed! :D"); + return childCallback(); + }, + unload: function(bindings, childCallback) { + console.log("Some Route has been loaed! :("); + return childCallback(); + }, + teardown: function(bindings, childCallback) { + console.log("Some Route has been torndown! :'("); + return childCallback(); + } + }); + + Finch.call("Some/Route"); + + Finch.route("Some/Route", function() { + return Finch.observe("hello", "foo", function(hello: any, foo: string) { + return console.log("" + hello + " and " + foo); + }); + }); + + Finch.route("Some/Route", function() { + return Finch.observe(["hello", "foo"], function(hello: any, foo: any) { + return console.log("" + hello + " and " + foo); + }); + }); + + Finch.route("Some/Route", function(bindings) { + return Finch.observe(function(params) { + }); + }); + + Finch.navigate("Some/Route"); + + Finch.navigate("Some/Route", { + hello: 'world', + foo: 'bar' + }); + + Finch.navigate("Some/Route", { + foo: 'bar' + }, true); + + Finch.navigate("Some/Route", true); + + Finch.navigate({ + hello: 'world2', + wow: 'wee' + }); + + Finch.navigate({ + foo: 'bar', + wow: 'wee!!!' + }); + + Finch.navigate({ + hello: 'world2' + }, true); + + Finch.listen(); + Finch.ignore(); + Finch.abort(); + + + //test from Finch + Finch.call("/foo/bar"); + Finch.call("/foo/bar/123"); + Finch.call("/foo/bar/123"); + Finch.call("/foo/bar/123?x=Hello&y=World"); + Finch.call("/foo/baz/456"); + Finch.call("/quux/789?band=Sunn O)))&genre=Post-Progressive Fridgecore"); + Finch.call("/foo/bar/baz"); + Finch.call("/foo/bar/quux"); + Finch.call("/foo"); + Finch.call("/foo/bar"); + Finch.call("/foo"); + Finch.call("/foo"); + Finch.call("/"); + Finch.call("/"); + Finch.call("/foo"); + Finch.call("/foo/bar"); + Finch.call("/foo/bar?baz=quux"); + Finch.call("/foo/bar?baz=xyzzy"); + + var cb: any; + Finch.route("foo", { + setup: cb.setup_foo = this.stub(), + load: cb.load_foo = this.stub(), + unload: cb.unload_foo = this.stub(), + teardown: cb.teardown_foo = this.stub() + }); + Finch.route("[foo]/bar", { + setup: cb.setup_foo_bar = this.stub(), + load: cb.load_foo_bar = this.stub(), + unload: cb.unload_foo_bar = this.stub(), + teardown: cb.teardown_foo_bar = this.stub() + }); + Finch.route("[foo/bar]/:id", { + setup: cb.setup_foo_bar_id = this.stub(), + load: cb.load_foo_bar_id = this.stub(), + unload: cb.unload_foo_bar_id = this.stub(), + teardown: cb.teardown_foo_bar_id = this.stub() + }); + Finch.route("[foo]/baz", { + setup: cb.setup_foo_baz = this.stub(), + load: cb.load_foo_baz = this.stub(), + unload: cb.unload_foo_baz = this.stub(), + teardown: cb.teardown_foo_baz = this.stub() + }); + Finch.route("[foo/baz]/:id", { + setup: cb.setup_foo_baz_id = this.stub(), + load: cb.load_foo_baz_id = this.stub(), + unload: cb.unload_foo_baz_id = this.stub(), + teardown: cb.teardown_foo_baz_id = this.stub() + }); + Finch.call("/foo"); + Finch.call("/foo/bar"); + Finch.call("/foo"); + Finch.call("/foo/bar/123?x=abc"); + Finch.call("/foo/bar/456?x=aaa&y=zzz"); + Finch.call("/foo/bar/456?x=bbb&y=zzz"); + Finch.call("/foo/bar/456?y=zzz&x=bbb"); + Finch.call("/foo/baz/789"); + Finch.call("/foo/baz/abc?term=Hello"); + Finch.call("/foo/baz/abc?term=World"); + Finch.route("bar", this.stub()); + Finch.call("/foo"); + Finch.call("/bar"); + Finch.route("/", function() { + }); + Finch.route("[/]home", function() { + }); + Finch.route("[/home]/news", { + setup: function() { + }, + load: function() { + }, + unload: function() { + return true; + }, + teardown: function() { + return false; + } + }); + Finch.route("/foo", { + setup: function() { + return true; + }, + load: function() { + return true; + }, + unload: function() { + }, + teardown: function() { + } + }); + Finch.route("[/]bar", { + setup: function() { + }, + load: function() { + }, + unload: function() { + }, + teardown: function() { + } + }); + Finch.call("/bar"); + Finch.call("/home/news"); + Finch.call("/foo"); + Finch.call("/home/news"); + Finch.call("/bar"); + Finch.route("baz", this.stub()); + Finch.call("/foo"); + Finch.call("/foo/bar"); + Finch.call("/baz"); + Finch.route("/home", { + setup: function(bindings, next) { + return next(); + }, + load: function(bindings, next) { + return next(); + }, + unload: function(bindings, next) { + return next(); + }, + teardown: function(bindings, next) { + return next(); + } + }); + Finch.route("[/home]/news", { + setup: function(bindings, next) { + return next(); + }, + load: function(bindings, next) { + return next(); + }, + unload: function(bindings, next) { + return next(); + }, + teardown: function(bindings, next) { + return next(); + } + }); + Finch.call("/home"); + Finch.call("/home/news"); + Finch.call("/foo"); + + Finch.route("/", function(bindings) { + return Finch.observe(["x"], function(x) { + }); + }); + Finch.call("/?x=123"); + Finch.call("/?x=123.456"); + Finch.call("/?x=true"); + Finch.call("/?x=false"); + Finch.call("/?x=stuff"); + Finch.options({ + CoerceParameterTypes: true + }); + Finch.call("/?x=123"); + Finch.call("/?x=123.456"); + Finch.call("/?x=true"); + Finch.call("/?x=false"); + Finch.call("/?x=stuff"); + Finch.route("/:x", function(_arg) { + }); + Finch.call("/123"); + Finch.call("/123.456"); + Finch.call("/true"); + Finch.call("/false"); + Finch.call("/stuff"); + Finch.options({ + CoerceParameterTypes: true + }); + Finch.call("/123"); + Finch.call("/123.456"); + Finch.call("/true"); + Finch.call("/false"); + Finch.call("/stuff"); + + Finch.navigate("/home"); + Finch.navigate("/home/news"); + Finch.navigate("/home"); + Finch.navigate("/home", { + foo: "bar" + }); + Finch.navigate("/home", { + hello: "world" + }); + Finch.navigate({ + foos: "bars" + }); + Finch.navigate({ + foos: "baz" + }); + Finch.navigate({ + hello: "world" + }, true); + Finch.navigate({ + foos: null + }, true); + Finch.navigate("/home/news", true); + Finch.navigate("/hello world", {}); + Finch.navigate("/hello world", { + foo: "bar bar" + }); + Finch.navigate({ + foo: "baz baz" + }); + Finch.navigate({ + hello: 'world world' + }, true); + Finch.navigate("/home?foo=bar", { + hello: "world" + }); + Finch.navigate("/home?foo=bar", { + hello: "world", + foo: "baz" + }); + Finch.navigate("/home?foo=bar", { + hello: "world", + free: "bird" + }); + Finch.navigate("#/home", true); + Finch.navigate("#/home"); + Finch.navigate("#/home/news", { + free: "birds", + hello: "worlds" + }); + Finch.navigate("#/home/news", { + foo: "bar" + }, true); + Finch.navigate("/home/news"); + Finch.navigate("../"); + Finch.navigate("./"); + Finch.navigate("./news"); + Finch.navigate("/home/news/article"); + Finch.navigate("../../account"); + + Finch.listen(); + Finch.ignore(); + Finch.route("/home", function(bindings, continuation) { + }); + Finch.route("/foo", function(bindings, continuation) { + }); + Finch.call("home"); + Finch.call("foo"); + Finch.abort(); + Finch.call("foo"); + Finch.route("/", { + 'setup': cb.slash_setup = this.stub(), + 'load': cb.slash_load = this.stub(), + 'unload': cb.slash_unload = this.stub(), + 'teardown': cb.slash_teardown = this.stub() + }); + Finch.route("[/]users/profile", { + 'setup': cb.profile_setup = this.stub(), + 'load': cb.profile_load = this.stub(), + 'unload': cb.profile_unload = this.stub(), + 'teardown': cb.profile_teardown = this.stub() + }); + Finch.route("[/]:page", { + 'setup': cb.page_setup = this.stub(), + 'load': cb.page_load = this.stub(), + 'unload': cb.page_unload = this.stub(), + 'teardown': cb.page_teardown = this.stub() + }); + Finch.call("/users"); +} diff --git a/Finch/Finch.d.ts b/Finch/Finch.d.ts index e3dd86c70..ca896570f 100644 --- a/Finch/Finch.d.ts +++ b/Finch/Finch.d.ts @@ -1,47 +1,47 @@ -// Type definitions for Finch 0.5.13 -// Project: https://github.com/stoodder/finchjs -// Definitions by: David Sichau -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -interface FinchCallback { - (bindings?: any, childCallback? : () => void): any; -} - -interface ExpandedCallback { - setup?: FinchCallback; - load?: FinchCallback; - unload?: FinchCallback; - teardown?: FinchCallback; -} - -interface ObserveCallback { - (...args: any[]): string; -} -interface FinchOptions { - CoerceParameterTypes?: boolean; -} - - -interface FinchStatic { - route(route: string, callback: FinchCallback): void; - route(route: string, callbacks: ExpandedCallback): void; - call( uri: string ): void; - - observe(argN: string[], callback: (params: ObserveCallback ) => void): void; - observe(callback: (params: ObserveCallback) => void): void; - observe(...args: any[]): void; - navigate(uri:string, queryParams?:any, doUpdate?:boolean ): void; - navigate(uri:string, doUpdate:boolean ): void; - navigate(queryParams:any, doUpdate?:boolean ): void; - listen(): boolean; - ignore(): boolean; - abort(): void; - options(options: FinchOptions): void; -} - - -declare var Finch: FinchStatic; -declare module "finch" { - export = Finch; -} +// Type definitions for Finch 0.5.13 +// Project: https://github.com/stoodder/finchjs +// Definitions by: David Sichau +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface FinchCallback { + (bindings?: any, childCallback? : () => void): any; +} + +interface ExpandedCallback { + setup?: FinchCallback; + load?: FinchCallback; + unload?: FinchCallback; + teardown?: FinchCallback; +} + +interface ObserveCallback { + (...args: any[]): string; +} +interface FinchOptions { + CoerceParameterTypes?: boolean; +} + + +interface FinchStatic { + route(route: string, callback: FinchCallback): void; + route(route: string, callbacks: ExpandedCallback): void; + call( uri: string ): void; + + observe(argN: string[], callback: (params: ObserveCallback ) => void): void; + observe(callback: (params: ObserveCallback) => void): void; + observe(...args: any[]): void; + navigate(uri:string, queryParams?:any, doUpdate?:boolean ): void; + navigate(uri:string, doUpdate:boolean ): void; + navigate(queryParams:any, doUpdate?:boolean ): void; + listen(): boolean; + ignore(): boolean; + abort(): void; + options(options: FinchOptions): void; +} + + +declare var Finch: FinchStatic; +declare module "finch" { + export = Finch; +} diff --git a/HubSpot-pace/HubSpot-pace-tests.ts b/HubSpot-pace/HubSpot-pace-tests.ts new file mode 100644 index 000000000..1c1daa2a6 --- /dev/null +++ b/HubSpot-pace/HubSpot-pace-tests.ts @@ -0,0 +1,61 @@ +/// + +pace.start({ + document: false +}); + +pace.start(); + +pace.restart(); + +pace.stop(); + +var paceOptions: HubSpotPaceInterfaces.PaceOptions; + +paceOptions = { + // Disable the 'elements' source + elements: false, + + // Only show the progress on regular and ajax-y page navigation, + // not every request + restartOnRequestAfter: false +} + +paceOptions = { + ajax: false, // disabled + document: false, // disabled + eventLag: false, // disabled + elements: { + selectors: ['.my-page'] + } +}; + +paceOptions = { + elements: { + selectors: ['.timeline,.timeline-error', '.user-profile,.profile-error'] + } +} + +paceOptions = { + restartOnPushState: false +} + +paceOptions = { + restartOnRequestAfter: false +} + +pace.options = { + restartOnRequestAfter: false +} + +pace.ignore(function(){ +}); + +pace.track(function(){ +}); + +pace.options = { + ajax: { + ignoreURLs: ['some-substring', /some-regexp/] + } +}; diff --git a/HubSpot-pace/HubSpot-pace.d.ts b/HubSpot-pace/HubSpot-pace.d.ts new file mode 100644 index 000000000..e10e0316a --- /dev/null +++ b/HubSpot-pace/HubSpot-pace.d.ts @@ -0,0 +1,115 @@ +// Type definitions for pace v0.7.5 +// Project: https://github.com/HubSpot/pace +// Definitions by: Borislav Zhivkov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module HubSpotPaceInterfaces { + interface PaceOptions { + /** + * How long should it take for the bar to animate to a new point after receiving it + */ + catchupTime?: number; + /** + * How quickly should the bar be moving before it has any progress info from a new source in %/ms + */ + initialRate?: number; + /** + * What is the minimum amount of time the bar should be on the screen. Irrespective of this number, the bar will always be on screen for 33 * (100 / maxProgressPerFrame) + ghostTime ms. + */ + minTime?: number; + /** + * What is the minimum amount of time the bar should sit after the last update before disappearing + */ + ghostTime?: number; + /** + * Its easy for a bunch of the bar to be eaten in the first few frames before we know how much there is to load. This limits how much of the bar can be used per frame + */ + maxProgressPerFrame?: number; + /** + * This tweaks the animation easing + */ + easeFactor?: number; + /** + * Should pace automatically start when the page is loaded, or should it wait for `start` to be called? Always false if pace is loaded with AMD or CommonJS. + */ + startOnPageLoad?: boolean; + /** + * Should we restart the browser when pushState or replaceState is called? (Generally means ajax navigation has occured) + */ + restartOnPushState?: boolean; + /** + * Should we show the progress bar for every ajax request (not just regular or ajax-y page navigation)? Set to false to disable. If so, how many ms does the request have to be running for before we show the progress? + */ + restartOnRequestAfter?: boolean | number; + /** + * What element should the pace element be appended to on the page? + */ + target?: string; + document?: boolean | string; + elements?: boolean | PaceElementsOptions; + eventLag?: boolean | PaceEventLagOptions; + ajax?: boolean | PaceAjaxOptions; + } + + interface PaceElementsOptions { + /** + * How frequently in ms should we check for the elements being tested for using the element monitor? + */ + checkInterval?: number; + /** + * What elements should we wait for before deciding the page is fully loaded (not required) + */ + selectors?: string[]; + } + + interface PaceEventLagOptions { + /** + * When we first start measuring event lag, not much is going on in the browser yet, so it's not uncommon for the numbers to be abnormally low for the first few samples. This configures how many samples we need before we consider a low number to mean completion. + */ + minSamples?: number; + /** + * How many samples should we average to decide what the current lag is? + */ + sampleCount?: number; + /** + * Above how many ms of lag is the CPU considered busy? + */ + lagThreshold?: number; + } + + interface PaceAjaxOptions { + /** + * Which HTTP methods should we track? + */ + trackMethods?: string[]; + /** + * Should we track web socket connections? + */ + trackWebSockets?: boolean; + /** + * A list of regular expressions or substrings of URLS we should ignore (for both tracking and restarting) + */ + ignoreURLs?: (string | RegExp)[]; + } + + interface Pace { + options: PaceOptions; + + start(options?: PaceOptions): void; + restart(): void; + stop(): void; + track(fn: () => void, ...args: any[]): void; + ignore(fn: () => void, ...args: any[]): void; + + on(event: string, handler: (...args: any[]) => void, context?: any): void; + off(event: string, handler?: (...args: any[]) => void): void; + once(event: string, handler: (...args: any[]) => void, context?: any): void; + } + + enum PaceEvent { start, stop, restart, done, hide } +} + +declare var pace: HubSpotPaceInterfaces.Pace; +declare module "HubSpot-pace" { + export = pace; +} diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..a9ae49873 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,5 @@ +- [ ] I tried using the latest `xxxx/xxxx.d.ts` file in this repo and had problems. +- [ ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript +- [ ] I have a question that is inappropriate for [StackOverflow](https://stackoverflow.com/). (Please ask any appropriate questions there). +- [ ] I want to talk about `xxxx/xxxx.d.ts`. + - The authors of that type definition are cc/ @.... diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..730bd78af --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +case 1. Add a new type definition. +- [ ] checked compilation succeeds with `--target es6` and `--noImplicitAny` options. +- [ ] has correct [naming convention](http://definitelytyped.org/guides/contributing.html#naming-the-file) +- [ ] has a [test file](http://definitelytyped.org/guides/contributing.html#tests) with the suffix of `-tests.ts` or `-tests.tsx`. + +case 2. Improvement to existing type definition. +- documentation or source code reference which provides context for the suggested changes. url http://api.jquery.com/html . + - it has been reviewed by a DefinitelyTyped member. diff --git a/README.md b/README.md index 7e1d60d87..47c56482c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi ## How to get the definitions -* Directly from the Github repos +* Directly from the GitHub repos * [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped) * [TypeScript Definition manager](https://github.com/DefinitelyTyped/tsd) diff --git a/accounting/accounting-tests.ts b/accounting/accounting-tests.ts index a00f2fefc..bc9b74eaa 100644 --- a/accounting/accounting-tests.ts +++ b/accounting/accounting-tests.ts @@ -1,107 +1,107 @@ -/// - -// formatMoney - -// Default usage: -accounting.formatMoney(12345678); // $12,345,678.00 - -// European formatting (custom symbol and separators), could also use options object as second param: -accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99 - -// Negative values are formatted nicely, too: -accounting.formatMoney(-500000, "£ ", 0); // £ -500,000 - -// Simple `format` string allows control of symbol position [%v = value, %s = symbol]: -accounting.formatMoney(5318008, { symbol: "GBP", format: "%v %s" }); // 5,318,008.00 GBP - -// Example usage with options object: -accounting.formatMoney(5318008, { - symbol: "GBP", - precision: 0, - thousand: "·", - format: { - pos: "%s %v", - neg: "%s (%v)", - zero: "%s --" - } -}); - -// Will recursively format an array of values: -accounting.formatMoney([123, 456, [78, 9]], "$", 0); // ["$123", "$456", ["$78", "$9"]] - - - -// formatColumn - -// Format list of numbers for display: -accounting.formatColumn([123.5, 3456.49, 777888.99, 12345678, -5432], "$ "); - -// Example usage (NB. use a space after the symbol to add arbitrary padding to all values): -accounting.formatColumn([123, 12345], "$ ", 0); // ["$ 123", "$ 12,345"] - -// List of numbers can be a multi-dimensional array (formatColumn is applied recursively): -accounting.formatColumn([[1, 100], [900, 9]]); // [["$ 1.00", "$100.00"], ["$900.00", "$ 9.00"]] - - - -// formatNumber - -// Example usage: -accounting.formatNumber(5318008); // 5,318,008 -accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210 -accounting.formatNumber(4999.99, 2, ".", ","); // 4.999,99 - -// Example usage with options object: -accounting.formatNumber(5318008, { - precision: 3, - thousand: " " -}); - -// Will recursively format an array of values: -accounting.formatNumber([123456, [7890, 123]]); // ["123,456", ["7,890", "123"]] - - - -// toFixed - -(0.615).toFixed(2); // "0.61" -accounting.toFixed(0.615, 2); // "0.62" - - - - -// unformat - -// Example usage: -accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9 -accounting.unformat("GBP £ 12,345,678.90"); // 12345678.9 - -// If a non-standard decimal separator was used (eg. a comma) unformat() will need it in order to work out -// which part of the number is a decimal/float: -accounting.unformat("€ 1.000.000,00", ","); // 1000000 - -// Settings object that controls default parameters for library methods: -accounting.settings = { - currency: { - symbol: "$", // default currency symbol is '$' - format: "%s%v", // controls output: %s = symbol, %v = value/number (can be object: see below) - decimal: ".", // decimal point separator - thousand: ",", // thousands separator - precision: 2 // decimal places - }, - number: { - precision: 0, // default precision on numbers is 0 - thousand: ",", - decimal: "." - } -}; - -// These can be changed externally to edit the library's defaults: -accounting.settings.currency.format = "%s %v"; - -// Format can be an object, with `pos`, `neg` and `zero`: -accounting.settings.currency.format = { - pos: "%s %v", // for positive values, eg. "$ 1.00" (required) - neg: "%s (%v)", // for negative values, eg. "$ (1.00)" [optional] - zero: "%s -- " // for zero values, eg. "$ --" [optional] -}; \ No newline at end of file +/// + +// formatMoney + +// Default usage: +accounting.formatMoney(12345678); // $12,345,678.00 + +// European formatting (custom symbol and separators), could also use options object as second param: +accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99 + +// Negative values are formatted nicely, too: +accounting.formatMoney(-500000, "£ ", 0); // £ -500,000 + +// Simple `format` string allows control of symbol position [%v = value, %s = symbol]: +accounting.formatMoney(5318008, { symbol: "GBP", format: "%v %s" }); // 5,318,008.00 GBP + +// Example usage with options object: +accounting.formatMoney(5318008, { + symbol: "GBP", + precision: 0, + thousand: "·", + format: { + pos: "%s %v", + neg: "%s (%v)", + zero: "%s --" + } +}); + +// Will recursively format an array of values: +accounting.formatMoney([123, 456, [78, 9]], "$", 0); // ["$123", "$456", ["$78", "$9"]] + + + +// formatColumn + +// Format list of numbers for display: +accounting.formatColumn([123.5, 3456.49, 777888.99, 12345678, -5432], "$ "); + +// Example usage (NB. use a space after the symbol to add arbitrary padding to all values): +accounting.formatColumn([123, 12345], "$ ", 0); // ["$ 123", "$ 12,345"] + +// List of numbers can be a multi-dimensional array (formatColumn is applied recursively): +accounting.formatColumn([[1, 100], [900, 9]]); // [["$ 1.00", "$100.00"], ["$900.00", "$ 9.00"]] + + + +// formatNumber + +// Example usage: +accounting.formatNumber(5318008); // 5,318,008 +accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210 +accounting.formatNumber(4999.99, 2, ".", ","); // 4.999,99 + +// Example usage with options object: +accounting.formatNumber(5318008, { + precision: 3, + thousand: " " +}); + +// Will recursively format an array of values: +accounting.formatNumber([123456, [7890, 123]]); // ["123,456", ["7,890", "123"]] + + + +// toFixed + +(0.615).toFixed(2); // "0.61" +accounting.toFixed(0.615, 2); // "0.62" + + + + +// unformat + +// Example usage: +accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9 +accounting.unformat("GBP £ 12,345,678.90"); // 12345678.9 + +// If a non-standard decimal separator was used (eg. a comma) unformat() will need it in order to work out +// which part of the number is a decimal/float: +accounting.unformat("€ 1.000.000,00", ","); // 1000000 + +// Settings object that controls default parameters for library methods: +accounting.settings = { + currency: { + symbol: "$", // default currency symbol is '$' + format: "%s%v", // controls output: %s = symbol, %v = value/number (can be object: see below) + decimal: ".", // decimal point separator + thousand: ",", // thousands separator + precision: 2 // decimal places + }, + number: { + precision: 0, // default precision on numbers is 0 + thousand: ",", + decimal: "." + } +}; + +// These can be changed externally to edit the library's defaults: +accounting.settings.currency.format = "%s %v"; + +// Format can be an object, with `pos`, `neg` and `zero`: +accounting.settings.currency.format = { + pos: "%s %v", // for positive values, eg. "$ 1.00" (required) + neg: "%s (%v)", // for negative values, eg. "$ (1.00)" [optional] + zero: "%s -- " // for zero values, eg. "$ --" [optional] +}; diff --git a/accounting/accounting.d.ts b/accounting/accounting.d.ts index ea861612b..675104047 100644 --- a/accounting/accounting.d.ts +++ b/accounting/accounting.d.ts @@ -3,28 +3,28 @@ // Definitions by: Sergey Gerasimov // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface IAccountingCurrencyFormat { - pos: string; // for positive values, eg. "$ 1.00" - neg?: string; // for negative values, eg. "$ (1.00)" +interface IAccountingCurrencyFormat { + pos: string; // for positive values, eg. "$ 1.00" + neg?: string; // for negative values, eg. "$ (1.00)" zero?: string; // for zero values, eg. "$ --" } -interface IAccountingCurrencySettings { - symbol?: string; // default currency symbol is '$' - format?: TFormat; // controls output: %s = symbol, %v = value/number - decimal?: string; // decimal point separator - thousand?: string; // thousands separator +interface IAccountingCurrencySettings { + symbol?: string; // default currency symbol is '$' + format?: TFormat; // controls output: %s = symbol, %v = value/number + decimal?: string; // decimal point separator + thousand?: string; // thousands separator precision?: number // decimal places } -interface IAccountingNumberSettings { - precision?: number; // default precision on numbers is 0 - thousand?: string; - decimal?: string; +interface IAccountingNumberSettings { + precision?: number; // default precision on numbers is 0 + thousand?: string; + decimal?: string; } -interface IAccountingSettings { - currency: IAccountingCurrencySettings; // IAccountingCurrencySettings or IAccountingCurrencySettings +interface IAccountingSettings { + currency: IAccountingCurrencySettings; // IAccountingCurrencySettings or IAccountingCurrencySettings number: IAccountingNumberSettings; } @@ -76,4 +76,4 @@ declare var accounting: IAccountingStatic; declare module "accounting" { export = accounting; -} \ No newline at end of file +} diff --git a/ace/all-tests.ts.tscparams b/ace/all-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/all-tests.ts.tscparams +++ b/ace/all-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-anchor-tests.ts.tscparams b/ace/tests/ace-anchor-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-anchor-tests.ts.tscparams +++ b/ace/tests/ace-anchor-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-background_tokenizer-tests.ts.tscparams b/ace/tests/ace-background_tokenizer-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-background_tokenizer-tests.ts.tscparams +++ b/ace/tests/ace-background_tokenizer-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-default-tests.ts.tscparams b/ace/tests/ace-default-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-default-tests.ts.tscparams +++ b/ace/tests/ace-default-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-document-tests.ts.tscparams b/ace/tests/ace-document-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-document-tests.ts.tscparams +++ b/ace/tests/ace-document-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-edit_session-tests.ts.tscparams b/ace/tests/ace-edit_session-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-edit_session-tests.ts.tscparams +++ b/ace/tests/ace-edit_session-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-editor1-tests.ts.tscparams b/ace/tests/ace-editor1-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-editor1-tests.ts.tscparams +++ b/ace/tests/ace-editor1-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams +++ b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-editor_navigation-tests.ts.tscparams b/ace/tests/ace-editor_navigation-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-editor_navigation-tests.ts.tscparams +++ b/ace/tests/ace-editor_navigation-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-multi_select-tests.ts.tscparams b/ace/tests/ace-multi_select-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-multi_select-tests.ts.tscparams +++ b/ace/tests/ace-multi_select-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-placeholder-tests.ts.tscparams b/ace/tests/ace-placeholder-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-placeholder-tests.ts.tscparams +++ b/ace/tests/ace-placeholder-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-range_list-tests.ts.tscparams b/ace/tests/ace-range_list-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-range_list-tests.ts.tscparams +++ b/ace/tests/ace-range_list-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-selection-tests.ts.tscparams b/ace/tests/ace-selection-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-selection-tests.ts.tscparams +++ b/ace/tests/ace-selection-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-token_iterator-tests.ts.tscparams b/ace/tests/ace-token_iterator-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-token_iterator-tests.ts.tscparams +++ b/ace/tests/ace-token_iterator-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/ace/tests/ace-virtual_renderer-tests.ts.tscparams b/ace/tests/ace-virtual_renderer-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/ace/tests/ace-virtual_renderer-tests.ts.tscparams +++ b/ace/tests/ace-virtual_renderer-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/acl/acl.d.ts b/acl/acl.d.ts index 57e85d9d5..66fee09d1 100644 --- a/acl/acl.d.ts +++ b/acl/acl.d.ts @@ -7,7 +7,7 @@ /// /// -/// +/// declare module "acl" { import http = require('http'); diff --git a/adm-zip/adm-zip-tests.ts b/adm-zip/adm-zip-tests.ts index 93f8f2f2d..8637751bf 100644 --- a/adm-zip/adm-zip-tests.ts +++ b/adm-zip/adm-zip-tests.ts @@ -17,7 +17,8 @@ console.log(zip.readAsText("some_folder/my_file.txt")); 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); - +// extracts everything and calls callback -> async extracction +zip.extractAllToAsync(/*target path*/"/home/me/zipcontent/", /*overwrite*/true, (error: Error)=> {}); // creating archives var zip = new AdmZip(); @@ -58,4 +59,4 @@ zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true); function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry { return obj !== null && typeof obj === "object" && typeof obj['entryName'] === 'string'; -} \ No newline at end of file +} diff --git a/adm-zip/adm-zip.d.ts b/adm-zip/adm-zip.d.ts index 208c13b27..a42978ca8 100644 --- a/adm-zip/adm-zip.d.ts +++ b/adm-zip/adm-zip.d.ts @@ -1,6 +1,6 @@ // Type definitions for adm-zip v0.4.4 // Project: https://github.com/cthackers/adm-zip -// Definitions by: John Vilk +// Definitions by: John Vilk , Abner Oliveira // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -211,6 +211,14 @@ declare module "adm-zip" { * will be overwriten if this is true. Default is FALSE */ extractAllTo(targetPath: string, overwrite?: boolean): void; + /** + * 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 + * @param callback The callback function will be called afeter extraction + */ + extractAllToAsync(targetPath: string, overwrite: boolean, callback: (error: Error) => void): 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 diff --git a/ag-grid/ag-grid.d.ts b/ag-grid/ag-grid.d.ts index f385a90f4..6dd6e90e4 100644 --- a/ag-grid/ag-grid.d.ts +++ b/ag-grid/ag-grid.d.ts @@ -1464,7 +1464,6 @@ declare module ag.grid { addDropTarget(eDropTarget: any, dropTargetCallback: any): void; } } -declare function require(name: string): any; declare module ag.grid { class AgList { private eGui; diff --git a/agenda/agenda-tests.ts b/agenda/agenda-tests.ts new file mode 100644 index 000000000..6be618e59 --- /dev/null +++ b/agenda/agenda-tests.ts @@ -0,0 +1,106 @@ +/// + +import * as Agenda from "agenda"; + + +var mongoConnectionString = "mongodb://127.0.0.1/agenda"; + +var agenda = new Agenda({ db: { address: mongoConnectionString } }); + + +agenda.define('delete old users', (job, done) => { + +}); + +agenda.on('ready', () => { + agenda.every('3 minutes', 'delete old users'); + + // Alternatively, you could also do: + agenda.every('*/3 * * * *', 'delete old users'); + + agenda.start(); +}); + +agenda.define('send email report', { priority: 'high', concurrency: 10 }, (job, done) => { +}); + +agenda.on('ready', () => { + agenda.schedule('in 20 minutes', 'send email report', { to: 'admin@example.com' }); + agenda.start(); +}); + +agenda.on('ready', () => { + var weeklyReport = agenda.create('send email report', { to: 'another-guy@example.com' }); + weeklyReport.repeatEvery('1 week').save(); + agenda.start(); +}); + +var agenda = new Agenda({ processEvery: '30 seconds' }); + +agenda.defaultConcurrency(5); + +var agenda = new Agenda({ defaultConcurrency: 5 }); + +agenda.lockLimit(0); + +var agenda = new Agenda({ lockLimit: 0 }); + +agenda.defaultLockLimit(0); + +var agenda = new Agenda({ defaultLockLimit: 0 }); + +agenda.defaultLockLifetime(10000); + +var agenda = new Agenda({ defaultLockLifetime: 10000 }); + +agenda.define('some long running job', function(job, done) { + done(); +}); + +agenda.every('15 minutes', ['printAnalyticsReport', 'sendNotifications', 'updateUserRecords']); + +agenda.schedule('tomorrow at noon', 'printAnalyticsReport', { userCount: 100 }); + +agenda.schedule('tomorrow at noon', ['printAnalyticsReport', 'sendNotifications', 'updateUserRecords']); + +agenda.now('do the hokey pokey'); + +var job = agenda.create('printAnalyticsReport', { userCount: 100 }); +job.save(function(err) { + console.log("Job successfully saved"); +}); + +agenda.jobs({ name: 'printAnalyticsReport' }, function(err, jobs) { + // Work with jobs (see below) +}); + +agenda.cancel({ name: 'printAnalyticsReport' }, function(err, numRemoved) { +}); + +agenda.purge(function(err, numRemoved) { +}); + +agenda.stop(function() { + process.exit(0); +}); + +job.repeatEvery('10 minutes'); + +job.repeatAt('3:30pm'); + +job.schedule('tomorrow at 6pm'); + +job.priority('low'); +job.priority(10); + +job.unique({ 'data.type': 'active', 'data.userId': '123' }); +job.fail('insuficient disk space'); +job.fail(new Error('insufficient disk space')); +job.run(function(err, job) { + console.log("I don't know why you would need to do this..."); +}); +job.remove(function(err) { + if (!err) console.log("Successfully removed job from collection"); +}) + + diff --git a/agenda/agenda.d.ts b/agenda/agenda.d.ts new file mode 100644 index 000000000..3bc7b1c85 --- /dev/null +++ b/agenda/agenda.d.ts @@ -0,0 +1,443 @@ +// Type definitions for Agenda v0.8.9 +// Project: https://github.com/rschmukler/agenda +// Definitions by: Meir Gottlieb +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "agenda" { + + import {EventEmitter} from "events"; + import {Db, Collection, ObjectID} from "mongodb"; + + interface Callback { + (err?: Error): void; + } + + interface ResultCallback { + (err?: Error, result?: T): void; + } + + /** + * Agenda Configuration. + */ + interface AgendaConfiguration { + + /** + * Sets the interval with which the queue is checked. A number in milliseconds or a frequency string. + */ + processEvery?: string | number; + + /** + * Takes a number which specifies the default number of a specific job that can be running at any given moment. + * By default it is 5. + */ + defaultConcurrency?: number; + + /** + * Takes a number which specifies the max number of jobs that can be running at any given moment. By default it + * is 20. + */ + maxConcurrency?: number; + + /** + * Takes a number which specifies the default number of a specific job that can be locked at any given moment. + * By default it is 0 for no max. + */ + defaultLockLimit?: number; + + /** + * Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is + * 0 for no max. + */ + lockLimit?: number; + + /** + * Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This + * can be overridden by specifying the lockLifetime option to a defined job. + */ + defaultLockLifetime?: number; + + /** + * Specifies that Agenda should be initialized using and existing MongoDB connection. + */ + mongo?: { + /** + * The MongoDB database connection to use. + */ + db: Db; + + /** + * The name of the collection to use. + */ + collection?: string; + } + + /** + * Specifies that Agenda should connect to MongoDB. + */ + db?: { + /** + * The connection URL. + */ + address: string; + + /** + * The name of the collection to use. + */ + collection?: string; + + /** + * Connection options to pass to MongoDB. + */ + options?: any; + } + } + + /** + * The database record associated with a job. + */ + interface JobAttributes { + /** + * The record identity. + */ + _id: ObjectID; + + /** + * The name of the job. + */ + name: string; + + /** + * The type of the job (single|normal). + */ + type: string; + + /** + * The job details. + */ + data: { [name: string]: any }; + + /** + * The priority of the job. + */ + priority: number; + + /** + * How often the job is repeated using a human-readable or cron format. + */ + repeatInterval: string | number; + + /** + * The timezone that conforms to [moment-timezone](http://momentjs.com/timezone/). + */ + repeatTimezone: string; + + /** + * Date/time the job was las modified. + */ + lastModifiedBy: string; + + /** + * Date/time the job will run next. + */ + nextRunAt: Date; + + /** + * Date/time the job was locked. + */ + lockedAt: Date; + + /** + * Date/time the job was last run. + */ + lastRunAt: Date; + + /** + * Date/time the job last finished running. + */ + lastFinishedAt: Date; + + /** + * The reason the job failed. + */ + failReason: string; + + /** + * The number of times the job has failed. + */ + failCount: number; + + /** + * The date/time the job last failed. + */ + failedAt: Date; + } + + /** + * A scheduled job. + */ + interface Job { + + /** + * The database record associated with the job. + */ + attrs: JobAttributes; + + /** + * Specifies an interval on which the job should repeat. + * @param interval A human-readable format String, a cron format String, or a Number. + * @param options An optional argument that can include a timezone field. The timezone should be a string as + * accepted by moment-timezone and is considered when using an interval in the cron string format. + */ + repeatEvery(interval: string | number, options?: { timezone?: string }): Job + + /** + * Specifies a time when the job should repeat. [Possible values](https://github.com/matthewmueller/date#examples). + * @param time + */ + repeatAt(time: string): Job + + /** + * Disables the job. + */ + disable(): Job; + + /** + * Enables the job. + */ + enable(): Job; + + /** + * Ensure that only one instance of this job exists with the specified properties + * @param value The properties associated with the job that must be unqiue. + * @param opts + */ + unique(value: any, opts?: { insertOnly?: boolean }): Job; + + /** + * Specifies the next time at which the job should run. + * @param time The next time at which the job should run. + */ + schedule(time: string | Date): Job; + + /** + * Specifies the priority weighting of the job. + * @param value The priority of the job (lowest|low|normal|high|highest|number). + */ + priority(value: string | number): Job; + + /** + * Sets job.attrs.failedAt to now, and sets job.attrs.failReason to reason. + * @param reason A message or Error object that indicates why the job failed. + */ + fail(reason: string | Error): Job; + + /** + * Runs the given job and calls callback(err, job) upon completion. Normally you never need to call this manually + * @param cb Called when the job is completed. + */ + run(cb?: ResultCallback): Job; + + /** + * Returns true if the job is running; otherwise, returns false. + */ + isRunning(): boolean; + + /** + * Saves the job into the database. + * @param cb Called when the job is saved. + */ + save(cb?: ResultCallback): Job; + + /** + * Removes the job from the database and cancels the job. + * @param cb Called after the job has beeb removed from the database. + */ + remove(cb?: Callback): void; + + /** + * Resets the lock on the job. Useful to indicate that the job hasn't timed out when you have very long running + * jobs. + * @param cb Called after the job has been saved to the database. + */ + touch(cb?: Callback): void; + } + + interface JobOptions { + + /** + * Maximum number of that job that can be running at once (per instance of agenda) + */ + concurrency?: number; + + /** + * Maximum number of that job that can be locked at once (per instance of agenda) + */ + lockLimit?: number; + + /** + * Interval in ms of how long the job stays locked for (see multiple job processors for more info). A job will + * automatically unlock if done() is called. + */ + lockLifetime?: number; + + /** + * (lowest|low|normal|high|highest|number) specifies the priority of the job. Higher priority jobs will run + * first. + */ + priority?: string | number; + } + + class Agenda extends EventEmitter { + + /** + * Constructs a new Agenda object. + * @param config Optional configuration to initialize the Agenda. + * @param cb Optional callback called with the MongoDB colleciton. + */ + constructor(config?: AgendaConfiguration, cb?: ResultCallback); + + /** + * Connect to the specified MongoDB server and database. + */ + database(url: string, collection?: string, options?: any, cb?: ResultCallback): Agenda; + + /** + * Initialize agenda with an existing MongoDB connection. + */ + mongo(db: Db, collection?: string, cb?: ResultCallback): Agenda; + + /** + * Sets the agenda name. + */ + name(value: string): Agenda; + + /** + * Sets the interval with which the queue is checked. A number in milliseconds or a frequency string. + */ + processEvery(interval: string | number): Agenda; + + /** + * Takes a number which specifies the max number of jobs that can be running at any given moment. By default it + * is 20. + * @param value The value to set. + */ + maxConcurrency(value: number): Agenda; + + /** + * Takes a number which specifies the default number of a specific job that can be running at any given moment. + * By default it is 5. + * @param value The value to set. + */ + defaultConcurrency(value: number): Agenda; + + /** + * Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is + * 0 for no max. + * @param value The value to set. + */ + lockLimit(value: number): Agenda; + + /** + * Takes a number which specifies the default number of a specific job that can be locked at any given moment. + * By default it is 0 for no max. + * @param value The value to set. + */ + defaultLockLimit(value: number): Agenda; + + /** + * Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This + * can be overridden by specifying the lockLifetime option to a defined job. + * @param value The value to set. + */ + defaultLockLifetime(value: number): Agenda; + + /** + * Returns an instance of a jobName with data. This does NOT save the job in the database. See below to learn + * how to manually work with jobs. + * @param name The name of the job. + * @param data Data to associated with the job. + */ + create(name: string, data?: any): Job; + + /** + * Find all Jobs matching `query` and pass same back in cb(). + * @param query + * @param cb + */ + jobs(query: any, cb: ResultCallback): void; + + /** + * Removes all jobs in the database without defined behaviors. Useful if you change a definition name and want + * to remove old jobs. + * @param cb Called with the number of jobs removed. + */ + purge(cb?: ResultCallback): void; + + /** + * Defines a job with the name of jobName. When a job of job name gets run, it will be passed to fn(job, done). + * To maintain asynchronous behavior, you must call done() when you are processing the job. If your function is + * synchronous, you may omit done from the signature. + * @param name The name of the jobs. + * @param options The options for the job. + * @param handler The handler to execute. + */ + define(name: string, handler: (job?: Job, done?: (err?: Error) => void) => void): void; + define(name: string, options: JobOptions, handler: (job?: Job, done?: (err?: Error) => void) => void): void; + + /** + * Runs job name at the given interval. Optionally, data and options can be passed in. + * @param interval Can be a human-readable format String, a cron format String, or a Number. + * @param names The name or names of the job(s) to run. + * @param data An optional argument that will be passed to the processing function under job.attrs.data. + * @param options An optional argument that will be passed to job.repeatEvery. + * @param cb An optional callback function which will be called when the job has been persisted in the database. + */ + every(interval: number | string, names: string, data?: any, options?: any, cb?: ResultCallback): Job; + every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback): Job[]; + + /** + * Schedules a job to run name once at a given time. + * @param when A Date or a String such as tomorrow at 5pm. + * @param names The name or names of the job(s) to run. + * @param data An optional argument that will be passed to the processing function under job.attrs.data. + * @param cb An optional callback function which will be called when the job has been persisted in the database. + */ + schedule(when: Date | string, names: string, data?: any, cb?: ResultCallback): Job; + schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback): Job[]; + + /** + * Schedules a job to run name once immediately. + * @param name The name of the job to run. + * @param data An optional argument that will be passed to the processing function under job.attrs.data. + * @param cb An optional callback function which will be called when the job has been persisted in the database. + */ + now(name: string, data?: any, cb?: ResultCallback): Job; + + /** + * Cancels any jobs matching the passed mongodb-native query, and removes them from the database. + * @param query Mongodb native query. + * @param cb Called with the number of jobs removed. + */ + cancel(query: any, cb?: ResultCallback): void; + + /** + * Starts the job queue processing, checking processEvery time to see if there are new jobs. + */ + start(): void; + + /** + * Stops the job queue processing. Unlocks currently running jobs. + * @param cb Called after the job processing queue shuts down and unlocks all jobs. + */ + stop(cb: Callback): void; + } + + module Agenda { + + } + + export = Agenda; +} diff --git a/alt/alt-tests.ts b/alt/alt-tests.ts index 403c9d99a..fad079b02 100644 --- a/alt/alt-tests.ts +++ b/alt/alt-tests.ts @@ -2,10 +2,8 @@ * Created by shearerbeard on 6/28/15. */ /// -/// import Alt = require("alt"); -import Promise = require("es6-promise"); //New alt instance var alt = new Alt(); @@ -43,8 +41,8 @@ class AbstractStoreModel implements AltJS.StoreModel { class GenerateActionsClass extends AbstractActions { constructor(config:AltJS.Alt) { - this.generateActions("notifyTest"); super(config); + this.generateActions("notifyTest"); } } @@ -74,7 +72,7 @@ var testSource:AltJS.Source = { fakeLoad():AltJS.SourceModel { return { remote() { - return new Promise.Promise((res:any, rej:any) => { + return new Promise((res:any, rej:any) => { setTimeout(() => { if(true) { res("stuff"); diff --git a/alt/alt.d.ts b/alt/alt.d.ts index 0e0b40d8f..0d7bc8632 100644 --- a/alt/alt.d.ts +++ b/alt/alt.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// declare module AltJS { diff --git a/amazon-product-api/amazon-product-api.d.ts b/amazon-product-api/amazon-product-api.d.ts index fc84dcc09..7ce5d92e3 100644 --- a/amazon-product-api/amazon-product-api.d.ts +++ b/amazon-product-api/amazon-product-api.d.ts @@ -3,8 +3,6 @@ // Definitions by: Matti Lehtinen // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - declare module "amazon-product-api" { interface ICredentials { diff --git a/amcharts/AmCharts.d.ts.tscparams b/amcharts/AmCharts.d.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/amcharts/AmCharts.d.ts.tscparams +++ b/amcharts/AmCharts.d.ts.tscparams @@ -1 +1 @@ - + diff --git a/amplifyjs/amplifyjs-tests.ts.tscparams b/amplifyjs/amplifyjs-tests.ts.tscparams index d3f5a12fa..8b1378917 100644 --- a/amplifyjs/amplifyjs-tests.ts.tscparams +++ b/amplifyjs/amplifyjs-tests.ts.tscparams @@ -1 +1 @@ - + diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts index d03c46ed7..fd74a48c0 100644 --- a/amqplib/amqplib.d.ts +++ b/amqplib/amqplib.d.ts @@ -38,6 +38,7 @@ declare module "amqplib/properties" { messageTtl?: number; expires?: number; deadLetterExchange?: string; + deadLetterRoutingKey?: string; maxLength?: number; } interface DeleteQueue { diff --git a/angular-cookie/angular-cookie-tests.ts b/angular-cookie/angular-cookie-tests.ts new file mode 100644 index 000000000..e6280fbeb --- /dev/null +++ b/angular-cookie/angular-cookie-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +angular.module('myApp', ['ipCookie']) + .controller('cookieController', ['ipCookie', function(ipCookie: angular.cookie.CookieService) { + ipCookie('key', 'value'); + ipCookie('key', { value: 'value'}); + ipCookie('key', [1, 2, 3]); + + ipCookie('key', 'value', { expires: 21 }); + ipCookie('key', 'value', { encode: function (value) { return value; } }); + + ipCookie(); + ipCookie('key'); + ipCookie('key', undefined, {decode: function (value) { return value; }}); + + ipCookie.remove('key'); + ipCookie.remove('key', { path: '/some/path/' }); + + var obj: Object = '255'; + }]); \ No newline at end of file diff --git a/angular-cookie/angular-cookie.d.ts b/angular-cookie/angular-cookie.d.ts new file mode 100644 index 000000000..99041f934 --- /dev/null +++ b/angular-cookie/angular-cookie.d.ts @@ -0,0 +1,65 @@ +// Type definitions for angular-cookie v4.1.0 +// Project: https://github.com/ivpusic/angular-cookie +// Definitions by: Borislav Zhivkov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module angular.cookie { + interface CookieService { + /** + * Get all cookies + */ + (): any; + + /** + * Get a cookie with a specific key + */ + (key: string): any; + + /** + * Create a cookie + */ + (key: string, value: any, options?: CookieOptions): any; + + /** + * Remove a cookie + */ + remove(key: string, options?: CookieOptions): void; + } + + interface CookieOptions { + /** + * The domain tells the browser to which domain the cookie should be sent. If you don't specify it, it becomes the domain of the page that sets the cookie. + */ + domain?: string; + + /** + * The path gives you the chance to specify a directory where the cookie is active. + */ + path?: string; + + /** + * Each cookie has an expiry date after which it is trashed. If you don't specify the expiry date the cookie is trashed when you close the browser. + */ + expires?: number; + + /** + * Allows you to set the expiration time in hours, minutes, seconds, or `milliseconds. If this is not specified, any expiration time specified will default to days. + */ + expirationUnit?: string; + + /** + * The Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections. + */ + secure?: boolean; + + /** + * The method that will be used to encode the cookie value (should be passed when using Set). + */ + encode?: (value: any) => any; + + /** + * The method that will be used to decode extracted cookie values (should be passed when using Get). + */ + decode?: (value: any) => any; + } +} \ No newline at end of file diff --git a/angular-environment/angular-environment-tests.ts b/angular-environment/angular-environment-tests.ts new file mode 100644 index 000000000..e7c077faf --- /dev/null +++ b/angular-environment/angular-environment-tests.ts @@ -0,0 +1,30 @@ +/// +var envServiceProvider: angular.environment.ServiceProvider; +var envService: angular.environment.Service; + +envServiceProvider.config({ + domains: { + development: ['localhost', 'dev.local'], + production: ['acme.com', 'acme.net', 'acme.org'] + }, + vars: { + development: { + apiUrl: '//localhost/api', + staticUrl: '//localhost/static' + }, + production: { + apiUrl: '//api.acme.com/v2', + staticUrl: '//static.acme.com' + } + } +}); + +envServiceProvider.check(); + +envService.get(); + +envService.set('production'); + +var isProd: boolean = envService.is('production'); + +var val: any = envService.read('apiUrl'); diff --git a/angular-environment/angular-environment.d.ts b/angular-environment/angular-environment.d.ts new file mode 100644 index 000000000..bb38b8f0a --- /dev/null +++ b/angular-environment/angular-environment.d.ts @@ -0,0 +1,52 @@ +// Type definitions for angular-environment v1.0.4 +// Project: https://github.com/juanpablob/angular-environment +// Definitions by: Matt Wheatley +// Definitions: https://github.com/LiberisLabs + +declare module angular.environment { + interface ServiceProvider { + /** + * Sets the configuration object + */ + config: (config: angular.environment.Config) => void; + /** + * Evaluates the current domain and + * loads the correct environment variables. + */ + check: () => void; + } + interface Service { + /** + * Retrieve the current environment + */ + get: () => string, + + /** + * Force sets the current environment + */ + set: (environment: string) => void, + + /** + * Evaluates current environment against + * environment parameter. + */ + is: (environment: string) => boolean, + + /** + * Retrieves the correct version of a + * variable for the current environment. + */ + read: (key: string) => any; + } + + interface Config { + /** + * Map of domains to their environments + */ + domains: { [environment: string]: Array }, + /** + * List of variables split by environment + */ + vars: { [environment: string]: { [variable: string]: any }}, + } +} diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index f42b35a89..967a16d10 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -21,7 +21,9 @@ declare module AngularFormly { } interface IFieldGroup { - data?: Object; + data?: { + [key: string]: any; + }; className?: string; elementAttributes?: string; fieldGroup?: IFieldArray; @@ -37,7 +39,9 @@ declare module AngularFormly { interface IFormOptionsAPI { - data?: Object; + data?: { + [key: string]: any; + }; fieldTransform?: Function; formState?: Object; removeChromeAutoComplete?: boolean; @@ -101,13 +105,13 @@ declare module AngularFormly { type?: string; //expression types - onBlur?: string; - onChange?: string; - onClick?: string; - onFocus?: string; - onKeydown?: string; - onKeypress?: string; - onKeyup?: string; + onBlur?: string | IExpressionFunction; + onChange?: string | IExpressionFunction; + onClick?: string | IExpressionFunction; + onFocus?: string | IExpressionFunction; + onKeydown?: string | IExpressionFunction; + onKeypress?: string | IExpressionFunction; + onKeyup?: string | IExpressionFunction; //Bootstrap types label?: string; @@ -177,7 +181,9 @@ declare module AngularFormly { * * see http://docs.angular-formly.com/docs/field-configuration-object#data-object */ - data?: Object; + data?: { + [key: string]: any; + }; /** @@ -198,7 +204,9 @@ declare module AngularFormly { className?: string; - elementAttributes?: string; + elementAttributes?: { + [key: string]: string; + }; /** @@ -534,7 +542,9 @@ declare module AngularFormly { apiCheckOptions?: Object; defaultOptions?: IFieldConfigurationObject | Function; controller?: Function | string | any[]; - data?: Object; + data?: { + [key: string]: any; + }; extends?: string; link?: ng.IDirectiveLinkFn; overwriteOk?: boolean; diff --git a/angular-fullscreen/angular-fullscreen-tests.ts b/angular-fullscreen/angular-fullscreen-tests.ts new file mode 100644 index 000000000..f45202c0d --- /dev/null +++ b/angular-fullscreen/angular-fullscreen-tests.ts @@ -0,0 +1,12 @@ +/// + +angular + .module('TestApp', ['FBAngular']) + .controller('TestCtrl', (Fullscreen: ng.fullscreen.IFullscreen) => { + Fullscreen.all(); + Fullscreen.toggleAll(); + Fullscreen.enable(document.getElementById('test-id')); + Fullscreen.cancel(); + Fullscreen.isEnabled(); + Fullscreen.isSupported(); + }); diff --git a/angular-fullscreen/angular-fullscreen.d.ts b/angular-fullscreen/angular-fullscreen.d.ts new file mode 100644 index 000000000..6fc31fbc5 --- /dev/null +++ b/angular-fullscreen/angular-fullscreen.d.ts @@ -0,0 +1,34 @@ +// Type definitions for AngularJS HTML5 Fullscreen v1.0.1 +// Project: https://github.com/fabiobiondi/angular-fullscreen +// Definitions by: Julien Paroche +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/angular-fullscreen + +/// + +declare module angular.fullscreen { + + /** + * Prefixing interface name with "I" is not recommended: http://www.typescriptlang.org/Handbook#writing-dts-files + * However, we let it here to keep consistency with all the other Angular-related definitions + */ + interface IFullscreen { + // enable document fullscreen + all(): void; + + // enable or disable the document fullscreen + toggleAll(): void; + + // enable fullscreen to a specific element + enable(element: Element|HTMLElement): void; + + // disable fullscreen + cancel(): void; + + // return true if fullscreen is enabled, otherwise false + isEnabled(): boolean; + + // return true if fullscreen API is supported by your browser + isSupported(): boolean; + } + +} diff --git a/angular-google-analytics/angular-google-analytics-service.d.ts b/angular-google-analytics/angular-google-analytics-service.d.ts new file mode 100644 index 000000000..e69b63d90 --- /dev/null +++ b/angular-google-analytics/angular-google-analytics-service.d.ts @@ -0,0 +1,62 @@ +// Type definitions for angular-google-analytics v1.1.0 +// Project: https://github.com/revolunet/angular-google-analytics +// Definitions by: Matt Wheatley +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module angular.google.analytics { + interface AnalyticsService { + /** + * @summary If logging is enabled then all outbound calls are accessible via an in-memory array. + * This is useful for troubleshooting and seeing the order of outbound calls with parameters. + */ + log: Array; + + /** + * @summary If in offline mode then all calls are queued to an in-memory array for future processing. + * All calls queued to the offlineQueue are not outbound calls yet and hence do not show up in the log. + */ + offlineQueue: Array; + + /** + * @summary Returns the current URL that would be sent if a `trackPage` call was made. + * @return {string} The URL + */ + getUrl: () => string; + + /** + * @summary Manually create classic analytics (ga.js) script tag + */ + createScriptTag: () => void; + + /** + * @summary Manually create universal analytics (analytics.js) script tag + */ + createAnalyticsScriptTag: () => void; + + /** + * @summary Allows for advanced configuration and definitions in univeral analytics only. This is a no-op when using classic analytics. + */ + set: (key: string, value: any, accountName?: string) => void; + + /** + * @summary Creates a new page view event + * @param {string} pageURL URL of page view + * @param {string} title Page Title + * @param {Object} dimensions Additional dimensions and metrics + */ + trackPage: (pageURL: string, title?: string, dimensions?: { [expr: string]: any }) => void; + + /** + * @summary Create a new event + */ + trackEvent: (category: string, action: string, label: string, value?: any, nonInteractionFlag?: boolean, dimensions?: { [expr: string]: any }) => void; + + trackException: (descrption: string, isFatal: boolean) => void; + + /** + * @summary While in offline mode, no calls to the ga function or pushes to the gaq array are made. + * This will queue all calls for later sending once offline mode is reset to false. + */ + offline: (offlineMode: boolean) => void; + } +} diff --git a/angular-google-analytics/angular-google-analytics-tests.ts b/angular-google-analytics/angular-google-analytics-tests.ts index 9da39ba3c..b8c40d64f 100644 --- a/angular-google-analytics/angular-google-analytics-tests.ts +++ b/angular-google-analytics/angular-google-analytics-tests.ts @@ -1,4 +1,5 @@ /// +/// function ConfigurationMethodChaining(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) { AnalyticsProvider @@ -54,3 +55,41 @@ function SetRouteTrackingBehaviors(AnalyticsProvider: angular.google.analytics.A AnalyticsProvider.setPageEvent("$stateChangeSuccess"); AnalyticsProvider.setRemoveRegExp(/\/\d+?$/); } + +function RetrieveCurrentURL(Analytics: angular.google.analytics.AnalyticsService) { + var test = Analytics.getUrl(); +} + +function ManualScriptTagInjection(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.createScriptTag(); + Analytics.createAnalyticsScriptTag(); +} + +function SetCustomDimensions(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.set('&uid', 1234); + Analytics.set('dimension1', 'Paid'); + Analytics.set('dimension2', 'Paid', 'accountName'); +} + +function PageTracking(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.trackPage('/video/detail/XXX'); + Analytics.trackPage('/video/detail/XXX', 'Video XXX'); + Analytics.trackPage('/video/detail/XXX', 'Video XXX', { dimension15: 'My Custom Dimension', metric18: 8000 }); +} + +function EventTracking(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.trackEvent('video', 'play', 'django.mp4'); + Analytics.trackEvent('video', 'play', 'django.mp4', 4); + Analytics.trackEvent('video', 'play', 'django.mp4', 4, true); + Analytics.trackEvent('video', 'play', 'django.mp4', 4, true, { dimension15: 'My Custom Dimension', metric18: 8000 }); +} + +function ExceptionTracking(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.trackException('Function "foo" is undefined on object "bar"', true); +} + +function OfflineMode(Analytics: angular.google.analytics.AnalyticsService) { + Analytics.offline(true); + Analytics.offline(false); + Analytics.offlineQueue; +} diff --git a/angular-growl-v2/angular-growl-v2-tests.ts b/angular-growl-v2/angular-growl-v2-tests.ts index c03e0725a..13c7cad2e 100644 --- a/angular-growl-v2/angular-growl-v2-tests.ts +++ b/angular-growl-v2/angular-growl-v2-tests.ts @@ -1,65 +1,65 @@ -/// - -var app = angular.module("ag", ["pascalprecht.translate", "$httpProvider"]); - -app.config((growlProvider:angular.growl.IGrowlProvider, $httpProvider:angular.IHttpProvider) => { - var ttl:angular.growl.IGrowlTTLConfig = { - success: 5000, - error: 4000 - }; - - growlProvider.globalTimeToLive(ttl) - .globalTimeToLive(5000) - .globalDisableCloseButton(true) - .globalDisableIcons(true) - .globalReversedOrder(false) - .globalDisableCountDown(true) - .messageVariableKey("someKey") - .globalInlineMessages(false) - .globalPosition("top-center") - .messagesKey("someKey") - .messageTextKey("someKey") - .messageTitleKey("someKey") - .messageSeverityKey("someKey") - .onlyUniqueMessages(false); - - $httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor); -}); - -app.controller("Ctrl", ($scope:angular.IScope, - growl:angular.growl.IGrowlService, - growlMessages:angular.growl.IGrowlMessagesService) => { - var config:angular.growl.IGrowlMessageConfig = { - ttl: 5000, - disableCountDown: true, - disableCloseButton: true - }; - - var message = "Some message"; - - growl.warning(message); - growl.warning(message, config); - growl.error(message); - growl.error(message, config); - growl.info(message); - growl.info(message, config); - growl.success(message); - growl.success(message, config); - growl.general(message); - growl.general(message, config); - growl.general(message, config, "error"); - growl.onlyUnique(); - growl.reverseOrder(); - growl.inlineMessages(); - growl.position(); - - growlMessages.initDirective(1, 10); - var messages:angular.growl.IGrowlMessage[] = growlMessages.getAllMessages(2); - growlMessages.destroyAllMessages(0); - growlMessages.addMessage(messages[0]); - growlMessages.deleteMessage(messages[1]); - - var testMessage = growl.warning(message); - testMessage.setText("Some other message"); - testMessage.destroy(); -}); +/// + +var app = angular.module("ag", ["pascalprecht.translate", "$httpProvider"]); + +app.config((growlProvider:angular.growl.IGrowlProvider, $httpProvider:angular.IHttpProvider) => { + var ttl:angular.growl.IGrowlTTLConfig = { + success: 5000, + error: 4000 + }; + + growlProvider.globalTimeToLive(ttl) + .globalTimeToLive(5000) + .globalDisableCloseButton(true) + .globalDisableIcons(true) + .globalReversedOrder(false) + .globalDisableCountDown(true) + .messageVariableKey("someKey") + .globalInlineMessages(false) + .globalPosition("top-center") + .messagesKey("someKey") + .messageTextKey("someKey") + .messageTitleKey("someKey") + .messageSeverityKey("someKey") + .onlyUniqueMessages(false); + + $httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor); +}); + +app.controller("Ctrl", ($scope:angular.IScope, + growl:angular.growl.IGrowlService, + growlMessages:angular.growl.IGrowlMessagesService) => { + var config:angular.growl.IGrowlMessageConfig = { + ttl: 5000, + disableCountDown: true, + disableCloseButton: true + }; + + var message = "Some message"; + + growl.warning(message); + growl.warning(message, config); + growl.error(message); + growl.error(message, config); + growl.info(message); + growl.info(message, config); + growl.success(message); + growl.success(message, config); + growl.general(message); + growl.general(message, config); + growl.general(message, config, "error"); + growl.onlyUnique(); + growl.reverseOrder(); + growl.inlineMessages(); + growl.position(); + + growlMessages.initDirective(1, 10); + var messages:angular.growl.IGrowlMessage[] = growlMessages.getAllMessages(2); + growlMessages.destroyAllMessages(0); + growlMessages.addMessage(messages[0]); + growlMessages.deleteMessage(messages[1]); + + var testMessage = growl.warning(message); + testMessage.setText("Some other message"); + testMessage.destroy(); +}); diff --git a/angular-growl-v2/angular-growl-v2.d.ts b/angular-growl-v2/angular-growl-v2.d.ts index 07c0dbe37..594e45c42 100644 --- a/angular-growl-v2/angular-growl-v2.d.ts +++ b/angular-growl-v2/angular-growl-v2.d.ts @@ -1,259 +1,259 @@ -// Type definitions for Angular Growl 2 v.0.7.5 -// Project: http://janstevens.github.io/angular-growl-2 -// Definitions by: Tadeusz Hucal -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module angular.growl { - - /** - * Global Time-To-Leave configuration. - */ - interface IGrowlTTLConfig { - success?: number; - error?: number; - warning?: number; - info?: number; - } - - /** - * Custom configuration used in single message call. - */ - interface IGrowlMessageConfig { - title?: string; - ttl?: number; - disableCountDown?: boolean; - disableIcons?: boolean; - disableCloseButton?: boolean; - onclose?: Function; - onopen?: Function; - position?: string; - referenceId?: number; - translateMessage?: boolean; - variables?: { [variable: string]: any; }; - } - - /** - * Growl message with configuration. - */ - interface IGrowlMessage extends IGrowlMessageConfig { - text: string; - - /** - * Destroy the message. - */ - destroy(): void; - /** - * Update the message body. - * @param newText new message body - */ - setText(newText: string): void; - } - - /** - * Growl service provider. - */ - interface IGrowlProvider extends angular.IServiceProvider { - /** - * Pre-defined server error interceptor. - */ - serverMessagesInterceptor: (string|IHttpInterceptorFactory)[]; - - /** - * Set default TTL settings. - * @param ttl configuration of TTL for different type of message - */ - globalTimeToLive(ttl: IGrowlTTLConfig): IGrowlProvider; - /** - * Set default TTL settings. - * @param ttl ttl in milliseconds - */ - globalTimeToLive(ttl: number): IGrowlProvider; - /** - * Set default setting for disabling close button. - * @param disableCloseButton - */ - globalDisableCloseButton(disableCloseButton: boolean): IGrowlProvider; - /** - * Set default setting for disabling icons. - * @param disableIcons - */ - globalDisableIcons(disableIcons: boolean): IGrowlProvider; - /** - * Set reversing order of displaying new messages. - * @param reverseOrder - */ - globalReversedOrder(reverseOrder: boolean): IGrowlProvider; - /** - * Set default setting for displaying message disappear countdown. - * @param disableCountDown - */ - globalDisableCountDown(disableCountDown: boolean): IGrowlProvider; - /** - * Set default allowance for inline messages. - * @param inline - */ - globalInlineMessages(inline: boolean): IGrowlProvider; - /** - * Set default message position. - * @param position - */ - globalPosition(position: string): IGrowlProvider; - /** - * Enable/disable displaying only unique messages. - * @param onlyUniqueMessages - */ - onlyUniqueMessages(onlyUniqueMessages: boolean): IGrowlProvider; - - /** - * Set key where messages are stored (for http interceptor). - * @param messageVariableKey - */ - messagesKey(messageKey: string): IGrowlProvider; - /** - * Set key where message text is stored (for http interceptor). - * @param messageVariableKey - */ - messageTextKey(messageTextKey: string): IGrowlProvider; - /** - * Set key where title of message is stored (for http interceptor). - * @param messageVariableKey - */ - messageTitleKey(messageTitleKey: string): IGrowlProvider; - /** - * Set key where severity of message is stored (for http interceptor). - * @param messageVariableKey - */ - messageSeverityKey(messageSeverityKey: string): IGrowlProvider; - /** - * Set key where variables for message are stored (for http interceptor). - * @param messageVariableKey - */ - messageVariableKey(messageVariableKey: string): IGrowlProvider; - } - - /** - * Growl service. - */ - interface IGrowlService { - /** - * Show warning message. - * @param message text to display (or code for angular-translate) - */ - warning(message: string): IGrowlMessage; - /** - * Show warning message. - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - */ - warning(message: string, config: IGrowlMessageConfig): IGrowlMessage; - - /** - * Show error message. - * @param message text to display (or code for angular-translate) - */ - error(message: string): IGrowlMessage; - /** - * Show error message. - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - */ - error(message: string, config: IGrowlMessageConfig): IGrowlMessage; - - /** - * Show information message. - * @param message text to display (or code for angular-translate) - */ - info(message: string): IGrowlMessage; - /** - * Show information message. - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - */ - info(message: string, config: IGrowlMessageConfig): IGrowlMessage; - - /** - * Show success message. - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - */ - success(message: string): IGrowlMessage; - /** - * Show success message. - * @param message text to display (or code for angular-translate) - */ - success(message: string, config: IGrowlMessageConfig): IGrowlMessage; - - /** - * Show message (generic). - * @param message text to display (or code for angular-translate) - */ - general(message: string): IGrowlMessage; - /** - * Show message (generic). - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - */ - general(message: string, config: IGrowlMessageConfig): IGrowlMessage; - /** - * Show message (generic). - * @param message text to display (or code for angular-translate) - * @param config additional message configuration - * @param severity message severity (error, warning, success, info). - */ - general(message: string, config: IGrowlMessageConfig, severity: string): IGrowlMessage; - - /** - * Get current setting for displaying only unique messages. - */ - onlyUnique(): boolean; - /** - * Get current setting for reversing messages order. - */ - reverseOrder(): boolean; - /** - * Get current allowance for inline messages. - */ - inlineMessages(): boolean; - /** - * Get current messages position. - */ - position(): string; - } - - /** - * GrowlMessages service. - */ - interface IGrowlMessagesService { - /** - * Initialize a directive - * We look at the preloaded directive and use this else we - * create a new blank object - * @param referenceId - * @param limitMessages - */ - initDirective(referenceId: number, limitMessages: number): angular.IDirective; - - /** - * Get current messages - */ - getAllMessages(referenceId?: number): IGrowlMessage[]; - - /** - * Destroy all messages - */ - destroyAllMessages(referenceId?: number): void; - - /** - * Add a message - */ - addMessage(message: IGrowlMessage): IGrowlMessage; - - /** - * Delete a message - */ - deleteMessage(message: IGrowlMessage): void; - - } -} +// Type definitions for Angular Growl 2 v.0.7.5 +// Project: http://janstevens.github.io/angular-growl-2 +// Definitions by: Tadeusz Hucal +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.growl { + + /** + * Global Time-To-Leave configuration. + */ + interface IGrowlTTLConfig { + success?: number; + error?: number; + warning?: number; + info?: number; + } + + /** + * Custom configuration used in single message call. + */ + interface IGrowlMessageConfig { + title?: string; + ttl?: number; + disableCountDown?: boolean; + disableIcons?: boolean; + disableCloseButton?: boolean; + onclose?: Function; + onopen?: Function; + position?: string; + referenceId?: number; + translateMessage?: boolean; + variables?: { [variable: string]: any; }; + } + + /** + * Growl message with configuration. + */ + interface IGrowlMessage extends IGrowlMessageConfig { + text: string; + + /** + * Destroy the message. + */ + destroy(): void; + /** + * Update the message body. + * @param newText new message body + */ + setText(newText: string): void; + } + + /** + * Growl service provider. + */ + interface IGrowlProvider extends angular.IServiceProvider { + /** + * Pre-defined server error interceptor. + */ + serverMessagesInterceptor: (string|IHttpInterceptorFactory)[]; + + /** + * Set default TTL settings. + * @param ttl configuration of TTL for different type of message + */ + globalTimeToLive(ttl: IGrowlTTLConfig): IGrowlProvider; + /** + * Set default TTL settings. + * @param ttl ttl in milliseconds + */ + globalTimeToLive(ttl: number): IGrowlProvider; + /** + * Set default setting for disabling close button. + * @param disableCloseButton + */ + globalDisableCloseButton(disableCloseButton: boolean): IGrowlProvider; + /** + * Set default setting for disabling icons. + * @param disableIcons + */ + globalDisableIcons(disableIcons: boolean): IGrowlProvider; + /** + * Set reversing order of displaying new messages. + * @param reverseOrder + */ + globalReversedOrder(reverseOrder: boolean): IGrowlProvider; + /** + * Set default setting for displaying message disappear countdown. + * @param disableCountDown + */ + globalDisableCountDown(disableCountDown: boolean): IGrowlProvider; + /** + * Set default allowance for inline messages. + * @param inline + */ + globalInlineMessages(inline: boolean): IGrowlProvider; + /** + * Set default message position. + * @param position + */ + globalPosition(position: string): IGrowlProvider; + /** + * Enable/disable displaying only unique messages. + * @param onlyUniqueMessages + */ + onlyUniqueMessages(onlyUniqueMessages: boolean): IGrowlProvider; + + /** + * Set key where messages are stored (for http interceptor). + * @param messageVariableKey + */ + messagesKey(messageKey: string): IGrowlProvider; + /** + * Set key where message text is stored (for http interceptor). + * @param messageVariableKey + */ + messageTextKey(messageTextKey: string): IGrowlProvider; + /** + * Set key where title of message is stored (for http interceptor). + * @param messageVariableKey + */ + messageTitleKey(messageTitleKey: string): IGrowlProvider; + /** + * Set key where severity of message is stored (for http interceptor). + * @param messageVariableKey + */ + messageSeverityKey(messageSeverityKey: string): IGrowlProvider; + /** + * Set key where variables for message are stored (for http interceptor). + * @param messageVariableKey + */ + messageVariableKey(messageVariableKey: string): IGrowlProvider; + } + + /** + * Growl service. + */ + interface IGrowlService { + /** + * Show warning message. + * @param message text to display (or code for angular-translate) + */ + warning(message: string): IGrowlMessage; + /** + * Show warning message. + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + */ + warning(message: string, config: IGrowlMessageConfig): IGrowlMessage; + + /** + * Show error message. + * @param message text to display (or code for angular-translate) + */ + error(message: string): IGrowlMessage; + /** + * Show error message. + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + */ + error(message: string, config: IGrowlMessageConfig): IGrowlMessage; + + /** + * Show information message. + * @param message text to display (or code for angular-translate) + */ + info(message: string): IGrowlMessage; + /** + * Show information message. + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + */ + info(message: string, config: IGrowlMessageConfig): IGrowlMessage; + + /** + * Show success message. + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + */ + success(message: string): IGrowlMessage; + /** + * Show success message. + * @param message text to display (or code for angular-translate) + */ + success(message: string, config: IGrowlMessageConfig): IGrowlMessage; + + /** + * Show message (generic). + * @param message text to display (or code for angular-translate) + */ + general(message: string): IGrowlMessage; + /** + * Show message (generic). + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + */ + general(message: string, config: IGrowlMessageConfig): IGrowlMessage; + /** + * Show message (generic). + * @param message text to display (or code for angular-translate) + * @param config additional message configuration + * @param severity message severity (error, warning, success, info). + */ + general(message: string, config: IGrowlMessageConfig, severity: string): IGrowlMessage; + + /** + * Get current setting for displaying only unique messages. + */ + onlyUnique(): boolean; + /** + * Get current setting for reversing messages order. + */ + reverseOrder(): boolean; + /** + * Get current allowance for inline messages. + */ + inlineMessages(): boolean; + /** + * Get current messages position. + */ + position(): string; + } + + /** + * GrowlMessages service. + */ + interface IGrowlMessagesService { + /** + * Initialize a directive + * We look at the preloaded directive and use this else we + * create a new blank object + * @param referenceId + * @param limitMessages + */ + initDirective(referenceId: number, limitMessages: number): angular.IDirective; + + /** + * Get current messages + */ + getAllMessages(referenceId?: number): IGrowlMessage[]; + + /** + * Destroy all messages + */ + destroyAllMessages(referenceId?: number): void; + + /** + * Add a message + */ + addMessage(message: IGrowlMessage): IGrowlMessage; + + /** + * Delete a message + */ + deleteMessage(message: IGrowlMessage): void; + + } +} diff --git a/angular-load/angular-load-tests.ts b/angular-load/angular-load-tests.ts new file mode 100644 index 000000000..b7d7c2e60 --- /dev/null +++ b/angular-load/angular-load-tests.ts @@ -0,0 +1,12 @@ +/// + +angular.module('app',['angularLoad']) + .run(['angularLoad',(angularLoad:angular.load.IAngularLoadService)=> { + angularLoad.loadScript("https://ajax.googleapis.com/ajax/libs/angular_material/1.0.4/angular-material.min.js").then( + ()=>console.log("angular material js loaded") + ); + + angularLoad.loadCss("https://ajax.googleapis.com/ajax/libs/angular_material/1.0.4/angular-material.css").then( + ()=>console.log("angular material css loaded") + ); + }]); diff --git a/angular-load/angular-load.d.ts b/angular-load/angular-load.d.ts new file mode 100644 index 000000000..a35d1c59d --- /dev/null +++ b/angular-load/angular-load.d.ts @@ -0,0 +1,15 @@ +// Type definitions for angular-load v0.4.1 +// Project: https://github.com/urish/angular-load +// Definitions by: david-gang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.load { + + interface IAngularLoadService { + loadScript(url:string): ng.IPromise; + loadCss(url:string): ng.IPromise; + } + +} diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 4ce3fe103..25ac6b830 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -63,7 +63,10 @@ declare module angular.material { interface IDialogOptions { templateUrl?: string; template?: string; + autoWrap?: boolean; // default: true targetEvent?: MouseEvent; + openFrom?: any; + closeTo?: any; scope?: angular.IScope; // default: new child scope preserveScope?: boolean; // default: false disableParentScroll?: boolean; // default: true @@ -77,8 +80,10 @@ declare module angular.material { resolve?: {[index: string]: angular.IPromise} controllerAs?: string; parent?: string|Element|JQuery; // default: root node - fullscreen?: boolean; + onShowing?: Function; onComplete?: Function; + onRemoving?: Function; + fullscreen?: boolean; } interface IDialogService { @@ -224,7 +229,7 @@ declare module angular.material { setDefaultTheme(theme: string): void; alwaysWatchTheme(alwaysWatch: boolean): void; } - + interface IDateLocaleProvider { months: string[]; shortMonths: string[]; @@ -239,4 +244,8 @@ declare module angular.material { msgCalendar: string; msgOpenCalendar: string; } + + interface IMenuService { + hide(response?: any, options?: any): angular.IPromise; + } } diff --git a/angular-meteor/angular-meteor-tests.ts b/angular-meteor/angular-meteor-tests.ts index 9ce0a33e9..cc2a62c8d 100644 --- a/angular-meteor/angular-meteor-tests.ts +++ b/angular-meteor/angular-meteor-tests.ts @@ -1,255 +1,255 @@ -/// - -interface ITodo { - _id?: string; - name: string; - public?: boolean; - sticky?: boolean; -} - -interface TodoAngularMeteorObject extends ITodo, angular.meteor.AngularMeteorObject {} - -interface CustomScope extends angular.meteor.IScope { - sticky: boolean; - - todos: angular.meteor.AngularMeteorCollection; - stickyTodos: angular.meteor.AngularMeteorCollection; - notAutoTodos: angular.meteor.AngularMeteorCollection; - - todo: ITodo; - todoNotAuto: TodoAngularMeteorObject; - todoSubscribed: TodoAngularMeteorObject; - - save: (todo: ITodo) => void; - saveAll: () =>void; - autoSave: (todo: ITodo) => void; - remove: (todoId: string) => void; - removeAll: () => void; - removeAuto: (todo: ITodo) => void; - toSticky: (todo: ITodo) => void; -} - -var Todos = new Mongo.Collection('todos'); - -var app = angular.module('angularMeteorTestApp'); - -app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => { - // Bind all the todos to $scope.todos - $scope.todos = $meteor.collection(Todos); - - $scope.sticky = true; - // Bind all sticky todos to $scope.stickyTodos - // Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it - // to $scope.stickyTodos - $scope.stickyTodos = $meteor.collection(function(){ - return Todos.find({sticky: $scope.getReactively('sticky')}); - }); - - // Bind without auto-save all todos to $scope.notAutoTodos - $scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos"); - - $scope.todoNotAuto = $meteor.object(Todos, 'TodoID', false); - $scope.todoSubscribed = $meteor.object(Todos, 'TodoID').subscribe('todos'); - $scope.todo = $scope.todoNotAuto.getRawObject(); - $scope.todoNotAuto.reset(); - $scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });; - - // todo might be an object like this {text: "Learn Angular", sticky: false} - // or an array like this: - // [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}] - - $scope.save = function(todo) { - $scope.notAutoTodos.save(todo); - }; - - $scope.saveAll = function() { - $scope.notAutoTodos.save(); - }; - - $scope.autoSave = function(todo) { - $scope.todos.push(todo); - }; - - // todoId might be an string like this "WhrnEez5yBRgo4yEm" - // or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"] - $scope.remove = function(todoId) { - $scope.notAutoTodos.remove(todoId); - }; - - $scope.removeAll = function() { - $scope.notAutoTodos.remove(); - }; - - $scope.removeAuto = function(todo) { - $scope.todos.splice( $scope.todos.indexOf(todo), 1 ); - } - - $scope.toSticky = function(todo) { - if (angular.isArray(todo)){ - angular.forEach(todo, function(object) { - object.sticky = true; - }); - } else { - todo.sticky = true; - } - - $scope.stickyTodos.save(todo); - }; - - var todoObject = {name:'first todo'}; - var todosArray = [{name:'second todo'}, {name:'third todo'}]; - var todoSecondObject = {name:'forth todo'}; - - $scope.todos.save(todoObject); // todos equals [{name:'first todo'}] - - $scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}] - - $scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] - // but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}] - - $scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] - - $scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] - - var todoIdsArray = ['secondTodoId', 'thirdTodoId']; - $scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection - - $scope.todos.pop(); // removes only in scope - - $scope.todos.remove(); // syncs also in Meteor collection - - // Subscribe -> - - $meteor.subscribe('todos').then((subscriptionHandle) => { - // Bind all the todos to $scope.todos - $scope.todos = $meteor.collection(Todos); - - console.log($scope.todos + ' is ready'); - - // You can use the subscription handle to stop the subscription if you want - subscriptionHandle.stop(); - }); - - $scope.subscribe('todos').then((subscriptionHandle) => { - // Bind all the todos to $scope.books - $scope.todos = $meteor.collection(Todos); - - console.log($scope.todos + ' is ready'); - - // No need to stop the subscription, it will automatically close on scope destroy - }); - - $meteor.call('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => { - // Handle success - console.log('success subscribing', data.name); - }, (err) => { - // Handle error - console.log('failed', err); - }); - - if (!$scope.loggingIn) { - $meteor.waitForUser(); - - $meteor.requireUser(); - - $meteor.requireValidUser(user => { - return user.username == 'admin'; - }); - - $meteor.loginWithPassword('user', 'password').then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - - $meteor.createUser({ - username:'moma', - email:'example@gmail.com', - password: 'Bksd@asdf', - profile: {expertize: 'Developer'} - }).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - - $meteor.changePassword('old', 'new232f3').then(() => { - console.log('Change password success'); - }, err => { - console.log('Error changing password - ', err); - }); - - $meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => { - console.log('Success sending forgot password email'); - }, err => { - console.log('Error sending forgot password email - ', err); - }); - - $meteor.resetPassword('tokenID', 'new232f3').then(() => { - console.log('Reset password success'); - }, err => { - console.log('Error resetting password - ', err); - }); - - $meteor.verifyEmail('tokenID').then(() => { - console.log('Success verifying password '); - }, err => { - console.log('Error verifying password - ', err); - }); - - $meteor.logout().then(() => { - console.log('Logout success'); - }, err => { - console.log('logout error - ', err); - }); - - $meteor.logoutOtherClients().then(() => { - console.log('Logout success'); - }, err => { - console.log('logout error - ', err); - }); - - var loginWithOptions = {requestPermissions: ['email']}; - - $meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - $meteor.loginWithGithub({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - $meteor.loginWithGoogle({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - $meteor.loginWithMeetup({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - $meteor.loginWithTwitter({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - $meteor.loginWithWeibo({requestPermissions: ['email']}).then(() => { - console.log('Login success'); - }, err => { - console.log('Login error - ', err); - }); - } - - $meteor.autorun($scope, () => { console.log("Aurorun triggered."); }); - $meteor.getCollectionByName('collectionName'); - - // requires meteor add mdg:camera - $meteor.getPicture().then(function(data){ - $scope['picture'] = data; - }); - - $meteor.session('counter').bind($scope, 'counter'); -}]); +/// + +interface ITodo { + _id?: string; + name: string; + public?: boolean; + sticky?: boolean; +} + +interface TodoAngularMeteorObject extends ITodo, angular.meteor.AngularMeteorObject {} + +interface CustomScope extends angular.meteor.IScope { + sticky: boolean; + + todos: angular.meteor.AngularMeteorCollection; + stickyTodos: angular.meteor.AngularMeteorCollection; + notAutoTodos: angular.meteor.AngularMeteorCollection; + + todo: ITodo; + todoNotAuto: TodoAngularMeteorObject; + todoSubscribed: TodoAngularMeteorObject; + + save: (todo: ITodo) => void; + saveAll: () =>void; + autoSave: (todo: ITodo) => void; + remove: (todoId: string) => void; + removeAll: () => void; + removeAuto: (todo: ITodo) => void; + toSticky: (todo: ITodo) => void; +} + +var Todos = new Mongo.Collection('todos'); + +var app = angular.module('angularMeteorTestApp'); + +app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => { + // Bind all the todos to $scope.todos + $scope.todos = $meteor.collection(Todos); + + $scope.sticky = true; + // Bind all sticky todos to $scope.stickyTodos + // Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it + // to $scope.stickyTodos + $scope.stickyTodos = $meteor.collection(function(){ + return Todos.find({sticky: $scope.getReactively('sticky')}); + }); + + // Bind without auto-save all todos to $scope.notAutoTodos + $scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos"); + + $scope.todoNotAuto = $meteor.object(Todos, 'TodoID', false); + $scope.todoSubscribed = $meteor.object(Todos, 'TodoID').subscribe('todos'); + $scope.todo = $scope.todoNotAuto.getRawObject(); + $scope.todoNotAuto.reset(); + $scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });; + + // todo might be an object like this {text: "Learn Angular", sticky: false} + // or an array like this: + // [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}] + + $scope.save = function(todo) { + $scope.notAutoTodos.save(todo); + }; + + $scope.saveAll = function() { + $scope.notAutoTodos.save(); + }; + + $scope.autoSave = function(todo) { + $scope.todos.push(todo); + }; + + // todoId might be an string like this "WhrnEez5yBRgo4yEm" + // or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"] + $scope.remove = function(todoId) { + $scope.notAutoTodos.remove(todoId); + }; + + $scope.removeAll = function() { + $scope.notAutoTodos.remove(); + }; + + $scope.removeAuto = function(todo) { + $scope.todos.splice( $scope.todos.indexOf(todo), 1 ); + } + + $scope.toSticky = function(todo) { + if (angular.isArray(todo)){ + angular.forEach(todo, function(object) { + object.sticky = true; + }); + } else { + todo.sticky = true; + } + + $scope.stickyTodos.save(todo); + }; + + var todoObject = {name:'first todo'}; + var todosArray = [{name:'second todo'}, {name:'third todo'}]; + var todoSecondObject = {name:'forth todo'}; + + $scope.todos.save(todoObject); // todos equals [{name:'first todo'}] + + $scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}] + + $scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] + // but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}] + + $scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] + + $scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}] + + var todoIdsArray = ['secondTodoId', 'thirdTodoId']; + $scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection + + $scope.todos.pop(); // removes only in scope + + $scope.todos.remove(); // syncs also in Meteor collection + + // Subscribe -> + + $meteor.subscribe('todos').then((subscriptionHandle) => { + // Bind all the todos to $scope.todos + $scope.todos = $meteor.collection(Todos); + + console.log($scope.todos + ' is ready'); + + // You can use the subscription handle to stop the subscription if you want + subscriptionHandle.stop(); + }); + + $scope.subscribe('todos').then((subscriptionHandle) => { + // Bind all the todos to $scope.books + $scope.todos = $meteor.collection(Todos); + + console.log($scope.todos + ' is ready'); + + // No need to stop the subscription, it will automatically close on scope destroy + }); + + $meteor.call('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => { + // Handle success + console.log('success subscribing', data.name); + }, (err) => { + // Handle error + console.log('failed', err); + }); + + if (!$scope.loggingIn) { + $meteor.waitForUser(); + + $meteor.requireUser(); + + $meteor.requireValidUser(user => { + return user.username == 'admin'; + }); + + $meteor.loginWithPassword('user', 'password').then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + + $meteor.createUser({ + username:'moma', + email:'example@gmail.com', + password: 'Bksd@asdf', + profile: {expertize: 'Developer'} + }).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + + $meteor.changePassword('old', 'new232f3').then(() => { + console.log('Change password success'); + }, err => { + console.log('Error changing password - ', err); + }); + + $meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => { + console.log('Success sending forgot password email'); + }, err => { + console.log('Error sending forgot password email - ', err); + }); + + $meteor.resetPassword('tokenID', 'new232f3').then(() => { + console.log('Reset password success'); + }, err => { + console.log('Error resetting password - ', err); + }); + + $meteor.verifyEmail('tokenID').then(() => { + console.log('Success verifying password '); + }, err => { + console.log('Error verifying password - ', err); + }); + + $meteor.logout().then(() => { + console.log('Logout success'); + }, err => { + console.log('logout error - ', err); + }); + + $meteor.logoutOtherClients().then(() => { + console.log('Logout success'); + }, err => { + console.log('logout error - ', err); + }); + + var loginWithOptions = {requestPermissions: ['email']}; + + $meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + $meteor.loginWithGithub({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + $meteor.loginWithGoogle({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + $meteor.loginWithMeetup({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + $meteor.loginWithTwitter({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + $meteor.loginWithWeibo({requestPermissions: ['email']}).then(() => { + console.log('Login success'); + }, err => { + console.log('Login error - ', err); + }); + } + + $meteor.autorun($scope, () => { console.log("Aurorun triggered."); }); + $meteor.getCollectionByName('collectionName'); + + // requires meteor add mdg:camera + $meteor.getPicture().then(function(data){ + $scope['picture'] = data; + }); + + $meteor.session('counter').bind($scope, 'counter'); +}]); diff --git a/angular-meteor/angular-meteor.d.ts b/angular-meteor/angular-meteor.d.ts index e536e3203..e3e66bf34 100644 --- a/angular-meteor/angular-meteor.d.ts +++ b/angular-meteor/angular-meteor.d.ts @@ -1,352 +1,352 @@ -// Type definitions for Angular JS Meteor v0.8.8 (angular.meteor module) -// Project: https://github.com/Urigo/angular-meteor -// Definitions by: Peter Grman -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// -/// - -declare module angular.meteor { - interface IRootScopeService extends angular.IRootScopeService { - /** - * The current logged in user and it's data. it is null if the user is not logged in. A reactive data source. - */ - currentUser: Meteor.User; - - /** - * True if a login method (such as Meteor.loginWithPassword, Meteor.loginWithFacebook, or Accounts.createUser) is currently in progress. - * A reactive data source. Can be use to display animation while user is logging in. - */ - loggingIn: boolean; - } - - interface IScope extends angular.IScope, IRootScopeService { - /** - * A method to get a $scope variable and watch it reactivly - * - * @param scopeVariableName - The name of the scope's variable to bind to - * @param [objectEquality=false] - Watch the object equality using angular.equals instead of comparing for reference equality, deeper watch but also slower - */ - getReactively(scopeVariableName: string, objectEquality?: boolean): ReactiveResult; - - /** - * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready. - * Calling $scope.subscribe will automatically stop the subscription when the scope is destroyed. - * - * @param name - Name of the subscription. Matches the name of the server's publish() call. - * @param publisherArguments - Optional arguments passed to publisher function on server. - * - * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle. - */ - subscribe(name: string, ...publisherArguments: any[]): angular.IPromise; - - /** - * The helpers method is part of the ReactiveContext, and available on every context and $scope. - * These method are defined as Object, where each key is the name of the variable that will be available on the context we run, and each value is a function with a return value. - * Under the hood, each helper starts a new Tracker.autorun. When its reactive dependencies change, the helper is rerun. - * To trigger a rerun every time an specific Angular variable change, use getReactively](/api/1.3.1/get-reactively) to make your Angular variable reactive inside the helper its used in. - * Each helper function should return a MongoDB Cursor and the helpers will expose it as a normal array to the context. - * - * @param definitions - Object containing `name` => `function` definition, where each name is a string and each function is the helper function. Should return a [MongoDB Cursor](http://docs.meteor.com/#/full/mongo_cursor) - * @return This method returns this, which the the reactive context, in order to provide the ability to chain the logic. - */ - helpers(definitions : { [helperName : string] : () => Mongo.Cursor }): IScope; - - /** - * This method is a wrapper of Tracker.autorun and shares exactly the same API. - * The autorun method is part of the ReactiveContext, and available on every context and $scope. - * The argument of this method is a callback, which will be called each time Autorun will be used. - * The Autorun will stop automatically when when it's context ($scope) is destroyed. - * - * @param runFunc - The function to run. It receives one argument: the Computation object that will be returned. - */ - autorun(runFunc : () => void) : Tracker.Computation; - } - - /** - * $meteor in angularjs - */ - interface IMeteorService { - /** - * A service that wraps the Meteor collections to enable reactivity within AngularJS. - * - * @param collection - A Meteor Collection or a reactive function to bind to. - * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor. - * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection. - * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection. - */ - collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection; - - /** - * A service that wraps the Meteor collections to enable reactivity within AngularJS. - * - * @param collection - A Meteor Collection or a reactive function to bind to. - * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor. - * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection. - * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection. - * @param [updateCollection] - A collection object which will be used for updates (insert, update, delete). - */ - collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection): AngularMeteorCollection2; - - /** - * A service that wraps a Meteor object to enable reactivity within AngularJS. - * Finds the first document that matches the selector, as ordered by sort and skip options. Wraps collection.findOne - * - * @param collection - A Meteor Collection to bind to. - * @param selector - A query describing the documents to find or just the ID of the document. - * - $meteor.object will find the first document that matches the selector, - * - as ordered by sort and skip options, exactly like Meteor's collection.findOne - * @param [autoClientSave=true] - By default, changes in the Angular object will automatically update the Meteor object. - * - However if set to false, changes in the client won't be automatically propagated back to the Meteor object. - */ - object(collection: Mongo.Collection, selector: Mongo.Selector|Mongo.ObjectID|string, autoClientSave?: boolean): AngularMeteorObject; - - /** - * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready. - * - * @param name - Name of the subscription. Matches the name of the server's publish() call. - * @param publisherArguments - Optional arguments passed to publisher function on server. - * - * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle. - */ - subscribe(name: string, ...publisherArguments: any[]): angular.IPromise; - - /** - * A service service which wraps up Meteor.methods with AngularJS promises. - * - * @param name - Name of method to invoke - * @param methodArguments - Optional method arguments - * - * @return The promise solves successfully with the return value of the method or return reject with the error from the method. - */ - call(name: string, ...methodArguments: any[]): angular.IPromise; - - // User Authentication BEGIN -> - - /** - * Returns a promise fulfilled with the currentUser when the user subscription is ready. - * This is useful when you want to grab the current user before the route is rendered. - * If there is no logged in user, it will return null. - * See the “Authentication with Routers” section of our tutorial for more information and a full example. - */ - waitForUser(): angular.IPromise; - - /** - * Resolves the promise successfully if a user is authenticated and rejects otherwise. - * This is useful in cases where you want to require a route to have an authenticated user. - * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page. - * See the “Authentication with Routers” section of our tutorial for more information and a full example. - */ - requireUser(): angular.IPromise; - - /** - * Resolves the promise successfully if a user is authenticated and the validatorFn returns true; rejects otherwise. - * This is useful in cases where you want to require a route to have an authenticated user and do extra validation like the user's role or group. - * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page. - * See the “Authentication with Routers” section of our tutorial for more information and a full example. - * - * The mandatory validator function will be called with the authenticated user as the single param and it's expected to return true in order to resolve. - * If it returns a string, the promise will be rejected using said string as the reason. - * Any other return (false, null, undefined) will be rejected with the default "FORBIDDEN" reason. - */ - requireValidUser(validatorFn: (user: Meteor.User) => boolean|string): angular.IPromise; - - /** - * Log the user in with a password. - * - * @param user - Either a string interpreted as a username or an email; or an object with a single key: email, username or id. - * @param password - The user's password. - */ - loginWithPassword(user: string|{email: string}|{username: string}|{id: string}, password: string): angular.IPromise; - - /** - * Create a new user. More information: http://docs.meteor.com/#/full/accounts_createuser - * - * @param options.username - A unique name for this user. Either this, or email is required. - * @param options.email - The user's email address. Either this, or username is required. - * @param options.password - The user's password. This is not sent in plain text over the wire. - * @param options.profile - The user's profile, typically including the name field. - */ - createUser(options: {username?: string; email?: string; password: string; profile?: Object}): angular.IPromise; - - /** - * Change the current user's password. Must be logged in. - * - * @param oldPassword - The user's current password. This is not sent in plain text over the wire. - * @param newPassword - A new password for the user. This is not sent in plain text over the wire. - */ - changePassword(oldPassword: string, newPassword: string): angular.IPromise; - - /** - * Request a forgot password email. - * - * @param options.email - The email address to send a password reset link. - */ - forgotPassword(options: {email: string}): angular.IPromise; - - /** - * Reset the password for a user using a token received in email. Logs the user in afterwards. - * - * @param token - The token retrieved from the reset password URL. - * @param newPassword - A new password for the user. This is not sent in plain text over the wire. - */ - resetPassword(token: string, newPassword: string): angular.IPromise; - - /** - * Marks the user's email address as verified. Logs the user in afterwards. - * - * @param token - The token retrieved from the reset password URL. - */ - verifyEmail(token: string): angular.IPromise; - - loginWithFacebook: ILoginWithExternalService; - loginWithTwitter: ILoginWithExternalService; - loginWithGoogle: ILoginWithExternalService; - loginWithGithub: ILoginWithExternalService; - loginWithMeetup: ILoginWithExternalService; - loginWithWeibo: ILoginWithExternalService; - - /** - * Log the user out. - * - * @return Resolves with no arguments on success, or reject with a Error argument on failure. - */ - logout(): angular.IPromise; - - /** - * Log out other clients logged in as the current user, but does not log out the client that calls this function. - * For example, when called in a user's browser, connections in that browser remain logged in, - * but any other browsers or DDP clients logged in as that user will be logged out. - * - * @return Resolves with no arguments on success, or reject with a Error argument on failure. - */ - logoutOtherClients(): angular.IPromise; - - // <- User Authentication END - // $meteorUtils BEGIN -> - - /** - * @param scope - The AngularJS scope you use the autorun on. - * @param fn - The function that will re-run every time a reactive variable changes inside it. - */ - autorun(scope: angular.IScope, fn: Function): void; - - /** - * @param collectionName - The name of the collection you want to get back - */ - getCollectionByName(collectionName: string): Mongo.Collection; - - // <- $meteorUtils END - // $meteorCamera BEGIN -> - - /** - * A helper service for taking pictures across platforms. - * Must add mdg:camera package to use! (meteor add mdg:camera) - * - * @param [options] - options is an optional argument that is an Object with the following possible keys: - * @param options.width - An integer that specifies the minimum width of the returned photo. - * @param options.height - An integer that specifies the minimum height of the returned photo. - * @param options.quality - A number from 0 to 100 specifying the desired quality of JPEG encoding. - * - * @return The promise solved successfully when the picture is taken with the data as a parameter or rejected with an error as a parameter in case of error. - */ - getPicture(options?: {width?: number; height?: number; quality?: number}): angular.IPromise; - - // <- $meteorCamera END - - /** - * A service that binds a scope variable to a Meteor Session variable. - * - * @param sessionKey - The name of the session variable - * @return An object with a single function bind - to bind to that variable. - */ - session(sessionKey: string): { - /** - * @param scope - The scope the document will be bound to. - * @param model - The name of the scope's model variable that the document will be bound to. - */ - bind: (scope: IScope, model: string) => void; - }; - } - - /** - * An object that connects a Meteor Object to an AngularJS scope variable. - * - * The object contains also all the properties from the generic type T, - * unfortunately TypeScript doesn't at the moment allow to extend a generic type (see https://github.com/Microsoft/TypeScript/issues/2225 for details and updates). - * For a workaround, you'll need to implement an interface which will merge AngularMeteorObject together with T and cast it, like this: - * - * interface TodoAngularMeteorObject extends ITodo, AngularMeteorObject { } - * var todo = $meteor.object(TodoCollection, 'TodoID'); - */ - interface AngularMeteorObject { - /** - * @param [doc] - The doc to save to the Meteor Object. If nothing is passed, the method saves everything in the AngularMeteorObject as is. - * - Unchanged properties will be overridden with their existing values, which may trigger hooks. - * - If doc is passed, the method only updates the Meteor Object with the properties passed, and no other changes will be saved. - * - * @return Returns a promise with an error in case for an error or a number of successful docs changed in case of success. - */ - save(doc?: T): angular.IPromise; - - /** - * Reset the current value of the object to the one in the server. - */ - reset(): void; - - /** - * Returns a copy of the AngularMeteorObject with all the AngularMeteor-specific internal properties removed. - * The returned object is then safe to use as a parameter for method calls, or anywhere else where the data needs to be converted to JSON. - */ - getRawObject(): T; - - /** - * A shorten (Syntactic sugar) function for the $meteor.subscribe function. - * Takes only one parameter and not returns a promise like $meteor.subscribe does. - * - * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service. - */ - subscribe(subscriptionName:string): AngularMeteorObject; - } - - /** - * An object that connects a Meteor Collection to an AngularJS scope variable - */ - interface AngularMeteorCollection extends AngularMeteorCollection2 { } - - /** - * An object that connects a Meteor Collection to an AngularJS scope variable, - * but can use a differen type for updates. - */ - interface AngularMeteorCollection2 extends Array { - /** - * @param [docs] - The docs to save to the Meteor Collection. - * - If the docs parameter is empty, the method saves everything in the AngularMeteorCollection as is. - * - If an object is passed, the method pushes that object into the AngularMeteorCollection. - * - If an array is passed, the method pushes all objects in the array into the AngularMeteorCollection. - */ - save(docs?: U|U[]): void; - - /** - * @param [keys] - The keys of the object to remove from the Meteor Collection. - * - If nothing is passed, the method removes all the documents from the AngularMeteorCollection. - * - If an object is passed, the method removes the object with that key from the AngularMeteorCollection. - * - If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection. - */ - remove(keys?: U|string|number|string[]|number[]): void; - - /** - * A shorten (Syntactic sugar) function for the $meteor.subscribe function. - * Takes only one parameter and not returns a promise like $meteor.subscribe does. - * - * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service. - */ - subscribe(subscriptionName:string): AngularMeteorCollection2; - } - - interface ILoginWithExternalService { - (options: Meteor.LoginWithExternalServiceOptions): angular.IPromise; - } - - interface ReactiveResult { } -} +// Type definitions for Angular JS Meteor v0.8.8 (angular.meteor module) +// Project: https://github.com/Urigo/angular-meteor +// Definitions by: Peter Grman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module angular.meteor { + interface IRootScopeService extends angular.IRootScopeService { + /** + * The current logged in user and it's data. it is null if the user is not logged in. A reactive data source. + */ + currentUser: Meteor.User; + + /** + * True if a login method (such as Meteor.loginWithPassword, Meteor.loginWithFacebook, or Accounts.createUser) is currently in progress. + * A reactive data source. Can be use to display animation while user is logging in. + */ + loggingIn: boolean; + } + + interface IScope extends angular.IScope, IRootScopeService { + /** + * A method to get a $scope variable and watch it reactivly + * + * @param scopeVariableName - The name of the scope's variable to bind to + * @param [objectEquality=false] - Watch the object equality using angular.equals instead of comparing for reference equality, deeper watch but also slower + */ + getReactively(scopeVariableName: string, objectEquality?: boolean): ReactiveResult; + + /** + * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready. + * Calling $scope.subscribe will automatically stop the subscription when the scope is destroyed. + * + * @param name - Name of the subscription. Matches the name of the server's publish() call. + * @param publisherArguments - Optional arguments passed to publisher function on server. + * + * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle. + */ + subscribe(name: string, ...publisherArguments: any[]): angular.IPromise; + + /** + * The helpers method is part of the ReactiveContext, and available on every context and $scope. + * These method are defined as Object, where each key is the name of the variable that will be available on the context we run, and each value is a function with a return value. + * Under the hood, each helper starts a new Tracker.autorun. When its reactive dependencies change, the helper is rerun. + * To trigger a rerun every time an specific Angular variable change, use getReactively](/api/1.3.1/get-reactively) to make your Angular variable reactive inside the helper its used in. + * Each helper function should return a MongoDB Cursor and the helpers will expose it as a normal array to the context. + * + * @param definitions - Object containing `name` => `function` definition, where each name is a string and each function is the helper function. Should return a [MongoDB Cursor](http://docs.meteor.com/#/full/mongo_cursor) + * @return This method returns this, which the the reactive context, in order to provide the ability to chain the logic. + */ + helpers(definitions : { [helperName : string] : () => Mongo.Cursor }): IScope; + + /** + * This method is a wrapper of Tracker.autorun and shares exactly the same API. + * The autorun method is part of the ReactiveContext, and available on every context and $scope. + * The argument of this method is a callback, which will be called each time Autorun will be used. + * The Autorun will stop automatically when when it's context ($scope) is destroyed. + * + * @param runFunc - The function to run. It receives one argument: the Computation object that will be returned. + */ + autorun(runFunc : () => void) : Tracker.Computation; + } + + /** + * $meteor in angularjs + */ + interface IMeteorService { + /** + * A service that wraps the Meteor collections to enable reactivity within AngularJS. + * + * @param collection - A Meteor Collection or a reactive function to bind to. + * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor. + * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection. + * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection. + */ + collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection; + + /** + * A service that wraps the Meteor collections to enable reactivity within AngularJS. + * + * @param collection - A Meteor Collection or a reactive function to bind to. + * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor. + * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection. + * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection. + * @param [updateCollection] - A collection object which will be used for updates (insert, update, delete). + */ + collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection): AngularMeteorCollection2; + + /** + * A service that wraps a Meteor object to enable reactivity within AngularJS. + * Finds the first document that matches the selector, as ordered by sort and skip options. Wraps collection.findOne + * + * @param collection - A Meteor Collection to bind to. + * @param selector - A query describing the documents to find or just the ID of the document. + * - $meteor.object will find the first document that matches the selector, + * - as ordered by sort and skip options, exactly like Meteor's collection.findOne + * @param [autoClientSave=true] - By default, changes in the Angular object will automatically update the Meteor object. + * - However if set to false, changes in the client won't be automatically propagated back to the Meteor object. + */ + object(collection: Mongo.Collection, selector: Mongo.Selector|Mongo.ObjectID|string, autoClientSave?: boolean): AngularMeteorObject; + + /** + * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready. + * + * @param name - Name of the subscription. Matches the name of the server's publish() call. + * @param publisherArguments - Optional arguments passed to publisher function on server. + * + * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle. + */ + subscribe(name: string, ...publisherArguments: any[]): angular.IPromise; + + /** + * A service service which wraps up Meteor.methods with AngularJS promises. + * + * @param name - Name of method to invoke + * @param methodArguments - Optional method arguments + * + * @return The promise solves successfully with the return value of the method or return reject with the error from the method. + */ + call(name: string, ...methodArguments: any[]): angular.IPromise; + + // User Authentication BEGIN -> + + /** + * Returns a promise fulfilled with the currentUser when the user subscription is ready. + * This is useful when you want to grab the current user before the route is rendered. + * If there is no logged in user, it will return null. + * See the “Authentication with Routers” section of our tutorial for more information and a full example. + */ + waitForUser(): angular.IPromise; + + /** + * Resolves the promise successfully if a user is authenticated and rejects otherwise. + * This is useful in cases where you want to require a route to have an authenticated user. + * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page. + * See the “Authentication with Routers” section of our tutorial for more information and a full example. + */ + requireUser(): angular.IPromise; + + /** + * Resolves the promise successfully if a user is authenticated and the validatorFn returns true; rejects otherwise. + * This is useful in cases where you want to require a route to have an authenticated user and do extra validation like the user's role or group. + * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page. + * See the “Authentication with Routers” section of our tutorial for more information and a full example. + * + * The mandatory validator function will be called with the authenticated user as the single param and it's expected to return true in order to resolve. + * If it returns a string, the promise will be rejected using said string as the reason. + * Any other return (false, null, undefined) will be rejected with the default "FORBIDDEN" reason. + */ + requireValidUser(validatorFn: (user: Meteor.User) => boolean|string): angular.IPromise; + + /** + * Log the user in with a password. + * + * @param user - Either a string interpreted as a username or an email; or an object with a single key: email, username or id. + * @param password - The user's password. + */ + loginWithPassword(user: string|{email: string}|{username: string}|{id: string}, password: string): angular.IPromise; + + /** + * Create a new user. More information: http://docs.meteor.com/#/full/accounts_createuser + * + * @param options.username - A unique name for this user. Either this, or email is required. + * @param options.email - The user's email address. Either this, or username is required. + * @param options.password - The user's password. This is not sent in plain text over the wire. + * @param options.profile - The user's profile, typically including the name field. + */ + createUser(options: {username?: string; email?: string; password: string; profile?: Object}): angular.IPromise; + + /** + * Change the current user's password. Must be logged in. + * + * @param oldPassword - The user's current password. This is not sent in plain text over the wire. + * @param newPassword - A new password for the user. This is not sent in plain text over the wire. + */ + changePassword(oldPassword: string, newPassword: string): angular.IPromise; + + /** + * Request a forgot password email. + * + * @param options.email - The email address to send a password reset link. + */ + forgotPassword(options: {email: string}): angular.IPromise; + + /** + * Reset the password for a user using a token received in email. Logs the user in afterwards. + * + * @param token - The token retrieved from the reset password URL. + * @param newPassword - A new password for the user. This is not sent in plain text over the wire. + */ + resetPassword(token: string, newPassword: string): angular.IPromise; + + /** + * Marks the user's email address as verified. Logs the user in afterwards. + * + * @param token - The token retrieved from the reset password URL. + */ + verifyEmail(token: string): angular.IPromise; + + loginWithFacebook: ILoginWithExternalService; + loginWithTwitter: ILoginWithExternalService; + loginWithGoogle: ILoginWithExternalService; + loginWithGithub: ILoginWithExternalService; + loginWithMeetup: ILoginWithExternalService; + loginWithWeibo: ILoginWithExternalService; + + /** + * Log the user out. + * + * @return Resolves with no arguments on success, or reject with a Error argument on failure. + */ + logout(): angular.IPromise; + + /** + * Log out other clients logged in as the current user, but does not log out the client that calls this function. + * For example, when called in a user's browser, connections in that browser remain logged in, + * but any other browsers or DDP clients logged in as that user will be logged out. + * + * @return Resolves with no arguments on success, or reject with a Error argument on failure. + */ + logoutOtherClients(): angular.IPromise; + + // <- User Authentication END + // $meteorUtils BEGIN -> + + /** + * @param scope - The AngularJS scope you use the autorun on. + * @param fn - The function that will re-run every time a reactive variable changes inside it. + */ + autorun(scope: angular.IScope, fn: Function): void; + + /** + * @param collectionName - The name of the collection you want to get back + */ + getCollectionByName(collectionName: string): Mongo.Collection; + + // <- $meteorUtils END + // $meteorCamera BEGIN -> + + /** + * A helper service for taking pictures across platforms. + * Must add mdg:camera package to use! (meteor add mdg:camera) + * + * @param [options] - options is an optional argument that is an Object with the following possible keys: + * @param options.width - An integer that specifies the minimum width of the returned photo. + * @param options.height - An integer that specifies the minimum height of the returned photo. + * @param options.quality - A number from 0 to 100 specifying the desired quality of JPEG encoding. + * + * @return The promise solved successfully when the picture is taken with the data as a parameter or rejected with an error as a parameter in case of error. + */ + getPicture(options?: {width?: number; height?: number; quality?: number}): angular.IPromise; + + // <- $meteorCamera END + + /** + * A service that binds a scope variable to a Meteor Session variable. + * + * @param sessionKey - The name of the session variable + * @return An object with a single function bind - to bind to that variable. + */ + session(sessionKey: string): { + /** + * @param scope - The scope the document will be bound to. + * @param model - The name of the scope's model variable that the document will be bound to. + */ + bind: (scope: IScope, model: string) => void; + }; + } + + /** + * An object that connects a Meteor Object to an AngularJS scope variable. + * + * The object contains also all the properties from the generic type T, + * unfortunately TypeScript doesn't at the moment allow to extend a generic type (see https://github.com/Microsoft/TypeScript/issues/2225 for details and updates). + * For a workaround, you'll need to implement an interface which will merge AngularMeteorObject together with T and cast it, like this: + * + * interface TodoAngularMeteorObject extends ITodo, AngularMeteorObject { } + * var todo = $meteor.object(TodoCollection, 'TodoID'); + */ + interface AngularMeteorObject { + /** + * @param [doc] - The doc to save to the Meteor Object. If nothing is passed, the method saves everything in the AngularMeteorObject as is. + * - Unchanged properties will be overridden with their existing values, which may trigger hooks. + * - If doc is passed, the method only updates the Meteor Object with the properties passed, and no other changes will be saved. + * + * @return Returns a promise with an error in case for an error or a number of successful docs changed in case of success. + */ + save(doc?: T): angular.IPromise; + + /** + * Reset the current value of the object to the one in the server. + */ + reset(): void; + + /** + * Returns a copy of the AngularMeteorObject with all the AngularMeteor-specific internal properties removed. + * The returned object is then safe to use as a parameter for method calls, or anywhere else where the data needs to be converted to JSON. + */ + getRawObject(): T; + + /** + * A shorten (Syntactic sugar) function for the $meteor.subscribe function. + * Takes only one parameter and not returns a promise like $meteor.subscribe does. + * + * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service. + */ + subscribe(subscriptionName:string): AngularMeteorObject; + } + + /** + * An object that connects a Meteor Collection to an AngularJS scope variable + */ + interface AngularMeteorCollection extends AngularMeteorCollection2 { } + + /** + * An object that connects a Meteor Collection to an AngularJS scope variable, + * but can use a differen type for updates. + */ + interface AngularMeteorCollection2 extends Array { + /** + * @param [docs] - The docs to save to the Meteor Collection. + * - If the docs parameter is empty, the method saves everything in the AngularMeteorCollection as is. + * - If an object is passed, the method pushes that object into the AngularMeteorCollection. + * - If an array is passed, the method pushes all objects in the array into the AngularMeteorCollection. + */ + save(docs?: U|U[]): void; + + /** + * @param [keys] - The keys of the object to remove from the Meteor Collection. + * - If nothing is passed, the method removes all the documents from the AngularMeteorCollection. + * - If an object is passed, the method removes the object with that key from the AngularMeteorCollection. + * - If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection. + */ + remove(keys?: U|string|number|string[]|number[]): void; + + /** + * A shorten (Syntactic sugar) function for the $meteor.subscribe function. + * Takes only one parameter and not returns a promise like $meteor.subscribe does. + * + * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service. + */ + subscribe(subscriptionName:string): AngularMeteorCollection2; + } + + interface ILoginWithExternalService { + (options: Meteor.LoginWithExternalServiceOptions): angular.IPromise; + } + + interface ReactiveResult { } +} diff --git a/angular-odata-resources/angular-odata-resources-tests.ts b/angular-odata-resources/angular-odata-resources-tests.ts index 23286adc0..a9194b006 100644 --- a/angular-odata-resources/angular-odata-resources-tests.ts +++ b/angular-odata-resources/angular-odata-resources-tests.ts @@ -174,6 +174,7 @@ var user = odataResourceClass.odata() .skip(10) .take(20) .orderBy("Name", "desc") + .transformUrl((s)=>s) .single(); user.$save(); diff --git a/angular-odata-resources/angular-odata-resources.d.ts b/angular-odata-resources/angular-odata-resources.d.ts index 65e7d26e2..d9c59ddf3 100644 --- a/angular-odata-resources/angular-odata-resources.d.ts +++ b/angular-odata-resources/angular-odata-resources.d.ts @@ -281,6 +281,7 @@ declare module OData { constructor(callback: ProviderCallback); filter(operand1: any, operand2?: any, operand3?: any): Provider; orderBy(arg1: string, arg2?: string): Provider; + transformUrl(transformMethod : (url:string)=>string): Provider; take(amount: number): Provider; skip(amount: number): Provider; private execute(); diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts index 0f98aead1..64bf8d6d6 100644 --- a/angular-protractor/angular-protractor-tests.ts +++ b/angular-protractor/angular-protractor-tests.ts @@ -406,9 +406,19 @@ function TestElementArrayFinder() { elementArrayFinder.each(function(element: protractor.ElementFinder){ // nothing }); + stringPromise = elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){ return 'abc'; - }) + }); + + stringPromise = elementArrayFinder.map(function(element: protractor.ElementFinder, index: number): string { + return 'abc'; + }); + + stringPromise = elementArrayFinder.map>(function(element: protractor.ElementFinder, index: number): webdriver.promise.Promise { + return element.getText(); + }); + elementArrayFinder = elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){ return element.getText().then((text: string) => { return text === "foo"; diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index 08f83e27d..78158df9c 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -992,6 +992,7 @@ declare module protractor { * of values returned by the map function. */ map(mapFn: (element: ElementFinder, index: number) => T): webdriver.promise.Promise; + map(mapFn: (element: ElementFinder, index: number) => T2): webdriver.promise.Promise; /** * Apply a filter function to each element within the ElementArrayFinder. Returns diff --git a/angular-touchspin/angular-touchspin-tests.ts b/angular-touchspin/angular-touchspin-tests.ts new file mode 100644 index 000000000..c6e229c7f --- /dev/null +++ b/angular-touchspin/angular-touchspin-tests.ts @@ -0,0 +1,29 @@ +/// +/// + +angular + .module('touchspin-tests', ['lm.touchspin']) + .config(function(touchspinConfigProvider: angularTouchSpin.ITouchSpinConfigProvider) { + touchspinConfigProvider.defaults({ + min: 0, + max: 0, + step: 0, + decimals: 0, + stepInterval: 0, + forceStepDivisibility: '', // none | floor | round | ceil + stepIntervalDelay: 0, + verticalButtons: true, + verticalUpClass: '', + verticalDownClass: '', + initVal: 0, + prefix: '', + postfix: '', + prefixExtraClass: '', + postfixExtraClass: '', + mousewheel: true, + buttonDownClass: '', + buttonUpClass: '', + buttonDownTxt: '', + buttonUpTxt: '' + }); + }); diff --git a/angular-touchspin/angular-touchspin.d.ts b/angular-touchspin/angular-touchspin.d.ts new file mode 100644 index 000000000..08cc353a3 --- /dev/null +++ b/angular-touchspin/angular-touchspin.d.ts @@ -0,0 +1,43 @@ +// Type definitions for Angular Touchspin v1.0.0 +// Project: https://github.com/nkovacic/angular-touchspin +// Definitions by: Niko Kovačič +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//// + + +declare module "angular-touchspin" { + let _: string; + export = _; +} + +declare module angularTouchSpin { + interface ITouchSpinOptions { + min?: number; + max?: number; + step?: number; + decimals?: number; + stepInterval?: number; + forceStepDivisibility?: string; // none | floor | round | ceil + stepIntervalDelay?: number; + verticalButtons?: boolean; + verticalUpClass?: string; + verticalDownClass?: string; + initVal?: number; + prefix?: string; + postfix?: string; + prefixExtraClass?: string; + postfixExtraClass?: string; + mousewheel?: boolean; + buttonDownClass?: string; + buttonUpClass?: string; + buttonDownTxt?: string; + buttonUpTxt?: string; + } + + interface ITouchSpinConfig extends ITouchSpinOptions { } + + interface ITouchSpinConfigProvider { + defaults(touchSpinOptions: ITouchSpinOptions): void; + } +} \ No newline at end of file diff --git a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts index 8ebfdb6c2..5b9d09d46 100644 --- a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts +++ b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts @@ -6,7 +6,15 @@ /// // Support for AMD require -declare module 'angular-bootstrap' {} +declare module 'angular-bootstrap' { + let _: string; + export = _; +} + +declare module 'angular-ui-bootstrap' { + let _: string; + export = _; +} declare module angular.ui.bootstrap { diff --git a/angular-wizard/angular-wizard-tests.ts b/angular-wizard/angular-wizard-tests.ts index 61ad7a484..05a5d574f 100644 --- a/angular-wizard/angular-wizard-tests.ts +++ b/angular-wizard/angular-wizard-tests.ts @@ -1,68 +1,114 @@ /// /// +/// /// // test file taken from https://github.com/mgonto/angular-wizard -interface WizardScope extends ng.IScope { - referenceCurrentStep:string; - stepValidation:()=>void; - finishedWizard:()=>void; - enterValidation:()=>void; +interface IWizardScope extends ng.IScope { + referenceCurrentStep: string; + stepValidation: () => void; + finishedWizard: () => void; + enterValidation: () => void; + exitValidation: boolean; + dynamicStepDisabled: string; } describe('AngularWizard', function () { - var $compile:ng.ICompileService, - $rootScope:ng.IRootScopeService, WizardHandler:angular.mgoAngularWizard.WizardHandler, scope:WizardScope; + var $compile: ng.ICompileService, + $q: ng.IQService, + $rootScope: ng.IRootScopeService, + $timeout: ng.ITimeoutService, + WizardHandler: angular.mgoAngularWizard.WizardHandler; + + beforeEach(() => angular.module('mgo-angular-wizard')); + + beforeEach(inject(function (_$compile_: ng.ICompileService, + _$q_: ng.IQService, + _$rootScope_: ng.IRootScopeService, + _$timeout_: ng.ITimeoutService, + _WizardHandler_: angular.mgoAngularWizard.WizardHandler) { + $compile = _$compile_; + $q = _$q_; + $rootScope = _$rootScope_; + $timeout = _$timeout_; + WizardHandler = _WizardHandler_; + })); /** - * Create the view with wizard to test + * Create the generic view with wizard to test * @param {Scope} scope A scope to bind to * @return {[DOM element]} A DOM element compiled */ - function createView(scope:WizardScope) { + function createGenericView(scope: IWizardScope) { scope.referenceCurrentStep = null; var element = angular.element('' - + ' ' - + '

This is the first step

' - + '

Here you can use whatever you want. You can use other directives, binding, etc.

' - + ' ' - + '
' - + ' ' - + '

Continuing

' - + '

You have continued here!

' - + ' ' - + '
' - + ' ' - + '

Even more steps!!

' - + ' ' - + '
' - + '
'); + + ' ' + + '

This is the first step

' + + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + + ' ' + + '
' + + ' ' + + '

Dynamic {{dynamicStepDisabled}}

' + + '

You have continued here!

' + + ' ' + + '
' + + ' ' + + '

Continuing

' + + '

You have continued here!

' + + ' ' + + '
' + + ' ' + + '

Even more steps!!

' + + ' ' + + '
' + + ''); var elementCompiled = $compile(element)(scope); $rootScope.$digest(); return elementCompiled; } it("should correctly create the wizard", function () { - var view = createView(scope); + var scope = $rootScope.$new(); + var view = createGenericView(scope); expect(WizardHandler).toBeTruthy(); - expect(view.find('section').length).toEqual(3); + expect(view.find('section').length).toEqual(4); // expect the correct step to be desirable one expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it("should go to the next step", function () { - var view = createView(scope); + var scope = $rootScope.$new(); + var view = createGenericView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Dynamic'); + }); + it("should render only those steps which are enabled", function () { + var scope =$rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); + it("should enable or disable dynamic steps based on conditions", function () { + var scope = $rootScope.$new(); + var view = createGenericView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + scope.dynamicStepDisabled = 'Y'; + $rootScope.$digest(); + WizardHandler.wizard().goTo(2); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); it("should return to a previous step", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -72,24 +118,27 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Starting'); }); it("should go to a step specified by name", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo('More steps'); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); it("should go to a step specified by index", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo(2); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); it("should go to next step becasue callback is truthy", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function () { return true @@ -98,8 +147,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Continuing'); }); it("should NOT go to next step because callback is falsey", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function () { return false @@ -108,16 +158,18 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Starting'); }); it("should go to next step because CANEXIT is UNDEFINED", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); it("should go to next step because CANEXIT is TRUE", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.stepValidation = function () { return true; }; @@ -130,8 +182,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('More steps'); }); it("should NOT go to next step because CANEXIT is FALSE", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.stepValidation = function () { return false; }; @@ -144,8 +197,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Continuing'); }); it("should go to next step because CANENTER is TRUE", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.enterValidation = function () { return true; }; @@ -158,8 +212,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('More steps'); }); it("should NOT go to next step because CANENTER is FALSE", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.enterValidation = function () { return false; }; @@ -172,8 +227,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Continuing'); }); it("should NOT return to a previous step. Although CANEXIT is false and we are heading to a previous state, the can enter validation is false", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.stepValidation = function () { return false; }; @@ -189,8 +245,9 @@ describe('AngularWizard', function () { expect(scope.referenceCurrentStep).toEqual('Continuing'); }); it("should return to a previous step even though CANEXIT is false", function () { - - var view = createView(scope); + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); scope.stepValidation = function () { return false; }; @@ -202,17 +259,66 @@ describe('AngularWizard', function () { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it("should finish", function () { - - var flag = false; - scope.finishedWizard = function () { - flag = true; + it("should go to the next step because the promise that CANENTER returns resolves to true", function (done) { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + scope.enterValidation = function () { + var deferred = $q.defer(); + $timeout(function () { + deferred.resolve(true); + done(); + }); + return deferred.promise; }; - var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $timeout.flush(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it("should go to the next step because CANEXIT is set to true", function () { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + scope.exitValidation = true; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it("should finish", function () { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var flag = false; + scope.finishedWizard = function () { flag = true; }; + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().finish(); expect(flag).toBeTruthy(); $rootScope.$digest(); }); + it("should go to first step when reset is called", function () { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo(2); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + WizardHandler.wizard().reset(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); + it("step description should be accessible", function () { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + expect((view.isolateScope()).steps[0].description).toEqual('Step description'); + }); }); - diff --git a/angular-wizard/angular-wizard.d.ts b/angular-wizard/angular-wizard.d.ts index f079a46c2..a854f94a0 100644 --- a/angular-wizard/angular-wizard.d.ts +++ b/angular-wizard/angular-wizard.d.ts @@ -1,21 +1,38 @@ -// Type definitions for Angular Wizard 0.4.2 +// Type definitions for Angular Wizard 0.6.1 // Project: https://github.com/mgonto/angular-wizard -// Definitions by: Marko Jurisic +// Definitions by: Marko Jurisic , Ronald Wildenberg // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module angular.mgoAngularWizard { interface WizardHandler { - wizard(name?:string): Wizard; - addWizard(name:string, wizard:Wizard):void; - removeWizard(name:string):void; + wizard(name?: string): Wizard; + addWizard(name: string, wizard: Wizard): void; + removeWizard(name: string): void; } interface Wizard { - next(nextHandler?:Function):void; - previous():void; - goTo(step:number):void; - goTo(step:string):void; - finish():void; - currentStepNumber():number; + next(nextHandler?: () => boolean): void; + previous(): void; + cancel: () => void; + goTo(step: number | string): void; + finish(): void; + reset: () => void; + + addStep: (step: WzStep) => void; + currentStep: () => WzStep; + currentStepNumber(): number; + currentStepDescription: () => string; + currentStepTitle: () => string; + getEnabledSteps(): WzStep[]; + } + + interface WzStep { + canenter: (...args: any[]) => boolean; + canexit: (...args: any[]) => boolean; + description: string; + selected: boolean; + title: string; + wzData: any; + wzTitle: string; } } diff --git a/angular2/angular2-2.0.0-alpha.26.d.ts b/angular2/angular2-2.0.0-alpha.26.d.ts deleted file mode 100644 index a527b13ca..000000000 --- a/angular2/angular2-2.0.0-alpha.26.d.ts +++ /dev/null @@ -1,4624 +0,0 @@ -// Type definitions for Angular v2.0.0-alpha.26 -// Project: http://angular.io/ -// Definitions by: angular team -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -// *********************************************************** -// This file is generated by the Angular build process. -// Please do not create manual edits or send pull requests -// modifying this file. -// *********************************************************** - -// Angular depends transitively on these libraries. -// If you don't have them installed you can run -// $ tsd query es6-promise rx rx-lite --action install --save -/// -/// - -interface List extends Array {} -interface Map {} -interface StringMap {} -interface Type {} - -declare module "angular2/angular2" { - type SetterFn = typeof Function; - type int = number; - - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: any; - stack: any; - toString(): string; - } -} - - -declare module "angular2/angular2" { - class AbstractChangeDetector extends ChangeDetector { - addChild(cd: ChangeDetector): any; - addShadowDomChild(cd: ChangeDetector): any; - callOnAllChangesDone(): any; - checkNoChanges(): any; - detectChanges(): any; - detectChangesInRecords(throwOnChange: boolean): any; - lightDomChildren: List; - markAsCheckOnce(): any; - markPathToRootAsCheckOnce(): any; - mode: string; - parent: ChangeDetector; - ref: ChangeDetectorRef; - remove(): any; - removeChild(cd: ChangeDetector): any; - removeShadowDomChild(cd: ChangeDetector): any; - shadowDomChildren: List; - } - - class ProtoRecord { - args: List; - bindingRecord: BindingRecord; - contextIndex: number; - directiveIndex: DirectiveIndex; - expressionAsString: string; - fixedArgs: List; - funcOrValue: any; - isLifeCycleRecord(): boolean; - isPipeRecord(): boolean; - isPureFunction(): boolean; - lastInBinding: boolean; - lastInDirective: boolean; - mode: number; - name: string; - selfIndex: number; - } - - class LifecycleEvent { - name: string; - } - - interface FormDirective { - addControl(dir: ControlDirective): void; - addControlGroup(dir: ControlGroupDirective): void; - getControl(dir: ControlDirective): Control; - removeControl(dir: ControlDirective): void; - removeControlGroup(dir: ControlGroupDirective): void; - updateModel(dir: ControlDirective, value: any): void; - } - - - /** - * A directive that contains a group of [ControlDirective]. - * - * @exportedAs angular2/forms - */ - class ControlContainerDirective { - formDirective: FormDirective; - name: string; - path: List; - } - - - /** - * A marker annotation that marks a class as available to `Injector` for creation. Used by tooling - * for generating constructor stubs. - * - * ``` - * class NeedsService { - * constructor(svc:UsefulService) {} - * } - * - * @Injectable - * class UsefulService {} - * ``` - * @exportedAs angular2/di_annotations - */ - class Injectable { - } - - - /** - * Injectable Objects that contains a live list of child directives in the light Dom of a directive. - * The directives are kept in depth-first pre-order traversal of the DOM. - * - * In the future this class will implement an Observable interface. - * For now it uses a plain list of observable callbacks. - * - * @exportedAs angular2/view - */ - class BaseQueryList { - add(obj: any): any; - fireCallbacks(): any; - onChange(callback: any): any; - removeCallback(callback: any): any; - reset(newList: any): any; - } - - class AppProtoView { - bindElement(parent: ElementBinder, distanceToParent: int, protoElementInjector: ProtoElementInjector, componentDirective?: DirectiveBinding): ElementBinder; - - /** - * Adds an event binding for the last created ElementBinder via bindElement. - * - * If the directive index is a positive integer, the event is evaluated in the context of - * the given directive. - * - * If the directive index is -1, the event is evaluated in the context of the enclosing view. - * - * @param {string} eventName - * @param {AST} expression - * @param {int} directiveIndex The directive index in the binder or -1 when the event is not bound - * to a directive - */ - bindEvent(eventBindings: List, boundElementIndex: number, directiveIndex?: int): void; - elementBinders: List; - protoChangeDetector: ProtoChangeDetector; - protoLocals: Map; - render: RenderProtoViewRef; - variableBindings: Map; - } - - - /** - * Const of making objects: http://jsperf.com/instantiate-size-of-object - */ - class AppView implements ChangeDispatcher, EventDispatcher { - callAction(elementIndex: number, actionExpression: string, action: Object): any; - changeDetector: ChangeDetector; - componentChildViews: List; - - /** - * The context against which data-binding expressions in this view are evaluated against. - * This is always a component instance. - */ - context: any; - dispatchEvent(elementIndex: number, eventName: string, locals: Map): boolean; - elementInjectors: List; - freeHostViews: List; - getDetectorFor(directive: DirectiveIndex): any; - getDirectiveFor(directive: DirectiveIndex): any; - hydrated(): boolean; - init(changeDetector: ChangeDetector, elementInjectors: List, rootElementInjectors: List, preBuiltObjects: List, componentChildViews: List): any; - - /** - * Variables, local to this view, that can be used in binding expressions (in addition to the - * context). This is used for thing like `