mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 13:30:28 +00:00
Merge pull request #3 from DefinitelyTyped/master
Pull request from master
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=none
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
|
||||
+38
-43
@@ -1,43 +1,38 @@
|
||||
*.dll
|
||||
*.exe
|
||||
*.cmd
|
||||
*.pdb
|
||||
*.suo
|
||||
*.js
|
||||
*.user
|
||||
*.cache
|
||||
*.cs
|
||||
*.sln
|
||||
*.csproj
|
||||
*.txt
|
||||
*.map
|
||||
*.swp
|
||||
.DS_Store
|
||||
|
||||
_Resharper.DefinitelyTyped
|
||||
bin
|
||||
obj
|
||||
Properties
|
||||
|
||||
# VIM backup files
|
||||
*~
|
||||
|
||||
# test folder
|
||||
_infrastructure/tests/build
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
*.js.map
|
||||
|
||||
#decimal.js
|
||||
!decimal.js
|
||||
|
||||
#rx.js
|
||||
!rx.js
|
||||
|
||||
#zip.js
|
||||
!zip.js
|
||||
|
||||
node_modules
|
||||
|
||||
.sublimets
|
||||
*.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
|
||||
yarn.lock
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- 4
|
||||
|
||||
sudo: false
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/// <reference path="3d-bin-packing.d.ts" />
|
||||
|
||||
import packer = require("3d-bin-packing");
|
||||
import samchon = require("samchon-framework");
|
||||
|
||||
function main(): void
|
||||
{
|
||||
///////////////////////////
|
||||
// CONSTRUCT OBJECTS
|
||||
///////////////////////////
|
||||
let wrapperArray: bws.packer.WrapperArray = new packer.WrapperArray();
|
||||
let instanceArray: bws.packer.InstanceArray = new packer.InstanceArray();
|
||||
|
||||
// Wrappers
|
||||
wrapperArray.push
|
||||
(
|
||||
new packer.Wrapper("Large", 1000, 40, 40, 15, 0),
|
||||
new packer.Wrapper("Medium", 700, 20, 20, 10, 0),
|
||||
new packer.Wrapper("Small", 500, 15, 15, 8, 0)
|
||||
);
|
||||
|
||||
///////
|
||||
// Each Instance is repeated #15
|
||||
///////
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20));
|
||||
|
||||
// Wrappers also can be packed into another Wrapper.
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0));
|
||||
|
||||
///////////////////////////
|
||||
// BEGINS PACKING
|
||||
///////////////////////////
|
||||
// CONSTRUCT PACKER
|
||||
let my_packer: bws.packer.Packer = new packer.Packer(wrapperArray, instanceArray);
|
||||
|
||||
///////
|
||||
// PACK (OPTIMIZE)
|
||||
let result: bws.packer.WrapperArray = my_packer.optimize();
|
||||
///////
|
||||
|
||||
///////////////////////////
|
||||
// TRACE PACKING RESULT
|
||||
///////////////////////////
|
||||
let xml: samchon.library.XML = result.toXML();
|
||||
console.log(xml.toString());
|
||||
}
|
||||
|
||||
main();
|
||||
Vendored
+1500
File diff suppressed because it is too large
Load Diff
+1086
-150
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
/// <reference path="md5.d.ts" />
|
||||
|
||||
var hash: string;
|
||||
hash = CybozuLabs.MD5.calc("abc");
|
||||
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_ASCII);
|
||||
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_UTF16);
|
||||
|
||||
var version: string;
|
||||
/// <reference path="CybozuLabs-md5.d.ts" />
|
||||
|
||||
var hash: string;
|
||||
hash = CybozuLabs.MD5.calc("abc");
|
||||
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_ASCII);
|
||||
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_UTF16);
|
||||
|
||||
var version: string;
|
||||
version = CybozuLabs.MD5.VERSION;
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for CybozuLabs.MD5
|
||||
// Project: http://labs.cybozu.co.jp/blog/mitsunari/2007/07/md5js_1.html
|
||||
// Definitions by: MIZUNE Pine <https://github.com/pine613>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace CybozuLabs.MD5 {
|
||||
var VERSION: string;
|
||||
var BY_ASCII: number;
|
||||
var BY_UTF16: number;
|
||||
function calc(str: string, option?: number): string;
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
/// <reference path="FileSaver.d.ts" />
|
||||
|
||||
import {saveAs as importedSaveAs} from "file-saver";
|
||||
function testImportedSaveAs() {
|
||||
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
var filename: string = 'hello world.txt';
|
||||
var disableAutoBOM = true;
|
||||
|
||||
importedSaveAs(data, filename, disableAutoBOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function.
|
||||
*/
|
||||
function testSaveAs() {
|
||||
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
var filename: string = 'hello world.txt';
|
||||
|
||||
saveAs(data, filename);
|
||||
var disableAutoBOM = true;
|
||||
|
||||
saveAs(data, filename, disableAutoBOM);
|
||||
}
|
||||
|
||||
Vendored
+15
-4
@@ -1,7 +1,7 @@
|
||||
// Type definitions for FileSaver.js
|
||||
// Project: https://github.com/eligrey/FileSaver.js/
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* @summary Interface for "saveAs" function.
|
||||
@@ -15,13 +15,24 @@ interface FileSaver {
|
||||
* @type {Blob}
|
||||
*/
|
||||
data: Blob,
|
||||
|
||||
|
||||
/**
|
||||
* @summary File name.
|
||||
* @type {DOMString}
|
||||
*/
|
||||
filename: string
|
||||
filename: string,
|
||||
|
||||
/**
|
||||
* @summary Disable Unicode text encoding hints or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
disableAutoBOM?: boolean
|
||||
): void
|
||||
}
|
||||
|
||||
declare var saveAs: FileSaver;
|
||||
declare var saveAs: FileSaver;
|
||||
|
||||
declare module "file-saver" {
|
||||
var fileSaver: { saveAs: typeof saveAs };
|
||||
export = fileSaver
|
||||
}
|
||||
|
||||
+368
-368
@@ -1,368 +1,368 @@
|
||||
/// <reference path="Finch.d.ts" />
|
||||
|
||||
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");
|
||||
}
|
||||
/// <reference path="Finch.d.ts" />
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
Vendored
+47
-47
@@ -1,47 +1,47 @@
|
||||
// Type definitions for Finch 0.5.13
|
||||
// Project: https://github.com/stoodder/finchjs
|
||||
// Definitions by: David Sichau <https://github.com/DavidSichau>
|
||||
// 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 <https://github.com/DavidSichau>
|
||||
// Definitions: https://github.com/DefinitelyTyped/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;
|
||||
}
|
||||
|
||||
Vendored
+5
-4
@@ -1,17 +1,18 @@
|
||||
// Type definitions for headroom.js v0.7.0
|
||||
// Project: http://wicky.nillia.ms/headroom.js/
|
||||
// Definitions by: Jakub Olek <https://github.com/hakubo/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface HeadroomOptions {
|
||||
offset?: number;
|
||||
tolerance?: any;
|
||||
classes?: {
|
||||
initial?: string;
|
||||
pinned?: string;
|
||||
unpinned?: string;
|
||||
top?: string;
|
||||
notBottom?:string;
|
||||
notTop?: string;
|
||||
pinned?: string;
|
||||
top?: string;
|
||||
unpinned?: string;
|
||||
};
|
||||
scroller?: Element;
|
||||
onPin?: () => void;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/// <reference path="HubSpot-pace.d.ts" />
|
||||
|
||||
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/]
|
||||
}
|
||||
};
|
||||
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
// Type definitions for pace v0.7.5
|
||||
// Project: https://github.com/HubSpot/pace
|
||||
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace 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;
|
||||
}
|
||||
@@ -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/ @....
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for JSONStream v0.8.0
|
||||
// Project: http://github.com/dominictarr/JSONStream
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/// <reference path="./openjscad.d.ts" />
|
||||
|
||||
function test() {
|
||||
|
||||
var gProcessor: OpenJsCad.Processor = null;
|
||||
|
||||
// Show all exceptions to the user:
|
||||
OpenJsCad.AlertUserOfUncaughtExceptions();
|
||||
|
||||
function onload()
|
||||
{
|
||||
gProcessor = new OpenJsCad.Processor(<HTMLDivElement>document.getElementById("viewer"));
|
||||
updateSolid();
|
||||
}
|
||||
|
||||
function updateSolid()
|
||||
{
|
||||
gProcessor.setJsCad((<HTMLTextAreaElement>document.getElementById('code')).value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
// Main entry point; here we construct our solid:
|
||||
var gear = involuteGear(
|
||||
15,
|
||||
10,
|
||||
20,
|
||||
0,
|
||||
5
|
||||
);
|
||||
var centerhole = CSG.cylinder({start: [0,0,-5], end: [0,0,5], radius: 2, resolution: 16});
|
||||
gear = gear.subtract(centerhole);
|
||||
return gear;
|
||||
}
|
||||
|
||||
function involuteGear(numTeeth: number, circularPitch: number, pressureAngle: number, clearance: number, thickness: number)
|
||||
{
|
||||
// default values:
|
||||
if(arguments.length < 3) pressureAngle = 20;
|
||||
if(arguments.length < 4) clearance = 0;
|
||||
if(arguments.length < 4) thickness = 1;
|
||||
|
||||
var addendum = circularPitch / Math.PI;
|
||||
var dedendum = addendum + clearance;
|
||||
|
||||
// radiuses of the 4 circles:
|
||||
var pitchRadius = numTeeth * circularPitch / (2 * Math.PI);
|
||||
var baseRadius = pitchRadius * Math.cos(Math.PI * pressureAngle / 180);
|
||||
var outerRadius = pitchRadius + addendum;
|
||||
var rootRadius = pitchRadius - dedendum;
|
||||
|
||||
var maxtanlength = Math.sqrt(outerRadius*outerRadius - baseRadius*baseRadius);
|
||||
var maxangle = maxtanlength / baseRadius;
|
||||
|
||||
var tl_at_pitchcircle = Math.sqrt(pitchRadius*pitchRadius - baseRadius*baseRadius);
|
||||
var angle_at_pitchcircle = tl_at_pitchcircle / baseRadius;
|
||||
var diffangle = angle_at_pitchcircle - Math.atan(angle_at_pitchcircle);
|
||||
var angularToothWidthAtBase = Math.PI / numTeeth + 2*diffangle;
|
||||
|
||||
// build a single 2d tooth in the 'points' array:
|
||||
var resolution = 5;
|
||||
var points = [new CSG.Vector2D(0,0)];
|
||||
for(var i = 0; i <= resolution; i++)
|
||||
{
|
||||
// first side of the tooth:
|
||||
var angle = maxangle * i / resolution;
|
||||
var tanlength = angle * baseRadius;
|
||||
var radvector = CSG.Vector2D.fromAngle(angle);
|
||||
var tanvector = radvector.normal();
|
||||
var p = radvector.times(baseRadius).plus(tanvector.times(tanlength));
|
||||
points[i+1] = p;
|
||||
|
||||
// opposite side of the tooth:
|
||||
radvector = CSG.Vector2D.fromAngle(angularToothWidthAtBase - angle);
|
||||
tanvector = radvector.normal().negated();
|
||||
p = radvector.times(baseRadius).plus(tanvector.times(tanlength));
|
||||
points[2 * resolution + 2 - i] = p;
|
||||
}
|
||||
|
||||
// create the polygon and extrude into 3D:
|
||||
var tooth3d = new CSG.Polygon2D(points).extrude({offset: [0, 0, thickness]});
|
||||
|
||||
var allteeth = new CSG();
|
||||
for(var i = 0; i < numTeeth; i++)
|
||||
{
|
||||
var angle = i*360/numTeeth;
|
||||
var rotatedtooth = <CSG>tooth3d.rotateZ(angle);
|
||||
allteeth = allteeth.unionForNonIntersecting(rotatedtooth);
|
||||
}
|
||||
|
||||
// build the root circle:
|
||||
points = [];
|
||||
var toothAngle = 2 * Math.PI / numTeeth;
|
||||
var toothCenterAngle = 0.5 * angularToothWidthAtBase;
|
||||
for(var i = 0; i < numTeeth; i++)
|
||||
{
|
||||
var angle = toothCenterAngle + i * toothAngle;
|
||||
var p = CSG.Vector2D.fromAngle(angle).times(rootRadius);
|
||||
points.push(p);
|
||||
}
|
||||
|
||||
// create the polygon and extrude into 3D:
|
||||
var rootcircle = new CSG.Polygon2D(points).extrude({offset: [0, 0, thickness]});
|
||||
|
||||
var result = rootcircle.union(allteeth);
|
||||
|
||||
// center at origin:
|
||||
result = <CSG>result.translate([0, 0, -thickness/2]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var cylresolution=16;
|
||||
|
||||
|
||||
function main2()
|
||||
{
|
||||
var params =
|
||||
{
|
||||
quality: 0,
|
||||
diameter1: 12.2,
|
||||
shaftlength1: 15,
|
||||
outerlength1: 20,
|
||||
nutradius1: 4.65,
|
||||
nutthickness1: 4.2,
|
||||
screwdiameter1: 5,
|
||||
diameter2: 9.5,
|
||||
shaftlength2: 10,
|
||||
outerlength2: 15,
|
||||
nutradius2: 3.2,
|
||||
nutthickness2: 2.6,
|
||||
screwdiameter2: 3,
|
||||
outerdiameter: 30,
|
||||
spiderlength: 12,
|
||||
spidermargin: 0,
|
||||
numteeth: 2
|
||||
};
|
||||
|
||||
|
||||
cylresolution=(params.quality == 1)? 64:16;
|
||||
|
||||
var outerdiameter=params.outerdiameter;
|
||||
outerdiameter=Math.max(outerdiameter, params.diameter1+0.5);
|
||||
outerdiameter=Math.max(outerdiameter, params.diameter2+0.5);
|
||||
|
||||
var spidercenterdiameter=outerdiameter/2;
|
||||
|
||||
var part1=makeShaft(params.diameter1, outerdiameter,spidercenterdiameter,params.shaftlength1,params.outerlength1,params.spiderlength, params.nutradius1, params.nutthickness1, params.screwdiameter1, params.numteeth);
|
||||
var part2=makeShaft(params.diameter2, outerdiameter,spidercenterdiameter,params.shaftlength2,params.outerlength2,params.spiderlength, params.nutradius2, params.nutthickness2, params.screwdiameter2, params.numteeth);
|
||||
var spider=makeSpider(outerdiameter, spidercenterdiameter, params.spiderlength, params.numteeth);
|
||||
|
||||
if(params.spidermargin > 0)
|
||||
{
|
||||
spider=spider.contract(params.spidermargin, 4);
|
||||
}
|
||||
|
||||
// rotate shaft parts for better 3d printing:
|
||||
part1=<CSG>part1.rotateX(180).translate([0,0,params.outerlength1+params.spiderlength]);
|
||||
part2=<CSG>part2.rotateX(180).translate([0,0,params.outerlength2+params.spiderlength]);
|
||||
|
||||
var result=<CSG>part1.translate([-outerdiameter-5,0,0]);
|
||||
result=result.union(<CSG>part2.translate([0,0,0]));
|
||||
result=result.union(<CSG>spider.translate([outerdiameter+5,0,-params.spidermargin]));
|
||||
return result;
|
||||
}
|
||||
|
||||
function makeShaft(innerdiameter: number, outerdiameter: number, spidercenterdiameter: number, shaftlength: number, outerlength: number, spiderlength: number, nutradius: number, nutthickness: number, screwdiameter: number, numteeth: number)
|
||||
{
|
||||
var result=CSG.cylinder({start:[0,0,0], end:[0,0,outerlength], radius:outerdiameter/2, resolution:cylresolution});
|
||||
|
||||
for(var i=0; i < numteeth; i++)
|
||||
{
|
||||
var angle=i*360/numteeth;
|
||||
var pie=makePie(outerdiameter/2, spiderlength,angle-45/numteeth, angle+45/numteeth);
|
||||
pie=<CSG>pie.translate([0,0,outerlength]);
|
||||
result=result.union(pie);
|
||||
}
|
||||
var spidercylinder=CSG.cylinder({start:[0,0,outerlength], end:[0,0,outerlength+spiderlength],radius:spidercenterdiameter/2,resolution:cylresolution});
|
||||
result=result.subtract(spidercylinder);
|
||||
var shaftcylinder=CSG.cylinder({start:[0,0,0], end:[0,0,shaftlength], radius:innerdiameter/2, resolution:cylresolution});
|
||||
result=result.subtract(shaftcylinder);
|
||||
|
||||
var screwz=shaftlength/2;
|
||||
if(screwz < nutradius) screwz=nutradius;
|
||||
var nutcutout = <CSG>hexagon(nutradius, nutthickness).translate([0,0,-nutthickness/2]);
|
||||
var grubnutradiusAtFlatSide = nutradius * Math.cos(Math.PI / 180 * 30);
|
||||
var nutcutoutrectangle = CSG.cube({
|
||||
radius: [outerlength/2, grubnutradiusAtFlatSide, nutthickness/2],
|
||||
center: [outerlength/2, 0, 0],
|
||||
});
|
||||
nutcutout = nutcutout.union(nutcutoutrectangle);
|
||||
nutcutout = <CSG>nutcutout.rotateY(90);
|
||||
nutcutout = <CSG>nutcutout.translate([(outerdiameter+innerdiameter)/4, 0, screwz]);
|
||||
result = result.subtract(nutcutout);
|
||||
|
||||
var screwcutout=CSG.cylinder({
|
||||
start: [outerdiameter/2, 0, screwz],
|
||||
end: [0, 0, screwz],
|
||||
radius: screwdiameter/2,
|
||||
resolution:cylresolution
|
||||
});
|
||||
result=result.subtract(screwcutout);
|
||||
|
||||
//return nutcutout;
|
||||
// nutcutout = nutcutout.translate([-grubnutheight/2 - centerholeradius - nutdistance,0,0]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function makePie(radius: number, height: number, startangle: number, endangle: number)
|
||||
{
|
||||
var absangle=Math.abs(startangle-endangle);
|
||||
if(absangle >= 180)
|
||||
{
|
||||
throw new Error("Pie angle must be less than 180 degrees");
|
||||
}
|
||||
var numsteps=cylresolution*absangle/360;
|
||||
if(numsteps < 1) numsteps=1;
|
||||
var points: CSG.Vector2D[] = [];
|
||||
for(var i=0; i <= numsteps; i++)
|
||||
{
|
||||
var angle=startangle+i/numsteps*(endangle-startangle);
|
||||
var vec = CSG.Vector2D.fromAngleDegrees(angle).times(radius);
|
||||
points.push(vec);
|
||||
}
|
||||
points.push(new CSG.Vector2D(0,0));
|
||||
var shape2d=new CSG.Polygon2D(points);
|
||||
var extruded=shape2d.extrude({
|
||||
offset: [0,0,height], // direction for extrusion
|
||||
});
|
||||
return extruded;
|
||||
}
|
||||
|
||||
function hexagon(radius: number, height: number)
|
||||
{
|
||||
var vertices: CSG.Vertex[] = [];
|
||||
for(var i=0; i < 6; i++)
|
||||
{
|
||||
var point=CSG.Vector2D.fromAngleDegrees(-i*60).times(radius).toVector3D(0);
|
||||
vertices.push(new CSG.Vertex(point));
|
||||
}
|
||||
var polygon=new CSG.Polygon(vertices);
|
||||
var hexagon=polygon.extrude([0,0,height]);
|
||||
return hexagon;
|
||||
}
|
||||
|
||||
function makeSpider(outerdiameter: number, spidercenterdiameter: number, spiderlength: number, numteeth: number)
|
||||
{
|
||||
var result=new CSG();
|
||||
var numspiderteeth=numteeth*2; // spider has twice the number of teeth
|
||||
for(var i=0; i < numspiderteeth; i++)
|
||||
{
|
||||
var angle=i*360/numspiderteeth;
|
||||
var pie=makePie(outerdiameter/2, spiderlength,angle-90/numspiderteeth, angle+90/numspiderteeth);
|
||||
pie=<CSG>pie.translate([0,0,0]);
|
||||
result=result.union(pie);
|
||||
}
|
||||
|
||||
var centercylinder=CSG.cylinder({start:[0,0,0], end:[0,0,spiderlength], radius:spidercenterdiameter/2, resolution:cylresolution});
|
||||
result=result.union(centercylinder);
|
||||
|
||||
return result;
|
||||
}
|
||||
Vendored
+912
@@ -0,0 +1,912 @@
|
||||
// Type definitions for OpenJsCad.js
|
||||
// Project: https://github.com/joostn/OpenJsCad
|
||||
// Definitions by: Dan Marshall <https://github.com/danmarshall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference path="../threejs/three.d.ts" />
|
||||
|
||||
declare namespace THREE {
|
||||
var CSG: {
|
||||
fromCSG: (csg: CSG, defaultColor: any) => {
|
||||
colorMesh: Mesh;
|
||||
wireframe: Mesh;
|
||||
boundLen: number;
|
||||
};
|
||||
getGeometryVertex: (geometry: any, vertex_position: any) => number;
|
||||
};
|
||||
function OrbitControls(object: any, domElement: any): void;
|
||||
function SpriteCanvasMaterial(parameters?: any): void;
|
||||
interface ICanvasRendererOptions {
|
||||
canvas?: HTMLCanvasElement;
|
||||
alpha?: boolean;
|
||||
}
|
||||
class CanvasRenderer implements Renderer {
|
||||
domElement: HTMLCanvasElement;
|
||||
private pixelRatio;
|
||||
private autoClear;
|
||||
private sortObjects;
|
||||
private sortElements;
|
||||
private info;
|
||||
private _projector;
|
||||
private _renderData;
|
||||
private _elements;
|
||||
private _lights;
|
||||
private _canvas;
|
||||
private _canvasWidth;
|
||||
private _canvasHeight;
|
||||
private _canvasWidthHalf;
|
||||
private _canvasHeightHalf;
|
||||
private _viewportX;
|
||||
private _viewportY;
|
||||
private _viewportWidth;
|
||||
private _viewportHeight;
|
||||
private _context;
|
||||
private _clearColor;
|
||||
private _clearAlpha;
|
||||
private _contextGlobalAlpha;
|
||||
private _contextGlobalCompositeOperation;
|
||||
private _contextStrokeStyle;
|
||||
private _camera;
|
||||
private _contextFillStyle;
|
||||
private _contextLineWidth;
|
||||
private _contextLineCap;
|
||||
private _contextLineJoin;
|
||||
private _contextLineDash;
|
||||
private _v1;
|
||||
private _v2;
|
||||
private _v3;
|
||||
private _v4;
|
||||
private _v5;
|
||||
private _v6;
|
||||
private _v1x;
|
||||
private _v1y;
|
||||
private _v2x;
|
||||
private _v2y;
|
||||
private _v3x;
|
||||
private _v3y;
|
||||
private _v4x;
|
||||
private _v4y;
|
||||
private _v5x;
|
||||
private _v5y;
|
||||
private _v6x;
|
||||
private _v6y;
|
||||
private _color;
|
||||
private _color1;
|
||||
private _color2;
|
||||
private _color3;
|
||||
private _color4;
|
||||
private _diffuseColor;
|
||||
private _emissiveColor;
|
||||
private _lightColor;
|
||||
private _patterns;
|
||||
private _image;
|
||||
private _uvs;
|
||||
private _uv1x;
|
||||
private _uv1y;
|
||||
private _uv2x;
|
||||
private _uv2y;
|
||||
private _uv3x;
|
||||
private _uv3y;
|
||||
private _clipBox;
|
||||
private _clearBox;
|
||||
private _elemBox;
|
||||
private _ambientLight;
|
||||
private _directionalLights;
|
||||
private _pointLights;
|
||||
private _vector3;
|
||||
private _centroid;
|
||||
private _normal;
|
||||
private _normalViewMatrix;
|
||||
constructor(parameters: ICanvasRendererOptions);
|
||||
supportsVertexTextures(): void;
|
||||
setFaceCulling: () => void;
|
||||
getPixelRatio(): number;
|
||||
setPixelRatio(value: any): void;
|
||||
setSize(width: any, height: any, updateStyle: any): void;
|
||||
setViewport(x: any, y: any, width: any, height: any): void;
|
||||
setScissor(): void;
|
||||
enableScissorTest(): void;
|
||||
setClearColor(color: any, alpha: any): void;
|
||||
setClearColorHex(hex: any, alpha: any): void;
|
||||
getClearColor(): Color;
|
||||
getClearAlpha(): number;
|
||||
getMaxAnisotropy(): number;
|
||||
clear(): void;
|
||||
clearColor(): void;
|
||||
clearDepth(): void;
|
||||
clearStencil(): void;
|
||||
render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean): void;
|
||||
calculateLights(): void;
|
||||
calculateLight(position: any, normal: any, color: any): void;
|
||||
renderSprite(v1: any, element: any, material: any): void;
|
||||
renderLine(v1: any, v2: any, element: any, material: any): void;
|
||||
renderFace3(v1: any, v2: any, v3: any, uv1: any, uv2: any, uv3: any, element: any, material: any): void;
|
||||
drawTriangle(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any): void;
|
||||
strokePath(color: any, linewidth: any, linecap: any, linejoin: any): void;
|
||||
fillPath(color: any): void;
|
||||
onTextureUpdate(event: any): void;
|
||||
textureToPattern(texture: any): void;
|
||||
patternPath(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any, u0: any, v0: any, u1: any, v1: any, u2: any, v2: any, texture: any): void;
|
||||
clipImage(x0: any, y0: any, x1: any, y1: any, x2: any, y2: any, u0: any, v0: any, u1: any, v1: any, u2: any, v2: any, image: any): void;
|
||||
expand(v1: any, v2: any, pixels: any): void;
|
||||
setOpacity(value: any): void;
|
||||
setBlending(value: any): void;
|
||||
setLineWidth(value: any): void;
|
||||
setLineCap(value: any): void;
|
||||
setLineJoin(value: any): void;
|
||||
setStrokeStyle(value: any): void;
|
||||
setFillStyle(value: any): void;
|
||||
setLineDash(value: any): void;
|
||||
}
|
||||
function RenderableObject(): void;
|
||||
function RenderableFace(): void;
|
||||
function RenderableVertex(): void;
|
||||
function RenderableLine(): void;
|
||||
function RenderableSprite(): void;
|
||||
function Projector(): void;
|
||||
}
|
||||
declare namespace OpenJsCad {
|
||||
interface ILog {
|
||||
(x: string): void;
|
||||
prevLogTime?: number;
|
||||
}
|
||||
var log: ILog;
|
||||
interface IViewerOptions {
|
||||
drawLines?: boolean;
|
||||
drawFaces?: boolean;
|
||||
color?: number[];
|
||||
bgColor?: number;
|
||||
noWebGL?: boolean;
|
||||
}
|
||||
interface ProcessorOptions extends IViewerOptions {
|
||||
verbose?: boolean;
|
||||
viewerwidth?: number;
|
||||
viewerheight?: number;
|
||||
viewerheightratio?: number;
|
||||
}
|
||||
class Viewer {
|
||||
private perspective;
|
||||
private drawOptions;
|
||||
private size;
|
||||
private defaultColor_;
|
||||
private bgColor_;
|
||||
private containerElm_;
|
||||
private scene_;
|
||||
private camera_;
|
||||
private controls_;
|
||||
private renderer_;
|
||||
private canvas;
|
||||
private pauseRender_;
|
||||
private requestID_;
|
||||
constructor(containerElm: any, size: any, options: IViewerOptions);
|
||||
createScene(drawAxes: any, axLen: any): void;
|
||||
createCamera(): void;
|
||||
createControls(canvas: any): void;
|
||||
webGLAvailable(): boolean;
|
||||
createRenderer(bool_noWebGL: any): void;
|
||||
render(): void;
|
||||
animate(): void;
|
||||
cancelAnimate(): void;
|
||||
refreshRenderer(bool_noWebGL: any): void;
|
||||
drawAxes(axLen: any): void;
|
||||
setCsg(csg: any, resetZoom: any): void;
|
||||
applyDrawOptions(): void;
|
||||
clear(): void;
|
||||
getUserMeshes(str?: any): THREE.Object3D[];
|
||||
resetZoom(r: any): void;
|
||||
parseSizeParams(): void;
|
||||
handleResize(): void;
|
||||
}
|
||||
function makeAbsoluteUrl(url: any, baseurl: any): any;
|
||||
function isChrome(): boolean;
|
||||
function runMainInWorker(mainParameters: any): void;
|
||||
function expandResultObjectArray(result: any): any;
|
||||
function checkResult(result: any): void;
|
||||
function resultToCompactBinary(resultin: any): any;
|
||||
function resultFromCompactBinary(resultin: any): any;
|
||||
function parseJsCadScriptSync(script: any, mainParameters: any, debugging: any): any;
|
||||
function parseJsCadScriptASync(script: any, mainParameters: any, options: any, callback: any): Worker;
|
||||
function getWindowURL(): URL;
|
||||
function textToBlobUrl(txt: any): string;
|
||||
function revokeBlobUrl(url: any): void;
|
||||
function FileSystemApiErrorHandler(fileError: any, operation: any): void;
|
||||
function AlertUserOfUncaughtExceptions(): void;
|
||||
function getParamDefinitions(script: any): any[];
|
||||
interface EventHandler {
|
||||
(ev?: Event): any;
|
||||
}
|
||||
/**
|
||||
* options parameter:
|
||||
* - drawLines: display wireframe lines
|
||||
* - drawFaces: display surfaces
|
||||
* - bgColor: canvas background color
|
||||
* - color: object color
|
||||
* - viewerwidth, viewerheight: set rendering size. Works with any css unit.
|
||||
* viewerheight can also be specified as a ratio to width, ie number e (0, 1]
|
||||
* - noWebGL: force render without webGL
|
||||
* - verbose: show additional info (currently only time used for rendering)
|
||||
*/
|
||||
interface ViewerSize {
|
||||
widthDefault: string;
|
||||
heightDefault: string;
|
||||
width: number;
|
||||
height: number;
|
||||
heightratio: number;
|
||||
}
|
||||
class Processor {
|
||||
private containerdiv;
|
||||
private options;
|
||||
private onchange;
|
||||
private static widthDefault;
|
||||
private static heightDefault;
|
||||
private viewerdiv;
|
||||
private viewer;
|
||||
private viewerSize;
|
||||
private processing;
|
||||
private currentObject;
|
||||
private hasValidCurrentObject;
|
||||
private hasOutputFile;
|
||||
private worker;
|
||||
private paramDefinitions;
|
||||
private paramControls;
|
||||
private script;
|
||||
private hasError;
|
||||
private debugging;
|
||||
private errordiv;
|
||||
private errorpre;
|
||||
private statusdiv;
|
||||
private controldiv;
|
||||
private statusspan;
|
||||
private statusbuttons;
|
||||
private abortbutton;
|
||||
private renderedElementDropdown;
|
||||
private formatDropdown;
|
||||
private generateOutputFileButton;
|
||||
private downloadOutputFileLink;
|
||||
private parametersdiv;
|
||||
private parameterstable;
|
||||
private currentFormat;
|
||||
private filename;
|
||||
private currentObjects;
|
||||
private currentObjectIndex;
|
||||
private isFirstRender_;
|
||||
private outputFileDirEntry;
|
||||
private outputFileBlobUrl;
|
||||
constructor(containerdiv: HTMLDivElement, options?: ProcessorOptions, onchange?: EventHandler);
|
||||
static convertToSolid(obj: any): any;
|
||||
cleanOption(option: any, deflt: any): any;
|
||||
toggleDrawOption(str: any): boolean;
|
||||
setDrawOption(str: any, bool: any): void;
|
||||
handleResize(): void;
|
||||
createElements(): void;
|
||||
getFilenameForRenderedObject(): string;
|
||||
setRenderedObjects(obj: any): void;
|
||||
setSelectedObjectIndex(index: number): void;
|
||||
selectedFormat(): any;
|
||||
selectedFormatInfo(): any;
|
||||
updateDownloadLink(): void;
|
||||
clearViewer(): void;
|
||||
abort(): void;
|
||||
enableItems(): void;
|
||||
setOpenJsCadPath(path: string): void;
|
||||
addLibrary(lib: any): void;
|
||||
setError(txt: string): void;
|
||||
setDebugging(debugging: boolean): void;
|
||||
setJsCad(script: string, filename?: string): void;
|
||||
getParamValues(): {};
|
||||
rebuildSolid(): void;
|
||||
hasSolid(): boolean;
|
||||
isProcessing(): boolean;
|
||||
clearOutputFile(): void;
|
||||
generateOutputFile(): void;
|
||||
currentObjectToBlob(): any;
|
||||
supportedFormatsForCurrentObject(): string[];
|
||||
formatInfo(format: any): any;
|
||||
downloadLinkTextForCurrentObject(): string;
|
||||
generateOutputFileBlobUrl(): void;
|
||||
generateOutputFileFileSystem(): void;
|
||||
createParamControls(): void;
|
||||
}
|
||||
}
|
||||
interface Window {
|
||||
Worker: Worker;
|
||||
// URL: URL;
|
||||
webkitURL: URL;
|
||||
requestFileSystem: any;
|
||||
webkitRequestFileSystem: any;
|
||||
}
|
||||
interface IAMFStringOptions {
|
||||
unit: string;
|
||||
}
|
||||
declare class CxG {
|
||||
toStlString(): string;
|
||||
toStlBinary(): void;
|
||||
toAMFString(AMFStringOptions?: IAMFStringOptions): void;
|
||||
getBounds(): CxG[];
|
||||
transform(matrix4x4: CSG.Matrix4x4): CxG;
|
||||
mirrored(plane: CSG.Plane): CxG;
|
||||
mirroredX(): CxG;
|
||||
mirroredY(): CxG;
|
||||
mirroredZ(): CxG;
|
||||
translate(v: number[]): CxG;
|
||||
translate(v: CSG.Vector3D): CxG;
|
||||
scale(f: CSG.Vector3D): CxG;
|
||||
rotateX(deg: number): CxG;
|
||||
rotateY(deg: number): CxG;
|
||||
rotateZ(deg: number): CxG;
|
||||
rotate(rotationCenter: CSG.Vector3D, rotationAxis: CSG.Vector3D, degrees: number): CxG;
|
||||
rotateEulerAngles(alpha: number, beta: number, gamma: number, position: number[]): CxG;
|
||||
}
|
||||
interface ICenter {
|
||||
center(cAxes: string[]): CxG;
|
||||
}
|
||||
declare class CSG extends CxG implements ICenter {
|
||||
polygons: CSG.Polygon[];
|
||||
properties: CSG.Properties;
|
||||
isCanonicalized: boolean;
|
||||
isRetesselated: boolean;
|
||||
cachedBoundingBox: CSG.Vector3D[];
|
||||
static defaultResolution2D: number;
|
||||
static defaultResolution3D: number;
|
||||
static fromPolygons(polygons: CSG.Polygon[]): CSG;
|
||||
static fromSlices(options: any): CSG;
|
||||
static fromObject(obj: any): CSG;
|
||||
static fromCompactBinary(bin: any): CSG;
|
||||
toPolygons(): CSG.Polygon[];
|
||||
union(csg: CSG[]): CSG;
|
||||
union(csg: CSG): CSG;
|
||||
unionSub(csg: CSG, retesselate?: boolean, canonicalize?: boolean): CSG;
|
||||
unionForNonIntersecting(csg: CSG): CSG;
|
||||
subtract(csg: CSG[]): CSG;
|
||||
subtract(csg: CSG): CSG;
|
||||
subtractSub(csg: CSG, retesselate: boolean, canonicalize: boolean): CSG;
|
||||
intersect(csg: CSG[]): CSG;
|
||||
intersect(csg: CSG): CSG;
|
||||
intersectSub(csg: CSG, retesselate?: boolean, canonicalize?: boolean): CSG;
|
||||
invert(): CSG;
|
||||
transform1(matrix4x4: CSG.Matrix4x4): CSG;
|
||||
transform(matrix4x4: CSG.Matrix4x4): CSG;
|
||||
toString(): string;
|
||||
expand(radius: number, resolution: number): CSG;
|
||||
contract(radius: number, resolution: number): CSG;
|
||||
stretchAtPlane(normal: number[], point: number[], length: number): CSG;
|
||||
expandedShell(radius: number, resolution: number, unionWithThis: boolean): CSG;
|
||||
canonicalized(): CSG;
|
||||
reTesselated(): CSG;
|
||||
getBounds(): CSG.Vector3D[];
|
||||
mayOverlap(csg: CSG): boolean;
|
||||
cutByPlane(plane: CSG.Plane): CSG;
|
||||
connectTo(myConnector: CSG.Connector, otherConnector: CSG.Connector, mirror: boolean, normalrotation: number): CSG;
|
||||
setShared(shared: CSG.Polygon.Shared): CSG;
|
||||
setColor(args: any): CSG;
|
||||
toCompactBinary(): {
|
||||
"class": string;
|
||||
numPolygons: number;
|
||||
numVerticesPerPolygon: Uint32Array;
|
||||
polygonPlaneIndexes: Uint32Array;
|
||||
polygonSharedIndexes: Uint32Array;
|
||||
polygonVertices: Uint32Array;
|
||||
vertexData: Float64Array;
|
||||
planeData: Float64Array;
|
||||
shared: CSG.Polygon.Shared[];
|
||||
};
|
||||
toPointCloud(cuberadius: any): CSG;
|
||||
getTransformationAndInverseTransformationToFlatLying(): any;
|
||||
getTransformationToFlatLying(): any;
|
||||
lieFlat(): CSG;
|
||||
projectToOrthoNormalBasis(orthobasis: CSG.OrthoNormalBasis): CAG;
|
||||
sectionCut(orthobasis: CSG.OrthoNormalBasis): CAG;
|
||||
fixTJunctions(): CSG;
|
||||
toTriangles(): any[];
|
||||
getFeatures(features: any): any;
|
||||
center(cAxes: string[]): CxG;
|
||||
toX3D(): Blob;
|
||||
toStlBinary(): Blob;
|
||||
toStlString(): string;
|
||||
toAMFString(m: IAMFStringOptions): Blob;
|
||||
}
|
||||
declare namespace CSG {
|
||||
function fnNumberSort(a: any, b: any): number;
|
||||
function parseOption(options: any, optionname: any, defaultvalue: any): any;
|
||||
function parseOptionAs3DVector(options: any, optionname: any, defaultvalue: any): Vector3D;
|
||||
function parseOptionAs3DVectorList(options: any, optionname: any, defaultvalue: any): any;
|
||||
function parseOptionAs2DVector(options: any, optionname: any, defaultvalue: any): any;
|
||||
function parseOptionAsFloat(options: any, optionname: any, defaultvalue: any): any;
|
||||
function parseOptionAsInt(options: any, optionname: any, defaultvalue: any): any;
|
||||
function parseOptionAsBool(options: any, optionname: any, defaultvalue: any): any;
|
||||
function cube(options: any): CSG;
|
||||
function sphere(options: any): CSG;
|
||||
function cylinder(options: any): CSG;
|
||||
function roundedCylinder(options: any): CSG;
|
||||
function roundedCube(options: any): CSG;
|
||||
/**
|
||||
* polyhedron accepts openscad style arguments. I.e. define face vertices clockwise looking from outside
|
||||
*/
|
||||
function polyhedron(options: any): CSG;
|
||||
function IsFloat(n: any): boolean;
|
||||
function solve2Linear(a: any, b: any, c: any, d: any, u: any, v: any): number[];
|
||||
class Vector3D extends CxG {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
constructor(v3: Vector3D);
|
||||
constructor(v2: Vector2D);
|
||||
constructor(v2: number[]);
|
||||
constructor(x: number, y: number);
|
||||
constructor(x: number, y: number, z: number);
|
||||
static Create(x: number, y: number, z: number): Vector3D;
|
||||
clone(): Vector3D;
|
||||
negated(): Vector3D;
|
||||
abs(): Vector3D;
|
||||
plus(a: Vector3D): Vector3D;
|
||||
minus(a: Vector3D): Vector3D;
|
||||
times(a: number): Vector3D;
|
||||
dividedBy(a: number): Vector3D;
|
||||
dot(a: Vector3D): number;
|
||||
lerp(a: Vector3D, t: number): Vector3D;
|
||||
lengthSquared(): number;
|
||||
length(): number;
|
||||
unit(): Vector3D;
|
||||
cross(a: Vector3D): Vector3D;
|
||||
distanceTo(a: Vector3D): number;
|
||||
distanceToSquared(a: Vector3D): number;
|
||||
equals(a: Vector3D): boolean;
|
||||
multiply4x4(matrix4x4: Matrix4x4): Vector3D;
|
||||
transform(matrix4x4: Matrix4x4): Vector3D;
|
||||
toString(): string;
|
||||
randomNonParallelVector(): Vector3D;
|
||||
min(p: Vector3D): Vector3D;
|
||||
max(p: Vector3D): Vector3D;
|
||||
toStlString(): string;
|
||||
toAMFString(): string;
|
||||
}
|
||||
class Vertex extends CxG {
|
||||
pos: Vector3D;
|
||||
tag: number;
|
||||
constructor(pos: Vector3D);
|
||||
static fromObject(obj: any): Vertex;
|
||||
flipped(): Vertex;
|
||||
getTag(): number;
|
||||
interpolate(other: Vertex, t: number): Vertex;
|
||||
transform(matrix4x4: Matrix4x4): Vertex;
|
||||
toString(): string;
|
||||
toStlString(): string;
|
||||
toAMFString(): string;
|
||||
}
|
||||
class Plane extends CxG {
|
||||
normal: Vector3D;
|
||||
w: number;
|
||||
tag: number;
|
||||
constructor(normal: Vector3D, w: number);
|
||||
static fromObject(obj: any): Plane;
|
||||
static EPSILON: number;
|
||||
static fromVector3Ds(a: Vector3D, b: Vector3D, c: Vector3D): Plane;
|
||||
static anyPlaneFromVector3Ds(a: Vector3D, b: Vector3D, c: Vector3D): Plane;
|
||||
static fromPoints(a: Vector3D, b: Vector3D, c: Vector3D): Plane;
|
||||
static fromNormalAndPoint(normal: Vector3D, point: Vector3D): Plane;
|
||||
static fromNormalAndPoint(normal: number[], point: number[]): Plane;
|
||||
flipped(): Plane;
|
||||
getTag(): number;
|
||||
equals(n: Plane): boolean;
|
||||
transform(matrix4x4: Matrix4x4): Plane;
|
||||
splitPolygon(polygon: Polygon): {
|
||||
type: any;
|
||||
front: any;
|
||||
back: any;
|
||||
};
|
||||
splitLineBetweenPoints(p1: Vector3D, p2: Vector3D): Vector3D;
|
||||
intersectWithLine(line3d: Line3D): Vector3D;
|
||||
intersectWithPlane(plane: Plane): Line3D;
|
||||
signedDistanceToPoint(point: Vector3D): number;
|
||||
toString(): string;
|
||||
mirrorPoint(point3d: Vector3D): Vector3D;
|
||||
}
|
||||
class Polygon extends CxG {
|
||||
vertices: Vertex[];
|
||||
shared: Polygon.Shared;
|
||||
plane: Plane;
|
||||
cachedBoundingSphere: any;
|
||||
cachedBoundingBox: Vector3D[];
|
||||
static defaultShared: CSG.Polygon.Shared;
|
||||
constructor(vertices: Vector3D, shared?: Polygon.Shared, plane?: Plane);
|
||||
constructor(vertices: Vertex[], shared?: Polygon.Shared, plane?: Plane);
|
||||
static fromObject(obj: any): Polygon;
|
||||
checkIfConvex(): void;
|
||||
setColor(args: any): Polygon;
|
||||
getSignedVolume(): number;
|
||||
getArea(): number;
|
||||
getTetraFeatures(features: any): any[];
|
||||
extrude(offsetvector: any): CSG;
|
||||
boundingSphere(): any;
|
||||
boundingBox(): Vector3D[];
|
||||
flipped(): Polygon;
|
||||
transform(matrix4x4: Matrix4x4): Polygon;
|
||||
toString(): string;
|
||||
projectToOrthoNormalBasis(orthobasis: OrthoNormalBasis): CAG;
|
||||
/**
|
||||
* Creates solid from slices (CSG.Polygon) by generating walls
|
||||
* @param {Object} options Solid generating options
|
||||
* - numslices {Number} Number of slices to be generated
|
||||
* - callback(t, slice) {Function} Callback function generating slices.
|
||||
* arguments: t = [0..1], slice = [0..numslices - 1]
|
||||
* return: CSG.Polygon or null to skip
|
||||
* - loop {Boolean} no flats, only walls, it's used to generate solids like a tor
|
||||
*/
|
||||
solidFromSlices(options: any): CSG;
|
||||
/**
|
||||
*
|
||||
* @param walls Array of wall polygons
|
||||
* @param bottom Bottom polygon
|
||||
* @param top Top polygon
|
||||
*/
|
||||
private _addWalls(walls, bottom, top, bFlipped);
|
||||
static verticesConvex(vertices: Vertex[], planenormal: any): boolean;
|
||||
static createFromPoints(points: number[][], shared?: CSG.Polygon.Shared, plane?: Plane): Polygon;
|
||||
static isConvexPoint(prevpoint: any, point: any, nextpoint: any, normal: any): boolean;
|
||||
static isStrictlyConvexPoint(prevpoint: any, point: any, nextpoint: any, normal: any): boolean;
|
||||
toStlString(): string;
|
||||
}
|
||||
}
|
||||
declare namespace CSG.Polygon {
|
||||
class Shared {
|
||||
color: any;
|
||||
tag: any;
|
||||
constructor(color: any);
|
||||
static fromObject(obj: any): Shared;
|
||||
static fromColor(args: any): Shared;
|
||||
getTag(): any;
|
||||
getHash(): any;
|
||||
}
|
||||
}
|
||||
declare namespace CSG {
|
||||
class PolygonTreeNode {
|
||||
parent: any;
|
||||
children: any;
|
||||
polygon: Polygon;
|
||||
removed: boolean;
|
||||
constructor();
|
||||
addPolygons(polygons: any): void;
|
||||
remove(): void;
|
||||
isRemoved(): boolean;
|
||||
isRootNode(): boolean;
|
||||
invert(): void;
|
||||
getPolygon(): Polygon;
|
||||
getPolygons(result: Polygon[]): void;
|
||||
splitByPlane(plane: any, coplanarfrontnodes: any, coplanarbacknodes: any, frontnodes: any, backnodes: any): void;
|
||||
_splitByPlane(plane: any, coplanarfrontnodes: any, coplanarbacknodes: any, frontnodes: any, backnodes: any): void;
|
||||
addChild(polygon: Polygon): PolygonTreeNode;
|
||||
invertSub(): void;
|
||||
recursivelyInvalidatePolygon(): void;
|
||||
}
|
||||
class Tree {
|
||||
polygonTree: PolygonTreeNode;
|
||||
rootnode: Node;
|
||||
constructor(polygons: Polygon[]);
|
||||
invert(): void;
|
||||
clipTo(tree: Tree, alsoRemovecoplanarFront?: boolean): void;
|
||||
allPolygons(): Polygon[];
|
||||
addPolygons(polygons: Polygon[]): void;
|
||||
}
|
||||
class Node {
|
||||
parent: Node;
|
||||
plane: Plane;
|
||||
front: any;
|
||||
back: any;
|
||||
polygontreenodes: PolygonTreeNode[];
|
||||
constructor(parent: Node);
|
||||
invert(): void;
|
||||
clipPolygons(polygontreenodes: PolygonTreeNode[], alsoRemovecoplanarFront: boolean): void;
|
||||
clipTo(tree: Tree, alsoRemovecoplanarFront: boolean): void;
|
||||
addPolygonTreeNodes(polygontreenodes: PolygonTreeNode[]): void;
|
||||
getParentPlaneNormals(normals: Vector3D[], maxdepth: number): void;
|
||||
}
|
||||
class Matrix4x4 {
|
||||
elements: number[];
|
||||
constructor(elements?: number[]);
|
||||
plus(m: Matrix4x4): Matrix4x4;
|
||||
minus(m: Matrix4x4): Matrix4x4;
|
||||
multiply(m: Matrix4x4): Matrix4x4;
|
||||
clone(): Matrix4x4;
|
||||
rightMultiply1x3Vector(v: Vector3D): Vector3D;
|
||||
leftMultiply1x3Vector(v: Vector3D): Vector3D;
|
||||
rightMultiply1x2Vector(v: Vector2D): Vector2D;
|
||||
leftMultiply1x2Vector(v: Vector2D): Vector2D;
|
||||
isMirroring(): boolean;
|
||||
static unity(): Matrix4x4;
|
||||
static rotationX(degrees: number): Matrix4x4;
|
||||
static rotationY(degrees: number): Matrix4x4;
|
||||
static rotationZ(degrees: number): Matrix4x4;
|
||||
static rotation(rotationCenter: CSG.Vector3D, rotationAxis: CSG.Vector3D, degrees: number): Matrix4x4;
|
||||
static translation(v: number[]): Matrix4x4;
|
||||
static translation(v: Vector3D): Matrix4x4;
|
||||
static mirroring(plane: Plane): Matrix4x4;
|
||||
static scaling(v: number[]): Matrix4x4;
|
||||
static scaling(v: Vector3D): Matrix4x4;
|
||||
}
|
||||
class Vector2D extends CxG {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
constructor(x: number[]);
|
||||
constructor(x: Vector2D);
|
||||
static fromAngle(radians: number): Vector2D;
|
||||
static fromAngleDegrees(degrees: number): Vector2D;
|
||||
static fromAngleRadians(radians: number): Vector2D;
|
||||
static Create(x: number, y: number): Vector2D;
|
||||
toVector3D(z: number): Vector3D;
|
||||
equals(a: Vector2D): boolean;
|
||||
clone(): Vector2D;
|
||||
negated(): Vector2D;
|
||||
plus(a: Vector2D): Vector2D;
|
||||
minus(a: Vector2D): Vector2D;
|
||||
times(a: number): Vector2D;
|
||||
dividedBy(a: number): Vector2D;
|
||||
dot(a: Vector2D): number;
|
||||
lerp(a: Vector2D, t: number): Vector2D;
|
||||
length(): number;
|
||||
distanceTo(a: Vector2D): number;
|
||||
distanceToSquared(a: Vector2D): number;
|
||||
lengthSquared(): number;
|
||||
unit(): Vector2D;
|
||||
cross(a: Vector2D): number;
|
||||
normal(): Vector2D;
|
||||
multiply4x4(matrix4x4: Matrix4x4): Vector2D;
|
||||
transform(matrix4x4: Matrix4x4): Vector2D;
|
||||
angle(): number;
|
||||
angleDegrees(): number;
|
||||
angleRadians(): number;
|
||||
min(p: Vector2D): Vector2D;
|
||||
max(p: Vector2D): Vector2D;
|
||||
toString(): string;
|
||||
abs(): Vector2D;
|
||||
}
|
||||
class Line2D extends CxG {
|
||||
normal: Vector2D;
|
||||
w: number;
|
||||
constructor(normal: Vector2D, w: number);
|
||||
static fromPoints(p1: Vector2D, p2: Vector2D): Line2D;
|
||||
reverse(): Line2D;
|
||||
equals(l: Line2D): boolean;
|
||||
origin(): Vector2D;
|
||||
direction(): Vector2D;
|
||||
xAtY(y: number): number;
|
||||
absDistanceToPoint(point: Vector2D): number;
|
||||
intersectWithLine(line2d: Line2D): Vector2D;
|
||||
transform(matrix4x4: Matrix4x4): Line2D;
|
||||
}
|
||||
class Line3D extends CxG {
|
||||
point: Vector3D;
|
||||
direction: Vector3D;
|
||||
constructor(point: Vector3D, direction: Vector3D);
|
||||
static fromPoints(p1: Vector3D, p2: Vector3D): Line3D;
|
||||
static fromPlanes(p1: Plane, p2: Plane): Line3D;
|
||||
intersectWithPlane(plane: Plane): Vector3D;
|
||||
clone(): Line3D;
|
||||
reverse(): Line3D;
|
||||
transform(matrix4x4: Matrix4x4): Line3D;
|
||||
closestPointOnLine(point: Vector3D): Vector3D;
|
||||
distanceToPoint(point: Vector3D): number;
|
||||
equals(line3d: Line3D): boolean;
|
||||
}
|
||||
class OrthoNormalBasis extends CxG {
|
||||
v: Vector3D;
|
||||
u: Vector3D;
|
||||
plane: Plane;
|
||||
planeorigin: Vector3D;
|
||||
constructor(plane: Plane, rightvector?: Vector3D);
|
||||
static GetCartesian(xaxisid: string, yaxisid: string): OrthoNormalBasis;
|
||||
static Z0Plane(): OrthoNormalBasis;
|
||||
getProjectionMatrix(): Matrix4x4;
|
||||
getInverseProjectionMatrix(): Matrix4x4;
|
||||
to2D(vec3: Vector3D): Vector2D;
|
||||
to3D(vec2: Vector2D): Vector3D;
|
||||
line3Dto2D(line3d: Line3D): Line2D;
|
||||
line2Dto3D(line2d: Line2D): Line3D;
|
||||
transform(matrix4x4: Matrix4x4): OrthoNormalBasis;
|
||||
}
|
||||
function interpolateBetween2DPointsForY(point1: Vector2D, point2: Vector2D, y: number): number;
|
||||
function reTesselateCoplanarPolygons(sourcepolygons: CSG.Polygon[], destpolygons: CSG.Polygon[]): void;
|
||||
class fuzzyFactory {
|
||||
multiplier: number;
|
||||
lookuptable: any;
|
||||
constructor(numdimensions: number, tolerance: number);
|
||||
lookupOrCreate(els: any, creatorCallback: any): any;
|
||||
}
|
||||
class fuzzyCSGFactory {
|
||||
vertexfactory: fuzzyFactory;
|
||||
planefactory: fuzzyFactory;
|
||||
polygonsharedfactory: any;
|
||||
constructor();
|
||||
getPolygonShared(sourceshared: Polygon.Shared): Polygon.Shared;
|
||||
getVertex(sourcevertex: Vertex): Vertex;
|
||||
getPlane(sourceplane: Plane): Plane;
|
||||
getPolygon(sourcepolygon: Polygon): Polygon;
|
||||
getCSG(sourcecsg: CSG): CSG;
|
||||
}
|
||||
var staticTag: number;
|
||||
function getTag(): number;
|
||||
class Properties {
|
||||
cube: Properties;
|
||||
center: any;
|
||||
facecenters: any[];
|
||||
roundedCube: Properties;
|
||||
cylinder: Properties;
|
||||
start: any;
|
||||
end: any;
|
||||
facepointH: any;
|
||||
facepointH90: any;
|
||||
sphere: Properties;
|
||||
facepoint: any;
|
||||
roundedCylinder: any;
|
||||
_transform(matrix4x4: Matrix4x4): Properties;
|
||||
_merge(otherproperties: Properties): Properties;
|
||||
static transformObj(source: any, result: any, matrix4x4: Matrix4x4): void;
|
||||
static cloneObj(source: any, result: any): void;
|
||||
static addFrom(result: any, otherproperties: Properties): void;
|
||||
}
|
||||
class Connector extends CxG {
|
||||
point: Vector3D;
|
||||
axisvector: Vector3D;
|
||||
normalvector: Vector3D;
|
||||
constructor(point: number[], axisvector: Vector3D, normalvector: number[]);
|
||||
constructor(point: number[], axisvector: number[], normalvector: number[]);
|
||||
constructor(point: number[], axisvector: number[], normalvector: Vector3D);
|
||||
constructor(point: Vector3D, axisvector: number[], normalvector: Vector3D);
|
||||
constructor(point: Vector3D, axisvector: number[], normalvector: number[]);
|
||||
constructor(point: Vector3D, axisvector: Vector3D, normalvector: Vector3D);
|
||||
normalized(): Connector;
|
||||
transform(matrix4x4: Matrix4x4): Connector;
|
||||
getTransformationTo(other: Connector, mirror: boolean, normalrotation: number): Matrix4x4;
|
||||
axisLine(): Line3D;
|
||||
extend(distance: number): Connector;
|
||||
}
|
||||
class ConnectorList {
|
||||
connectors_: Connector[];
|
||||
closed: boolean;
|
||||
constructor(connectors: Connector[]);
|
||||
static defaultNormal: number[];
|
||||
static fromPath2D(path2D: CSG.Path2D, arg1: any, arg2: any): ConnectorList;
|
||||
static _fromPath2DTangents(path2D: any, start: any, end: any): ConnectorList;
|
||||
static _fromPath2DExplicit(path2D: any, angleIsh: any): ConnectorList;
|
||||
setClosed(bool: boolean): void;
|
||||
appendConnector(conn: Connector): void;
|
||||
followWith(cagish: any): CSG;
|
||||
verify(): void;
|
||||
}
|
||||
interface IRadiusOptions {
|
||||
radius?: number;
|
||||
resolution?: number;
|
||||
}
|
||||
interface ICircleOptions extends IRadiusOptions {
|
||||
center?: Vector2D | number[];
|
||||
}
|
||||
interface IArcOptions extends ICircleOptions {
|
||||
startangle?: number;
|
||||
endangle?: number;
|
||||
maketangent?: boolean;
|
||||
}
|
||||
interface IEllpiticalArcOptions extends IRadiusOptions {
|
||||
clockwise?: boolean;
|
||||
large?: boolean;
|
||||
xaxisrotation?: number;
|
||||
xradius?: number;
|
||||
yradius?: number;
|
||||
}
|
||||
interface IRectangleOptions {
|
||||
center?: Vector2D;
|
||||
corner1?: Vector2D;
|
||||
corner2?: Vector2D;
|
||||
radius?: Vector2D;
|
||||
}
|
||||
interface IRoundRectangleOptions {
|
||||
roundradius: number;
|
||||
resolution?: number;
|
||||
}
|
||||
class Path2D extends CxG {
|
||||
closed: boolean;
|
||||
points: Vector2D[];
|
||||
lastBezierControlPoint: Vector2D;
|
||||
constructor(points: number[], closed?: boolean);
|
||||
constructor(points: Vector2D[], closed?: boolean);
|
||||
static arc(options: IArcOptions): Path2D;
|
||||
concat(otherpath: Path2D): Path2D;
|
||||
appendPoint(point: Vector2D): Path2D;
|
||||
appendPoints(points: Vector2D[]): Path2D;
|
||||
close(): Path2D;
|
||||
rectangularExtrude(width: number, height: number, resolution: number): CSG;
|
||||
expandToCAG(pathradius: number, resolution: number): CAG;
|
||||
innerToCAG(): CAG;
|
||||
transform(matrix4x4: Matrix4x4): Path2D;
|
||||
appendBezier(controlpoints: any, options: any): Path2D;
|
||||
appendArc(endpoint: Vector2D, options: IEllpiticalArcOptions): Path2D;
|
||||
}
|
||||
}
|
||||
declare class CAG extends CxG implements ICenter {
|
||||
sides: CAG.Side[];
|
||||
isCanonicalized: boolean;
|
||||
constructor();
|
||||
static fromSides(sides: CAG.Side[]): CAG;
|
||||
static fromPoints(points: CSG.Vector2D[]): CAG;
|
||||
static fromPointsNoCheck(points: CSG.Vector2D[]): CAG;
|
||||
static fromFakeCSG(csg: CSG): CAG;
|
||||
static linesIntersect(p0start: CSG.Vector2D, p0end: CSG.Vector2D, p1start: CSG.Vector2D, p1end: CSG.Vector2D): boolean;
|
||||
static circle(options: CSG.ICircleOptions): CAG;
|
||||
static rectangle(options: CSG.IRectangleOptions): CAG;
|
||||
static roundedRectangle(options: any): CAG;
|
||||
static fromCompactBinary(bin: any): CAG;
|
||||
toString(): string;
|
||||
_toCSGWall(z0: any, z1: any): CSG;
|
||||
_toVector3DPairs(m: CSG.Matrix4x4): CSG.Vector3D[][];
|
||||
_toPlanePolygons(options: any): CSG.Polygon[];
|
||||
_toWallPolygons(options: any): any[];
|
||||
union(cag: CAG[]): CAG;
|
||||
union(cag: CAG): CAG;
|
||||
subtract(cag: CAG[]): CAG;
|
||||
subtract(cag: CAG): CAG;
|
||||
intersect(cag: CAG[]): CAG;
|
||||
intersect(cag: CAG): CAG;
|
||||
transform(matrix4x4: CSG.Matrix4x4): CAG;
|
||||
area(): number;
|
||||
flipped(): CAG;
|
||||
getBounds(): CSG.Vector2D[];
|
||||
isSelfIntersecting(): boolean;
|
||||
expandedShell(radius: number, resolution: number): CAG;
|
||||
expand(radius: number, resolution: number): CAG;
|
||||
contract(radius: number, resolution: number): CAG;
|
||||
extrudeInOrthonormalBasis(orthonormalbasis: CSG.OrthoNormalBasis, depth: number, options?: any): CSG;
|
||||
extrudeInPlane(axis1: any, axis2: any, depth: any, options: any): CSG;
|
||||
extrude(options: CAG_extrude_options): CSG;
|
||||
rotateExtrude(options: any): CSG;
|
||||
check(): void;
|
||||
canonicalized(): CAG;
|
||||
toCompactBinary(): {
|
||||
'class': string;
|
||||
sideVertexIndices: Uint32Array;
|
||||
vertexData: Float64Array;
|
||||
};
|
||||
getOutlinePaths(): CSG.Path2D[];
|
||||
overCutInsideCorners(cutterradius: any): CAG;
|
||||
center(cAxes: string[]): CxG;
|
||||
toDxf(): Blob;
|
||||
static PathsToDxf(paths: CSG.Path2D[]): Blob;
|
||||
}
|
||||
declare namespace CAG {
|
||||
class Vertex {
|
||||
pos: CSG.Vector2D;
|
||||
tag: number;
|
||||
constructor(pos: CSG.Vector2D);
|
||||
toString(): string;
|
||||
getTag(): number;
|
||||
}
|
||||
class Side extends CxG {
|
||||
vertex0: Vertex;
|
||||
vertex1: Vertex;
|
||||
tag: number;
|
||||
constructor(vertex0: Vertex, vertex1: Vertex);
|
||||
static _fromFakePolygon(polygon: CSG.Polygon): Side;
|
||||
toString(): string;
|
||||
toPolygon3D(z0: any, z1: any): CSG.Polygon;
|
||||
transform(matrix4x4: CSG.Matrix4x4): Side;
|
||||
flipped(): Side;
|
||||
direction(): CSG.Vector2D;
|
||||
getTag(): number;
|
||||
lengthSquared(): number;
|
||||
length(): number;
|
||||
}
|
||||
class fuzzyCAGFactory {
|
||||
vertexfactory: CSG.fuzzyFactory;
|
||||
constructor();
|
||||
getVertex(sourcevertex: Vertex): Vertex;
|
||||
getSide(sourceside: Side): Side;
|
||||
getCAG(sourcecag: CAG): CAG;
|
||||
}
|
||||
}
|
||||
interface CAG_extrude_options {
|
||||
offset?: number[];
|
||||
twistangle?: number;
|
||||
twiststeps?: number;
|
||||
}
|
||||
declare namespace CSG {
|
||||
class Polygon2D extends CAG {
|
||||
constructor(points: Vector2D[]);
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
/// <reference path="PayPal-Cordova-Plugin.d.ts"/>
|
||||
|
||||
var item: PayPalItem;
|
||||
item = new PayPalItem("name", 10, "25.00", "USD");
|
||||
item = new PayPalItem("name", 10, "25.00", "USD", null);
|
||||
item = new PayPalItem("name", 10, "25.00", "USD", "SKU_ID");
|
||||
|
||||
var item_name: string = item.name;
|
||||
var item_quantity: number = item.quantity;
|
||||
var item_price: string = item.price;
|
||||
var item_currency: string = item.currency;
|
||||
var item_sku: string = item.sku;
|
||||
|
||||
|
||||
|
||||
var paymentDetails: PayPalPaymentDetails;
|
||||
paymentDetails = new PayPalPaymentDetails("10.50", "2.50", "1.25");
|
||||
|
||||
var paymentDetails_subtotal: string = paymentDetails.subtotal;
|
||||
var paymentDetails_shipping: string = paymentDetails.shipping;
|
||||
var paymentDetails_tax: string = paymentDetails.tax;
|
||||
|
||||
|
||||
|
||||
var shippingAddress: PayPalShippingAddress;
|
||||
shippingAddress = new PayPalShippingAddress("name", "line1", "line2", "city", "state", "postalCode", "countryCode");
|
||||
|
||||
var shippingAddress_recipientName: string = shippingAddress.recipientName;
|
||||
var shippingAddress_line1: string = shippingAddress.line1;
|
||||
var shippingAddress_line2: string = shippingAddress.line2;
|
||||
var shippingAddress_city: string = shippingAddress.city;
|
||||
var shippingAddress_state: string = shippingAddress.state;
|
||||
var shippingAddress_postalCode: string = shippingAddress.postalCode;
|
||||
var shippingAddress_countryCode: string = shippingAddress.countryCode;
|
||||
|
||||
|
||||
|
||||
var payment: PayPalPayment;
|
||||
payment = new PayPalPayment("10.00", "USD", "description", "Auth");
|
||||
payment = new PayPalPayment("10.00", "USD", "description", "Auth", paymentDetails);
|
||||
|
||||
var payment_amount: string = payment.amount;
|
||||
var payment_currency: string = payment.currency;
|
||||
var payment_shortDescription: string = payment.shortDescription;
|
||||
var payment_intent: string = payment.intent;
|
||||
var payment_details: PayPalPaymentDetails = payment.details;
|
||||
var payment_invoiceNumber: string = payment.invoiceNumber;
|
||||
var payment_custom: string = payment.custom;
|
||||
var payment_softDescriptor: string = payment.softDescriptor;
|
||||
var payment_bnCode: string = payment.bnCode;
|
||||
var payment_items: PayPalItem[] = [item, item, item];
|
||||
var payment_shippingAddress: PayPalShippingAddress = shippingAddress;
|
||||
|
||||
|
||||
|
||||
var configOptions: PayPalConfigurationOptions = {
|
||||
defaultUserEmail: "email",
|
||||
defaultUserPhoneCountryCode: "countryCode",
|
||||
defaultUserPhoneNumber: "phoneNumber",
|
||||
merchantName: "merchantName",
|
||||
merchantPrivacyPolicyURL: "merchantPrivacyPolicyURL",
|
||||
merchantUserAgreementURL: "merchantUserAgreementURL",
|
||||
acceptCreditCards: true,
|
||||
payPalShippingAddressOption: 10,
|
||||
rememberUser: true,
|
||||
languageOrLocale: "languageOrLocal",
|
||||
disableBlurWhenBackgrounding: true,
|
||||
presentingInPopover: true,
|
||||
forceDefaultsInSandbox: true,
|
||||
sandboxUserPassword: "sandboxUserPassword",
|
||||
sandboxUserPin: "sandboxUserPin"
|
||||
};
|
||||
|
||||
|
||||
|
||||
var config: PayPalConfiguration;
|
||||
config = new PayPalConfiguration();
|
||||
config = new PayPalConfiguration(null);
|
||||
config = new PayPalConfiguration(configOptions);
|
||||
|
||||
var config_defaultUserEmail: string = config.defaultUserEmail;
|
||||
var config_defaultUserPhoneCountryCode: string = config.defaultUserPhoneCountryCode;
|
||||
var config_defaultUserPhoneNumber: string = config.defaultUserPhoneNumber;
|
||||
var config_merchantName: string = config.merchantName;
|
||||
var config_merchantPrivacyPolicyURL: string = config.merchantPrivacyPolicyURL;
|
||||
var config_merchantUserAgreementURL: string = config.merchantUserAgreementURL;
|
||||
var config_acceptCreditCards: boolean = config.acceptCreditCards;
|
||||
var config_payPalShippingAddressOption: number = config.payPalShippingAddressOption;
|
||||
var config_rememberUser: boolean = config.rememberUser;
|
||||
var config_languageOrLocale: string = config.languageOrLocale;
|
||||
var config_disableBlurWhenBackgrounding: boolean = config.disableBlurWhenBackgrounding;
|
||||
var config_presentingInPopover: boolean = config.presentingInPopover;
|
||||
var config_forceDefaultsInSandbox: boolean = config.forceDefaultsInSandbox;
|
||||
var config_sandboxUserPasword: string = config.sandboxUserPassword;
|
||||
var config_sandboxUserPin: string = config.sandboxUserPin;
|
||||
|
||||
|
||||
|
||||
var clientIds: PayPalCordovaPlugin.PayPalClientIds = {
|
||||
PayPalEnvironmentProduction: "",
|
||||
PayPalEnvironmentSandbox: ""
|
||||
};
|
||||
|
||||
|
||||
|
||||
var apiModule: PayPalCordovaPlugin.PayPalMobileStatic = PayPalMobile;
|
||||
apiModule.version((result: string) => {});
|
||||
apiModule.init(clientIds, () => {});
|
||||
apiModule.prepareToRender("environment", config, () => {});
|
||||
apiModule.renderSinglePaymentUI(payment, (result: any) => {}, (cancelReason: string) => {});
|
||||
apiModule.applicationCorrelationIDForEnvironment("environment", (applicationCorrelationId: string) => {});
|
||||
apiModule.clientMetadataID((clientMetadataId: string) => {});
|
||||
apiModule.renderFuturePaymentUI((result: any) => {}, (cancelReason: string) => {});
|
||||
apiModule.renderProfileSharingUI(["openid", "profile", "email"], (result: any) => {}, (cancelReason: string) => {});
|
||||
+615
@@ -0,0 +1,615 @@
|
||||
// Type definitions for PayPal-Cordova-Plugin 3.1.10
|
||||
// Project: https://github.com/paypal/PayPal-Cordova-Plugin
|
||||
// Definitions by: Justin Unterreiner <https://github.com/Justin-Credible>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
//#region paypal-mobile-js-helper.js
|
||||
|
||||
/**
|
||||
* The PayPalItem class defines an optional itemization for a payment.
|
||||
*
|
||||
* @see https://developer.paypal.com/docs/api/#item-object for more details.
|
||||
*/
|
||||
declare class PayPalItem {
|
||||
|
||||
/**
|
||||
* @param name Name of the item. 127 characters max.
|
||||
* @param quantity Number of units. 10 characters max.
|
||||
* @param price Unit price for this item 10 characters max.
|
||||
* May be negative for "coupon" etc.
|
||||
* @param currency ISO standard currency code.
|
||||
* @param sku The stock keeping unit for this item. 50 characters max (optional).
|
||||
*/
|
||||
constructor(name: string, quantity: number, price: string, currency: string, sku?: string);
|
||||
|
||||
/**
|
||||
* Name of the item. 127 characters max.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Number of units. 10 characters max.
|
||||
*/
|
||||
quantity: number;
|
||||
|
||||
/**
|
||||
* Unit price for this item 10 characters max.
|
||||
* May be negative for "coupon" etc.
|
||||
*/
|
||||
price: string;
|
||||
|
||||
/**
|
||||
* ISO standard currency code.
|
||||
*/
|
||||
currency: string;
|
||||
|
||||
/**
|
||||
* The stock keeping unit for this item. 50 characters max (optional).
|
||||
*/
|
||||
sku: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The PayPalPaymentDetails class defines optional amount details.
|
||||
*
|
||||
* @see https://developer.paypal.com/webapps/developer/docs/api/#details-object for more details.
|
||||
*/
|
||||
declare class PayPalPaymentDetails {
|
||||
|
||||
/**
|
||||
* @param subtotal Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||
* @param shipping Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
||||
* @param tax Amount charged for tax. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
constructor(subtotal: string, shipping: string, tax: string);
|
||||
|
||||
/**
|
||||
* Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
subtotal: string;
|
||||
|
||||
/**
|
||||
* Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
shipping: string;
|
||||
|
||||
/**
|
||||
* Amount charged for tax. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
tax: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor. Returns a PayPalPayment with the specified amount, currency code, and short description.
|
||||
*/
|
||||
declare class PayPalPayment {
|
||||
|
||||
/**
|
||||
* @param amount The amount of the payment.
|
||||
* @param currencyCode The ISO 4217 currency for the payment.
|
||||
* @param shortDescription A short descripton of the payment.
|
||||
* @param intent • "Sale" for an immediate payment.
|
||||
* • "Auth" for payment authorization only, to be captured separately at a later time.
|
||||
* • "Order" for taking an order, with authorization and capture to be done separately at a later time.
|
||||
* @param details PayPalPaymentDetails object (optional).
|
||||
*/
|
||||
constructor(amount: string, currency: string, shortDescription: string, intent: string, details?: PayPalPaymentDetails);
|
||||
|
||||
/**
|
||||
* The amount of the payment.
|
||||
*/
|
||||
amount: string;
|
||||
|
||||
/**
|
||||
* The ISO 4217 currency for the payment.
|
||||
*/
|
||||
currency: string;
|
||||
|
||||
/**
|
||||
* A short descripton of the payment.
|
||||
*/
|
||||
shortDescription: string;
|
||||
|
||||
/**
|
||||
* • "Sale" for an immediate payment.
|
||||
* • "Auth" for payment authorization only, to be captured separately at a later time.
|
||||
* • "Order" for taking an order, with authorization and capture to be done separately at a later time.
|
||||
*/
|
||||
intent: string;
|
||||
|
||||
/**
|
||||
* PayPalPaymentDetails object (optional).
|
||||
*/
|
||||
details: PayPalPaymentDetails;
|
||||
|
||||
/**
|
||||
* Optional invoice number, for your tracking purposes. (up to 256 characters).
|
||||
*/
|
||||
invoiceNumber: string;
|
||||
|
||||
/**
|
||||
* Optional text, for your tracking purposes. (up to 256 characters).
|
||||
*/
|
||||
custom: string;
|
||||
|
||||
/**
|
||||
* Optional text which will appear on the customer's credit card statement. (up to 22 characters).
|
||||
*/
|
||||
softDescriptor: string;
|
||||
|
||||
/**
|
||||
* Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com, for your tracking purposes.
|
||||
*/
|
||||
bnCode: string;
|
||||
|
||||
/**
|
||||
* Optional array of PayPalItem objects.
|
||||
* @see PayPalItem
|
||||
* @note If you provide one or more items, be sure that the various prices correctly sum to the payment `amount` or to `paymentDetails.subtotal`.
|
||||
*/
|
||||
items: PayPalItem[];
|
||||
|
||||
/**
|
||||
* Optional customer shipping address, if your app wishes to provide this to the SDK.
|
||||
* @note make sure to set `payPalShippingAddressOption` in PayPalConfiguration to 1 or 3.
|
||||
*/
|
||||
shippingAddress: PayPalShippingAddress;
|
||||
}
|
||||
|
||||
declare class PayPalShippingAddress {
|
||||
|
||||
/**
|
||||
* @param recipientName Name of the recipient at this address. 50 characters max.
|
||||
* @param line1 Line 1 of the address (e.g., Number, street, etc). 100 characters max.
|
||||
* @param line2 Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
|
||||
* @param city City name. 50 characters max.
|
||||
* @param state 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
|
||||
* @param postalCode ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
||||
* @param countryCode 2-letter country code. 2 characters max.
|
||||
*/
|
||||
constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string);
|
||||
|
||||
/**
|
||||
* Name of the recipient at this address. 50 characters max.
|
||||
*/
|
||||
recipientName: string;
|
||||
|
||||
/**
|
||||
* Line 1 of the address (e.g., Number, street, etc). 100 characters max.
|
||||
*/
|
||||
line1: string;
|
||||
|
||||
/**
|
||||
* Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
|
||||
*/
|
||||
line2: string;
|
||||
|
||||
/**
|
||||
* City name. 50 characters max.
|
||||
*/
|
||||
city: string;
|
||||
|
||||
/**
|
||||
* 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
|
||||
*/
|
||||
state: string;
|
||||
|
||||
/**
|
||||
* ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
||||
*/
|
||||
postalCode: string;
|
||||
|
||||
/**
|
||||
* 2-letter country code. 2 characters max.
|
||||
*/
|
||||
countryCode: string;
|
||||
}
|
||||
|
||||
declare class PayPalConfiguration {
|
||||
|
||||
/**
|
||||
* @param options A set of options to use. Any options not specified will assume default values.
|
||||
*/
|
||||
constructor(options?: PayPalConfigurationOptions);
|
||||
|
||||
/**
|
||||
* Will be overridden by email used in most recent PayPal login.
|
||||
*/
|
||||
defaultUserEmail: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone country code used in most recent PayPal login
|
||||
*/
|
||||
defaultUserPhoneCountryCode: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone number used in most recent PayPal login.
|
||||
* @note If you set defaultUserPhoneNumber, be sure to also set defaultUserPhoneCountryCode.
|
||||
*/
|
||||
defaultUserPhoneNumber: string;
|
||||
|
||||
/**
|
||||
* Your company name, as it should be displayed to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantName: string;
|
||||
|
||||
/**
|
||||
* URL of your company's privacy policy, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantPrivacyPolicyURL: string;
|
||||
|
||||
/**
|
||||
* URL of your company's user agreement, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantUserAgreementURL: string;
|
||||
|
||||
/**
|
||||
* If set to false, the SDK will only support paying with PayPal, not with credit cards.
|
||||
* This applies only to single payments (via PayPalPaymentViewController).
|
||||
* Future payments (via PayPalFuturePaymentViewController) always use PayPal.
|
||||
* Defaults to true.
|
||||
*/
|
||||
acceptCreditCards: boolean;
|
||||
|
||||
/**
|
||||
* For single payments, options for the shipping address.
|
||||
*
|
||||
* - 0 - PayPalShippingAddressOptionNone: no shipping address applies.
|
||||
*
|
||||
* - 1 - PayPalShippingAddressOptionProvided: shipping address will be provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment.
|
||||
*
|
||||
* - 2 - PayPalShippingAddressOptionPayPal: user will choose from shipping addresses on file
|
||||
* for their PayPal account.
|
||||
*
|
||||
* - 3 - PayPalShippingAddressOptionBoth: user will choose from the shipping address provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account.
|
||||
*
|
||||
* Defaults to 0 (PayPalShippingAddressOptionNone).
|
||||
*/
|
||||
payPalShippingAddressOption: number;
|
||||
|
||||
/**
|
||||
* If set to true, then if the user pays via their PayPal account,
|
||||
* the SDK will remember the user's PayPal username or phone number;
|
||||
* if the user pays via their credit card, then the SDK will remember
|
||||
* the PayPal Vault token representing the user's credit card.
|
||||
*
|
||||
* If set to false, then any previously-remembered username, phone number, or
|
||||
* credit card token will be erased, and subsequent payment information will
|
||||
* not be remembered.
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
rememberUser: boolean;
|
||||
|
||||
/**
|
||||
* If not set, or if set to nil, defaults to the device's current language setting.
|
||||
*
|
||||
* Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.).
|
||||
* If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es".
|
||||
* If the library does not contain localized strings for a specified language, then will fall back to American English.
|
||||
*
|
||||
* If you specify only a language code, and that code matches the device's currently preferred language,
|
||||
* then the library will attempt to use the device's current region as well.
|
||||
* E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
|
||||
*
|
||||
* These localizations are currently included:
|
||||
* da,de,en,en_AU,en_GB,en_SV,es,es_MX,fr,he,it,ja,ko,nb,nl,pl,pt,pt_BR,ru,sv,tr,zh-Hans,zh-Hant_HK,zh-Hant_TW.
|
||||
*/
|
||||
languageOrLocale: string;
|
||||
|
||||
/**
|
||||
* Normally, the SDK blurs the screen when the app is backgrounded,
|
||||
* to obscure credit card or PayPal account details in the iOS-saved screenshot.
|
||||
* If your app already does its own blurring upon backgrounding, you might choose to disable this.
|
||||
* Defaults to false.
|
||||
*/
|
||||
disableBlurWhenBackgrounding: boolean;
|
||||
|
||||
/**
|
||||
* If you will present the SDK's view controller within a popover, then set this property to true.
|
||||
* Defaults to false. (iOS only)
|
||||
*/
|
||||
presentingInPopover: boolean;
|
||||
|
||||
/**
|
||||
* Sandbox credentials can be difficult to type on a mobile device. Setting this flag to true will
|
||||
* cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields.
|
||||
*
|
||||
* This setting will have no effect if the operation mode is production.
|
||||
* Defaults to false.
|
||||
*/
|
||||
forceDefaultsInSandbox: boolean;
|
||||
|
||||
/**
|
||||
* Password to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPassword: string;
|
||||
|
||||
/**
|
||||
* PIN to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPin: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the options that can be passed into the PayPalConfiguration class constructor.
|
||||
*/
|
||||
interface PayPalConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Will be overridden by email used in most recent PayPal login.
|
||||
*/
|
||||
defaultUserEmail?: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone country code used in most recent PayPal login
|
||||
*/
|
||||
defaultUserPhoneCountryCode?: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone number used in most recent PayPal login.
|
||||
* @note If you set defaultUserPhoneNumber, be sure to also set defaultUserPhoneCountryCode.
|
||||
*/
|
||||
defaultUserPhoneNumber?: string;
|
||||
|
||||
/**
|
||||
* Your company name, as it should be displayed to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantName?: string;
|
||||
|
||||
/**
|
||||
* URL of your company's privacy policy, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantPrivacyPolicyURL?: string;
|
||||
|
||||
/**
|
||||
* URL of your company's user agreement, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantUserAgreementURL?: string;
|
||||
|
||||
/**
|
||||
* If set to false, the SDK will only support paying with PayPal, not with credit cards.
|
||||
* This applies only to single payments (via PayPalPaymentViewController).
|
||||
* Future payments (via PayPalFuturePaymentViewController) always use PayPal.
|
||||
* Defaults to true.
|
||||
*/
|
||||
acceptCreditCards?: boolean;
|
||||
|
||||
/**
|
||||
* For single payments, options for the shipping address.
|
||||
*
|
||||
* - 0 - PayPalShippingAddressOptionNone?: no shipping address applies.
|
||||
*
|
||||
* - 1 - PayPalShippingAddressOptionProvided?: shipping address will be provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment.
|
||||
*
|
||||
* - 2 - PayPalShippingAddressOptionPayPal?: user will choose from shipping addresses on file
|
||||
* for their PayPal account.
|
||||
*
|
||||
* - 3 - PayPalShippingAddressOptionBoth?: user will choose from the shipping address provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account.
|
||||
*
|
||||
* Defaults to 0 (PayPalShippingAddressOptionNone).
|
||||
*/
|
||||
payPalShippingAddressOption?: number;
|
||||
|
||||
/**
|
||||
* If set to true, then if the user pays via their PayPal account,
|
||||
* the SDK will remember the user's PayPal username or phone number;
|
||||
* if the user pays via their credit card, then the SDK will remember
|
||||
* the PayPal Vault token representing the user's credit card.
|
||||
*
|
||||
* If set to false, then any previously-remembered username, phone number, or
|
||||
* credit card token will be erased, and subsequent payment information will
|
||||
* not be remembered.
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
rememberUser?: boolean;
|
||||
|
||||
/**
|
||||
* If not set, or if set to nil, defaults to the device's current language setting.
|
||||
*
|
||||
* Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.).
|
||||
* If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es".
|
||||
* If the library does not contain localized strings for a specified language, then will fall back to American English.
|
||||
*
|
||||
* If you specify only a language code, and that code matches the device's currently preferred language,
|
||||
* then the library will attempt to use the device's current region as well.
|
||||
* E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
|
||||
*
|
||||
* These localizations are currently included:
|
||||
* da,de,en,en_AU,en_GB,en_SV,es,es_MX,fr,he,it,ja,ko,nb,nl,pl,pt,pt_BR,ru,sv,tr,zh-Hans,zh-Hant_HK,zh-Hant_TW.
|
||||
*/
|
||||
languageOrLocale?: string;
|
||||
|
||||
/**
|
||||
* Normally, the SDK blurs the screen when the app is backgrounded,
|
||||
* to obscure credit card or PayPal account details in the iOS-saved screenshot.
|
||||
* If your app already does its own blurring upon backgrounding, you might choose to disable this.
|
||||
* Defaults to false.
|
||||
*/
|
||||
disableBlurWhenBackgrounding?: boolean;
|
||||
|
||||
/**
|
||||
* If you will present the SDK's view controller within a popover, then set this property to true.
|
||||
* Defaults to false. (iOS only)
|
||||
*/
|
||||
presentingInPopover?: boolean;
|
||||
|
||||
/**
|
||||
* Sandbox credentials can be difficult to type on a mobile device. Setting this flag to true will
|
||||
* cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields.
|
||||
*
|
||||
* This setting will have no effect if the operation mode is production.
|
||||
* Defaults to false.
|
||||
*/
|
||||
forceDefaultsInSandbox?: boolean;
|
||||
|
||||
/**
|
||||
* Password to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPassword?: string;
|
||||
|
||||
/**
|
||||
* PIN to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPin?: string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region cdv-plugin-paypal-mobile-sdk.js
|
||||
|
||||
declare namespace PayPalCordovaPlugin {
|
||||
|
||||
export interface PayPalClientIds {
|
||||
PayPalEnvironmentProduction: string;
|
||||
PayPalEnvironmentSandbox: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the portion of an object that is common to all responses.
|
||||
*/
|
||||
export interface BaseResult {
|
||||
client: Client;
|
||||
response_type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the client portion of the response.
|
||||
*/
|
||||
export interface Client {
|
||||
paypal_sdk_version: string;
|
||||
environment: string;
|
||||
platform: string;
|
||||
product_name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the response for a successful callback from renderSinglePaymentUI().
|
||||
*/
|
||||
export interface SinglePaymentResult extends BaseResult {
|
||||
response: {
|
||||
intent: string;
|
||||
id: string;
|
||||
state: string;
|
||||
authorization_id: string;
|
||||
create_time: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the response for a successful callback from renderFuturePaymentUI().
|
||||
*/
|
||||
export interface FuturePaymentResult extends BaseResult {
|
||||
response: {
|
||||
code: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PayPalMobileStatic {
|
||||
/**
|
||||
* Retrieve the version of the PayPal iOS SDK library. Useful when contacting support.
|
||||
*
|
||||
* @param completionCallback a callback function accepting a string
|
||||
*/
|
||||
version(completionCallback: (result: string) => void): void;
|
||||
|
||||
/**
|
||||
* You MUST call this method to initialize the PayPal Mobile SDK.
|
||||
*
|
||||
* The PayPal Mobile SDK can operate in different environments to facilitate development and testing.
|
||||
*
|
||||
* @param clientIdsForEnvironments set of client ids for environments
|
||||
* Example: var clientIdsForEnvironments = {
|
||||
* PayPalEnvironmentProduction : @"my-client-id-for-Production",
|
||||
* PayPalEnvironmentSandbox : @"my-client-id-for-Sandbox"
|
||||
* }
|
||||
* @param completionCallback a callback function on success
|
||||
*/
|
||||
init(clientIdsForEnvironments: PayPalCordovaPlugin.PayPalClientIds, completionCallback: () => void): void;
|
||||
|
||||
/**
|
||||
* You must preconnect to PayPal to prepare the device for processing payments.
|
||||
* This improves the user experience, by making the presentation of the
|
||||
* UI faster. The preconnect is valid for a limited time, so
|
||||
* the recommended time to preconnect is on page load.
|
||||
*
|
||||
* @param environment available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
|
||||
* @param configuration PayPalConfiguration object, for Future Payments merchantName, merchantPrivacyPolicyURL
|
||||
* and merchantUserAgreementURL must be set be set
|
||||
* @param completionCallback a callback function on success
|
||||
*/
|
||||
prepareToRender(environment: string, configuration: PayPalConfiguration, completionCallback: () => void): void;
|
||||
|
||||
/**
|
||||
* Start PayPal UI to collect payment from the user.
|
||||
* See https://developer.paypal.com/webapps/developer/docs/integration/mobile/ios-integration-guide/
|
||||
* for more documentation of the params.
|
||||
*
|
||||
* @param payment PayPalPayment object
|
||||
* @param completionCallback a callback function accepting a js object, called when the user has completed payment
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user cancels the payment
|
||||
*/
|
||||
renderSinglePaymentUI(payment: PayPalPayment, completionCallback: (result: PayPalCordovaPlugin.SinglePaymentResult) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Once a user has consented to future payments, when the user subsequently initiates a PayPal payment
|
||||
* from their device to be completed by your server, PayPal uses a Correlation ID to verify that the
|
||||
* payment is originating from a valid, user-consented device+application.
|
||||
* This helps reduce fraud and decrease declines.
|
||||
* This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device.
|
||||
* Pass the result to your server, to include in the payment request sent to PayPal.
|
||||
* Do not otherwise cache or store this value.
|
||||
*
|
||||
* @param environment available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
|
||||
* @param callback applicationCorrelationID Your server will send this to PayPal in a 'Paypal-Application-Correlation-Id' header.
|
||||
*/
|
||||
applicationCorrelationIDForEnvironment(environment: string, completionCallback: (applicationCorrelationId: string) => void): void;
|
||||
|
||||
/**
|
||||
* Once a user has consented to future payments, when the user subsequently initiates a PayPal payment
|
||||
* from their device to be completed by your server, PayPal uses a Correlation ID to verify that the
|
||||
* payment is originating from a valid, user-consented device+application.
|
||||
* This helps reduce fraud and decrease declines.
|
||||
* This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device.
|
||||
* Pass the result to your server, to include in the payment request sent to PayPal.
|
||||
* Do not otherwise cache or store this value.
|
||||
*
|
||||
* @param callback clientMetadataID Your server will send this to PayPal in a 'PayPal-Client-Metadata-Id' header.
|
||||
*/
|
||||
clientMetadataID(completionCallback: (clientMetadataId: string) => void): void;
|
||||
|
||||
/**
|
||||
* Please Read Docs on Future Payments at https://github.com/paypal/PayPal-iOS-SDK#future-payments
|
||||
*
|
||||
* @param completionCallback a callback function accepting a js object with future payment authorization
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user canceled without agreement
|
||||
*/
|
||||
renderFuturePaymentUI(completionCallback: (result: PayPalCordovaPlugin.FuturePaymentResult) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
|
||||
/**
|
||||
* Please Read Docs on Profile Sharing at https://github.com/paypal/PayPal-iOS-SDK#profile-sharing
|
||||
*
|
||||
* @param scopes scopes Set of requested scope-values. Accepted scopes are: openid, profile, address, email, phone, futurepayments and paypalattributes
|
||||
* See https://developer.paypal.com/docs/integration/direct/identity/attributes/ for more details
|
||||
* @param completionCallback a callback function accepting a js object with future payment authorization
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user canceled without agreement
|
||||
*/
|
||||
renderProfileSharingUI(scopes: string[], completionCallback: (result: any) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var PayPalMobile: PayPalCordovaPlugin.PayPalMobileStatic;
|
||||
|
||||
//#endregion
|
||||
@@ -1,38 +1,225 @@
|
||||
# DefinitelyTyped [](https://travis-ci.org/borisyankov/DefinitelyTyped)
|
||||
# DefinitelyTyped [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
|
||||
|
||||
[](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
> The repository for *high quality* TypeScript type definitions.
|
||||
|
||||
For more information see the [definitelytyped.org](http://definitelytyped.org) website.
|
||||
Also see the [definitelytyped.org](http://definitelytyped.org) website, although information in this README is more up-to-date.
|
||||
|
||||
## Usage
|
||||
|
||||
Include a line like this:
|
||||
## What are declaration files?
|
||||
|
||||
```typescript
|
||||
/// <reference path="jquery.d.ts" />
|
||||
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
|
||||
|
||||
|
||||
## How do I get them?
|
||||
|
||||
### npm
|
||||
|
||||
This is the preferred method. This is only available for TypeScript 2.0+ users. For example:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @types/node
|
||||
```
|
||||
|
||||
## Contributions
|
||||
The types should then be automatically included by the compiler.
|
||||
See more in the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html).
|
||||
|
||||
DefinitelyTyped only works because of contributions by users like you!
|
||||
For an NPM package "foo", typings for it will be at "@types/foo".
|
||||
If you can't find your package, look for it on [TypeSearch](https://microsoft.github.io/TypeSearch/).
|
||||
|
||||
Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) on how to contribute to DefinitelyTyped.
|
||||
If you still can't find it, check if it [bundles](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) its own typings.
|
||||
This is usually provided in a `"types"` or `"typings"` field in the `package.json`,
|
||||
or just look for any ".d.ts" files in the package and manually include them with a `/// <reference path="" />`.
|
||||
|
||||
## How to get the definitions
|
||||
|
||||
* Directly from the Github repos
|
||||
* [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped)
|
||||
* [TypeScript Definition manager](https://github.com/DefinitelyTyped/tsd)
|
||||
### Other methods
|
||||
|
||||
## List of definitions
|
||||
These can be used by TypeScript 1.0.
|
||||
|
||||
* See [CONTRIBUTORS.md](CONTRIBUTORS.md)
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* [NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)
|
||||
* Manually download from the `master` branch of this repository
|
||||
|
||||
## Requested definitions
|
||||
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
|
||||
Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest).
|
||||
|
||||
## Licence
|
||||
## How can I contribute?
|
||||
|
||||
DefinitelyTyped only works because of contributions by users like you!
|
||||
|
||||
### Test
|
||||
|
||||
Before you share your improvement with the world, use it yourself.
|
||||
|
||||
#### Test editing an exiting package
|
||||
|
||||
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html).
|
||||
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`,
|
||||
or copy them from there and paste inside of `declarations.d.ts` and follow the steps below.
|
||||
|
||||
|
||||
#### Test a new package
|
||||
|
||||
* Add a new file `declarations.d.ts` to your project.
|
||||
* Add it to the compilation, through `"includes"` or `"files"` in your [tsconfig](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html),
|
||||
or through a `/// <reference path="" />` declaration in your code.
|
||||
* Inside `declarations.d.ts`, write `declare module "foo" { }`, then write the module declaration inside.
|
||||
* Test that your code works.
|
||||
* *Then*, once you've tested your definitions, make a PR contributing the definition.
|
||||
|
||||
|
||||
### Make a pull request
|
||||
|
||||
Once you've tested your package, you can share it on DefinitelyTyped.
|
||||
|
||||
First, [fork](https://guides.github.com/activities/forking/) this repository.
|
||||
Then inside your repository:
|
||||
|
||||
* `git checkout types-2.0`
|
||||
|
||||
New work should generally be done on the `types-2.0` branch.
|
||||
If you want your changes to be available to `typings` users, then you may edit `master` instead.
|
||||
|
||||
|
||||
#### Edit an existing package
|
||||
|
||||
* `cd my-package-to-edit`
|
||||
* Make changes. Remember to edit tests.
|
||||
* You may also want to add yourself to "Definitions by" section of the package header.
|
||||
* `npm install -g typescript@2.0` and run `tsc`.
|
||||
|
||||
When you make a PR to edit an existing package, `dt-bot` should @-mention previous authors.
|
||||
If it doesn't, you can do so yourself in the comment associated with the PR.
|
||||
|
||||
|
||||
#### Create a new package
|
||||
|
||||
If you are the library author, or can make a pull request to the library, [bundle](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) types instead of publishing to DefinitelyTyped.
|
||||
|
||||
If you are adding typings for an NPM package, create a directory with the same name.
|
||||
If the package you are adding typings for is not on NPM, make sure the name you choose for it does not conflict with the name of a package on NPM.
|
||||
(You can use `npm info foo` to check for the existence of the `foo` package.)
|
||||
|
||||
Your package should have this structure:
|
||||
|
||||
| File | Purpose |
|
||||
| --- | --- |
|
||||
| index.d.ts | This contains the typings for the package. |
|
||||
| foo-tests.ts | This contains sample code which tests the typings. This code does *not* run, but it is type-checked. |
|
||||
| tsconfig.json | This allows you to run `tsc` within the package. |
|
||||
|
||||
`index.d.ts` should start with a header looking like:
|
||||
|
||||
```ts
|
||||
// Type definitions for foo 1.2
|
||||
// Project: https://github.com/baz/foo
|
||||
// Definitions by: My Self <https://github.com/me>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
```
|
||||
|
||||
The `Project` link does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.
|
||||
|
||||
`tsconfig.json` should look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"foo-tests.ts"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
These should be identical accross projects except that `foo-tests` will be replaced with the name of your test file,
|
||||
and you may also add the `"jsx"` compiler option if your library needs it.
|
||||
|
||||
DefinitelyTyped members routinely monitor for new PRs, though keep in mind that the number of other PRs may slow things down.
|
||||
|
||||
|
||||
#### Common mistakes
|
||||
|
||||
* First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html).
|
||||
* Formatting: Either use all tabs, or always use 4 spaces. Also, always use semicolons, and use egyptian braces.
|
||||
* `interface X {}`: An empty interface is essentially the `{}` type: it places no constraints on an object.
|
||||
* `interface Foo { new(): Foo }`:
|
||||
This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }
|
||||
* `namespace foo {}`:
|
||||
Do not add a namespace just so that the `import * as foo` syntax will work.
|
||||
If it is commonJs module with a single export, you should use the `import foo = require("foo")` syntax.
|
||||
See more explanation [here](https://stackoverflow.com/questions/39415661/why-cant-i-import-a-class-or-function-with-import-as-x-from-y).
|
||||
* `getMeAT<T>(): T`:
|
||||
If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion.
|
||||
Prefer to use a real type assertion, e.g. `getMeAT() as number`.
|
||||
Example where a type parameter is acceptable: `function id<T>(value: T): T;`.
|
||||
Example where it is not acceptable: `function parseJson<T>(json: string): T;`.
|
||||
Exception: `new Map<string, number>()` is OK.
|
||||
|
||||
|
||||
#### Removing a package
|
||||
|
||||
When a package [bundles](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) its own types, types should be removed from DefinitelyTyped to avoid confusion.
|
||||
Make a PR doing the following:
|
||||
* Delete the directory.
|
||||
* Add a new entry to `notNeededPackages.json`.
|
||||
- `libraryName`: Descriptive name of the library, e.g. "Angular 2" instead of "angular2". (May be identical to "typingsPackageName".)
|
||||
- `typingsPackageName`: This is the name of the directory you just deleted.
|
||||
- `sourceRepoURL`: This should point to the repository that contains the typings.
|
||||
- `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version.
|
||||
* Any other packages in DefinitelyTyped that referenced the deleted package should be updated to reference the bundled types.
|
||||
To do this, add a `package.json` with `"dependencies": { "foo": "x.y.z" }`.
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
#### What exactly is the relationship between this repository and the `@types` packages on NPM?
|
||||
|
||||
The `types-2.0` branch is automatically published to the `@types` scope on NPM thanks to [types-publisher](https://github.com/Microsoft/types-publisher).
|
||||
This usually happens within an hour of changes being merged.
|
||||
|
||||
Changes to the `master` branch are also manually merged into the `types-2.0` branch, but this takes longer.
|
||||
|
||||
#### I'm writing a definition that depends on another definition. Should I use `<reference types="" />` or an import?
|
||||
|
||||
If the module you're referencing is an written as an external module (uses `export`), use an import.
|
||||
If the module you're referenceing is an ambient module (uses `declare module`, or just declares globals), use `<reference types="" />`.
|
||||
|
||||
#### What do I do about older versions of typings?
|
||||
|
||||
Currently we don't support this, though it is [planned](https://github.com/Microsoft/types-publisher/issues/3).
|
||||
If you're adding a new major version of a library, you can copy `index.d.ts` to `foo-v2.3.d.ts` and edit `index.d.ts` to be the new version.
|
||||
|
||||
#### I notice some packages having a `package.json` here.
|
||||
|
||||
Usually you won't need this. When publishing a package we will normally automatically create a `package.json` for it.
|
||||
A `package.json` may be included for the sake of specifying dependencies. Here's an [example](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/types-2.0/pikaday/package.json).
|
||||
We do not allow other fields, such as `"description"`, to be defined manually.
|
||||
Also, if you need to reference an older version of typings, you must do that by adding `"dependencies": { "@types/foo": "x.y.z" }` to the package.json.
|
||||
|
||||
#### Definitions in types-2.0 seem written differently than in master.
|
||||
|
||||
If you're targeting types-2.0, write it like the types-2.0 definitions.
|
||||
If you're targeting master, we may change it to the new style when merging from master to types-2.0.
|
||||
|
||||
#### Can I request a definition?
|
||||
|
||||
Here are the [currently requested definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/labels/Definition%3ARequest).
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="_debugger.d.ts"/>
|
||||
import _debugger = require("_debugger");
|
||||
var {Client} = _debugger;
|
||||
|
||||
var client = new Client();
|
||||
|
||||
client.connect(8888, 'localhost');
|
||||
client.listbreakpoints((err, res) => {
|
||||
|
||||
});
|
||||
Vendored
+135
@@ -0,0 +1,135 @@
|
||||
// Type definitions for Node.js debugger API
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Basarat Ali Syed <https://github.com/basarat>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare namespace NodeJS {
|
||||
export module _debugger {
|
||||
export interface Packet {
|
||||
raw: string;
|
||||
headers: string[];
|
||||
body: Message;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
seq: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RequestInfo {
|
||||
command: string;
|
||||
arguments: any;
|
||||
}
|
||||
|
||||
export interface Request extends Message, RequestInfo {
|
||||
}
|
||||
|
||||
export interface Event extends Message {
|
||||
event: string;
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface Response extends Message {
|
||||
request_seq: number;
|
||||
success: boolean;
|
||||
/** Contains error message if success === false. */
|
||||
message?: string;
|
||||
/** Contains message body if success === true. */
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface BreakpointMessageBody {
|
||||
type: string;
|
||||
target: number;
|
||||
line: number;
|
||||
}
|
||||
|
||||
export class Protocol {
|
||||
res: Packet;
|
||||
state: string;
|
||||
execute(data: string): void;
|
||||
serialize(rq: Request): string;
|
||||
onResponse: (pkt: Packet) => void;
|
||||
}
|
||||
|
||||
export var NO_FRAME: number;
|
||||
export var port: number;
|
||||
|
||||
export interface ScriptDesc {
|
||||
name: string;
|
||||
id: number;
|
||||
isNative?: boolean;
|
||||
handle?: number;
|
||||
type: string;
|
||||
lineOffset?: number;
|
||||
columnOffset?: number;
|
||||
lineCount?: number;
|
||||
}
|
||||
|
||||
export interface Breakpoint {
|
||||
id: number;
|
||||
scriptId: number;
|
||||
script: ScriptDesc;
|
||||
line: number;
|
||||
condition?: string;
|
||||
scriptReq?: string;
|
||||
}
|
||||
|
||||
export interface RequestHandler {
|
||||
(err: boolean, body: Message, res: Packet): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ResponseBodyHandler {
|
||||
(err: boolean, body?: any): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ExceptionInfo {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface BreakResponse {
|
||||
script?: ScriptDesc;
|
||||
exception?: ExceptionInfo;
|
||||
sourceLine: number;
|
||||
sourceLineText: string;
|
||||
sourceColumn: number;
|
||||
}
|
||||
|
||||
export function SourceInfo(body: BreakResponse): string;
|
||||
|
||||
export interface ClientInstance extends EventEmitter {
|
||||
protocol: Protocol;
|
||||
scripts: ScriptDesc[];
|
||||
handles: ScriptDesc[];
|
||||
breakpoints: Breakpoint[];
|
||||
currentSourceLine: number;
|
||||
currentSourceColumn: number;
|
||||
currentSourceLineText: string;
|
||||
currentFrame: number;
|
||||
currentScript: string;
|
||||
|
||||
connect(port: number, host: string): void;
|
||||
req(req: any, cb: RequestHandler): void;
|
||||
reqFrameEval(code: string, frame: number, cb: RequestHandler): void;
|
||||
mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void;
|
||||
setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void;
|
||||
clearBreakpoint(rq: Request, cb: RequestHandler): void;
|
||||
listbreakpoints(cb: RequestHandler): void;
|
||||
reqSource(from: number, to: number, cb: RequestHandler): void;
|
||||
reqScripts(cb: any): void;
|
||||
reqContinue(cb: RequestHandler): void;
|
||||
}
|
||||
|
||||
export var Client : {
|
||||
new (): ClientInstance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "_debugger"{
|
||||
export = NodeJS._debugger;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/// <reference path="./abs.d.ts" />
|
||||
|
||||
import Abs from 'abs';
|
||||
|
||||
const x: string = Abs('/foo');
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for abs 1.1.0
|
||||
// Project: https://github.com/IonicaBizau/node-abs
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "abs" {
|
||||
/**
|
||||
* Compute the absolute path of an input.
|
||||
* @param input The input path.
|
||||
*/
|
||||
function Abs(input: string): string;
|
||||
|
||||
export default Abs;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/// <reference path="./absolute.d.ts" />
|
||||
|
||||
import absolute from 'absolute';
|
||||
|
||||
const x: boolean = absolute('/home/foo');
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for absolute 0.0.1
|
||||
// Project: https://github.com/bahamas10/node-absolute
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "absolute" {
|
||||
/**
|
||||
* Test if a path is absolute
|
||||
*/
|
||||
function absolute(path: string): boolean;
|
||||
|
||||
export default absolute;
|
||||
}
|
||||
Vendored
+14
-2
@@ -1,7 +1,7 @@
|
||||
// Type definitions for acc-wizard
|
||||
// Project: https://github.com/sathomas/acc-wizard
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface AccWizardOptions {
|
||||
/**
|
||||
@@ -47,7 +47,19 @@ interface AccWizardOptions {
|
||||
nextText: string;
|
||||
|
||||
/**
|
||||
* @summary Text for back button
|
||||
* @summary Text for back button.
|
||||
* @type {string}
|
||||
*/
|
||||
backText: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for next button. (default: "submit")
|
||||
* @type {string}
|
||||
*/
|
||||
nextType: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for back button. (default: "reset")
|
||||
* @type {string}
|
||||
*/
|
||||
backType: string;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
--noImplicitAny
|
||||
+107
-107
@@ -1,107 +1,107 @@
|
||||
/// <reference path="accounting.d.ts"/>
|
||||
|
||||
// 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]
|
||||
};
|
||||
/// <reference path="accounting.d.ts"/>
|
||||
|
||||
// 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]
|
||||
};
|
||||
|
||||
Vendored
+16
-16
@@ -1,30 +1,30 @@
|
||||
// Type definitions for accounting.js 0.3.2
|
||||
// Project: http://josscrowcroft.github.io/accounting.js/
|
||||
// Definitions by: Sergey Gerasimov <https://github.com/gerich-home/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/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<TFormat> {
|
||||
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<TFormat> {
|
||||
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<any>; // IAccountingCurrencySettings<string> or IAccountingCurrencySettings<IAccountingCurrencyFormat>
|
||||
interface IAccountingSettings {
|
||||
currency: IAccountingCurrencySettings<any>; // IAccountingCurrencySettings<string> or IAccountingCurrencySettings<IAccountingCurrencyFormat>
|
||||
number: IAccountingNumberSettings;
|
||||
}
|
||||
|
||||
@@ -76,4 +76,4 @@ declare var accounting: IAccountingStatic;
|
||||
|
||||
declare module "accounting" {
|
||||
export = accounting;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+334
-288
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
editor.on("blur", (e) => e);
|
||||
editor.on("change", (e) => e);
|
||||
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path='acl-mongodbBackend.d.ts'/>
|
||||
/// <reference path='acl.d.ts'/>
|
||||
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
@@ -14,4 +14,3 @@ acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// Type definitions for node_acl 0.4.7
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="acl.d.ts" />
|
||||
/// <reference path="../mongodb/mongodb.d.ts" />
|
||||
|
||||
declare module "acl" {
|
||||
import mongo = require('mongodb');
|
||||
|
||||
interface AclStatic {
|
||||
mongodbBackend: MongodbBackendStatic;
|
||||
}
|
||||
|
||||
interface MongodbBackend extends Backend<Callback> { }
|
||||
interface MongodbBackendStatic {
|
||||
new(db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
|
||||
new(db: mongo.Db, prefix: string): MongodbBackend;
|
||||
new(db: mongo.Db): MongodbBackend;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path='acl-redisBackend.d.ts'/>
|
||||
/// <reference path='acl.d.ts'/>
|
||||
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// Type definitions for node_acl 0.4.7
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="acl.d.ts" />
|
||||
/// <reference path='../redis/redis.d.ts'/>
|
||||
|
||||
declare module "acl" {
|
||||
import redis = require('redis');
|
||||
|
||||
interface AclStatic {
|
||||
redisBackend: RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface RedisBackend extends Backend<redis.RedisClient> { }
|
||||
interface RedisBackendStatic {
|
||||
new(redis: redis.RedisClient, prefix: string): RedisBackend;
|
||||
new(redis: redis.RedisClient): RedisBackend;
|
||||
}
|
||||
}
|
||||
Vendored
+33
-3
@@ -1,11 +1,14 @@
|
||||
// Type definitions for node_acl 0.4.7
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path='../node/node.d.ts'/>
|
||||
|
||||
/// <reference path='../redis/redis.d.ts'/>
|
||||
/// <reference path="../mongodb/mongodb-1.4.9.d.ts" />
|
||||
|
||||
declare module "acl" {
|
||||
import http = require('http');
|
||||
import Promise = require("bluebird");
|
||||
@@ -17,7 +20,7 @@ declare module "acl" {
|
||||
type Callback = (err: Error) => any;
|
||||
type AnyCallback = (err: Error, obj: any) => any;
|
||||
type AllowedCallback = (err: Error, allowed: boolean) => any;
|
||||
type GetUserId = (req: http.ServerRequest, res: http.ServerResponse) => Value;
|
||||
type GetUserId = (req: http.IncomingMessage, res: http.ServerResponse) => Value;
|
||||
|
||||
interface AclStatic {
|
||||
new (backend: Backend<any>, logger: Logger, options: Option): Acl;
|
||||
@@ -115,6 +118,33 @@ declare module "acl" {
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
// for redis backend
|
||||
import redis = require('redis');
|
||||
|
||||
interface AclStatic {
|
||||
redisBackend: RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface RedisBackend extends Backend<redis.RedisClient> { }
|
||||
interface RedisBackendStatic {
|
||||
new(redis: redis.RedisClient, prefix: string): RedisBackend;
|
||||
new(redis: redis.RedisClient): RedisBackend;
|
||||
}
|
||||
|
||||
// for mongodb backend
|
||||
import mongo = require('mongodb');
|
||||
|
||||
interface AclStatic {
|
||||
mongodbBackend: MongodbBackendStatic;
|
||||
}
|
||||
|
||||
interface MongodbBackend extends Backend<Callback> { }
|
||||
interface MongodbBackendStatic {
|
||||
new(db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
|
||||
new(db: mongo.Db, prefix: string): MongodbBackend;
|
||||
new(db: mongo.Db): MongodbBackend;
|
||||
}
|
||||
|
||||
var _: AclStatic;
|
||||
export = _;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ var string: string;
|
||||
// acorn
|
||||
string = acorn.version;
|
||||
program = acorn.parse('code');
|
||||
program = acorn.parse('code', {range: true, onToken: tokens, onComment: comments});
|
||||
program = acorn.parse('code', {ranges: true, onToken: tokens, onComment: comments});
|
||||
program = acorn.parse('code', {
|
||||
ranges: true,
|
||||
onToken: (token) => tokens.push(token),
|
||||
|
||||
Vendored
+3
-2
@@ -1,14 +1,15 @@
|
||||
// Type definitions for Acorn v1.0.1
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../estree/estree.d.ts" />
|
||||
|
||||
declare module acorn {
|
||||
declare namespace acorn {
|
||||
var version: string;
|
||||
function parse(input: string, options?: Options): ESTree.Program;
|
||||
function parseExpressionAt(input: string, pos: number, options?: Options): ESTree.Expression;
|
||||
function getLineInfo(input: string, offset: number): ESTree.Position;
|
||||
var defaultOptions: Options;
|
||||
|
||||
interface TokenType {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/// <reference path="adal-angular.d.ts" />
|
||||
|
||||
// Code samples from:
|
||||
// - https://github.com/AzureAD/azure-activedirectory-library-for-js
|
||||
// - https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp
|
||||
|
||||
// Variable provided by AngularJS
|
||||
var $httpProvider: angular.IHttpProvider = null;
|
||||
var adalAuthenticationServiceProvider: adal.AdalAuthenticationServiceProvider = null;
|
||||
var adalAuthenticationService: adal.AdalAuthenticationService = null;
|
||||
|
||||
var endpoints = {
|
||||
"https://yourhost/api": "b6a68585-5287-45b2-ba82-383ba1f60932",
|
||||
};
|
||||
adalAuthenticationServiceProvider.init({
|
||||
tenant: "52d4b072-9470-49fb-8721-bc3a1c9912a1",
|
||||
clientId: "e9a5a8b6-8af7-4719-9821-0deef255f68e",
|
||||
endpoints: endpoints
|
||||
},
|
||||
$httpProvider
|
||||
);
|
||||
|
||||
adalAuthenticationServiceProvider.init({
|
||||
clientId: "e9a5a8b6-8af7-4719-9821-0deef255f68e"
|
||||
},
|
||||
$httpProvider
|
||||
);
|
||||
|
||||
adalAuthenticationServiceProvider.init(
|
||||
{
|
||||
clientId: 'cb68f72f...',
|
||||
cacheLocation: 'localStorage'
|
||||
},
|
||||
$httpProvider // pass http provider to inject request interceptor to attach tokens
|
||||
);
|
||||
|
||||
adalAuthenticationServiceProvider.init({
|
||||
tenant: 'Enter your tenant name here e.g. contoso.onmicrosoft.com',
|
||||
clientId: 'Enter your client ID here e.g. e9a5a8b6-8af7-4719-9821-0deef255f68e',
|
||||
extraQueryParameter: 'nux=1'
|
||||
},
|
||||
$httpProvider
|
||||
);
|
||||
|
||||
adalAuthenticationService.login();
|
||||
adalAuthenticationService.logOut();
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// Type definitions for ADAL.JS 1.0.8
|
||||
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-js
|
||||
// Definitions by: mmaitre314 <https://github.com/mmaitre314>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="adal.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare namespace adal {
|
||||
|
||||
interface AdalAuthenticationServiceProvider {
|
||||
init(configOptions: Config, httpProvider: angular.IHttpProvider): void;
|
||||
}
|
||||
|
||||
interface UserInfo {
|
||||
isAuthenticated: boolean,
|
||||
userName: string,
|
||||
loginError: string,
|
||||
profile: any
|
||||
}
|
||||
|
||||
interface AdalAuthenticationService {
|
||||
|
||||
config: Config;
|
||||
userInfo: UserInfo,
|
||||
|
||||
login(): void;
|
||||
loginInProgress(): boolean;
|
||||
logOut(): void;
|
||||
getCachedToken(resource: string): string;
|
||||
acquireToken(resource: string): angular.IPromise<string>;
|
||||
getUser(): angular.IPromise<User>;
|
||||
getResourceForEndpoint(endpoint: string): string,
|
||||
clearCache(): void;
|
||||
clearCacheForResource(resource: string): void;
|
||||
info(message: string): void;
|
||||
verbose(message: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="adal.d.ts" />
|
||||
|
||||
var endpoints = {
|
||||
"https://yourhost/api": "b6a68585-5287-45b2-ba82-383ba1f60932",
|
||||
};
|
||||
|
||||
var config : adal.Config = {
|
||||
tenant: "52d4b072-9470-49fb-8721-bc3a1c9912a1", // Optional by default, it sends common
|
||||
clientId: "e9a5a8b6-8af7-4719-9821-0deef255f68e", // Required
|
||||
endpoints: endpoints // If you need to send CORS api requests.
|
||||
};
|
||||
|
||||
var auth = new AuthenticationContext(config);
|
||||
|
||||
Logging.log = (message: string) => {
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
Logging.level = 4;
|
||||
|
||||
auth.info("Logging message");
|
||||
|
||||
var userName: string = auth.getCachedUser().userName;
|
||||
var postLogoutRedirectUrl = auth.config.postLogoutRedirectUri;
|
||||
var isValidRequest = auth.getRequestInfo('hash').valid;
|
||||
Vendored
+169
@@ -0,0 +1,169 @@
|
||||
// Type definitions for ADAL.JS 1.0.8
|
||||
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-js
|
||||
// Definitions by: mmaitre314 <https://github.com/mmaitre314>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var AuthenticationContext: adal.AuthenticationContextStatic;
|
||||
declare var Logging: adal.Logging;
|
||||
|
||||
declare module 'adal' {
|
||||
export = { AuthenticationContext, Logging };
|
||||
}
|
||||
|
||||
declare namespace adal {
|
||||
|
||||
interface Config {
|
||||
tenant?: string;
|
||||
clientId: string;
|
||||
redirectUri?: string;
|
||||
cacheLocation?: string;
|
||||
displayCall?: (urlNavigate: string) => any;
|
||||
correlationId?: string;
|
||||
loginResource?: string;
|
||||
resource?: string;
|
||||
endpoints?: any; // If you need to send CORS api requests.
|
||||
extraQueryParameter?: string;
|
||||
postLogoutRedirectUri?: string; // redirect url after succesful logout operation
|
||||
}
|
||||
|
||||
interface User {
|
||||
userName: string;
|
||||
profile: any;
|
||||
}
|
||||
|
||||
interface RequestInfo {
|
||||
valid: boolean;
|
||||
parameters: any;
|
||||
stateMatch: boolean;
|
||||
stateResponse: string;
|
||||
requestType: string;
|
||||
}
|
||||
|
||||
interface Logging {
|
||||
log: (message: string) => void;
|
||||
level: LoggingLevel;
|
||||
}
|
||||
|
||||
enum LoggingLevel {
|
||||
ERROR = 0,
|
||||
WARNING = 1,
|
||||
INFO = 2,
|
||||
VERBOSE = 3
|
||||
}
|
||||
|
||||
interface AuthenticationContextStatic {
|
||||
new (config: Config): AuthenticationContext;
|
||||
}
|
||||
|
||||
interface AuthenticationContext {
|
||||
|
||||
instance: string;
|
||||
config: Config;
|
||||
|
||||
/**
|
||||
* Gets initial Idtoken for the app backend
|
||||
* Saves the resulting Idtoken in localStorage.
|
||||
*/
|
||||
login(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether login is in progress now or not.
|
||||
*/
|
||||
loginInProgress(): boolean;
|
||||
|
||||
/**
|
||||
* Gets token for the specified resource from local storage cache
|
||||
* @param {string} resource A URI that identifies the resource for which the token is valid.
|
||||
* @returns {string} token if exists and not expired or null
|
||||
*/
|
||||
getCachedToken(resource: string): string;
|
||||
|
||||
/**
|
||||
* Retrieves and parse idToken from localstorage
|
||||
* @returns {User} user object
|
||||
*/
|
||||
getCachedUser(): User;
|
||||
|
||||
registerCallback(expectedState: string, resource: string, callback: (message: string, token: string) => any): void;
|
||||
|
||||
/**
|
||||
* Acquire token from cache if not expired and available. Acquires token from iframe if expired.
|
||||
* @param {string} resource ResourceUri identifying the target resource
|
||||
* @param {requestCallback} callback
|
||||
*/
|
||||
acquireToken(resource: string, callback: (message: string, token: string) => any): void;
|
||||
|
||||
/**
|
||||
* Redirect the Browser to Azure AD Authorization endpoint
|
||||
* @param {string} urlNavigate The authorization request url
|
||||
*/
|
||||
promptUser(urlNavigate: string): void;
|
||||
|
||||
/**
|
||||
* Clear cache items.
|
||||
*/
|
||||
clearCache(): void;
|
||||
|
||||
/**
|
||||
* Clear cache items for a resource.
|
||||
*/
|
||||
clearCacheForResource(resource: string): void;
|
||||
|
||||
/**
|
||||
* Logout user will redirect page to logout endpoint.
|
||||
* After logout, it will redirect to post_logout page if provided.
|
||||
*/
|
||||
logOut(): void;
|
||||
|
||||
/**
|
||||
* Gets a user profile
|
||||
* @param {requestCallback} callback - The callback that handles the response.
|
||||
*/
|
||||
getUser(callback: (message: string, user?: User) => any): void;
|
||||
|
||||
/**
|
||||
* Checks if hash contains access token or id token or error_description
|
||||
* @param {string} hash - Hash passed from redirect page
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isCallback(hash: string): boolean;
|
||||
|
||||
/**
|
||||
* Gets login error
|
||||
* @returns {string} error message related to login
|
||||
*/
|
||||
getLoginError(): string;
|
||||
|
||||
/**
|
||||
* Gets requestInfo from given hash.
|
||||
* @returns {RequestInfo} for appropriate hash.
|
||||
*/
|
||||
getRequestInfo(hash: string): RequestInfo;
|
||||
|
||||
/**
|
||||
* Saves token from hash that is received from redirect.
|
||||
*/
|
||||
saveTokenFromHash(requestInfo: RequestInfo): void;
|
||||
|
||||
/**
|
||||
* Gets resource for given endpoint if mapping is provided with config.
|
||||
* @param {string} endpoint - API endpoint
|
||||
* @returns {string} resource for this API endpoint
|
||||
*/
|
||||
getResourceForEndpoint(endpoint: string): string;
|
||||
|
||||
/**
|
||||
* Handles redirection after login operation.
|
||||
* Gets access token from url and saves token to the (local/session) storage
|
||||
* or saves error in case unsuccessful login.
|
||||
*/
|
||||
handleWindowCallback(): void;
|
||||
|
||||
log(level: number, message: string, error: any): void;
|
||||
error(message: string, error: any): void;
|
||||
warn(message: string): void;
|
||||
info(message: string): void;
|
||||
verbose(message: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for add2home v2.0.5
|
||||
// Project: http://cubiq.org/add-to-home-screen
|
||||
// Definitions by: James Wilkins <http://www.codeplex.com/site/users/view/jamesnw>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var addToHome: {
|
||||
/** Shows the popup.
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/// <reference path="adm-zip.d.ts" />
|
||||
import AdmZip = require("adm-zip");
|
||||
|
||||
|
||||
// reading archives
|
||||
var zip = new AdmZip("./my_file.zip");
|
||||
var zipEntries = zip.getEntries(); // an array of ZipEntry records
|
||||
var zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records
|
||||
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
console.log(zipEntry.toString()); // outputs zip entries information
|
||||
@@ -18,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();
|
||||
@@ -31,3 +31,32 @@ zip.addLocalFile("/home/me/some_picture.png");
|
||||
var willSendthis = zip.toBuffer();
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/"/home/me/files.zip");
|
||||
|
||||
function processZipEntry(zipEntry: AdmZip.IZipEntry) {
|
||||
console.log('comment', zipEntry.comment);
|
||||
}
|
||||
|
||||
//tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP
|
||||
import Zip = require("adm-zip");
|
||||
// loads and parses existing zip file local_file.zip
|
||||
var zip = new Zip("local_file.zip");
|
||||
// creates new in memory zip
|
||||
zip = new Zip();
|
||||
// loads and parses existing zip file local_file.zip
|
||||
zip = new Zip("local_file.zip");
|
||||
// get all entries and iterate them
|
||||
zip.getEntries().forEach((entry) => {
|
||||
var entryName = entry.entryName;
|
||||
var decompressedData = zip.readFile(entry); // decompressed buffer of the entry
|
||||
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
|
||||
});
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt
|
||||
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true);
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/myfile.txt
|
||||
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';
|
||||
}
|
||||
|
||||
Vendored
+90
-83
@@ -1,12 +1,12 @@
|
||||
// Type definitions for adm-zip v0.4.4
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>, Abner Oliveira <https://github.com/abner>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module AdmZip {
|
||||
class ZipFile {
|
||||
declare module "adm-zip" {
|
||||
class AdmZip {
|
||||
/**
|
||||
* Create a new, empty archive.
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ declare module AdmZip {
|
||||
* @param entry ZipEntry object
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: IZipEntry): Buffer;
|
||||
readFile(entry: AdmZip.IZipEntry): Buffer;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry String with the full path of the entry
|
||||
@@ -41,7 +41,7 @@ declare module AdmZip {
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
readFileAsync(entry: AdmZip.IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
@@ -57,7 +57,7 @@ declare module AdmZip {
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: IZipEntry, encoding?: string): string;
|
||||
readAsText(fileName: AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry String with the full path of the entry
|
||||
@@ -71,7 +71,7 @@ declare module AdmZip {
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
readAsTextAsync(fileName: AdmZip.IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
@@ -83,7 +83,7 @@ declare module AdmZip {
|
||||
* and files if the given entry is a directory
|
||||
* @param entry A ZipEntry object.
|
||||
*/
|
||||
deleteFile(entry: IZipEntry): void;
|
||||
deleteFile(entry: AdmZip.IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
@@ -110,7 +110,7 @@ declare module AdmZip {
|
||||
* @param entry ZipEntry object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: IZipEntry, comment: string): void;
|
||||
addZipEntryComment(entry: AdmZip.IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry String with the full path of the entry.
|
||||
@@ -122,7 +122,7 @@ declare module AdmZip {
|
||||
* @param entry ZipEntry object.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: IZipEntry): string;
|
||||
getZipEntryComment(entry: AdmZip.IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
@@ -136,7 +136,7 @@ declare module AdmZip {
|
||||
* @param entry ZipEntry object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: IZipEntry, content: Buffer): void;
|
||||
updateFile(entry: AdmZip.IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
@@ -167,14 +167,14 @@ declare module AdmZip {
|
||||
* Returns an array of ZipEntry objects representing the files and folders
|
||||
* inside the archive
|
||||
*/
|
||||
getEntries(): IZipEntry[];
|
||||
getEntries(): AdmZip.IZipEntry[];
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by
|
||||
* ``name``.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return ZipEntry The entry corresponding to the name.
|
||||
*/
|
||||
getEntry(name: string): IZipEntry;
|
||||
getEntry(name: string): AdmZip.IZipEntry;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
@@ -203,7 +203,7 @@ declare module AdmZip {
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
extractEntryTo(entryPath: AdmZip.IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
@@ -211,6 +211,14 @@ declare module AdmZip {
|
||||
* 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
|
||||
@@ -225,76 +233,75 @@ declare module AdmZip {
|
||||
toBuffer(): Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
interface IZipEntry {
|
||||
namespace AdmZip {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
extra: Buffer;
|
||||
/**
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
*/
|
||||
getCompressedData(): Buffer;
|
||||
/**
|
||||
* Asynchronously retrieve the compressed data for this entry. Note that
|
||||
* this may trigger compression if any properties were modified.
|
||||
*/
|
||||
getCompressedDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
getData(): Buffer;
|
||||
/**
|
||||
* Asynchronously get the decompressed data associated with this entry.
|
||||
*/
|
||||
getDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Returns the CEN Entry Header to be written to the output zip file, plus
|
||||
* the extra data and the entry comment.
|
||||
*/
|
||||
packHeader(): Buffer;
|
||||
/**
|
||||
* Returns a nicely formatted string with the most important properties of
|
||||
* the ZipEntry.
|
||||
*/
|
||||
toString(): string;
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
extra: Buffer;
|
||||
/**
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
*/
|
||||
getCompressedData(): Buffer;
|
||||
/**
|
||||
* Asynchronously retrieve the compressed data for this entry. Note that
|
||||
* this may trigger compression if any properties were modified.
|
||||
*/
|
||||
getCompressedDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
getData(): Buffer;
|
||||
/**
|
||||
* Asynchronously get the decompressed data associated with this entry.
|
||||
*/
|
||||
getDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Returns the CEN Entry Header to be written to the output zip file, plus
|
||||
* the extra data and the entry comment.
|
||||
*/
|
||||
packHeader(): Buffer;
|
||||
/**
|
||||
* Returns a nicely formatted string with the most important properties of
|
||||
* the ZipEntry.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "adm-zip" {
|
||||
import zipFile = AdmZip.ZipFile;
|
||||
export = zipFile;
|
||||
export = AdmZip;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/// <reference path="ag-grid" />
|
||||
|
||||
checkGridOptions(<ag.grid.GridOptions>{});
|
||||
checkColDef(<ag.grid.ColDef>{});
|
||||
|
||||
function checkGridOptions(gridOptions: ag.grid.GridOptions): void {
|
||||
|
||||
gridOptions.virtualPaging = true;
|
||||
gridOptions.toolPanelSuppressPivot = true;
|
||||
gridOptions.toolPanelSuppressValues = true;
|
||||
gridOptions.rowsAlreadyGrouped = true;
|
||||
gridOptions.suppressRowClickSelection = true;
|
||||
gridOptions.suppressCellSelection = true;
|
||||
gridOptions.sortingOrder = ['asc','desc'];
|
||||
gridOptions.suppressMultiSort = true;
|
||||
gridOptions.suppressHorizontalScroll = true;
|
||||
gridOptions.unSortIcon = true;
|
||||
gridOptions.rowHeight = 0;
|
||||
gridOptions.rowBuffer = 0;
|
||||
gridOptions.enableColResize = true;
|
||||
gridOptions.enableCellExpressions = true;
|
||||
gridOptions.enableSorting = true;
|
||||
gridOptions.enableServerSideSorting = true;
|
||||
gridOptions.enableFilter = true;
|
||||
gridOptions.enableServerSideFilter = true;
|
||||
gridOptions.colWidth = 0;
|
||||
gridOptions.suppressMenuHide = true;
|
||||
gridOptions.singleClickEdit = true;
|
||||
gridOptions.debug = true;
|
||||
gridOptions.icons = {};
|
||||
gridOptions.angularCompileRows = true;
|
||||
gridOptions.angularCompileFilters = true;
|
||||
gridOptions.angularCompileHeaders = true;
|
||||
gridOptions.localeText = {};
|
||||
gridOptions.localeTextFunc = function() {}
|
||||
gridOptions.suppressScrollLag = true;
|
||||
gridOptions.groupSuppressAutoColumn = true;
|
||||
gridOptions.groupSelectsChildren = true;
|
||||
gridOptions.groupHidePivotColumns = true;
|
||||
gridOptions.groupIncludeFooter = true;
|
||||
gridOptions.groupUseEntireRow = true;
|
||||
gridOptions.groupSuppressRow = true;
|
||||
gridOptions.groupSuppressBlankHeader = true;
|
||||
gridOptions.forPrint = true;
|
||||
gridOptions.groupColumnDef = {};
|
||||
gridOptions.context = {};
|
||||
gridOptions.rowStyle = {color: 'red'};
|
||||
gridOptions.rowClass = 'green';
|
||||
gridOptions.groupDefaultExpanded = false;
|
||||
gridOptions.slaveGrids = [];
|
||||
gridOptions.rowSelection = 'single';
|
||||
gridOptions.rowDeselection = true;
|
||||
gridOptions.rowData = [];
|
||||
gridOptions.floatingTopRowData = [];
|
||||
gridOptions.floatingBottomRowData = [];
|
||||
gridOptions.showToolPanel = true;
|
||||
gridOptions.groupKeys = ['a','b']
|
||||
gridOptions.groupAggFields = ['a','b']
|
||||
gridOptions.columnDefs = [];
|
||||
gridOptions.datasource = {};
|
||||
gridOptions.pinnedColumnCount = 0;
|
||||
gridOptions.groupHeaders = true;
|
||||
gridOptions.headerHeight = 0;
|
||||
gridOptions.groupRowInnerRenderer = function(params) {};
|
||||
gridOptions.groupRowRenderer = {};
|
||||
gridOptions.isScrollLag = function() {return true;}
|
||||
gridOptions.isExternalFilterPresent = function() { return true; };
|
||||
gridOptions.doesExternalFilterPass = function(node: ag.grid.RowNode) { return false; };
|
||||
gridOptions.getRowStyle = function() {};
|
||||
gridOptions.getRowClass = function() {};
|
||||
gridOptions.headerCellRenderer = function() {};
|
||||
gridOptions.groupAggFunction = function(nodes: any[]) {};
|
||||
gridOptions.onReady = function(api: any) {};
|
||||
gridOptions.onModelUpdated = function() {};
|
||||
gridOptions.onCellClicked = function(params) {};
|
||||
gridOptions.onCellDoubleClicked = function(params) {};
|
||||
gridOptions.onCellContextMenu = function(params) {};
|
||||
gridOptions.onCellValueChanged = function(params) {};
|
||||
gridOptions.onCellFocused = function(params) {};
|
||||
gridOptions.onRowSelected = function(params) {};
|
||||
gridOptions.onSelectionChanged = function() {};
|
||||
gridOptions.onBeforeFilterChanged = function() {};
|
||||
gridOptions.onAfterFilterChanged = function() {};
|
||||
gridOptions.onFilterModified = function() {};
|
||||
gridOptions.onBeforeSortChanged = function() {};
|
||||
gridOptions.onAfterSortChanged = function() {};
|
||||
gridOptions.onVirtualRowRemoved = function(params) {};
|
||||
gridOptions.onRowClicked = function(params) {};
|
||||
gridOptions.api = null;
|
||||
gridOptions.columnApi = null;
|
||||
|
||||
}
|
||||
|
||||
function checkColDef(colDef: ag.grid.ColDef): void {
|
||||
|
||||
colDef.sort = 'test';
|
||||
colDef.sortedAt = 0;
|
||||
colDef.sortingOrder = ['asc','desc'];
|
||||
colDef.headerName = 'test';
|
||||
colDef.field = 'test';
|
||||
colDef.headerValueGetter = 'test';
|
||||
colDef.colId = 'test';
|
||||
colDef.hide = true;
|
||||
colDef.headerTooltip = 'test';
|
||||
colDef.valueGetter = 'test';
|
||||
colDef.headerCellRenderer = {};
|
||||
colDef.headerClass = 'test';
|
||||
colDef.width = 0;
|
||||
colDef.minWidth = 0;
|
||||
colDef.maxWidth = 0;
|
||||
colDef.cellClass = 'test';
|
||||
colDef.cellStyle = {color: 'test'};
|
||||
colDef.cellRenderer = function() {};
|
||||
colDef.floatingCellRenderer = function() {};
|
||||
colDef.aggFunc = 'test';
|
||||
colDef.comparator = function() {};
|
||||
colDef.checkboxSelection = true;
|
||||
colDef.suppressMenu = true;
|
||||
colDef.suppressSorting = true;
|
||||
colDef.unSortIcon = true;
|
||||
colDef.suppressSizeToFit = true;
|
||||
colDef.suppressResize = true;
|
||||
colDef.headerGroup = 'test';
|
||||
colDef.headerGroupShow = 'test';
|
||||
colDef.editable = true;
|
||||
colDef.newValueHandler = function() {};
|
||||
colDef.volatile = true;
|
||||
colDef.template = 'test';
|
||||
colDef.templateUrl = 'test';
|
||||
colDef.filter = 'test';
|
||||
colDef.filterParams = {};
|
||||
colDef.onCellValueChanged = function() {};
|
||||
colDef.onCellClicked = function() {};
|
||||
colDef.onCellDoubleClicked = function() {};
|
||||
colDef.onCellContextMenu = function() {};
|
||||
colDef.cellClassRules = {};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+1991
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,106 @@
|
||||
///<reference path="agenda.d.ts"/>
|
||||
|
||||
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");
|
||||
})
|
||||
|
||||
|
||||
Vendored
+451
@@ -0,0 +1,451 @@
|
||||
// Type definitions for Agenda v0.8.9
|
||||
// Project: https://github.com/rschmukler/agenda
|
||||
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path='../node/node.d.ts' />
|
||||
/// <reference path='../mongodb/mongodb.d.ts' />
|
||||
|
||||
declare module "agenda" {
|
||||
|
||||
import {EventEmitter} from "events";
|
||||
import {Db, Collection, ObjectID} from "mongodb";
|
||||
|
||||
interface Callback {
|
||||
(err?: Error): void;
|
||||
}
|
||||
|
||||
interface ResultCallback<T> {
|
||||
(err?: Error, result?: T): void;
|
||||
}
|
||||
|
||||
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?: Agenda.AgendaConfiguration, cb?: ResultCallback<Collection>);
|
||||
|
||||
/**
|
||||
* Connect to the specified MongoDB server and database.
|
||||
*/
|
||||
database(url: string, collection?: string, options?: any, cb?: ResultCallback<Collection>): Agenda;
|
||||
|
||||
/**
|
||||
* Initialize agenda with an existing MongoDB connection.
|
||||
*/
|
||||
mongo(db: Db, collection?: string, cb?: ResultCallback<Collection>): 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): Agenda.Job;
|
||||
|
||||
/**
|
||||
* Find all Jobs matching `query` and pass same back in cb().
|
||||
* @param query
|
||||
* @param cb
|
||||
*/
|
||||
jobs(query: any, cb: ResultCallback<Agenda.Job[]>): 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<number>): 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?: Agenda.Job, done?: (err?: Error) => void) => void): void;
|
||||
define(name: string, options: Agenda.JobOptions, handler: (job?: Agenda.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<Agenda.Job>): Agenda.Job;
|
||||
every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.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<Agenda.Job>): Agenda.Job;
|
||||
schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.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<Agenda.Job>): Agenda.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<number>): 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;
|
||||
}
|
||||
|
||||
namespace Agenda {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Job's state
|
||||
*/
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>): 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>): 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;
|
||||
|
||||
/**
|
||||
* Calculates next time the job should run
|
||||
*/
|
||||
computeNextRunAt(): Job;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
export = Agenda;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/// <reference path="ajv.d.ts" />
|
||||
|
||||
import * as Ajv from 'ajv';
|
||||
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
|
||||
var validate = ajv.compile({});
|
||||
var valid = validate({});
|
||||
if (!valid) console.log(validate.errors);
|
||||
|
||||
var valid = ajv.validate({}, {});
|
||||
if (!valid) console.log(ajv.errors);
|
||||
|
||||
ajv.addSchema({}, 'mySchema');
|
||||
var valid = ajv.validate('mySchema', {});
|
||||
if (!valid) console.log(ajv.errorsText());
|
||||
|
||||
ajv.addKeyword('range', {
|
||||
type: 'number', compile: function (sch, parentSchema) {
|
||||
var min: any = sch[0];
|
||||
var max: any = sch[1];
|
||||
|
||||
return parentSchema.exclusiveRange === true
|
||||
? function (data) { return data > min && data < max; }
|
||||
: function (data) { return data >= min && data <= max; }
|
||||
}
|
||||
});
|
||||
|
||||
var schema = { "range": [2, 4], "exclusiveRange": true };
|
||||
var validate = ajv.compile(schema);
|
||||
console.log(validate(2.01)); // true
|
||||
console.log(validate(3.99)); // true
|
||||
console.log(validate(2)); // false
|
||||
console.log(validate(4)); // false
|
||||
|
||||
declare var request: any;
|
||||
function loadSchema(uri: any, callback: any) {
|
||||
request.json(uri, function (err: any, res: any, body: any) {
|
||||
if (err || res.statusCode >= 400)
|
||||
callback(err || new Error('Loading error: ' + res.statusCode));
|
||||
else
|
||||
callback(null, body);
|
||||
});
|
||||
}
|
||||
var ajv = new Ajv({ loadSchema: loadSchema });
|
||||
|
||||
ajv.compileAsync(schema, function (err, validate) {
|
||||
if (err) return;
|
||||
var valid = validate({});
|
||||
});
|
||||
|
||||
declare var knex: any;
|
||||
function checkIdExists(schema: any, data: any) {
|
||||
return knex(schema.table)
|
||||
.select('id')
|
||||
.where('id', data)
|
||||
.then(function (rows: any) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
var validate = ajv.compile(schema);
|
||||
|
||||
(validate({ userId: 1, postId: 19 }) as PromiseLike<boolean>)
|
||||
.then(function (valid) {
|
||||
// "valid" is always true here
|
||||
console.log('Data is valid');
|
||||
}, function (err) {
|
||||
if (!(err instanceof Ajv.ValidationError)) throw err;
|
||||
// data is invalid
|
||||
console.log('Validation errors:', err.errors);
|
||||
});
|
||||
|
||||
var ajv = new Ajv({ /* async: 'es7', */ transpile: 'nodent' });
|
||||
var validate = ajv.compile(schema); // transpiled es7 async function
|
||||
(validate({}) as PromiseLike<any>).then(() => { }, () => { });
|
||||
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
// Type definitions for ajv
|
||||
// Project: https://github.com/epoberezkin/ajv
|
||||
// Definitions by: York Yao <https://github.com/plantain-00/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "ajv" {
|
||||
class Ajv {
|
||||
/**
|
||||
* Create Ajv instance.
|
||||
*/
|
||||
constructor(options?: Ajv.AjvOptions);
|
||||
/**
|
||||
* Generate validating function and cache the compiled schema for future use.
|
||||
*/
|
||||
compile(schema: any): Ajv.AjvValidate;
|
||||
/**
|
||||
* Asyncronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema.
|
||||
*/
|
||||
compileAsync(schema: any, callback: (error: Error, validate: Ajv.AjvValidate) => void): void;
|
||||
/**
|
||||
* Validate data using passed schema (it will be compiled and cached).
|
||||
*/
|
||||
validate(schema: any, data: any): boolean | PromiseLike<boolean>;
|
||||
errors: Ajv.ValidationError[];
|
||||
/**
|
||||
* Add schema(s) to validator instance.
|
||||
*/
|
||||
addSchema(schema: any, key: string): void;
|
||||
/**
|
||||
* Adds meta schema(s) that can be used to validate other schemas.
|
||||
* That function should be used instead of addSchema because there may be instance options that would compile a meta schema incorrectly (at the moment it is removeAdditional option).
|
||||
*/
|
||||
addMetaSchema(schema: any, key: string): void;
|
||||
/**
|
||||
* Validates schema.
|
||||
* This method should be used to validate schemas rather than validate due to the inconsistency of uri format in JSON-Schema standard.
|
||||
*/
|
||||
validateSchema(schema: any): Boolean;
|
||||
/**
|
||||
* Retrieve compiled schema previously added with addSchema by the key passed to addSchema or by its full reference (id).
|
||||
* Returned validating function has schema property with the reference to the original schema.
|
||||
*/
|
||||
getSchema(key: string): Ajv.AjvValidate;
|
||||
/**
|
||||
* Remove added/cached schema.
|
||||
* Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.
|
||||
*/
|
||||
removeSchema(schema: any): void;
|
||||
/**
|
||||
* Add custom format to validate strings. It can also be used to replace pre-defined formats for Ajv instance.
|
||||
*/
|
||||
addFormat(name: string, format: any): void;
|
||||
/**
|
||||
* Add custom validation keyword to Ajv instance.
|
||||
*/
|
||||
addKeyword(keyword: string, definition: Ajv.AjxKeywordDefinition): void;
|
||||
errorsText(): any;
|
||||
static ValidationError: Function;
|
||||
}
|
||||
namespace Ajv {
|
||||
type AjvOptions = {
|
||||
v5?: boolean;
|
||||
allErrors?: boolean;
|
||||
verbose?: boolean;
|
||||
jsonPointers?: boolean;
|
||||
uniqueItems?: boolean;
|
||||
unicode?: boolean;
|
||||
format?: string;
|
||||
formats?: any;
|
||||
schemas?: any;
|
||||
missingRefs?: boolean;
|
||||
loadSchema?(uri: string, callback: (error: Error, body: any) => void): void;
|
||||
removeAdditional?: boolean;
|
||||
useDefaults?: boolean;
|
||||
coerceTypes?: boolean;
|
||||
async?: any;
|
||||
transpile?: string;
|
||||
meta?: boolean;
|
||||
validateSchema?: boolean;
|
||||
addUsedSchema?: boolean;
|
||||
inlineRefs?: boolean;
|
||||
passContext?: boolean;
|
||||
loopRequired?: number;
|
||||
ownProperties?: boolean;
|
||||
multipleOfPrecision?: boolean;
|
||||
errorDataPath?: string,
|
||||
messages?: boolean;
|
||||
beautify?: boolean;
|
||||
cache?: any;
|
||||
}
|
||||
type AjvValidate = ((data: any) => boolean | PromiseLike<boolean>) & {
|
||||
errors: ValidationError[];
|
||||
}
|
||||
type AjxKeywordDefinition = {
|
||||
async?: boolean;
|
||||
type: string;
|
||||
compile?: (schema: any, parentsSchema: any) => ((data: any) => boolean | PromiseLike<boolean>);
|
||||
validate?: (schema: any, data: any) => boolean;
|
||||
}
|
||||
type ValidationError = {
|
||||
keyword: string;
|
||||
dataPath: string;
|
||||
schemaPath: string;
|
||||
params: any;
|
||||
message: string;
|
||||
schema: any;
|
||||
parentSchema: any;
|
||||
data: any;
|
||||
}
|
||||
}
|
||||
export = Ajv;
|
||||
}
|
||||
Vendored
+15
-15
@@ -1,11 +1,11 @@
|
||||
// Type definitions for alertify 0.3.11
|
||||
// Project: http://fabien-d.github.io/alertify.js/
|
||||
// Definitions by: John Jeffery <http://github.com/jjeffery>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var alertify: alertify.IAlertifyStatic;
|
||||
|
||||
declare module alertify {
|
||||
declare namespace alertify {
|
||||
interface IAlertifyStatic {
|
||||
/**
|
||||
* Create an alert dialog box
|
||||
@@ -16,7 +16,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
alert(message: string, fn?: Function, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Create a confirm dialog box
|
||||
* @param message The message passed from the callee
|
||||
@@ -26,7 +26,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
confirm(message: string, fn?: Function, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Extend the log method to create custom methods
|
||||
* @param type Custom method name
|
||||
@@ -34,7 +34,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
extend(type: string): (message: string, wait?: number) => IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize Alertify and create the 2 main elements.
|
||||
* Initialization will happen automatically on the first
|
||||
@@ -42,7 +42,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
init(): void;
|
||||
|
||||
|
||||
/**
|
||||
* Show a new log message box
|
||||
* @param message The message passed from the callee
|
||||
@@ -52,7 +52,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
log(message: string, type?: string, wait?: number): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Create a prompt dialog box
|
||||
* @param message The message passed from the callee
|
||||
@@ -63,7 +63,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
prompt(message: string, fn?: Function, placeholder?: string, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for log messages
|
||||
* @param message The message passed from the callee
|
||||
@@ -71,7 +71,7 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
success(message: string): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for log messages
|
||||
* @param message The message passed from the callee
|
||||
@@ -79,14 +79,14 @@ declare module alertify {
|
||||
* @since 0.0.1
|
||||
*/
|
||||
error(message: string): IAlertifyStatic;
|
||||
|
||||
|
||||
/**
|
||||
* Used to set alertify properties
|
||||
* @param Properties
|
||||
* @since 0.2.11
|
||||
*/
|
||||
set(args: IProperties): void;
|
||||
|
||||
|
||||
/**
|
||||
* The labels used for dialog buttons
|
||||
*/
|
||||
@@ -105,13 +105,13 @@ declare module alertify {
|
||||
interface IProperties {
|
||||
/** Default value for milliseconds display of log messages */
|
||||
delay?: number;
|
||||
|
||||
|
||||
/** Default values for display of labels */
|
||||
labels?: ILabels;
|
||||
|
||||
|
||||
/** Default button for focus */
|
||||
buttonFocus?: string;
|
||||
|
||||
|
||||
/** Should buttons be displayed in reverse order */
|
||||
buttonReverse?: boolean;
|
||||
}
|
||||
@@ -121,4 +121,4 @@ declare module alertify {
|
||||
ok?: string;
|
||||
cancel?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="./alexa-sdk.d.ts" />
|
||||
|
||||
import * as Alexa from "alexa-sdk";
|
||||
|
||||
exports.handler = function(event: Alexa.RequestBody, context: Alexa.Context, callback: Function) {
|
||||
let alexa = Alexa.handler(event, context);
|
||||
alexa.registerHandlers(handlers);
|
||||
alexa.execute();
|
||||
};
|
||||
|
||||
let handlers: Alexa.Handlers = {
|
||||
'LaunchRequest': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit('SayHello');
|
||||
},
|
||||
'HelloWorldIntent': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit('SayHello');
|
||||
},
|
||||
'SayHello': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit(':tell', 'Hello World!');
|
||||
}
|
||||
};
|
||||
Vendored
+132
@@ -0,0 +1,132 @@
|
||||
// Type definitions for Alexa SDK for Node.js v1.0.3
|
||||
// Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
|
||||
// Definitions by: Pete Beegle <https://github.com/petebeegle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'alexa-sdk' {
|
||||
export function handler(event: RequestBody, context: Context, callback?: Function): AlexaObject;
|
||||
export function CreateStateHandler(state: string, obj: any): any;
|
||||
export var StateString: string;
|
||||
|
||||
interface AlexaObject {
|
||||
_event: any;
|
||||
_context: any;
|
||||
_callback: any;
|
||||
state: any;
|
||||
appId: any;
|
||||
response: any;
|
||||
dynamoDBTableName: any;
|
||||
saveBeforeResponse: boolean;
|
||||
registerHandlers: (...handlers: Handlers[]) => any;
|
||||
execute: () => void;
|
||||
}
|
||||
|
||||
interface Handlers {
|
||||
[intent: string]: () => void;
|
||||
}
|
||||
|
||||
interface Handler {
|
||||
on: any;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emitWithState: any;
|
||||
state: any;
|
||||
handler: any;
|
||||
event: RequestBody;
|
||||
attributes: any;
|
||||
context: any;
|
||||
name: any;
|
||||
isOverriden: any;
|
||||
}
|
||||
|
||||
interface Context {
|
||||
callbackWaitsForEmptyEventLoop: boolean;
|
||||
logGroupName: string;
|
||||
logStreamName: string;
|
||||
functionName: string;
|
||||
memoryLimitInMB: string;
|
||||
functionVersion: string;
|
||||
invokeid: string;
|
||||
awsRequestId: string;
|
||||
}
|
||||
|
||||
interface RequestBody {
|
||||
version: string;
|
||||
session: Session;
|
||||
request: LaunchRequest | IntentRequest | SessionEndedRequest;
|
||||
}
|
||||
|
||||
interface Session {
|
||||
new: boolean;
|
||||
sessionId: string;
|
||||
attributes: any;
|
||||
application: SessionApplication;
|
||||
user: SessionUser;
|
||||
}
|
||||
|
||||
interface SessionApplication {
|
||||
applicationId: string;
|
||||
}
|
||||
|
||||
interface SessionUser {
|
||||
userId: string;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
interface LaunchRequest extends IRequest {}
|
||||
|
||||
interface IntentRequest extends IRequest {
|
||||
intent: Intent;
|
||||
}
|
||||
|
||||
interface Intent {
|
||||
name: string;
|
||||
slots: any;
|
||||
}
|
||||
|
||||
interface SessionEndedRequest extends IRequest{
|
||||
reason: string;
|
||||
}
|
||||
|
||||
interface IRequest {
|
||||
type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest";
|
||||
requestId: string;
|
||||
timeStamp: string;
|
||||
}
|
||||
|
||||
interface ResponseBody {
|
||||
version: string;
|
||||
sessionAttributes?: any;
|
||||
response: Response;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
outputSpeech?: OutputSpeech;
|
||||
card?: Card;
|
||||
reprompt?: Reprompt;
|
||||
shouldEndSession: boolean;
|
||||
}
|
||||
|
||||
interface OutputSpeech {
|
||||
type: "PlainText" | "SSML";
|
||||
text?: string;
|
||||
ssml?: string;
|
||||
}
|
||||
|
||||
interface Card {
|
||||
type: "Simple" | "Standard" | "LinkAccount";
|
||||
title?: string;
|
||||
content?: string;
|
||||
text?: string;
|
||||
image?: Image;
|
||||
}
|
||||
|
||||
interface Image {
|
||||
smallImageUrl: string;
|
||||
largeImageUrl: string;
|
||||
}
|
||||
|
||||
interface Reprompt {
|
||||
outputSpeech: OutputSpeech;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
///<reference path="./algoliasearch-client-js.d.ts"/>
|
||||
|
||||
var algoliasearch = require('algoliasearch');
|
||||
|
||||
var _clientOptions: ClientOptions = {
|
||||
timeout : 12,
|
||||
protocol: "",
|
||||
httpAgent: ""
|
||||
};
|
||||
|
||||
var _synonymOption: SynonymOption = {
|
||||
forwardToSlaves: false,
|
||||
replaceExistingSynonyms: false
|
||||
};
|
||||
|
||||
var _algoliaUserKeyOptions : AlgoliaUserKeyOptions = {
|
||||
validity: 0,
|
||||
maxQueriesPerIPPerHour: 0,
|
||||
indexes: [""],
|
||||
queryParameters: { attributesToRetrieve: ["algolia"] },
|
||||
description: ""
|
||||
};
|
||||
|
||||
var _searchSynonymOptions : SearchSynonymOptions = {
|
||||
query: "",
|
||||
page: 0,
|
||||
type: "",
|
||||
hitsPerPage: 0
|
||||
};
|
||||
|
||||
var _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
|
||||
filters: "",
|
||||
validUntil: 0,
|
||||
restrictIndices: "",
|
||||
userToken: ""
|
||||
};
|
||||
|
||||
var _algoliaIndexSettings : AlgoliaIndexSettings = {
|
||||
attributesToIndex: [""],
|
||||
attributesforFaceting: [""],
|
||||
unretrievableAttributes: [""],
|
||||
attributesToRetrieve: [""],
|
||||
ranking: [""],
|
||||
customRanking: [""],
|
||||
slaves: [""],
|
||||
maxValuesPerFacet: '',
|
||||
attributesToHighlight: [""],
|
||||
attributesToSnippet: [""],
|
||||
highlightPreTag: '',
|
||||
highlightPostTag: '',
|
||||
snippetEllipsisText: '',
|
||||
restrictHighlightAndSnippetArrays: false,
|
||||
hitsPerPage: 0,
|
||||
minWordSizefor1Typo: 0,
|
||||
minWordSizefor2Typos: 0,
|
||||
typoTolerance: false,
|
||||
allowTyposOnNumericTokens: false,
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
separatorsToIndex: '',
|
||||
queryType: '',
|
||||
removeWordsIfNoResults: '',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [""],
|
||||
removeStopWords: [""],
|
||||
disablePrefixOnAttributes: [""],
|
||||
disableExactOnAttributes: [""],
|
||||
exactOnSingleWordQuery: '',
|
||||
alternativesAsExact: false,
|
||||
attributeForDistinct: "",
|
||||
distinct: false,
|
||||
numericAttributesToIndex: [""],
|
||||
allowCompressionOfIntegerArray: false,
|
||||
altCorrections: [{}],
|
||||
minProximity: 0,
|
||||
placeholders: ''
|
||||
};
|
||||
|
||||
var _algoliaQueryParameters : AlgoliaQueryParameters = {
|
||||
query: '',
|
||||
filters: '',
|
||||
attributesToRetrieve: [""],
|
||||
restrictSearchableAttributes: [""],
|
||||
facets: '',
|
||||
maxValuesPerFacet: '',
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
highlightPostTag: '',
|
||||
snippetEllipsisText: '',
|
||||
restrictHighlightAndSnippetArrays: false,
|
||||
hitsPerPage: 0,
|
||||
page: 0,
|
||||
offset: 0,
|
||||
length: 0,
|
||||
minWordSizefor1Typo: 0,
|
||||
minWordSizefor2Typos: 0,
|
||||
typoTolerance: false,
|
||||
allowTyposOnNumericTokens: false,
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
aroundLatLng: '',
|
||||
aroundLatLngViaIP: '',
|
||||
aroundRadius: '',
|
||||
aroundPrecision: 0,
|
||||
minimumAroundRadius: 0,
|
||||
insideBoundingBox: '',
|
||||
queryType: '',
|
||||
insidePolygon: '',
|
||||
removeWordsIfNoResults: '',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [''],
|
||||
removeStopWords: [''],
|
||||
disableExactOnAttributes: [''],
|
||||
exactOnSingleWordQuery: '',
|
||||
alternativesAsExact: true,
|
||||
distinct: 0,
|
||||
getRankingInfo: false,
|
||||
numericAttributesToIndex: [''],
|
||||
numericFilters: [''],
|
||||
tagFilters: '',
|
||||
facetFilters: '',
|
||||
analytics: false,
|
||||
analyticsTags: [''],
|
||||
synonyms: true,
|
||||
replaceSynonymsInHighlight: false,
|
||||
minProximity: 0
|
||||
};
|
||||
|
||||
var index: AlgoliaIndex = algoliasearch('', '').initIndex('');
|
||||
|
||||
var search = index.search({query: ""});
|
||||
index.search({query: ""}, function(err, res){});
|
||||
|
||||
|
||||
+1571
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Created by shearerbeard on 6/28/15.
|
||||
*/
|
||||
///<reference path="alt.d.ts"/>
|
||||
|
||||
import Alt = require("alt");
|
||||
|
||||
//New alt instance
|
||||
var alt = new Alt();
|
||||
|
||||
//Interfaces for our Action Types
|
||||
interface TestActionsGenerate {
|
||||
notifyTest(str:string):void;
|
||||
}
|
||||
|
||||
interface TestActionsExplicit {
|
||||
doTest(str:string):void;
|
||||
success():void;
|
||||
error():void;
|
||||
loading():void;
|
||||
}
|
||||
|
||||
//Create abstracts to inherit ghost methods
|
||||
class AbstractActions implements AltJS.ActionsClass {
|
||||
constructor( alt:AltJS.Alt){}
|
||||
actions:any;
|
||||
dispatch: ( ...payload:Array<any>) => void;
|
||||
generateActions:( ...actions:Array<string>) => void;
|
||||
}
|
||||
|
||||
class AbstractStoreModel<S> implements AltJS.StoreModel<S> {
|
||||
bindActions:( ...actions:Array<Object>) => void;
|
||||
bindAction:( ...args:Array<any>) => void;
|
||||
bindListeners:(obj:any)=> void;
|
||||
exportPublicMethods:(config:{[key:string]:(...args:Array<any>) => any}) => any;
|
||||
exportAsync:( source:any) => void;
|
||||
waitFor:any;
|
||||
exportConfig:any;
|
||||
getState:() => S;
|
||||
}
|
||||
|
||||
class GenerateActionsClass extends AbstractActions {
|
||||
constructor(config:AltJS.Alt) {
|
||||
super(config);
|
||||
this.generateActions("notifyTest");
|
||||
}
|
||||
}
|
||||
|
||||
class ExplicitActionsClass extends AbstractActions {
|
||||
doTest(str:string) {
|
||||
this.dispatch(str);
|
||||
}
|
||||
success() {
|
||||
this.dispatch();
|
||||
}
|
||||
error() {
|
||||
this.dispatch();
|
||||
}
|
||||
loading() {
|
||||
this.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
var generatedActions = alt.createActions<TestActionsGenerate>(GenerateActionsClass);
|
||||
var explicitActions = alt.createActions<ExplicitActionsClass>(ExplicitActionsClass);
|
||||
|
||||
interface AltTestState {
|
||||
hello:string;
|
||||
}
|
||||
|
||||
var testSource:AltJS.Source = {
|
||||
fakeLoad():AltJS.SourceModel<string> {
|
||||
return {
|
||||
remote() {
|
||||
return new Promise<string>((res:any, rej:any) => {
|
||||
setTimeout(() => {
|
||||
if(true) {
|
||||
res("stuff");
|
||||
} else {
|
||||
rej("Things have broken");
|
||||
}
|
||||
}, 250)
|
||||
});
|
||||
},
|
||||
local() {
|
||||
return "local";
|
||||
},
|
||||
success: explicitActions.success,
|
||||
error: explicitActions.error,
|
||||
loading:explicitActions.loading
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class TestStore extends AbstractStoreModel<AltTestState> implements AltTestState {
|
||||
hello:string = "world";
|
||||
constructor() {
|
||||
super();
|
||||
this.bindAction(generatedActions.notifyTest, this.onTest);
|
||||
this.bindActions(explicitActions);
|
||||
this.exportAsync(testSource);
|
||||
this.exportPublicMethods({
|
||||
split: this.split
|
||||
});
|
||||
}
|
||||
onTest(str:string) {
|
||||
this.hello = str;
|
||||
}
|
||||
|
||||
onDoTest(str:string) {
|
||||
this.hello = str;
|
||||
}
|
||||
|
||||
split():string[] {
|
||||
return this.hello.split("");
|
||||
}
|
||||
}
|
||||
|
||||
interface ExtendedTestStore extends AltJS.AltStore<AltTestState> {
|
||||
fakeLoad():string;
|
||||
split():Array<string>;
|
||||
}
|
||||
|
||||
var testStore = <ExtendedTestStore>alt.createStore<AltTestState>(TestStore);
|
||||
|
||||
function testCallback(state:AltTestState) {
|
||||
console.log(state);
|
||||
}
|
||||
|
||||
//Listen allows a typed state callback
|
||||
testStore.listen(testCallback);
|
||||
testStore.unlisten(testCallback);
|
||||
|
||||
//State generic passes to derived store
|
||||
var name:string = testStore.getState().hello;
|
||||
var nameChars:Array<string> = testStore.split();
|
||||
|
||||
generatedActions.notifyTest("types");
|
||||
explicitActions.doTest("more types");
|
||||
|
||||
export var result = testStore.getState();
|
||||
Vendored
+166
@@ -0,0 +1,166 @@
|
||||
// Type definitions for Alt 0.16.10
|
||||
// Project: https://github.com/goatslacker/alt
|
||||
// Definitions by: Michael Shearer <https://github.com/Shearerbeard>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../react/react.d.ts"/>
|
||||
|
||||
declare namespace AltJS {
|
||||
|
||||
interface StoreReduce {
|
||||
action:any;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface StoreModel<S> {
|
||||
//Actions
|
||||
bindAction?( action:Action<any>, handler:ActionHandler):void;
|
||||
bindActions?(actions:ActionsClass):void;
|
||||
|
||||
//Methods/Listeners
|
||||
exportPublicMethods?(exportConfig:any):void;
|
||||
bindListeners?(config:{[methodName:string]:Action<any> | Actions}):void;
|
||||
exportAsync?(source:Source):void;
|
||||
registerAsync?(datasource:Source):void;
|
||||
|
||||
//state
|
||||
setState?(state:S):void;
|
||||
setState?(stateFn:(currentState:S, nextState:S) => S):void;
|
||||
getState?():S;
|
||||
waitFor?(store:AltStore<any>):void;
|
||||
|
||||
//events
|
||||
onSerialize?(fn:(data:any) => any):void;
|
||||
onDeserialize?(fn:(data:any) => any):void;
|
||||
on?(event:AltJS.lifeCycleEvents, callback:() => any):void;
|
||||
emitChange?():void;
|
||||
waitFor?(storeOrStores:AltStore<any> | Array<AltStore<any>>):void;
|
||||
otherwise?(data:any, action:AltJS.Action<any>):void;
|
||||
observe?(alt:Alt):any;
|
||||
reduce?(state:any, config:StoreReduce):Object;
|
||||
preventDefault?():void;
|
||||
afterEach?(payload:Object, state:Object):void;
|
||||
beforeEach?(payload:Object, state:Object):void;
|
||||
// TODO: Embed dispatcher interface in def
|
||||
dispatcher?:any;
|
||||
|
||||
//instance
|
||||
getInstance?():AltJS.AltStore<S>;
|
||||
alt?:Alt;
|
||||
displayName?:string;
|
||||
}
|
||||
|
||||
export type Source = {[name:string]: () => SourceModel<any>};
|
||||
|
||||
export interface SourceModel<S> {
|
||||
local(state:any, ...args: any[]):any;
|
||||
remote(state:any, ...args: any[]):Promise<S>;
|
||||
shouldFetch?(fetchFn:(...args:Array<any>) => boolean):void;
|
||||
loading?:(args:any) => void;
|
||||
success?:(state:S) => void;
|
||||
error?:(args:any) => void;
|
||||
interceptResponse?(response:any, action:Action<any>, ...args:Array<any>):any;
|
||||
}
|
||||
|
||||
export interface AltStore<S> {
|
||||
getState():S;
|
||||
listen(handler:(state:S) => any):() => void;
|
||||
unlisten(handler:(state:S) => any):void;
|
||||
emitChange():void;
|
||||
}
|
||||
|
||||
export enum lifeCycleEvents {
|
||||
bootstrap,
|
||||
snapshot,
|
||||
init,
|
||||
rollback,
|
||||
error
|
||||
}
|
||||
|
||||
export type Actions = {[action:string]:Action<any>};
|
||||
|
||||
export interface Action<T> {
|
||||
( args:T):void;
|
||||
defer(data:any):void;
|
||||
}
|
||||
|
||||
export interface ActionsClass {
|
||||
generateActions?( ...action:Array<string>):void;
|
||||
dispatch( ...payload:Array<any>):void;
|
||||
actions?:Actions;
|
||||
}
|
||||
|
||||
type StateTransform = (store:StoreModel<any>) => AltJS.AltStore<any>;
|
||||
|
||||
interface AltConfig {
|
||||
dispatcher?:any;
|
||||
serialize?:(serializeFn:(data:Object) => string) => void;
|
||||
deserialize?:(deserializeFn:(serialData:string) => Object) => void;
|
||||
storeTransforms?:Array<StateTransform>;
|
||||
batchingFunction?:(callback:( ...data:Array<any>) => any) => void;
|
||||
}
|
||||
|
||||
class Alt {
|
||||
constructor(config?:AltConfig);
|
||||
actions:Actions;
|
||||
bootstrap(jsonData:string):void;
|
||||
takeSnapshot( ...storeNames:Array<string>):string;
|
||||
flush():Object;
|
||||
recycle( ...stores:Array<AltJS.AltStore<any>>):void;
|
||||
rollback():void;
|
||||
dispatch(action?:AltJS.Action<any>, data?:Object, details?:any):void;
|
||||
|
||||
//Actions methods
|
||||
addActions(actionsName:string, ActionsClass: ActionsClassConstructor):void;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object):T;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object, ...constructorArgs:Array<any>):T;
|
||||
generateActions<T>( ...actions:Array<string>):T;
|
||||
getActions(actionsName:string):AltJS.Actions;
|
||||
|
||||
//Stores methods
|
||||
addStore(name:string, store:StoreModel<any>, saveStore?:boolean):void;
|
||||
createStore<S>(store:StoreModel<S>, name?:string):AltJS.AltStore<S>;
|
||||
getStore(name:string):AltJS.AltStore<any>;
|
||||
}
|
||||
|
||||
export interface AltFactory {
|
||||
new(config?:AltConfig):Alt;
|
||||
}
|
||||
|
||||
type ActionsClassConstructor = new (alt:Alt) => AltJS.ActionsClass;
|
||||
|
||||
type ActionHandler = ( ...data:Array<any>) => any;
|
||||
type ExportConfig = {[key:string]:(...args:Array<any>) => any};
|
||||
}
|
||||
|
||||
declare module "alt/utils/chromeDebug" {
|
||||
function chromeDebug(alt:AltJS.Alt):void;
|
||||
export = chromeDebug;
|
||||
}
|
||||
|
||||
declare module "alt/AltContainer" {
|
||||
|
||||
import React = require("react");
|
||||
|
||||
interface ContainerProps {
|
||||
store?:AltJS.AltStore<any>;
|
||||
stores?:Array<AltJS.AltStore<any>>;
|
||||
inject?:{[key:string]:any};
|
||||
actions?:{[key:string]:Object};
|
||||
render?:(...props:Array<any>) => React.ReactElement<any>;
|
||||
flux?:AltJS.Alt;
|
||||
transform?:(store:AltJS.AltStore<any>, actions:any) => any;
|
||||
shouldComponentUpdate?:(props:any) => boolean;
|
||||
component?:React.Component<any, any>;
|
||||
}
|
||||
|
||||
type AltContainer = React.ReactElement<ContainerProps>;
|
||||
var AltContainer:React.ComponentClass<ContainerProps>;
|
||||
|
||||
export = AltContainer;
|
||||
}
|
||||
|
||||
declare module "alt" {
|
||||
var alt:AltJS.AltFactory;
|
||||
export = alt;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/// <reference path="./amazon-product-api.d.ts" />
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
import amazon = require('amazon-product-api');
|
||||
|
||||
var client = amazon.createClient({
|
||||
awsId: process.env.AWS_ACCESS_KEY_ID,
|
||||
awsSecret: process.env.AWS_SECRET,
|
||||
awsTag: process.env.AWS_ASSOCIATE_TAG
|
||||
});
|
||||
|
||||
|
||||
// Item Search
|
||||
|
||||
var searchQuery = {
|
||||
director: 'Quentin Tarantino',
|
||||
actor: 'Samuel L. Jackson',
|
||||
searchIndex: 'DVD',
|
||||
audienceRating: 'R',
|
||||
responseGroup: 'ItemAttributes,Offers,Images'
|
||||
};
|
||||
|
||||
client.itemSearch(searchQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " search results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.itemSearch(searchQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(getResultCount(results) + " search results");
|
||||
});
|
||||
|
||||
|
||||
// Item Lookup
|
||||
|
||||
var lookupQuery = {
|
||||
itemId: 'B00008OE6I',
|
||||
idType: 'ASIN',
|
||||
responseGroup: 'OfferFull',
|
||||
Condition: 'All'
|
||||
};
|
||||
|
||||
client.itemLookup(lookupQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.itemLookup(lookupQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
});
|
||||
|
||||
// Browse Node Lookup
|
||||
|
||||
var nodeLookupQuery = {
|
||||
browseNodeId: '2625373011'
|
||||
};
|
||||
|
||||
client.browseNodeLookup(nodeLookupQuery).then((results) => {
|
||||
console.log(getResultCount(results) + " node lookup results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.browseNodeLookup(nodeLookupQuery, (err, results) => {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(getResultCount(results) + " node lookup results");
|
||||
});
|
||||
|
||||
function getResultCount(results: Object[]) {
|
||||
return results != undefined ? results.length : 0;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// Type definitions for amazon-product-api
|
||||
// Project: https://github.com/t3chnoboy/amazon-product-api
|
||||
// Definitions by: Matti Lehtinen <https://github.com/MattiLehtinen/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "amazon-product-api" {
|
||||
|
||||
interface ICredentials {
|
||||
awsId: string,
|
||||
awsSecret: string,
|
||||
awsTag: string
|
||||
}
|
||||
|
||||
interface IAmazonProductQueryCallback {
|
||||
(err: string, results: Object[]): void;
|
||||
}
|
||||
|
||||
interface IAmazonProductClient {
|
||||
itemSearch(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
itemLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
browseNodeLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
|
||||
}
|
||||
|
||||
export function createClient(credentials:ICredentials) : IAmazonProductClient;
|
||||
}
|
||||
Vendored
+360
-122
@@ -1,10 +1,10 @@
|
||||
// Type definitions for amCharts
|
||||
// Project: http://www.amcharts.com/
|
||||
// Definitions by: aleksey-bykov <https://github.com/aleksey-bykov>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page.
|
||||
declare module AmCharts {
|
||||
declare namespace AmCharts {
|
||||
|
||||
/** Set it to true if you have base href set for your page. This will fix rendering problems in Firefox caused by base href. */
|
||||
var baseHref: boolean;
|
||||
@@ -26,17 +26,33 @@ declare module AmCharts {
|
||||
|
||||
/** Clears all the charts on page, removes listeners and intervals. */
|
||||
function clear();
|
||||
|
||||
/** Handle ready event */
|
||||
function ready(Function): void;
|
||||
|
||||
/** Create chart by params. */
|
||||
function makeChart(selector: string, params: any, delay?: number): AmChart;
|
||||
|
||||
/** Set a method to be called before initializing the chart.
|
||||
* When the method is called, the chart instance is passed as an attribute.
|
||||
* You can use this feature to preprocess chart data or do some other things you need
|
||||
* before initializing the chart.
|
||||
* @param {Function} handler - The method to be called.
|
||||
* @param {string[]} types - Which chart types should call this method. Defaults to all
|
||||
* if none is passed.
|
||||
*/
|
||||
function addInitHandler(handler: Function, types: string[]);
|
||||
|
||||
/** AmPieChart class creates pie/donut chart. In order to display pie chart you need to set at least three properties - dataProvider, titleField and valueField.
|
||||
@example
|
||||
var chartData = [{title:"Pie I have eaten",value:70},{title:"Pie I haven\'t eaten",value:30}];
|
||||
var chartData = [{title:"Pie I have eaten",value:70},{title:"Pie I haven\'t eaten",value:30}];
|
||||
var chart = new AmCharts.AmPieChart();
|
||||
chart.valueField = "value";
|
||||
chart.titleField = "title";
|
||||
chart.dataProvider = chartData;
|
||||
chart.write("chartdiv");
|
||||
*/
|
||||
class AmPieChart {
|
||||
class AmPieChart extends AmChart {
|
||||
/** Name of the field in chart's dataProvider which holds slice's alpha. */
|
||||
alphaField: string;
|
||||
/** Pie lean angle (for 3D effect). Valid range is 0 - 90. */
|
||||
@@ -113,7 +129,7 @@ declare module AmCharts {
|
||||
outlineAlpha: number;
|
||||
/** Pie outline color. #FFFFFF */
|
||||
outlineColor: string;
|
||||
/** Pie outline thickness.
|
||||
/** Pie outline thickness.
|
||||
@default 1
|
||||
*/
|
||||
outlineThickness: number;
|
||||
@@ -178,28 +194,15 @@ declare module AmCharts {
|
||||
/** You can trigger the animation of the pie chart. */
|
||||
animateAgain();
|
||||
/** You can trigger the click on a slice from outside. index - the number of a slice or Slice object. */
|
||||
clickSlice(index);
|
||||
clickSlice(index: number);
|
||||
/** Hides slice. index - the number of a slice or Slice object. */
|
||||
hideSlice(index);
|
||||
hideSlice(index: number);
|
||||
/** You can simulate roll-out of a slice from outside. index - the number of a slice or Slice object. */
|
||||
rollOutSlice(index);
|
||||
rollOutSlice(index: number);
|
||||
/** You can simulate roll-over a slice from outside. index - the number of a slice or Slice object. */
|
||||
rollOverSlice(index);
|
||||
rollOverSlice(index: number);
|
||||
/** Shows slice. index - the number of a slice or Slice object. */
|
||||
showSlice(index);
|
||||
|
||||
/** Adds event listener of the type "clickSlice" or "pullInSlice" or "pullOutSlice" to the object.
|
||||
@param type Always "clickSlice" or "pullInSlice" or "pullOutSlice".
|
||||
@param handler
|
||||
If the type is "clickSlice", dispatched when user clicks on a slice.
|
||||
If the type is "pullInSlice", dispatched when user clicks on a slice and the slice is pulled-in.
|
||||
If the type is "pullOutSlice", dispatched when user clicks on a slice and the slice is pulled-out.
|
||||
If the type is "rollOutSlice", dispatched when user rolls-out of the slice.
|
||||
If the type is "rollOverSlice", dispatched when user rolls-over the slice.
|
||||
*/
|
||||
addListener(type: string, handler: (e: {/** Always "rollOverSlice". */
|
||||
type: string; dataItem: Slice;
|
||||
}) => void );
|
||||
showSlice(index: number);
|
||||
}
|
||||
|
||||
/** AmRadarChart is the class you have to use for radar and polar chart types.
|
||||
@@ -219,7 +222,7 @@ declare module AmCharts {
|
||||
chart.dataProvider = chartData;
|
||||
chart.categoryField = "country";
|
||||
chart.startDuration = 2;
|
||||
|
||||
|
||||
var valueAxis = new AmCharts.ValueAxis();
|
||||
valueAxis.axisAlpha = 0.15;
|
||||
valueAxis.minimum = 0;
|
||||
@@ -227,13 +230,13 @@ declare module AmCharts {
|
||||
valueAxis.axisTitleOffset = 20;
|
||||
valueAxis.gridCount = 5;
|
||||
chart.addValueAxis(valueAxis);
|
||||
|
||||
|
||||
var graph = new AmCharts.AmGraph();
|
||||
graph.valueField = "litres";
|
||||
graph.bullet = "round";
|
||||
graph.balloonText = "[[value]] litres of beer per year"
|
||||
chart.addGraph(graph);
|
||||
|
||||
|
||||
chart.write("chartdiv");
|
||||
}
|
||||
*/
|
||||
@@ -262,7 +265,7 @@ declare module AmCharts {
|
||||
{x:1, y:6, value:35}
|
||||
];
|
||||
|
||||
var chart = new AmCharts.AmXYChart();
|
||||
var chart = new AmCharts.AmXYChart();
|
||||
chart.pathToImages = "../../amcharts/javascript/images/";
|
||||
chart.dataProvider = chartData;
|
||||
chart.marginLeft = 35;
|
||||
@@ -276,7 +279,7 @@ declare module AmCharts {
|
||||
var yAxis = new AmCharts.ValueAxis();
|
||||
yAxis.position = "bottom";
|
||||
yAxis.autoGridCount = true;
|
||||
chart.addValueAxis(yAxis);
|
||||
chart.addValueAxis(yAxis);
|
||||
|
||||
var graph = new AmCharts.AmGraph();
|
||||
graph.valueField = "value";
|
||||
@@ -292,7 +295,7 @@ declare module AmCharts {
|
||||
var chartScrollbar = new AmCharts.ChartScrollbar();
|
||||
chartScrollbar.hideResizeGrips = false;
|
||||
chart.addChartScrollbar(chartScrollbar);
|
||||
|
||||
|
||||
chart.write("chartdiv);
|
||||
*/
|
||||
class AmXYChart extends AmRectangularChart {
|
||||
@@ -311,22 +314,32 @@ declare module AmCharts {
|
||||
|
||||
If you do not set properties such as dashLength, lineAlpha, lineColor, etc - values of the axis are used.*/
|
||||
class Guide {
|
||||
/** If you set it to true, the guide will be displayed above the graphs. */
|
||||
above: boolean;
|
||||
/** Radar chart only. Specifies angle at which guide should start. Affects only fills, not lines. */
|
||||
angle: number;
|
||||
/** Baloon fill color. */
|
||||
balloonColor: string;
|
||||
/** The text which will be displayed if the user rolls-over the guide. */
|
||||
balloonText: string;
|
||||
/** Specifies if label should be bold or not. */
|
||||
boldLabel: boolean;
|
||||
/** Category of the guide (in case the guide is for category axis). */
|
||||
category: string;
|
||||
/** Dash length. */
|
||||
dashLength: number;
|
||||
/** Date of the guide (in case the guide is for category axis and parseDates is set to true). */
|
||||
date: Date;
|
||||
/** Works if a guide is added to CategoryAxis and this axis is non-date-based. If you set it to true, the guide will start (or be placed, if it's not a fill) on the beginning of the category cell and will end at the end of toCategory cell. */
|
||||
expand: boolean;
|
||||
/** Fill opacity. Value range is 0 - 1. */
|
||||
fillAlpha: number;
|
||||
/** Fill color. */
|
||||
fillColor: string;
|
||||
/** Font size of guide label. */
|
||||
fontSize: string;
|
||||
/** Unique id of a Guide. You don't need to set it, unless you want to. */
|
||||
id: string;
|
||||
/** Specifies whether label should be placed inside or outside plot area. */
|
||||
inside: boolean;
|
||||
/** The label which will be displayed near the guide. */
|
||||
@@ -339,6 +352,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
lineColor: string;
|
||||
/** Line thickness. */
|
||||
lineThickness: number;
|
||||
/** Position of guide label. Possible values are "left" or "right" for horizontal axis and "top" or "bottom" for vertical axis. */
|
||||
position: string;
|
||||
/** Tick length. */
|
||||
tickLength: number;
|
||||
/** Radar chart only. Specifies angle at which guide should end. Affects only fills, not lines. */
|
||||
@@ -351,10 +366,12 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
toValue: number;
|
||||
/** Value of the guide (in case the guide is for value axis). */
|
||||
value: number;
|
||||
/** Value axis of a guide. As you can add guides directly to the chart, you might need to specify which which value axis should be used. */
|
||||
valueAxis: ValueAxis;
|
||||
}
|
||||
/** ImagesSettings is a class which holds common settings of all MapImage objects. */
|
||||
class ImagesSettings {
|
||||
/** Opacity of the image.
|
||||
/** Opacity of the image.
|
||||
@default 1
|
||||
*/
|
||||
alpha: number;
|
||||
@@ -368,7 +385,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
color: string;
|
||||
/** Height of a description window. */
|
||||
descriptionWindowHeight: number;
|
||||
/** Width of a description window.
|
||||
/** Width of a description window.
|
||||
@default 250
|
||||
*/
|
||||
descriptionWindowWidth: number;
|
||||
@@ -378,10 +395,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
descriptionWindowY: number;
|
||||
/** Label color. #000000 */
|
||||
labelColor: string;
|
||||
/** Font size of a label.
|
||||
/** Font size of a label.
|
||||
@default 11
|
||||
*/
|
||||
labelFontSize: number;
|
||||
labelfontSize: string;
|
||||
/** Position of the label. Allowed values are: left, right, top, bottom and middle. right */
|
||||
labelPosition: string;
|
||||
/** Label roll-over color. #00CC00 */
|
||||
@@ -546,7 +563,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Hides event bullets. */
|
||||
hideStockEvents();
|
||||
/** Removes event listener from the object. */
|
||||
removeListener(obj, type, handler);
|
||||
removeListener(obj: any, type: string, handler: any);
|
||||
/** Removes panel from the stock chart. Requires stockChart.validateNow() method to be called after this action. */
|
||||
removePanel(panel: StockPanel);
|
||||
/** Shows event bullets. */
|
||||
@@ -556,7 +573,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Method which forces the stock chart to rebuild. Should be called after properties are changed. */
|
||||
validateNow();
|
||||
/** Zooms chart to specified dates. startDate, endDate - Date objects. */
|
||||
zoom(startDate, endDate);
|
||||
zoom(startDate: Date, endDate: Date);
|
||||
/** Zooms out the chart. */
|
||||
zoomOut();
|
||||
|
||||
@@ -575,7 +592,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
|
||||
/** Adds event listener of the type "rollOutStockEvent" or "rollOverStockEvent" or "clickStockEvent" to the object.
|
||||
@param type // Either "rollOutStockEvent" or "rollOverStockEvent" or "clickStockEvent".
|
||||
@param handler
|
||||
@param handler
|
||||
If the type is "rollOutStockEvent", dispatched when the user rolls-out of the Stock event (bullet).
|
||||
If the type is "rollOverStockEvent", dispatched when the user rolls-over of the Stock event (bullet).
|
||||
If the type is "clickStockEvent", dispatched when the user clicks on the Stock event (bullet).
|
||||
@@ -716,7 +733,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
*/
|
||||
equalWidths: boolean;
|
||||
/** Font size. Will use chart's font size if not set. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Horizontal space between legend item and left/right border. */
|
||||
horizontalGap: number;
|
||||
/** The text which will be displayed in the legend. Tag [[title]] will be replaced with the title of the graph. [[title]] */
|
||||
@@ -789,6 +806,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
textClickEnabled: boolean;
|
||||
/** In case legend position is set to "absolute", you can set distance from top of the chart, in pixels. */
|
||||
top: number;
|
||||
/** Legend markers can mirror graph’s settings, displaying a line and a real bullet as in the graph itself.
|
||||
Set this property to true if you want to enable this feature. Note, if you set graph colors in dataProvider, they will not be reflected in the marker.
|
||||
@default false*/
|
||||
useGraphSettings: boolean;
|
||||
/** Specifies if legend labels should be use same color as corresponding markers. */
|
||||
useMarkerColorForLabels: boolean;
|
||||
/** Alignment of the value text. Possible values are "left" and "right". right */
|
||||
@@ -886,8 +907,17 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** AmChart is a base class of all charts. It can not be instantiated explicitly. AmCoordinateChart, AmPieChart and AmMap extend AmChart class. */
|
||||
class AmChart {
|
||||
/** used when constructing a chart with a theme */
|
||||
constructor(theme: any);
|
||||
/** Background color. You should set backgroundAlpha to >0 value in order background to be visible. We recommend setting background color directly on a chart's DIV instead of using this property. #FFFFFF */
|
||||
constructor(theme?: any);
|
||||
/** Specifies, if class names should be added to chart elements. */
|
||||
addClassNames: boolean;
|
||||
/** Array of Labels. Example of label object, with all possible properties:
|
||||
{"x": 20, "y": 20, "text": "this is label", "align": "left", "size": 12, "color": "#CC0000", "alpha": 1, "rotation": 0, "bold": true, "url": "http://www.amcharts.com"} */
|
||||
allLabels: Label[];
|
||||
/** Set this to false if you don't want chart to resize itself whenever its parent container size changes. */
|
||||
autoResize: boolean;
|
||||
/** Opacity of background. Set it to >0 value if you want backgroundColor to work. However we recommend changing div's background-color style for changing background color. */
|
||||
backgroundAlpha: number;
|
||||
/** Background color. You should set backgroundAlpha to >0 value in order background to be visible. We recommend setting background color directly on a chart's DIV instead of using this property. #FFFFFF */
|
||||
backgroundColor: string;
|
||||
/** The chart creates AmBalloon class itself. If you want to customize balloon, get balloon instance using this property, and then change balloon's properties. AmBalloon */
|
||||
balloon: AmBalloon;
|
||||
@@ -895,32 +925,89 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
borderAlpha: number;
|
||||
/** Color of chart's border. You should set borderAlpha >0 in order border to be visible. We recommend setting border color directly on a chart's DIV instead of using this property. #000000 */
|
||||
borderColor: string;
|
||||
/** This prefix is added to all class names which are added to all visual elements of a chart in case addClassNames is set to true. */
|
||||
classNamePrefix: string;
|
||||
/** Text color. #000000 */
|
||||
color: string;
|
||||
/** Non-commercial version only. Specifies position of link to amCharts site. Allowed values are: top-left, top-right, bottom-left and bottom-right.
|
||||
@default 'top-left'
|
||||
*/
|
||||
creditsPosition: string;
|
||||
/** Array of data objects, for example: [{country:"US", value:524},{country:"UK", value:624},{country:"Lithuania", value:824}]. You can have any number of fields and use any field names. In case of AmMap, data provider should be MapData object. */
|
||||
dataProvider: any[];
|
||||
/** Decimal separator.
|
||||
@Default . */
|
||||
decimalSeparator: string;
|
||||
/** Using this property you can add any additional information to SVG, like SVG filters or clip paths. The structure of this object should be identical to XML structure of a object you are adding, only in JSON format. */
|
||||
defs: any;
|
||||
/** Export config. Specifies how export to image/data export/print/annotate menu will look and behave. You can find a lot of examples in amcharts/plugins/export folder. */
|
||||
export: ExportSettings;
|
||||
/** Font family. Verdana */
|
||||
fontFamily: string;
|
||||
/** Font size.
|
||||
@default 11
|
||||
*/
|
||||
fontSize: number;
|
||||
/** Height of a chart. "100%" means the chart's height will be equal to it's container's (DIV) height and will resize if height of the container changes. Set a number instead of percents if your chart's size needs to be fixed.
|
||||
@default 1
|
||||
fontSize: string;
|
||||
/** If you set this to true, the lines of the chart will be distorted and will produce hand-drawn effect. Try to adjust chart.handDrawScatter and chart.handDrawThickness properties for a more scattered result.
|
||||
@Default false
|
||||
*/
|
||||
height: any;
|
||||
handDrawn: boolean;
|
||||
/** Defines by how many pixels hand-drawn line (when handDrawn is set to true) will fluctuate.
|
||||
@Default 2
|
||||
*/
|
||||
handDrawScatter: number;
|
||||
/** Defines by how many pixels line thickness will fluctuate (when handDrawn is set to true).
|
||||
@Default 1
|
||||
*/
|
||||
handDrawThickness: number;
|
||||
/** Time, in milliseconds after which balloon is hidden if the user rolls-out of the object. Might be useful for AmMap to avoid balloon flickering while moving mouse over the areas. Note, this is not duration of fade-out. Duration of fade-out is set in AmBalloon class.
|
||||
@Default 150
|
||||
*/
|
||||
hideBalloonTime: number;
|
||||
/** Allows changing language easily.
|
||||
* Note, you should include the language.js file from amcharts/lang or ammap/lang folder and then use variable name used in this file, like chart.language = "de";
|
||||
* Note, for maps this works differently - you use language only for country names, as there are no other strings in the maps application. */
|
||||
language: string;
|
||||
/** Legend of a chart. */
|
||||
legend: AmLegend;
|
||||
/** Reference to the div of the legend. */
|
||||
legendDiv: HTMLElement;
|
||||
/** Object with precision, decimalSeparator and thousandsSeparator set which will be used for number formatting. Precision set to -1 means that values won't be rounded. {precision:-1, decimalSeparator:'.', thousandsSeparator:','} */
|
||||
numberFormatter: Object;
|
||||
/** You can add listeners of events using this property. Example: listeners = [{"event":"dataUpdated", "method":handleEvent}]; */
|
||||
listerns: Object[];
|
||||
/** This setting affects touch-screen devices only. If a chart is on a page, and panEventsEnabled are set to true, the page won't move if the user touches the chart first. If a chart is big enough and occupies all the screen of your touch device, the user won’t be able to move the page at all. That's why the default value is "false". If you think that selecting/panning the chart or moving/pinching the map is a primary purpose of your users, you should set panEventsEnabled to true. */
|
||||
panEventsEnabled: boolean;
|
||||
/** Object with precision, decimalSeparator and thousandsSeparator set which will be used for formatting percent values. {precision:2, decimalSeparator:'.', thousandsSeparator:','} */
|
||||
percentFormatter: Object;
|
||||
/** Specifies absolute or relative path to amCharts files, i.e. "amcharts/". (where all .js files are located)
|
||||
If relative URLs are used, they will be relative to the current web page, displaying the chart.
|
||||
You can also set path globally, using global JavaScript variable AmCharts_path. If this variable is set, and "path" is not set in chart config, the chart will assume the path from the global variable. This allows setting amCharts path globally. I.e.:
|
||||
var AmCharts_path = "/libs/amcharts/";
|
||||
"path" parameter will be used by the charts to locate it's files, like images, plugins or patterns.*/
|
||||
path: string;
|
||||
/** Specifies path to the folder where images like resize grips, lens and similar are.
|
||||
IMPORTANT: Since V3.14.12, you should use "path" to point to amCharts directory instead. The "pathToImages" will be automatically set and does not need to be in the chart config, unless you keep your images separately from other amCharts files. */
|
||||
pathToImages: string;
|
||||
/** Precision of percent values. -1 means percent values won't be rounded at all and show as they are.
|
||||
@default 2
|
||||
*/
|
||||
percentPrecision: number;
|
||||
/** Precision of values. -1 means values won't be rounded at all and show as they are.
|
||||
@Default 1*/
|
||||
precision: number;
|
||||
/** Prefixes which are used to make big numbers shorter: 2M instead of 2000000, etc. Prefixes are used on value axes and in the legend. To enable prefixes, set usePrefixes property to true. [{number:1e+3,prefix:"k"},{number:1e+6,prefix:"M"},{number:1e+9,prefix:"G"},{number:1e+12,prefix:"T"},{number:1e+15,prefix:"P"},{number:1e+18,prefix:"E"},{number:1e+21,prefix:"Z"},{number:1e+24,prefix:"Y"}] */
|
||||
prefixesOfBigNumbers: any[];
|
||||
/** Prefixes which are used to make small numbers shorter: 2μ instead of 0.000002, etc. Prefixes are used on value axes and in the legend. To enable prefixes, set usePrefixes property to true. [{number:1e-24, prefix:"y"},{number:1e-21, prefix:"z"},{number:1e-18, prefix:"a"},{number:1e-15, prefix:"f"},{number:1e-12, prefix:"p"},{number:1e-9, prefix:"n"},{number:1e-6, prefix:"μ"},{number:1e-3, prefix:"m"}] */
|
||||
prefixesOfSmallNumbers: any[];
|
||||
/** A config object for Responsive plugin. */
|
||||
responsive: any;
|
||||
/** Theme of a chart. Config files of themes can be found in amcharts/themes/ folder. More info about using themes. */
|
||||
theme: string;
|
||||
/** Thousands separator.
|
||||
@default .
|
||||
*/
|
||||
thousandsSeparator: string;
|
||||
/** Array of Title objects. */
|
||||
titles: Title[];
|
||||
/** Type of a chart. Required when creating chart using JSON. Possible types are: serial, pie, xy, radar, funnel, gauge, map, stock. */
|
||||
type: string;
|
||||
/** If true, prefixes will be used for big and small numbers. You can set arrays of prefixes via prefixesOfSmallNumbers and prefixesOfBigNumbers properties. */
|
||||
usePrefixes: boolean;
|
||||
/** Read-only. Indicates current version of a script. */
|
||||
@@ -938,7 +1025,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
bold - specifies if text is bold (true/false),
|
||||
url - url
|
||||
*/
|
||||
addLabel(x: number, y: number, text: string, align: string, size, color: string, rotation, alpha: number, bold: boolean, url: string);
|
||||
addLabel(x: number|string, y: number|string, text: string, align: string, size?: number, color?: string, rotation?: number, alpha?: number, bold?: boolean, url?: string);
|
||||
/** Adds a legend to the chart.
|
||||
By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter.
|
||||
(NOTE: This method will not work on StockPanel.)
|
||||
@@ -955,7 +1042,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
addLegend(legend: AmLegend, legendDiv: HTMLElement);
|
||||
|
||||
/** Adds title to the top of the chart. Pie, Radar positions are updated so that they won't overlap. Plot area of Serial/XY chart is also updated unless autoMargins property is set to false. You can add any number of titles - each of them will be placed in a new line. To remove titles, simply clear titles array: chart.titles = []; and call chart.validateNow() method. text - text of a title size - font size color - title color alpha - title opacity bold - boolean value indicating if title should be bold. */
|
||||
addTitle(text, size, color, alpha, bold);
|
||||
addTitle(text: string, size: number, color: string, alpha: number, bold: boolean);
|
||||
/** Clears the chart area, intervals, etc. */
|
||||
clear();
|
||||
/** Removes all labels added to the chart. */
|
||||
@@ -996,34 +1083,22 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** AmCoordinateChart is a base class of AmRectangularChart. It can not be instantiated explicitly. */
|
||||
|
||||
class AmCoordinateChart extends AmChart {
|
||||
/** Read-only. Array, holding processed chart's data. */
|
||||
chartData: Object[];
|
||||
/** Specifies the colors of the graphs if the lineColor of a graph is not set.
|
||||
It there are more graphs then colors in this array, the chart picks random color.
|
||||
@default ['#FF6600', '#FCD202', '#B0DE09', '#0D8ECF', '#2A0CD0', '#CD0D74', '#CC0000', '#00CC00', '#0000CC', '#DDDDDD', '#999999', '#333333', '#990000'] */
|
||||
colors: any[];
|
||||
colors: string[];
|
||||
/** The array of graphs belonging to this chart.
|
||||
To add/remove graph use addGraph/removeGraph methods instead of adding/removing graphs directly to array.
|
||||
*/
|
||||
graphs: any[];
|
||||
/** The opacity of plot area's border.
|
||||
Value range is 0 - 1.
|
||||
graphs: AmGraph[];
|
||||
/** Specifies if grid should be drawn above the graphs or below. Will not work properly with 3D charts.
|
||||
@default false
|
||||
*/
|
||||
plotAreaBorderAlpha: number;
|
||||
/** The color of the plot area's border.
|
||||
Note, the it is invisible by default, as plotAreaBorderAlpha default value is 0.
|
||||
Set it to a value higher than 0 to make it visible.
|
||||
@default #000000
|
||||
*/
|
||||
plotAreaBorderColor: string;
|
||||
/** Opacity of plot area.
|
||||
Plural form is used to keep the same property names as our Flex charts'.
|
||||
Flex charts can accept array of numbers to generate gradients.
|
||||
Although you can set array here, only first value of this array will be used.
|
||||
*/
|
||||
plotAreaFillAlphas: number;
|
||||
/** You can set both one color if you need a solid color or array of colors to generate gradients, for example: ["#000000", "#0000CC"]
|
||||
@default #FFFFFF
|
||||
*/
|
||||
plotAreaFillColors: any;
|
||||
gridAboveGraphs: boolean;
|
||||
/** Instead of adding guides to the axes, you can push all of them to this array. In case guide has category or date defined, it will automatically will be assigned to the category axis. Otherwise to first value axis, unless you specify a different valueAxis for the guide. */
|
||||
guides: Guide[];
|
||||
/** Specifies whether the animation should be sequenced or all objects should appear at once.
|
||||
@default true
|
||||
*/
|
||||
@@ -1053,6 +1128,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Adds a graph to the chart.
|
||||
*/
|
||||
addGraph(graph: AmGraph);
|
||||
/** Adds a legend to the chart. By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. (NOTE: This method will not work on StockPanel.) */
|
||||
/** Adds value axis to the chart.
|
||||
One value axis is created automatically, so if you don't want to change anything or add more value axes, you don't need to add it.
|
||||
*/
|
||||
@@ -1140,33 +1216,33 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
|
||||
/** SerialDataItem holds all the information about each series. When working with a chart, you do not create SerialDataItem objects or change it's properties directly. Consider properties of a SerialDataItem read-only - change values in chart's data provider if you need to. When serial chart parses dataProvider, it generates "chartData" array. Objects of this array are SerialDataItem objects. */
|
||||
class SerialDataItem {
|
||||
|
||||
|
||||
/** You can access each GraphDataItem using this object. The data structure is: graphDataItem = serialDataItem.axes[axisId].graphs[graphId]. */
|
||||
axes: Object;
|
||||
|
||||
|
||||
/** category value. String if parseDates is false, Date if true. */
|
||||
category: any;
|
||||
|
||||
|
||||
/** Timestamp of a series date. Avalable only if parseDates property of CategoryAxis is set to true. */
|
||||
time: number;
|
||||
|
||||
|
||||
/** Coordinate (horizontal or vertical, depends on chart's rotate property) of the series. */
|
||||
x: number;
|
||||
}
|
||||
|
||||
class CategoryAxis extends AxisBase {
|
||||
|
||||
|
||||
/** When parse dates is on for the category axis, the chart will try to highlight the beginning of the periods, like month, in bold. Set this to false to disable the functionality.
|
||||
@default true
|
||||
*/
|
||||
boldPeriodBeginning: boolean;
|
||||
|
||||
|
||||
/** Date formats of different periods. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, WW - weeks, YYYY - years. Check this page for date formatting strings. [{period:'fff',format:'JJ:NN:SS'},{period:'ss',format:'JJ:NN:SS'},{period:'mm',format:'JJ:NN'},{period:'hh',format:'JJ:NN'},{period:'DD',format:'MMM DD'},{period:'WW',format:'MMM DD'},{period:'MM',format:'MMM'},{period:'YYYY',format:'YYYY'}] */
|
||||
dateFormats: any[];
|
||||
|
||||
|
||||
/** In case your category axis values are Date objects and parseDates is set to true, the chart will parse dates and will place your data points at irregular intervals. However if you want dates to be parsed (displayed on the axis, baloons, etc), but data points to be placed at equal intervals (omiting dates with no data), set equalSpacing to true. */
|
||||
equalSpacing: boolean;
|
||||
|
||||
|
||||
/** Field in data provider which specifies if the category value should always be shown. For example: categoryAxis.forceShowField = "forceShow"; Field in data provider which specifies if the category value should always be shown. For example: categoryAxis.forceShowField = "forceShow";
|
||||
And in data:
|
||||
{category:"one", forceShow:true, value:100}
|
||||
@@ -1176,6 +1252,11 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Specifies if a grid line is placed on the center of a cell or on the beginning of a cell. Possible values are: "start" and "middle" This setting doesn't work if parseDates is set to true. middle */
|
||||
gridPosition: string;
|
||||
|
||||
/** Specifies if minor grid should be displayed.
|
||||
NOTE: If equalSpacing is set to true, this setting will be ignored.
|
||||
@default false*/
|
||||
minorGridEnabled: boolean;
|
||||
|
||||
/** Specifies the shortest period of your data. This should be set only if parseDates is set to "true". Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years. DD */
|
||||
minPeriod: string;
|
||||
|
||||
@@ -1185,17 +1266,25 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Specifies whether the graph should start on axis or not. In case you display columns, it is recommended to set this to false. If parseDates is set to true, startOnAxis will allways be false, unless equalSpacing is set to true. */
|
||||
startOnAxis: boolean;
|
||||
|
||||
/** Works only when parseDates is set to true and equalSpacing is false. If you set it to true, at the position where bigger period changes,
|
||||
category axis will display date strings of bot small and big period, in two rows.
|
||||
@default false*/
|
||||
twoLineMode: boolean;
|
||||
|
||||
/** Use line color for bullet
|
||||
@default false*/
|
||||
useLineColorForBulletBorder: boolean;
|
||||
/** Number returns coordinate of a category. Works only if parseDates is false. If parseDates is true, use dateToCoordinate method. category - String */
|
||||
categoryToCoordinate(category);
|
||||
categoryToCoordinate(category: string);
|
||||
|
||||
/** date - Date object Returns Date of the coordinate, in case parseDates is set to true and equalSpacing is set to false. coordinate - Number */
|
||||
coordinateToDate(coordinate);
|
||||
coordinateToDate(coordinate: number);
|
||||
|
||||
/** Number Returns coordinate of the date, in case parseDates is set to true. if parseDates is false, use categoryToCoordinate method. date - Date object */
|
||||
dateToCoordinate(date);
|
||||
|
||||
dateToCoordinate(date: Date);
|
||||
|
||||
/** Number Returns index of the category which is most close to specified coordinate. x - coordinate */
|
||||
xToIndex(x);
|
||||
xToIndex(x: number);
|
||||
}
|
||||
|
||||
/** ChartScrollbar class displays chart scrollbar. Supported by AmSerialChart and AmXYChart.
|
||||
@@ -1269,7 +1358,9 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
|
||||
/** AmRectangularChart is a base class of AmSerialChart and AmXYChart. It can not be instantiated explicitly.*/
|
||||
class AmRectangularChart extends AmCoordinateChart {
|
||||
/** The angle of the 3D part of plot area. This creates a 3D effect (if the "depth3D" is > 0). */
|
||||
/** The angle of the 3D part of plot area. This creates a 3D effect (if the "depth3D" is > 0).
|
||||
@default 0
|
||||
*/
|
||||
angle: number;
|
||||
/** Space left from axis labels/title to the chart's outside border, if autoMargins set to true.
|
||||
@default 10
|
||||
@@ -1279,11 +1370,12 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
@default true
|
||||
*/
|
||||
autoMargins: boolean;
|
||||
/** Chart cursor. */
|
||||
/** Cursor of a chart. */
|
||||
chartCursor: ChartCursor;
|
||||
/** Chart scrollbar. */
|
||||
chartScrollbar: ChartScrollbar;
|
||||
/** The depth of the 3D part of plot area. This creates a 3D effect (if the "angle" is > 0). */
|
||||
/** The depth of the 3D part of plot area. This creates a 3D effect (if the "angle" is > 0).
|
||||
@default 0*/
|
||||
depth3D: number;
|
||||
/** Number of pixels between the container's bottom border and plot area. This space can be used for bottom axis' values. If autoMargin is true and bottom side has axis, this property is ignored.
|
||||
@default 20
|
||||
@@ -1297,18 +1389,66 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
@default 20
|
||||
*/
|
||||
marginRight: number;
|
||||
/** Flag which should be set to false if you need margins to be recalculated on next chart.validateNow() call. */
|
||||
/** Flag which should be set to false if you need margins to be recalculated on next chart.validateNow() call.
|
||||
@default false
|
||||
*/
|
||||
marginsUpdated: boolean;
|
||||
/** Number of pixels between the container's top border and plot area. This space can be used for top axis' values. If autoMargin is true and top side has axis, this property is ignored.
|
||||
@default 20
|
||||
*/
|
||||
marginTop: number;
|
||||
/** The opacity of plot area's border. Value range is 0 - 1.
|
||||
@default 0
|
||||
*/
|
||||
plotAreaBorderAlpha: number;
|
||||
/** The color of the plot area's border. Note, the it is invisible by default, as plotAreaBorderAlpha default value is 0. Set it to a value higher than 0 to make it visible.
|
||||
@default '#000000'*/
|
||||
plotAreaBorderColor: string;
|
||||
/** Opacity of plot area. Plural form is used to keep the same property names as our Flex charts'. Flex charts can accept array of numbers to generate gradients. Although you can set array here, only first value of this array will be used.
|
||||
@default 0
|
||||
*/
|
||||
plotAreaFillAlphas: number;
|
||||
/** You can set both one color if you need a solid color or array of colors to generate gradients, for example: ["#000000", "#0000CC"]
|
||||
@default '#FFFFFF'
|
||||
*/
|
||||
plotAreaFillColors: any;
|
||||
/** If you are using gradients to fill the plot area, you can use this property to set gradient angle. The only allowed values are horizontal and vertical: 0, 90, 180, 270.
|
||||
@default 0
|
||||
*/
|
||||
plotAreaGradientAngle: number;
|
||||
/** Array of trend lines added to a chart. You can add trend lines to a chart using this array or access already existing trend lines */
|
||||
trendLines: any[];
|
||||
/** It's a simple object containing information about zoom-out button. Other available properties of this object are fontSize and color. color specifies text color of a button. {backgroundColor:'#b2e1ff',backgroundAlpha:1} */
|
||||
zoomOutButton: Object;
|
||||
trendLines: TrendLine[];
|
||||
/** Opacity of zoom-out button background.
|
||||
@default 0
|
||||
*/
|
||||
zoomOutButtonAlpha: number;
|
||||
/** Zoom-out button background color.
|
||||
@default '#e5e5e5'
|
||||
*/
|
||||
zoomOutButtonColor: string;
|
||||
/** Name of zoom-out button image. In the images folder there is another lens image, called lensWhite.png. You might want to have white lens when background is dark. Or you can simply use your own image.
|
||||
@default lens.png
|
||||
*/
|
||||
zoomOutButtonImage: string;
|
||||
/** Size of zoom-out button image
|
||||
@default: 17
|
||||
*/
|
||||
zoomOutButtonImageSize: number;
|
||||
/** Padding around the text and image.
|
||||
@default: 8
|
||||
*/
|
||||
zoomOutButtonPadding: number;
|
||||
/** Opacity of zoom-out button background when mouse is over it.
|
||||
@default: 1
|
||||
*/
|
||||
zoomOutButtonRollOverAlpha: number;
|
||||
/** Text in the zoom-out button. Show all */
|
||||
zoomOutText: string;
|
||||
|
||||
/** Adds a ChartCursor object to a chart */
|
||||
addChartCursor(cursor: ChartCursor);
|
||||
/** Adds a ChartScrollbar to a chart */
|
||||
addChartScrollbar(scrollbar: ChartScrollbar);
|
||||
/** Adds a TrendLine to a chart.
|
||||
You should call chart.validateNow() after this method is called in order the trend line to be visible. */
|
||||
addTrendLine(trendLine: TrendLine);
|
||||
@@ -1316,9 +1456,9 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
removeChartCursor();
|
||||
/** Removes scrollbar from the chart */
|
||||
removeChartScrollbar();
|
||||
/** Removes a trend line from a chart.
|
||||
/** Removes a trend line from a chart.
|
||||
You should call chart.validateNow() in order the changes to be visible. */
|
||||
removeTrendLine;
|
||||
removeTrendLine(trendLine: TrendLine);
|
||||
}
|
||||
|
||||
/* Trend lines are straight lines indicating trends, might also be used for some different purposes. Can be used by Serial and XY charts. To add/remove trend line, use chart.addTrendLine(trendLine)/chart.removeTrendLine(trendLine) methods or simply pass array of trend lines: chart.trendLines = [trendLine1, trendLine2].
|
||||
@@ -1356,7 +1496,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
categoryBalloonColor: string;
|
||||
/** Category balloon date format (used only if category axis parses dates). Check this page for instructions on how to format dates. MMM DD, YYYY */
|
||||
categoryBalloonDateFormat: string;
|
||||
/** Specifies whether category balloon is enabled.
|
||||
/** Specifies whether category balloon is enabled.
|
||||
@default true
|
||||
*/
|
||||
categoryBalloonEnabled: boolean;
|
||||
@@ -1372,6 +1512,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
@default true
|
||||
*/
|
||||
enabled: boolean;
|
||||
/** If set to true, instead of a cursor line user will see a fill which width will always be equal to the width of one data item.
|
||||
Recommend setting cursorAlpha to 0.1 or some other small number if using this feature.
|
||||
@default false*/
|
||||
fullWidth: boolean;
|
||||
/** If this is set to true, only one balloon at a time will be displayed. Note, this is quite CPU consuming. */
|
||||
oneBalloonOnly: boolean;
|
||||
/** If this is set to true, the user will be able to pan the chart (Serial only) instead of zooming. */
|
||||
@@ -1395,7 +1539,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Hides cursor. */
|
||||
hideCursor();
|
||||
/** You can force cursor to appear at specified cateogry or date. */
|
||||
showCursorAt(category);
|
||||
showCursorAt(category: string);
|
||||
/** Adds event listener of the type "changed" to the object.
|
||||
@param type Always "changed".
|
||||
@param handler Dispatched when cursor position is changed. "index" is a series index over which chart cursors currently is. "zooming" specifies if user is currently zooming (is selecting) the chart. mostCloseGraph property is set only when oneBalloonOnly is set to true.*/
|
||||
@@ -1425,34 +1569,40 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** AmSerialChart is the class you have to use for majority of chart types. The supported chart types are: line, area, column, bar, step line, smoothed line, candlestick and OHLC. The chart can be rotated by 90 degrees so the column chart becomes bar chart. The chart supports simple and logarithmic scales, it can have multiple value axes. The chart can place data points at equal intervals or can parse dates and place data points at irregular intervals.
|
||||
@example
|
||||
var chartData = [{title:"sample 1",value:130},{title:"sample 2",value:26}];
|
||||
|
||||
|
||||
var chart = new AmCharts.AmSerialChart();
|
||||
chart.categoryField = "title";
|
||||
chart.dataProvider = chartData;
|
||||
|
||||
|
||||
var graph = new AmCharts.AmGraph();
|
||||
graph.valueField = "value";
|
||||
graph.type = "column";
|
||||
graph.fillAlphas = 1;
|
||||
chart.addGraph(graph);
|
||||
|
||||
|
||||
chart.write("chartdiv");
|
||||
*/
|
||||
class AmSerialChart extends AmRectangularChart {
|
||||
/** Read-only. Chart creates category axis itself. If you want to change some properties, you should get this axis from the chart and set properties to this object. */
|
||||
/** Date format of the graph balloon (if chart parses dates and you don't use chartCursor).
|
||||
@default 'MMM DD, YYYY'
|
||||
*/
|
||||
balloonDateFormat: string;
|
||||
/** Read-only. Chart creates category axis itself. If you want to change some properties, you should get this axis from the chart and set properties to this object. */
|
||||
categoryAxis: CategoryAxis;
|
||||
/** Category field name tells the chart the name of the field in your dataProvider object which will be used for category axis values. */
|
||||
categoryField: string;
|
||||
/** Read-only. Array of SerialDataItem objects generated from dataProvider. */
|
||||
chartData: any[];
|
||||
/** The gap in pixels between two columns of the same category.
|
||||
@default 5
|
||||
*/
|
||||
columnSpacing: number;
|
||||
/** Relative width of columns. Value range is 0 - 1. 0.8 */
|
||||
/** Space between 3D stacked columns.
|
||||
@default 0
|
||||
*/
|
||||
columnSpacing3D: number;
|
||||
/** Relative width of columns. Value range is 0 - 1.
|
||||
@default 0.8
|
||||
*/
|
||||
columnWidth: number;
|
||||
/** Array holding chart's data. */
|
||||
dataProvider: any[];
|
||||
/** Read-only. If category axis parses dates endDate indicates date to which the chart is currently displayed. */
|
||||
endDate: Date;
|
||||
/** Read-only. Category index to which the chart is currently displayed. */
|
||||
@@ -1461,8 +1611,14 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
maxSelectedSeries: number;
|
||||
/** The longest time span allowed to select (in milliseconds) for example, 259200000 will limit selection to 3 days. */
|
||||
maxSelectedTime: number;
|
||||
/** The shortest time span allowed to select (in milliseconds) for example, 1000 will limit selection to 1 second. */
|
||||
/** The shortest time span allowed to select (in milliseconds) for example, 1000 will limit selection to 1 second.
|
||||
@default 0
|
||||
*/
|
||||
minSelectedTime: number;
|
||||
/** Specifies if scrolling of a chart with mouse wheel is enabled. If you press shift while rotating mouse wheel, the chart will zoom-in/out. */
|
||||
mouseWheelScrollEnabled: boolean;
|
||||
/** Specifies if zooming of a chart with mouse wheel is enabled. If you press shift while rotating mouse wheel, the chart will scroll. */
|
||||
mouseWheelZoomEnabled: boolean;
|
||||
/** If you set this to true, the chart will be rotated by 90 degrees (the columns will become bars). */
|
||||
rotate: boolean;
|
||||
/** Read-only. If category axis parses dates startDate indicates date from which the chart is currently displayed. */
|
||||
@@ -1475,15 +1631,15 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
zoomOutOnDataUpdate: boolean;
|
||||
|
||||
/** Number Returns index of the specified category value. value - series (category value) which index you want to find. */
|
||||
getCategoryIndexByValue(value);
|
||||
getCategoryIndexByValue(value: number);
|
||||
/** Zooms out, charts shows all available data. */
|
||||
zoomOut();
|
||||
/** Zooms the chart by the value of the category axis. start - category value, String \\ end - category value, String */
|
||||
zoomToCategoryValues(start, end);
|
||||
zoomToCategoryValues(start: Date, end: Date);
|
||||
/** Zooms the chart from one date to another. start - start date, Date object \\ end - end date, Date object */
|
||||
zoomToDates(start, end);
|
||||
zoomToDates(start: Date, end: Date);
|
||||
/** Zooms the chart by the index of the category. start - start index, Number \\ end - end index, Number */
|
||||
zoomToIndexes(start, end);
|
||||
zoomToIndexes(start: Date, end: Date);
|
||||
}
|
||||
|
||||
class PeriodSelector {
|
||||
@@ -1522,7 +1678,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
.
|
||||
@param handler - Dispatched when dates in period selector input fields are changed or user clicks on one of the predefined period buttons. */
|
||||
|
||||
addListener(type, handler: (e: {
|
||||
addListener(type: string, handler: (e: {
|
||||
/** Always: "changed" */
|
||||
|
||||
type: string;
|
||||
@@ -1695,6 +1851,31 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
urlTarget: string;
|
||||
}
|
||||
|
||||
/** Creates a label on the chart which can be placed anywhere, multiple can be assigned. */
|
||||
class Label {
|
||||
/** @Default 'left' */
|
||||
align: string;
|
||||
/** @Default 1 */
|
||||
alpha: number;
|
||||
/** Specifies if label is bold or not. */
|
||||
bold: boolean;
|
||||
/** Color of a label */
|
||||
color: string;
|
||||
/** Unique id of a Label. You don't need to set it, unless you want to. */
|
||||
id: string;
|
||||
/** Rotation angle. */
|
||||
rotation: number;
|
||||
/** Text size */
|
||||
size: number;
|
||||
/** Text of a label */
|
||||
text: string;
|
||||
/** URL which will be access if user clicks on a label. */
|
||||
url: string;
|
||||
/** X position of a label. */
|
||||
x: number|string;
|
||||
/** y position of a label. */
|
||||
y: number|string;
|
||||
}
|
||||
/** Common settings of legends. If you change a property after the chart is initialized, you should call stockChart.validateNow() method in order for it to work. If there is no default value specified, default value of StockLegend class will be used. */
|
||||
class LegendSettings {
|
||||
/** Alignment of legend entries. Possible values are: "left", "right" and "center". */
|
||||
@@ -1807,7 +1988,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Balloon background color. Usually balloon background color is set by the chart. Only if "adjustBorderColor" is "true" this color will be used. #CC0000 */
|
||||
fillColor: string;
|
||||
/** Size of text in the balloon. Chart's fontSize is used by default. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Horizontal padding of the balloon.
|
||||
@default 8
|
||||
3*/
|
||||
@@ -1865,7 +2046,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Fill color. Every second space between grid lines can be filled with color. Set fillAlpha to a value greater than 0 to see the fills. */
|
||||
fillColor: string;
|
||||
/** Text size. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Opacity of grid lines. */
|
||||
gridAlpha: number;
|
||||
/** Color of grid lines. */
|
||||
@@ -1945,7 +2126,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
*/
|
||||
enabled: boolean;
|
||||
/** Font size. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Specifies which graph will be displayed in the scrollbar. */
|
||||
graph: AmGraph;
|
||||
/** Graph fill opacity. */
|
||||
@@ -2004,6 +2185,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
alphaField: string;
|
||||
/** Value balloon color. Will use graph or data item color if not set. */
|
||||
balloonColor: string;
|
||||
/** If you set some function, the graph will call it and pass GraphDataItem and AmGraph object to it. This function should return a string which will be displayed in a balloon. */
|
||||
balloonFunction(graphDataItem: GraphDataItem, amGraph: AmGraph): string;
|
||||
/** Balloon text. You can use tags like [[value]], [[description]], [[percents]], [[open]], [[category]] [[value]] */
|
||||
balloonText: string;
|
||||
/** Specifies if the line graph should be placed behind column graphs */
|
||||
@@ -2069,7 +2252,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** You can set another graph here and if fillAlpha is >0, the area from this graph to fillToGraph will be filled (instead of filling the area to the X axis). */
|
||||
fillToGraph: AmGraph;
|
||||
/** Size of value labels text. Will use chart's fontSize if not set. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Orientation of the gradient fills (only for "column" graph type). Possible values are "vertical" and "horizontal". vertical */
|
||||
gradientOrientation: string;
|
||||
/** Specifies whether the graph is hidden. Do not use this to show/hide the graph, use hideGraph(graph) and showGraph(graph) methods instead. */
|
||||
@@ -2193,7 +2376,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Fill color. Every second space between grid lines can be filled with color. Set fillAlpha to a value greater than 0 to see the fills. #FFFFFF */
|
||||
fillColor: string;
|
||||
/** Size of value labels text. Will use chart's fontSize if not set. */
|
||||
fontSize: number;
|
||||
fontSize: string;
|
||||
/** Opacity of grid lines. 0.2 */
|
||||
gridAlpha: number;
|
||||
/** Color of grid lines. #000000 */
|
||||
@@ -2247,7 +2430,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Color of axis title. Will use text color of chart if not set any. */
|
||||
titleColor: string;
|
||||
/** Font size of axis title. Will use font size of chart plus two pixels if not set any. */
|
||||
titleFontSize: number;
|
||||
titlefontSize: string;
|
||||
|
||||
/** Adds guide to the axis. */
|
||||
addGuide(guide:Guide);
|
||||
@@ -2269,24 +2452,43 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
durationUnits: Object;
|
||||
/** Radar chart only. Possible values are: "polygons" and "circles". Set "circles" for polar charts. polygons */
|
||||
gridType: string;
|
||||
/** Unique id of value axis. It is not required to set it, unless you need to tell the graph which exact value axis it should use. */
|
||||
id: string;
|
||||
/** Specifies whether guide values should be included when calculating min and max of the axis. */
|
||||
includeGuidesInMinMax: boolean;
|
||||
/** If true, the axis will include hidden graphs when calculating min and max values. */
|
||||
includeHidden: boolean;
|
||||
/** Specifies whether values on axis can only be integers or both integers and doubles. */
|
||||
integersOnly: boolean;
|
||||
/** You can use this function to format Value axis labels. This function is called and these parameters are passed: labelFunction(value, valueText, valueAxis);
|
||||
Where value is numeric value, valueText is formatted string and valueAxis is a reference to valueAxis object.
|
||||
|
||||
If axis type is "date", labelFunction will pass different arguments:
|
||||
labelFunction(valueText, date, valueAxis)
|
||||
|
||||
Your function should return string.*/
|
||||
labelFunction(value: number, valueText: string, valueAxis: ValueAxis): string;
|
||||
labelFunction(valueText: string, data: Date, valueAxis: ValueAxis): string;
|
||||
/** Specifies if this value axis' scale should be logarithmic. */
|
||||
logarithmic: boolean;
|
||||
/** Read-only. Maximum value of the axis. */
|
||||
max: number;
|
||||
/** If you don't want max value to be calculated by the chart, set it using this property. This value might still be adjusted so that it would be possible to draw grid at rounded intervals. */
|
||||
maximum: number;
|
||||
/** If your value axis is date-based, you can specify maximum date of the axis. Can be set as date object, timestamp number or string if dataDateFormat is set. */
|
||||
maximumData: Date;
|
||||
/** Read-only. Minimum value of the axis. */
|
||||
min: number;
|
||||
/** If you don't want min value to be calculated by the chart, set it using this property. This value might still be adjusted so that it would be possible to draw grid at rounded intervals. */
|
||||
minimum: number;
|
||||
/** If your value axis is date-based, you can specify minimum date of the axis. Can be set as date object, timestamp number or string if dataDateFormat is set. */
|
||||
minimumDate: Date;
|
||||
/** If set value axis scale (min and max numbers) will be multiplied by it. I.e. if set to 1.2 the scope of values will increase by 20%. */
|
||||
minMaxMultiplier: number;
|
||||
/** Works with radar charts only. If you set it to “middle”, labels and data points will be placed in the middle between axes. */
|
||||
pointPosition: string;
|
||||
/** Possible values are: "top", "bottom", "left", "right". If axis is vertical, default position is "left". If axis is horizontal, default position is "bottom". */
|
||||
position: string;
|
||||
/** Precision (number of decimals) of values. */
|
||||
precision: number;
|
||||
/** Radar chart only. Specifies if categories (axes' titles) should be displayed near axes)
|
||||
@@ -2301,10 +2503,22 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
stackType: string;
|
||||
/** Read-only. Value difference between two grid lines. */
|
||||
step: number;
|
||||
/** If you set minimum and maximum for your axis, chart adjusts them so that grid would start and end on the beginning and end of plot area and grid would be at equal intervals. If you set strictMinMax to true, the chart will not adjust minimum and maximum of value axis. */
|
||||
strictMinMax: boolean;
|
||||
/** In case you synchronize one value axis with another, you need to set the synchronization multiplier. Use synchronizeWithAxis method to set with which axis it should be synced. */
|
||||
synchronizationMultiplier: number;
|
||||
/** One value axis can be synchronized with another value axis. You can use both reference to your axis or id of the axis here. You should set synchronizationMultiplyer in order for this to work. */
|
||||
synchronizeWith: ValueAxis;
|
||||
/** If this value axis is stacked and has columns, setting valueAxis.totalText = "[[total]]" will make it to display total value above the most-top column. */
|
||||
totalText: string;
|
||||
/** Color of total text. */
|
||||
totalTextColor: string;
|
||||
/** Distance from data point to total text. */
|
||||
totalTextOffset: number;
|
||||
/** This allows you to have logarithmic value axis and have zero values in the data. You must set it to >0 value in order to work. */
|
||||
treatZeroAs: number;
|
||||
/** Type of value axis. If your values in data provider are dates and you want this axis to show dates instead of numbers, set it to "date". */
|
||||
type: string;
|
||||
/** Unit which will be added to the value label. */
|
||||
unit: string;
|
||||
/** Position of the unit. Possible values are "left" and "right". right */
|
||||
@@ -2314,20 +2528,23 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** If true, values will always be formatted using scientific notation (5e+8, 5e-8...) Otherwise only values bigger then 1e+21 and smaller then 1e-7 will be displayed in scientific notation. */
|
||||
useScientificNotation: boolean;
|
||||
|
||||
/** Adds guide to the axis. */
|
||||
addGuide(guide: Guide);
|
||||
/** Adds event listener to the object. type - string like 'axisChanged' (should be listed in 'events' section of this class or classes which extend this class). handler - function which is called when event happens */
|
||||
addListener(type, handler);
|
||||
addListener(type: string, handler: any);
|
||||
/** Number, - value of coordinate. Returns value of the coordinate. coordinate - y or x coordinate, in pixels. */
|
||||
coordinateToValue(coordinate);
|
||||
coordinateToValue(coordinate: number);
|
||||
/** Number - coordinate Returns coordinate of the value in pixels. value - Number */
|
||||
getCoordinate(value);
|
||||
|
||||
getCoordinate(value: number);
|
||||
/** Removes guide from the axis.*/
|
||||
removeGuide(guide: Guide);
|
||||
/** Removes event listener from the object. */
|
||||
removeListener(obj, type, handler);
|
||||
|
||||
removeListener(obj: any, type: string, handler: any);
|
||||
|
||||
/** One value axis can be synchronized with another value axis. You should set synchronizationMultiplyer in order for this to work. */
|
||||
synchronizeWithAxis(axis:ValueAxis);
|
||||
/** XY Chart only. Zooms-in the axis to the provided values. */
|
||||
zoomToValues(startValue, endValue);
|
||||
zoomToValues(startValue: number, endValue: number);
|
||||
|
||||
/** Adds event listener of the type "axisZoomed" to the object.
|
||||
@param type Always "axisZoomed".
|
||||
@@ -2347,4 +2564,25 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
/** Removes event listener from chart object. */
|
||||
removeListener(chart: AmChart, type: string, handler: any);
|
||||
}
|
||||
|
||||
class Title {
|
||||
/** @default 1 */
|
||||
alpha: number;
|
||||
/** Specifies if the tile is bold or not.
|
||||
@default false*/
|
||||
bold: boolean;
|
||||
/** Text color of a title. */
|
||||
color: string;
|
||||
/** Unique id of a Title. You don't need to set it, unless you want to. */
|
||||
id: string;
|
||||
/** Text size */
|
||||
size: number;
|
||||
/** Text of a label */
|
||||
text: string;
|
||||
}
|
||||
class ExportSettings {
|
||||
enabled: boolean;
|
||||
libs: Object;
|
||||
menu: Object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
/// <reference path="amplify-deferred.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
// Copied examples directly from AmplifyJs site
|
||||
|
||||
// Subscribe and publish with no data
|
||||
|
||||
amplify.subscribe("nodataexample", function () {
|
||||
alert("nodataexample topic published!");
|
||||
});
|
||||
|
||||
// Subscribe and publish with data
|
||||
|
||||
amplify.publish("nodataexample");
|
||||
|
||||
amplify.subscribe("dataexample", function (data) {
|
||||
alert(data.foo); // bar
|
||||
});
|
||||
|
||||
|
||||
amplify.publish("dataexample", { foo: "bar" });
|
||||
|
||||
amplify.subscribe("dataexample2", function (param1, param2) {
|
||||
alert(param1 + param2); // barbaz
|
||||
});
|
||||
|
||||
//...
|
||||
|
||||
amplify.publish("dataexample2", "bar", "baz");
|
||||
|
||||
// Subscribe and publish with context and data
|
||||
|
||||
amplify.subscribe("datacontextexample", $("p:first"), function (data) {
|
||||
this.text(data.exampleText); // first p element would have "foo bar baz" as text
|
||||
});
|
||||
|
||||
amplify.publish("datacontextexample", { exampleText: "foo bar baz" });
|
||||
|
||||
// Subscribe to a topic with high priority
|
||||
|
||||
amplify.subscribe("priorityexample", function (data) {
|
||||
alert(data.foo);
|
||||
});
|
||||
|
||||
amplify.subscribe("priorityexample", function (data) {
|
||||
if (data.foo === "oops") {
|
||||
return false;
|
||||
}
|
||||
}, 1);
|
||||
|
||||
|
||||
// Store data with amplify storage picking the default storage technology:
|
||||
|
||||
amplify.publish("priorityexample", { foo: "bar" });
|
||||
amplify.publish("priorityexample", { foo: "oops" });
|
||||
|
||||
amplify.store("storeExample1", { foo: "bar" });
|
||||
amplify.store("storeExample2", "baz");
|
||||
// retrieve the data later via the key
|
||||
var myStoredValue = amplify.store("storeExample1"),
|
||||
myStoredValue2 = amplify.store("storeExample2"),
|
||||
myStoredValues = amplify.store();
|
||||
myStoredValue.foo; // bar
|
||||
myStoredValue2; // baz
|
||||
myStoredValues.storeExample1.foo; // bar
|
||||
myStoredValues.storeExample2; // baz
|
||||
|
||||
// Store data explicitly with session storage
|
||||
|
||||
amplify.store.sessionStorage("explicitExample", { foo2: "baz" });
|
||||
// retrieve the data later via the key
|
||||
var myStoredValue2 = amplify.store.sessionStorage("explicitExample");
|
||||
myStoredValue2.foo2; // baz
|
||||
|
||||
|
||||
// REQUEST
|
||||
|
||||
// Set up and use a request utilizing Ajax
|
||||
|
||||
|
||||
amplify.request.define("ajaxExample1", "ajax", {
|
||||
url: "/myApiUrl",
|
||||
dataType: "json",
|
||||
type: "GET"
|
||||
});
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxExample1", function (data) {
|
||||
data.foo; // bar
|
||||
});
|
||||
|
||||
// Set up and use a request utilizing Ajax and Caching
|
||||
|
||||
amplify.request.define("ajaxExample2", "ajax", {
|
||||
url: "/myApiUrl",
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
cache: "persist"
|
||||
});
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxExample2", function (data) {
|
||||
data.foo; // bar
|
||||
});
|
||||
|
||||
// a second call will result in pulling from the cache
|
||||
amplify.request("ajaxExample2", function (data) {
|
||||
data.baz; // qux
|
||||
})
|
||||
|
||||
// Set up and use a RESTful request utilizing Ajax
|
||||
|
||||
amplify.request.define("ajaxRESTFulExample", "ajax", {
|
||||
url: "/myRestFulApi/{type}/{id}",
|
||||
type: "GET"
|
||||
})
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxRESTFulExample",
|
||||
{
|
||||
type: "foo",
|
||||
id: "bar"
|
||||
},
|
||||
function (data) {
|
||||
// /myRESTFulApi/foo/bar was the URL used
|
||||
data.foo; // bar
|
||||
}
|
||||
);
|
||||
|
||||
// POST data with Ajax
|
||||
|
||||
amplify.request.define("ajaxPostExample", "ajax", {
|
||||
url: "/myRestFulApi",
|
||||
type: "POST"
|
||||
})
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxPostExample",
|
||||
{
|
||||
type: "foo",
|
||||
id: "bar"
|
||||
},
|
||||
function (data) {
|
||||
data.foo; // bar
|
||||
}
|
||||
);
|
||||
// Using data maps
|
||||
|
||||
// When searching Twitter, the key for the search phrase is q.If we want a more descriptive name, such as term, we can use a data map:
|
||||
|
||||
amplify.request.define("twitter-search", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: {
|
||||
term: "q"
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request("twitter-search", { term: "amplifyjs" });
|
||||
|
||||
// Similarly, we can create a request that searches for mentions, by accepting a username:
|
||||
|
||||
amplify.request.define("twitter-mentions", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: function (data) {
|
||||
return {
|
||||
q: "@" + data.user
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request("twitter-mentions", { user: "amplifyjs" });
|
||||
|
||||
// Setting up and using decoders
|
||||
|
||||
//Example:
|
||||
|
||||
var appEnvelopeDecoder: amplifyDecoder = function (data, status, xhr, success, error) {
|
||||
if (data.status === "success") {
|
||||
success(data.data);
|
||||
} else if (data.status === "fail" || data.status === "error") {
|
||||
error(data.message, data.status);
|
||||
} else {
|
||||
error(data.message, "fatal");
|
||||
}
|
||||
};
|
||||
|
||||
//a new decoder can be added to the amplifyDecoders interface
|
||||
interface amplifyDecoders {
|
||||
appEnvelope: amplifyDecoder;
|
||||
}
|
||||
|
||||
amplify.request.decoders.appEnvelope = appEnvelopeDecoder;
|
||||
|
||||
//but you can also just add it via an index
|
||||
amplify.request.decoders['appEnvelopeStr'] = appEnvelopeDecoder;
|
||||
|
||||
|
||||
amplify.request.define("decoderExample", "ajax", {
|
||||
url: "/myAjaxUrl",
|
||||
type: "POST",
|
||||
decoder: "appEnvelope"
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "decoderExample",
|
||||
success: function (data) {
|
||||
data.foo; // bar
|
||||
},
|
||||
error: function (message, level) {
|
||||
alert("always handle errors with alerts.");
|
||||
}
|
||||
});
|
||||
|
||||
// POST with caching and single - use decoder
|
||||
|
||||
// Example:
|
||||
|
||||
amplify.request.define("decoderSingleExample", "ajax", {
|
||||
url: "/myAjaxUrl",
|
||||
type: "POST",
|
||||
decoder: function (data, status, xhr, success, error) {
|
||||
if (data.status === "success") {
|
||||
success(data.data);
|
||||
} else if (data.status === "fail" || data.status === "error") {
|
||||
error(data.message, data.status);
|
||||
} else {
|
||||
error(data.message, "fatal");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "decoderSingleExample",
|
||||
success: function (data) {
|
||||
data.foo; // bar
|
||||
},
|
||||
error: function (message, level) {
|
||||
alert("always handle errors with alerts.");
|
||||
}
|
||||
});
|
||||
// Handling Status
|
||||
// Status in Success and Error Callbacks
|
||||
|
||||
// amplify.request comes with built in support for status.The status parameter appears in the default success or error callbacks when using an ajax definition.
|
||||
|
||||
amplify.request.define("statusExample1", "ajax", {
|
||||
//...
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "statusExample1",
|
||||
success: function (data, status) {
|
||||
},
|
||||
error: function (data, status) {
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "statusExample1"
|
||||
}).done(function (data, status) {
|
||||
}).fail(function (data, status) {
|
||||
}).always(function (data, status) { });
|
||||
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
// Type definitions for AmplifyJs 1.1.0 using JQuery Deferred
|
||||
// Project: http://amplifyjs.com/
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>, Laurentiu Stamate <https://github.com/laurentiustamate94>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
interface amplifyRequestSettings {
|
||||
resourceId: string;
|
||||
data?: any;
|
||||
success?: (...args: any[]) => void;
|
||||
error?: (...args: any[]) => void;
|
||||
}
|
||||
|
||||
interface amplifyDecoder {
|
||||
(
|
||||
data?: any,
|
||||
status?: string,
|
||||
xhr?: JQueryXHR,
|
||||
success?: (...args: any[]) => void,
|
||||
error?: (...args: any[]) => void
|
||||
): void
|
||||
}
|
||||
|
||||
interface amplifyDecoders {
|
||||
[decoderName: string]: amplifyDecoder;
|
||||
jsSend: amplifyDecoder;
|
||||
}
|
||||
|
||||
interface amplifyAjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
dataMap?: {} | ((data: any) => {});
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
interface amplifyRequest {
|
||||
|
||||
/***
|
||||
* Request a resource.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data: A set of key/value pairs of data to be sent to the resource.
|
||||
* callback: A function to invoke if the resource is retrieved successfully.
|
||||
*/
|
||||
(resourceId: string, hash?: any, callback?: Function): JQueryPromise<any>;
|
||||
|
||||
/***
|
||||
* Request a resource.
|
||||
* settings: A set of key/value pairs of settings for the request.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data (optional): Data associated with the request.
|
||||
* success (optional): Function to invoke on success.
|
||||
* error (optional): Function to invoke on error.
|
||||
*/
|
||||
(settings: amplifyRequestSettings): JQueryPromise<any>;
|
||||
|
||||
/***
|
||||
* Define a resource.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* requestType: The type of data retrieval method from the server. See the request types sections for more information.
|
||||
* settings: A set of key/value pairs that relate to the server communication technology. The following settings are available:
|
||||
* Any settings found in jQuery.ajax().
|
||||
* cache: See the cache section for more details.
|
||||
* decoder: See the decoder section for more details.
|
||||
*/
|
||||
define(resourceId: string, requestType: string, settings?: amplifyAjaxSettings): void;
|
||||
|
||||
/***
|
||||
* Define a custom request.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* resource: Function to handle requests. Receives a hash with the following properties:
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data: Data provided by the user.
|
||||
* success: Callback to invoke on success.
|
||||
* error: Callback to invoke on error.
|
||||
*/
|
||||
define(resourceId: string, resource: (settings: amplifyRequestSettings) => void): void;
|
||||
|
||||
decoders: amplifyDecoders;
|
||||
cache: any;
|
||||
}
|
||||
|
||||
interface amplifySubscribe {
|
||||
/***
|
||||
* Subscribe to a message.
|
||||
* topic: Name of the message to subscribe to.
|
||||
* callback: Function to invoke when the message is published.
|
||||
*/
|
||||
(topic: string, callback: Function): void;
|
||||
/***
|
||||
* Subscribe to a message.
|
||||
* topic: Name of the message to subscribe to.
|
||||
* context: What this will be when the callback is invoked.
|
||||
* callback: Function to invoke when the message is published.
|
||||
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
|
||||
*/
|
||||
(topic: string, context: any, callback: Function, priority?: number): void;
|
||||
/***
|
||||
* Subscribe to a message.
|
||||
* topic: Name of the message to subscribe to.
|
||||
* callback: Function to invoke when the message is published.
|
||||
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
|
||||
*/
|
||||
(topic: string, callback: Function, priority?: number): void;
|
||||
}
|
||||
interface amplifyStorageTypeStore {
|
||||
/***
|
||||
* Stores a value for a given key using the default storage type.
|
||||
*
|
||||
* key: Identifier for the value being stored.
|
||||
* value: The value to store. The value can be anything that can be serialized as JSON.
|
||||
* [options]: A set of key/value pairs that relate to settings for storing the value.
|
||||
*/
|
||||
(key: string, value: any, options?: any): void;
|
||||
|
||||
/***
|
||||
* Gets a stored value based on the key.
|
||||
*/
|
||||
(key: string): any;
|
||||
|
||||
/***
|
||||
* Gets a hash of all stored values.
|
||||
*/
|
||||
(): any;
|
||||
}
|
||||
|
||||
interface amplifyStore extends amplifyStorageTypeStore {
|
||||
|
||||
/***
|
||||
* IE 8+, Firefox 3.5+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
|
||||
*/
|
||||
localStorage: amplifyStorageTypeStore;
|
||||
|
||||
/***
|
||||
* IE 8+, Firefox 2+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
|
||||
*/
|
||||
sessionStorage: amplifyStorageTypeStore;
|
||||
|
||||
/***
|
||||
* Firefox 2+
|
||||
*/
|
||||
globalStorage: amplifyStorageTypeStore;
|
||||
|
||||
/***
|
||||
* IE 5 - 7
|
||||
*/
|
||||
userData: amplifyStorageTypeStore;
|
||||
|
||||
/***
|
||||
* An in-memory store is provided as a fallback if none of the other storage types are available.
|
||||
*/
|
||||
memory: amplifyStorageTypeStore;
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface amplifyStatic {
|
||||
|
||||
subscribe: amplifySubscribe;
|
||||
|
||||
/***
|
||||
* Remove a subscription.
|
||||
* topic: The topic being unsubscribed from.
|
||||
* callback: The callback that was originally subscribed.
|
||||
*/
|
||||
unsubscribe(topic: string, callback: Function): void;
|
||||
|
||||
/***
|
||||
* Publish a message.
|
||||
* topic: The name of the message to publish.
|
||||
* Any additional parameters will be passed to the subscriptions.
|
||||
* amplify.publish returns a boolean indicating whether any subscriptions returned false. The return value is true if none of the subscriptions returned false, and false otherwise. Note that only one subscription can return false because doing so will prevent additional subscriptions from being invoked.
|
||||
*/
|
||||
publish(topic: string, ...args: any[]): boolean;
|
||||
|
||||
store: amplifyStore;
|
||||
|
||||
request: amplifyRequest;
|
||||
|
||||
}
|
||||
|
||||
declare var amplify: amplifyStatic;
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
|
||||
|
||||
Vendored
+4
-3
@@ -1,7 +1,7 @@
|
||||
// Type definitions for AmplifyJs 1.1.0
|
||||
// Project: http://amplifyjs.com/
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
@@ -29,6 +29,7 @@ interface amplifyDecoders {
|
||||
|
||||
interface amplifyAjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
dataMap?: {} | ((data: any) => {});
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ interface amplifyRequest {
|
||||
* success (optional): Function to invoke on success.
|
||||
* error (optional): Function to invoke on error.
|
||||
*/
|
||||
(settings: amplifyRequestSettings);
|
||||
(settings: amplifyRequestSettings): any;
|
||||
|
||||
/***
|
||||
* Define a resource.
|
||||
@@ -178,4 +179,4 @@ interface amplifyStatic {
|
||||
}
|
||||
|
||||
declare var amplify: amplifyStatic;
|
||||
|
||||
declare module "amplify" { export =amplify; }
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Tests for Amplitude SDK TypeScript definitions
|
||||
|
||||
/// <reference path="amplitude-js.d.ts" />
|
||||
|
||||
module Amplitude.Tests {
|
||||
function all() {
|
||||
amplitude.init('YOUR_API_KEY_HERE', null, {
|
||||
// optional configuration options
|
||||
saveEvents: true,
|
||||
includeUtm: true,
|
||||
includeReferrer: true,
|
||||
batchEvents: true,
|
||||
eventUploadThreshold: 50
|
||||
});
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE');
|
||||
amplitude.setUserId('USER_ID_HERE');
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
|
||||
amplitude.setUserId(null); // not string 'null'
|
||||
amplitude.setVersionName('VERSION_NAME_HERE');
|
||||
|
||||
amplitude.regenerateDeviceId();
|
||||
amplitude.setDeviceId('CUSTOM_DEVICE_ID');
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
|
||||
'color': 'blue',
|
||||
'age': 20,
|
||||
'key': 'value'
|
||||
});
|
||||
amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
|
||||
|
||||
let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().unset('gender').unset('age');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('karma', 10)
|
||||
.add('karma', 1)
|
||||
.unset('karma');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('colors', ['rose', 'gold'])
|
||||
.append('ab-tests', 'campaign_a')
|
||||
.append('existing_list', [4, 5]);
|
||||
amplitude.identify(identify);
|
||||
|
||||
amplitude.setUserProperties({
|
||||
gender: 'female',
|
||||
age: 20
|
||||
});
|
||||
|
||||
amplitude.clearUserProperties();
|
||||
|
||||
amplitude.setOptOut(true);
|
||||
amplitude.setOptOut(false);
|
||||
|
||||
amplitude.setGroup('orgId', '15');
|
||||
amplitude.setGroup('sport', ['soccer', 'tennis']);
|
||||
|
||||
// TODO: Implement those.
|
||||
/*
|
||||
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
|
||||
amplitude.logRevenueV2(revenue);
|
||||
|
||||
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
*/
|
||||
}
|
||||
}
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
// Type definitions for Amplitude SDK 2.12.1
|
||||
// Project: https://github.com/amplitude/Amplitude-Javascript
|
||||
// Definitions by: Arvydas Sidorenko <https://github.com/Asido>
|
||||
// Definitions: https://github.com/Asido/DefinitelyTyped
|
||||
|
||||
declare module amplitude {
|
||||
interface Config {
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
deviceId?: string;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
sessionTimeout?: number;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export function init(apiKey: string): void;
|
||||
export function init(apiKey: string, userId: string): void;
|
||||
export function init(apiKey: string, userId: string, options: Config): void;
|
||||
export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify): void;
|
||||
|
||||
export function setUserProperties(properties: Object): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string): void;
|
||||
export function logEvent(event: string, data: Object): void;
|
||||
export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
|
||||
|
||||
export var options: Config;
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for amqp-rpc v0.0.8
|
||||
// Project: https://github.com/demchenkoe/node-amqp-rpc/
|
||||
// Definitions by: Wonshik Kim <https://github.com/wokim/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/// <reference path="amqplib.d.ts" />
|
||||
|
||||
// promise api tests
|
||||
import amqp = require("amqplib");
|
||||
|
||||
var msg = "Hello World";
|
||||
|
||||
// test promise api
|
||||
amqp.connect("amqp://localhost")
|
||||
.then(connection => {
|
||||
return connection.createChannel()
|
||||
.tap(channel => channel.checkQueue("myQueue"))
|
||||
.then(channel => channel.sendToQueue("myQueue", new Buffer(msg)))
|
||||
.ensure(() => connection.close());
|
||||
});
|
||||
|
||||
amqp.connect("amqp://localhost")
|
||||
.then(connection => {
|
||||
return connection.createChannel()
|
||||
.tap(channel => channel.checkQueue("myQueue"))
|
||||
.then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())))
|
||||
.ensure(() => connection.close());
|
||||
});
|
||||
|
||||
// test promise api properties
|
||||
var amqpMessage: amqp.Message;
|
||||
amqpMessage.properties.contentType = "application/json";
|
||||
var amqpAssertExchangeOptions: amqp.Options.AssertExchange;
|
||||
var anqpAssertExchangeReplies: amqp.Replies.AssertExchange;
|
||||
|
||||
|
||||
// callback api tests
|
||||
import amqpcb = require("amqplib/callback_api");
|
||||
|
||||
amqpcb.connect("amqp://localhost", (err, connection) => {
|
||||
if(!err) {
|
||||
connection.createChannel((err, channel) => {
|
||||
if (!err) {
|
||||
channel.assertQueue("myQueue", {}, (err, ok) => {
|
||||
if(!err) {
|
||||
channel.sendToQueue("myQueue", new Buffer(msg));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
amqpcb.connect("amqp://localhost", (err, connection) => {
|
||||
if(!err) {
|
||||
connection.createChannel((err, channel) => {
|
||||
if (!err) {
|
||||
channel.assertQueue("myQueue", {}, (err, ok) => {
|
||||
if(!err) {
|
||||
channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// test callback api properties
|
||||
var amqpcbMessage: amqpcb.Message;
|
||||
amqpcbMessage.properties.contentType = "application/json";
|
||||
var amqpcbAssertExchangeOptions: amqpcb.Options.AssertExchange;
|
||||
var anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange;
|
||||
Vendored
+219
@@ -0,0 +1,219 @@
|
||||
// Type definitions for amqplib 0.3.x
|
||||
// Project: https://github.com/squaremo/amqp.node
|
||||
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../when/when.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "amqplib/properties" {
|
||||
namespace Replies {
|
||||
interface Empty {
|
||||
}
|
||||
interface AssertQueue {
|
||||
queue: string;
|
||||
messageCount: number;
|
||||
consumerCount: number;
|
||||
}
|
||||
interface PurgeQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface AssertExchange {
|
||||
exchange: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag: string;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Options {
|
||||
interface AssertQueue {
|
||||
exclusive?: boolean;
|
||||
durable?: boolean;
|
||||
autoDelete?: boolean;
|
||||
arguments?: any;
|
||||
messageTtl?: number;
|
||||
expires?: number;
|
||||
deadLetterExchange?: string;
|
||||
deadLetterRoutingKey?: string;
|
||||
maxLength?: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
ifUnused?: boolean;
|
||||
ifEmpty?: boolean;
|
||||
}
|
||||
interface AssertExchange {
|
||||
durable?: boolean;
|
||||
internal?: boolean;
|
||||
autoDelete?: boolean;
|
||||
alternateExchange?: string;
|
||||
arguments?: any;
|
||||
}
|
||||
interface DeleteExchange {
|
||||
ifUnused?: boolean;
|
||||
}
|
||||
interface Publish {
|
||||
expiration?: string;
|
||||
userId?: string;
|
||||
CC?: string | string[];
|
||||
|
||||
mandatory?: boolean;
|
||||
persistent?: boolean;
|
||||
deliveryMode?: boolean | number;
|
||||
BCC?: string | string[];
|
||||
|
||||
contentType?: string;
|
||||
contentEncoding?: string;
|
||||
headers?: any;
|
||||
priority?: number;
|
||||
correlationId?: string;
|
||||
replyTo?: string;
|
||||
messageId?: string;
|
||||
timestamp?: number;
|
||||
type?: string;
|
||||
appId?: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag?: string;
|
||||
noLocal?: boolean;
|
||||
noAck?: boolean;
|
||||
exclusive?: boolean;
|
||||
priority?: number;
|
||||
arguments?: any;
|
||||
}
|
||||
interface Get {
|
||||
noAck?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
interface Message {
|
||||
content: Buffer;
|
||||
fields: any;
|
||||
properties: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "amqplib" {
|
||||
|
||||
import events = require("events");
|
||||
import when = require("when");
|
||||
import shared = require("amqplib/properties")
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
interface Connection extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
createChannel(): when.Promise<Channel>;
|
||||
createConfirmChannel(): when.Promise<Channel>;
|
||||
}
|
||||
|
||||
interface Channel extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
|
||||
assertQueue(queue: string, options?: Options.AssertQueue): when.Promise<Replies.AssertQueue>;
|
||||
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
|
||||
purgeQueue(queue: string): when.Promise<Replies.PurgeQueue>;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): when.Promise<Replies.AssertExchange>;
|
||||
checkExchange(exchange: string): when.Promise<Replies.Empty>;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange): when.Promise<Replies.Empty>;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): when.Promise<Replies.Consume>;
|
||||
|
||||
cancel(consumerTag: string): when.Promise<Replies.Empty>;
|
||||
get(queue: string, options?: Options.Get): when.Promise<Message | boolean>;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): when.Promise<Replies.Empty>;
|
||||
recover(): when.Promise<Replies.Empty>;
|
||||
}
|
||||
|
||||
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
|
||||
}
|
||||
|
||||
declare module "amqplib/callback_api" {
|
||||
|
||||
import events = require("events");
|
||||
import shared = require("amqplib/properties")
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
interface Connection extends events.EventEmitter {
|
||||
close(callback?: (err: any) => void): void;
|
||||
createChannel(callback: (err: any, channel: Channel) => void): void;
|
||||
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
|
||||
}
|
||||
|
||||
interface Channel extends events.EventEmitter {
|
||||
close(callback: (err: any) => void): void;
|
||||
|
||||
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void;
|
||||
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void;
|
||||
purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
|
||||
checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
|
||||
|
||||
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): void;
|
||||
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
}
|
||||
|
||||
interface ConfirmChannel extends Channel {
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
|
||||
waitForConfirms(callback?: (err: any) => void): void;
|
||||
}
|
||||
|
||||
function connect(callback: (err: any, connection: Connection) => void): void;
|
||||
function connect(url: string, callback: (err: any, connection: Connection) => void): void;
|
||||
function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/// <reference path="./analytics-node.d.ts" />
|
||||
|
||||
var analytics: AnalyticsNode.Analytics;
|
||||
import Analytics = require("analytics-node");
|
||||
|
||||
function testConfig(): void {
|
||||
analytics = new Analytics('YOUR_WRITE_KEY', {
|
||||
flushAt: 20,
|
||||
flushAfter: 10000
|
||||
});
|
||||
}
|
||||
|
||||
function testIdentify(): void {
|
||||
analytics.identify({
|
||||
userId: '019mr8mf4r',
|
||||
traits: {
|
||||
name: 'Michael Bolton',
|
||||
email: 'mbolton@initech.com',
|
||||
plan: 'Enterprise',
|
||||
friends: 42
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testTrack(): void {
|
||||
analytics.track({
|
||||
userId: '019mr8mf4r',
|
||||
event: 'Purchased an Item',
|
||||
properties: {
|
||||
revenue: 39.95,
|
||||
shippingMethod: '2-day'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testPage(): void {
|
||||
analytics.page({
|
||||
userId: '019mr8mf4r',
|
||||
category: 'Docs',
|
||||
name: 'Node.js Library',
|
||||
properties: {
|
||||
url: 'https://segment.com/docs/libraries/node',
|
||||
path: '/docs/libraries/node/',
|
||||
title: 'Node.js Library - Segment',
|
||||
referrer: 'https://github.com/segmentio/analytics-node'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testAlias(): void {
|
||||
// the anonymous user does actions ...
|
||||
analytics.track({ userId: 'anonymous_user', event: 'Anonymous Event' })
|
||||
// the anonymous user signs up and is aliased
|
||||
analytics.alias({ previousId: 'anonymous_user', userId: 'identified@gmail.com' })
|
||||
// the identified user is identified
|
||||
analytics.identify({ userId: 'identified@gmail.com', traits: { plan: 'Free' } })
|
||||
// the identified user does actions ...
|
||||
analytics.track({ userId: 'identified@gmail.com', event: 'Identified Action' })
|
||||
}
|
||||
|
||||
function testGroup(): void {
|
||||
analytics.group({
|
||||
userId: '019mr8mf4r',
|
||||
groupId: '56',
|
||||
traits: {
|
||||
name: 'Initech',
|
||||
description: 'Accounting Software'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testIntegrations(): void {
|
||||
analytics.track({
|
||||
event: 'Upgraded Membershipt',
|
||||
userId: '97234974',
|
||||
integrations: {
|
||||
'All': false,
|
||||
'Vero': true,
|
||||
'Google Analytics': false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testFlush(): void {
|
||||
analytics.flush();
|
||||
analytics.flush(function(err, batch) {
|
||||
if (err) { alert("Oh nos!"); }
|
||||
else { console.log(batch.batch[0].type); }
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+83
@@ -0,0 +1,83 @@
|
||||
// Type definitions for Segment's analytics.js for Node.js
|
||||
// Project: https://segment.com/docs/libraries/node/
|
||||
// Definitions by: Andrew Fong <https://github.com/fongandrew>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace AnalyticsNode {
|
||||
|
||||
interface Integrations {
|
||||
[index: string]: boolean;
|
||||
}
|
||||
|
||||
export class Analytics {
|
||||
constructor(writeKey: string, opts?: {
|
||||
flushAt?: number,
|
||||
flushAfter?: number
|
||||
});
|
||||
|
||||
/* The identify method lets you tie a user to their actions and record
|
||||
traits about them. */
|
||||
identify(message: {
|
||||
userId: string | number;
|
||||
traits?: Object;
|
||||
timestamp?: Date;
|
||||
context?: Object;
|
||||
integrations?: Integrations;
|
||||
}): Analytics;
|
||||
|
||||
/* The track method lets you record the actions your users perform. */
|
||||
track(message: {
|
||||
userId: string | number;
|
||||
event: string;
|
||||
properties?: Object;
|
||||
timestamp?: Date;
|
||||
context?: Object;
|
||||
integrations?: Integrations;
|
||||
}): Analytics;
|
||||
|
||||
/* The page method lets you record page views on your website, along with
|
||||
optional extra information about the page being viewed. */
|
||||
page(message: {
|
||||
userId: string | number;
|
||||
category?: string;
|
||||
name?: string;
|
||||
properties?: Object;
|
||||
timestamp?: Date;
|
||||
context?: Object;
|
||||
integrations?: Integrations;
|
||||
}): Analytics;
|
||||
|
||||
/* alias is how you associate one identity with another. */
|
||||
alias(message: {
|
||||
previousId: string | number;
|
||||
userId: string | number;
|
||||
integrations?: Integrations;
|
||||
}): Analytics;
|
||||
|
||||
/* Group calls can be used to associate individual users with shared
|
||||
accounts or companies. */
|
||||
group(message: {
|
||||
userId: string | number;
|
||||
groupId: string | number;
|
||||
traits?: Object;
|
||||
context?: Object;
|
||||
timestamp?: Date;
|
||||
anonymous_id?: string | number;
|
||||
integrations?: Integrations;
|
||||
}): Analytics;
|
||||
|
||||
/* Flush batched calls to make sure nothing is left in the queue */
|
||||
flush(fn?: (err: Error, batch: {
|
||||
batch: Array<{
|
||||
type: string;
|
||||
}>;
|
||||
messageId: string;
|
||||
sentAt: Date;
|
||||
timestamp: Date;
|
||||
}) => void): Analytics;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "analytics-node" {
|
||||
export = AnalyticsNode.Analytics;
|
||||
}
|
||||
Vendored
+17
-17
@@ -1,42 +1,42 @@
|
||||
// Type definitions for AngularAgility
|
||||
// Project: https://github.com/AngularAgility/AngularAgility
|
||||
// Definitions by: Roland Zwaga <https://github.com/rolandzwaga>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
|
||||
declare module aa {
|
||||
declare namespace aa {
|
||||
|
||||
export interface ILabelStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic, labelText:string, isRequired:boolean)=>void;
|
||||
}
|
||||
|
||||
|
||||
export interface IFieldGroupStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic)=>void;
|
||||
}
|
||||
|
||||
|
||||
export interface IValMsgPlacementStrategies {
|
||||
[strategyName: string]: (formFieldElement:ng.IAugmentedJQueryStatic, formName:string, formFieldName:string)=>void;
|
||||
}
|
||||
|
||||
|
||||
export interface IValidIconStrategy {
|
||||
validIcon:string;
|
||||
invalidIcon:string;
|
||||
getContainer(element:ng.IAugmentedJQueryStatic):void;
|
||||
}
|
||||
|
||||
|
||||
export interface ISpinnerClickStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic)=>void;
|
||||
}
|
||||
|
||||
|
||||
export interface IOnNavigateAwayStrategies {
|
||||
[strategyName: string]: (rootFormScope:ng.IScope, rootForm:ng.IAugmentedJQueryStatic, $injector:ng.auto.IInjectorService)=>void;
|
||||
}
|
||||
|
||||
|
||||
export interface IValidationMessages {
|
||||
[validationKey: string]: string;
|
||||
}
|
||||
|
||||
|
||||
export interface IGlobalSettings {
|
||||
[settingName: string]: any;
|
||||
}
|
||||
@@ -53,18 +53,18 @@ declare module aa {
|
||||
valMsgForTemplate:string;
|
||||
confirmResetStrategy:()=>boolean;
|
||||
globalSettings:IGlobalSettings;
|
||||
|
||||
|
||||
labelStrategies:ILabelStrategies;
|
||||
fieldGroupStrategies:IFieldGroupStrategies;
|
||||
valMsgPlacementStrategies:IValMsgPlacementStrategies;
|
||||
spinnerClickStrategies:ISpinnerClickStrategies;
|
||||
onNavigateAwayStrategies:IOnNavigateAwayStrategies;
|
||||
}
|
||||
|
||||
|
||||
export interface INotifyPredicate {
|
||||
(message:string, options:any, notifier:any):any;
|
||||
}
|
||||
|
||||
|
||||
export interface INotifyDefaults {
|
||||
success: INotifyPredicate;
|
||||
info: INotifyPredicate;
|
||||
@@ -72,7 +72,7 @@ declare module aa {
|
||||
danger: INotifyPredicate;
|
||||
error: INotifyPredicate;
|
||||
}
|
||||
|
||||
|
||||
export interface INotifyConfig {
|
||||
name:string;
|
||||
template?:string;
|
||||
@@ -80,14 +80,14 @@ declare module aa {
|
||||
options:INotifyOptions;
|
||||
namedDefaults:INotifyDefaults;
|
||||
}
|
||||
|
||||
|
||||
export interface INotifyOptions {
|
||||
cssClasses?:string;
|
||||
messageType:string;
|
||||
allowHtml:boolean;
|
||||
message:string;
|
||||
}
|
||||
|
||||
|
||||
export interface INotifyConfigProvider extends ng.IServiceProvider {
|
||||
notifyConfigs:any;
|
||||
defaultTargetContainerName:string;
|
||||
@@ -95,7 +95,7 @@ declare module aa {
|
||||
addOrUpdateNotifyConfig(name:string, opts:INotifyConfig):void;
|
||||
optionsTransformer(options:INotifyOptions, $sce:ng.ISCEService):void;
|
||||
}
|
||||
|
||||
|
||||
export interface IExternalFormValidationConfig {
|
||||
validations:any;
|
||||
ignore?:any;
|
||||
@@ -103,4 +103,4 @@ declare module aa {
|
||||
resolve?:any;
|
||||
resolveFn?:(modelValue:string)=>string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
///<reference path='angular-bootstrap-calendar.d.ts'/>
|
||||
///<reference path='../angularjs/angular.d.ts'/>
|
||||
|
||||
var myApp = angular.module('testModule');
|
||||
|
||||
interface MyAppScope extends ng.IScope {
|
||||
events: ng.bootstrap.calendar.IEvent[];
|
||||
}
|
||||
|
||||
myApp.config(function (calendarConfig: ng.bootstrap.calendar.ICalendarConfig) {
|
||||
|
||||
calendarConfig.templates.calendarMonthView = 'path/to/custom/template.html'; //change the month view template to a custom template
|
||||
|
||||
calendarConfig.dateFormatter = 'moment'; //use either moment or angular to format dates on the calendar. Default angular. Setting this will override any date formats you have already set.
|
||||
|
||||
calendarConfig.allDateFormats.moment.date.hour = 'HH:mm'; //this will configure times on the day view to display in 24 hour format rather than the default of 12 hour
|
||||
|
||||
calendarConfig.allDateFormats.moment.title.day = 'ddd D MMM'; //this will configure the day view title to be shorter
|
||||
|
||||
calendarConfig.i18nStrings.weekNumber = 'Week {week}'; //This will set the week number hover label on the month view
|
||||
|
||||
calendarConfig.displayAllMonthEvents = true; //This will display all events on a month view even if they're not in the current month. Default false.
|
||||
|
||||
calendarConfig.displayEventEndTimes = true; //This will display event end times on the month and year views. Default false.
|
||||
|
||||
calendarConfig.showTimesOnWeekView = true; //Make the week view more like the day view, with the caveat that event end times are ignored.
|
||||
|
||||
});
|
||||
|
||||
var someController: Function = ($scope: MyAppScope) => {
|
||||
$scope.events = [
|
||||
{
|
||||
title: 'My event title', // The title of the event
|
||||
type: 'info', // The type of the event (determines its color). Can be important, warning, info, inverse, success or special
|
||||
startsAt: new Date(2013, 5, 1, 1), // A javascript date object for when the event starts
|
||||
endsAt: new Date(2014, 8, 26, 15), // Optional - a javascript date object for when the event ends
|
||||
editable: false, // If edit-event-html is set and this field is explicitly set to false then dont make it editable.
|
||||
deletable: false, // If delete-event-html is set and this field is explicitly set to false then dont make it deleteable
|
||||
draggable: true, //Allow an event to be dragged and dropped
|
||||
resizable: true, //Allow an event to be resizable
|
||||
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
|
||||
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
|
||||
cssClass: 'a-css-class-name' //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
|
||||
}
|
||||
];
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user