Merge pull request #10 from DefinitelyTyped/master

Pull latest changes from head
This commit is contained in:
Christopher Cortes
2017-04-28 17:44:10 +02:00
committed by GitHub
4620 changed files with 147746 additions and 199540 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ If adding a new definition:
If changing an existing definition:
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
- [ ] Increase the version number in the header if appropriate.
- [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "../tslint.json" }`.
- [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dslint/dt.json" }`.
If removing a declaration:
- [ ] If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
+13 -11
View File
@@ -71,7 +71,9 @@ Add to your `tsconfig.json`:
Create `types/foo/index.d.ts` containing declarations for the module "foo".
You should now be able import from `"foo"` in your code and it will route to the new type definition.
Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime.
Once you've tested your definitions with real code, make a PR contributing the definition by copying `types/foo` to `DefinitelyTyped/foo` and adding a `tsconfig.json` and `foo-tests.ts`.
Once you've tested your definitions with real code, make a [PR](#make-a-pull-request)
then follow the instructions to [edit an existing package](#edit-an-existing-package) or
[create a new package](#create-a-new-package).
### Make a pull request
@@ -83,7 +85,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
#### Edit an existing package
* `cd my-package-to-edit`
* `cd types/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.
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
@@ -153,15 +155,15 @@ If a package was never on DefinitelyTyped, it does not need to be added to `notN
#### Lint
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "../tslint.json" }`. All new packages must be linted.
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "dtslint/dt.json" }`. All new packages must be linted.
If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
```js
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
// This package uses the Function type, and it will take effort to fix.
"forbidden-types": false
"ban-types": false
}
}
```
@@ -184,11 +186,6 @@ This usually happens within an hour of changes being merged.
If the module you're referencing is an external module (uses `export`), use an import.
If the module you're referencing 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.
@@ -214,7 +211,7 @@ If default imports work in your environment, consider turning on the [`--allowSy
Do not change the type definition if it is accurate.
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
#### I want to use features from TypeScript 2.1.
#### I want to use features from TypeScript 2.1 or above.
Then you will have to add a comment to the last line of your definition header (after `// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`): `// TypeScript Version: 2.1`.
@@ -256,6 +253,11 @@ transitively `react-router-bootstrap` (which depends on `react-router`) also add
Also, `/// <reference types=".." />` will not work with path mapping, so dependencies must use `import`.
#### What about scoped packages?
Types for a scoped package `@foo/bar` should go in `types/foo__bar`. Note the double underscore.
#### The file history in GitHub looks incomplete.
GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) file history for renamed files. Use [`git log --follow`](https://www.git-scm.com/docs/git-log) instead.
+210
View File
@@ -12,18 +12,54 @@
"sourceRepoURL": "https://github.com/ant-design/ant-design",
"asOfVersion": "1.0.0"
},
{
"libraryName": "anydb-sql",
"typingsPackageName": "anydb-sql",
"sourceRepoURL": "https://github.com/doxout/anydb-sql",
"asOfVersion": "0.6.46"
},
{
"libraryName": "Argon2",
"typingsPackageName": "argon2",
"sourceRepoURL": "https://github.com/ranisalt/node-argon2",
"asOfVersion": "0.15.0"
},
{
"libraryName": "aws-sdk",
"typingsPackageName": "aws-sdk",
"sourceRepoURL": "https://github.com/aws/aws-sdk-js",
"asOfVersion": "2.7.0"
},
{
"libraryName": "axe-core",
"typingsPackageName": "axe-core",
"sourceRepoURL": "https://github.com/dequelabs/axe-core",
"asOfVersion": "2.0.7"
},
{
"libraryName": "axios",
"typingsPackageName": "axios",
"sourceRepoURL": "https://github.com/mzabriskie/axios",
"asOfVersion": "0.14.0"
},
{
"libraryName": "azure-mobile-apps",
"typingsPackageName": "azure-mobile-apps",
"sourceRepoURL": "https://github.com/Azure/azure-mobile-apps-node/",
"asOfVersion": "3.0.0"
},
{
"libraryName": "BabylonJS",
"typingsPackageName": "babylonjs",
"sourceRepoURL": "http://www.babylonjs.com/",
"asOfVersion": "2.4.1"
},
{
"libraryName": "Bugsnag Browser",
"typingsPackageName": "bugsnag-js",
"sourceRepoURL": "https://github.com/bugsnag/bugsnag-js",
"asOfVersion": "3.1.0"
},
{
"libraryName": "camel-case",
"typingsPackageName": "camel-case",
@@ -54,6 +90,12 @@
"sourceRepoURL": "https://github.com/date-fns/date-fns",
"asOfVersion": "2.6.0"
},
{
"libraryName": "DevExtreme",
"typingsPackageName": "devextreme",
"sourceRepoURL": "http://js.devexpress.com/",
"asOfVersion": "16.2.1"
},
{
"libraryName": "Dexie.js",
"typingsPackageName": "dexie",
@@ -78,6 +120,24 @@
"sourceRepoURL": "https://github.com/bterlson/ecmarkup",
"asOfVersion": "3.4.0"
},
{
"libraryName": "electron-builder",
"typingsPackageName": "electron-builder",
"sourceRepoURL": "https://github.com/loopline-systems/electron-builder",
"asOfVersion": "2.8.0"
},
{
"libraryName": "EventEmitter3",
"typingsPackageName": "eventemitter3",
"sourceRepoURL": "https://github.com/primus/eventemitter3",
"asOfVersion": "2.0.2"
},
{
"libraryName": "JSON-Patch",
"typingsPackageName": "fast-json-patch",
"sourceRepoURL": "https://github.com/Starcounter-Jack/JSON-Patch",
"asOfVersion": "1.1.5"
},
{
"libraryName": "FastSimplexNoise",
"typingsPackageName": "fast-simplex-noise",
@@ -102,6 +162,12 @@
"sourceRepoURL": "https://github.com/mikedeboer/node-github",
"asOfVersion": "7.1.0"
},
{
"libraryName": "gulp-typescript",
"typingsPackageName": "gulp-typescript",
"sourceRepoURL": "https://github.com/ivogabe/gulp-typescript",
"asOfVersion": "2.13.0"
},
{
"libraryName": "Facebook's Immutable",
"typingsPackageName": "immutable",
@@ -156,12 +222,30 @@
"sourceRepoURL": "https://github.com/blakeembrey/is-upper-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "JSNLog",
"typingsPackageName": "jsnlog",
"sourceRepoURL": "https://github.com/mperdeck/jsnlog.js",
"asOfVersion": "2.17.2"
},
{
"libraryName": "jsonschema",
"typingsPackageName": "jsonschema",
"sourceRepoURL": "https://github.com/tdegrunt/jsonschema",
"asOfVersion": "1.1.1"
},
{
"libraryName": "knockout-paging",
"typingsPackageName": "knockout-paging",
"sourceRepoURL": "https://github.com/ErikSchierboom/knockout-paging",
"asOfVersion": "0.3.1"
},
{
"libraryName": "knockout-pre-rendered",
"typingsPackageName": "knockout-pre-rendered",
"sourceRepoURL": "https://github.com/ErikSchierboom/knockout-pre-rendered",
"asOfVersion": "0.7.1"
},
{
"libraryName": "Linq.JS",
"typingsPackageName": "linq",
@@ -192,12 +276,30 @@
"sourceRepoURL": "https://github.com/blakeembrey/lower-case-first",
"asOfVersion": "1.0.1"
},
{
"libraryName": "maquette",
"typingsPackageName": "maquette",
"sourceRepoURL": "http://maquettejs.org/",
"asOfVersion": "2.1.6"
},
{
"libraryName": "mendixmodelsdk",
"typingsPackageName": "mendixmodelsdk",
"sourceRepoURL": "http://www.mendix.com",
"asOfVersion": "0.8.1"
},
{
"libraryName": "mobservable",
"typingsPackageName": "mobservable",
"sourceRepoURL": "github.com/mweststrate/mobservable",
"asOfVersion": "1.2.5"
},
{
"libraryName": "mobservable-react",
"typingsPackageName": "mobservable-react",
"sourceRepoURL": "https://github.com/mweststrate/mobservable-react",
"asOfVersion": "1.0.0"
},
{
"libraryName": "Moment",
"typingsPackageName": "moment",
@@ -222,12 +324,24 @@
"sourceRepoURL": "https://github.com/foretagsplatsen/numbro/",
"asOfVersion": "1.9.3"
},
{
"libraryName": "Onsen UI",
"typingsPackageName": "onsenui",
"sourceRepoURL": "http://onsen.io",
"asOfVersion": "2.0.0"
},
{
"libraryName": "param-case",
"typingsPackageName": "param-case",
"sourceRepoURL": "https://github.com/blakeembrey/param-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "parse5",
"typingsPackageName": "parse5",
"sourceRepoURL": "https://github.com/inikulin/parse5",
"asOfVersion": "3.0.0"
},
{
"libraryName": "pascal-case",
"typingsPackageName": "pascal-case",
@@ -240,12 +354,24 @@
"sourceRepoURL": "https://github.com/blakeembrey/path-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "pg-promise",
"typingsPackageName": "pg-promise",
"sourceRepoURL": "https://github.com/vitaly-t/pg-promise",
"asOfVersion": "5.4.3"
},
{
"libraryName": "pixi-spine",
"typingsPackageName": "pixi-spine",
"sourceRepoURL": "https://github.com/pixijs/pixi-spine",
"asOfVersion": "1.4.2"
},
{
"libraryName": "pkcs11js",
"typingsPackageName": "pkcs11js",
"sourceRepoURL": "https://github.com/PeculiarVentures/pkcs11js",
"asOfVersion": "1.0.4"
},
{
"libraryName": "poly2tri.js",
"typingsPackageName": "poly2tri",
@@ -276,6 +402,12 @@
"sourceRepoURL": "https://github.com/reactjs/redux",
"asOfVersion": "3.6.0"
},
{
"libraryName": "redux-batched-actions",
"typingsPackageName": "redux-batched-actions",
"sourceRepoURL": "https://github.com/tshelburne/redux-batched-actions",
"asOfVersion": "0.1.5"
},
{
"libraryName": "redux-persist",
"typingsPackageName": "redux-persist",
@@ -300,12 +432,36 @@
"sourceRepoURL": "https://github.com/gaearon/redux-thunk",
"asOfVersion": "2.1.0"
},
{
"libraryName": "reselect",
"typingsPackageName": "reselect",
"sourceRepoURL": "https://github.com/rackt/reselect",
"asOfVersion": "2.2.0"
},
{
"libraryName": "rest-io",
"typingsPackageName": "rest-io",
"sourceRepoURL": "https://github.com/EnoF/rest-io",
"asOfVersion": "4.1.0"
},
{
"libraryName": "route-recognizer",
"typingsPackageName": "route-recognizer",
"sourceRepoURL": "https://github.com/tildeio/route-recognizer",
"asOfVersion": "0.3.0"
},
{
"libraryName": "node-scanf",
"typingsPackageName": "scanf",
"sourceRepoURL": "https://github.com/Lellansin/node-scanf",
"asOfVersion": "0.7.3"
},
{
"libraryName": "sendgrid",
"typingsPackageName": "sendgrid",
"sourceRepoURL": "https://github.com/sendgrid/sendgrid-nodejs",
"asOfVersion": "4.3.0"
},
{
"libraryName": "sentence-case",
"typingsPackageName": "sentence-case",
@@ -342,18 +498,42 @@
"sourceRepoURL": "https://github.com/andrewplummer/Sugar",
"asOfVersion": "2.0.2"
},
{
"libraryName": "svg.js",
"typingsPackageName": "svg.js",
"sourceRepoURL": "http://www.svgjs.com/",
"asOfVersion": "2.3.1"
},
{
"libraryName": "swap-case",
"typingsPackageName": "swap-case",
"sourceRepoURL": "https://github.com/blakeembrey/swap-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "Tabris.js",
"typingsPackageName": "tabris",
"sourceRepoURL": "http://tabrisjs.com",
"asOfVersion": "1.8.0"
},
{
"libraryName": "tcomb",
"typingsPackageName": "tcomb",
"sourceRepoURL": "http://gcanti.github.io/tcomb/guide/index.html",
"asOfVersion": "2.6.0"
},
{
"libraryName": "title-case",
"typingsPackageName": "title-case",
"sourceRepoURL": "https://github.com/blakeembrey/title-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "TsMonad",
"typingsPackageName": "tsmonad",
"sourceRepoURL": "https://github.com/cbowdon/TsMonad",
"asOfVersion": "0.5.0"
},
{
"libraryName": "TypeScript",
"typingsPackageName": "typescript",
@@ -366,6 +546,12 @@
"sourceRepoURL": "https://github.com/Microsoft/TypeScript",
"asOfVersion": "2.0.0"
},
{
"libraryName": "uk.co.workingedge.phonegap.plugin.istablet",
"typingsPackageName": "uk.co.workingedge.phonegap.plugin.istablet",
"sourceRepoURL": "https://github.com/dpa99c/phonegap-istablet",
"asOfVersion": "1.1.3"
},
{
"libraryName": "upper-case",
"typingsPackageName": "upper-case",
@@ -378,6 +564,12 @@
"sourceRepoURL": "https://github.com/blakeembrey/upper-case-first",
"asOfVersion": "1.1.2"
},
{
"libraryName": "vso-node-api",
"typingsPackageName": "vso-node-api",
"sourceRepoURL": "https://github.com/Microsoft/vso-node-api",
"asOfVersion": "4.0.0"
},
{
"libraryName": "vuejs",
"typingsPackageName": "vue",
@@ -390,17 +582,35 @@
"sourceRepoURL": "https://github.com/vuejs/vue-router",
"asOfVersion": "2.0.0"
},
{
"libraryName": "webcola",
"typingsPackageName": "webcola",
"sourceRepoURL": "https://github.com/tgdwyer/WebCola",
"asOfVersion": "3.2.0"
},
{
"libraryName": "x2js",
"typingsPackageName": "x2js",
"sourceRepoURL": "https://code.google.com/p/x2js/",
"asOfVersion": "3.1.0"
},
{
"libraryName": "xml-js",
"typingsPackageName": "xml-js",
"sourceRepoURL": "https://github.com/nashwaan/xml-js",
"asOfVersion": "1.0.0"
},
{
"libraryName": "@xmpp/jid",
"typingsPackageName": "xmpp-jid",
"sourceRepoURL": "github.com/node-xmpp/node-xmpp/",
"asOfVersion": "1.2.0"
},
{
"libraryName": "Zone.js",
"typingsPackageName": "zone.js",
"sourceRepoURL": "https://github.com/angular/zone.js",
"asOfVersion": "0.5.12"
}
]
}
+1 -1
View File
@@ -18,7 +18,7 @@
"compile-scripts": "tsc -p scripts",
"not-needed": "node scripts/not-needed.js",
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1",
"lint": "dtslint --dt types"
"lint": "dtslint types"
},
"devDependencies": {
"dtslint": "Microsoft/dtslint#production",
+1 -1
View File
@@ -31,7 +31,7 @@ function fixTslint(dir: string): void {
if (!fs.existsSync(target)) return;
let json = JSON.parse(fs.readFileSync(target, 'utf-8'));
json = fix(json);
const text = Object.keys(json).length === 1 ? '{ "extends": "../tslint.json" }' : JSON.stringify(json, undefined, 4);
const text = Object.keys(json).length === 1 ? '{ "extends": "dtslint/dt.json" }' : JSON.stringify(json, undefined, 4);
fs.writeFileSync(target, text + "\n", "utf-8");
}
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -63,7 +63,7 @@ declare namespace acorn {
class SourceLocation implements ESTree.SourceLocation {
start: Position;
end: Position;
source?: string;
source?: string | null;
constructor(p: Parser, start: Position, end: Position);
}
+162
View File
@@ -0,0 +1,162 @@
import { Equation, Expression, Fraction, parse, toTex } from 'algebra.js';
{
let expr = new Expression("x");
expr = expr.subtract(3);
expr = expr.add("x");
expr.toString();
let eq = new Equation(expr, 4);
eq.toString();
let x = eq.solveFor("x");
x.toString();
}
{
let frac = new Fraction(1, 2);
frac.toString();
frac = frac.add(new Fraction(3, 4));
frac.toString();
frac = frac.subtract(2);
frac.toString();
frac = frac.multiply(new Fraction(4, 3));
frac.toString();
frac = frac.divide(5);
frac.toString();
let x = new Expression("x");
x = x.add(3);
x.toString();
x = x.subtract(new Fraction(1, 3));
x.toString();
x = x.add("y");
x.toString();
let otherExp = new Expression("x").add(6);
x = x.add(otherExp);
x.toString();
let expr1 = new Expression("a").add("b").add("c");
let expr2 = new Expression("c").subtract("b");
let expr3 = expr1.subtract(expr2);
expr1.toString() + " - (" + expr2.toString() + ") = " + expr3.toString();
expr1 = new Expression("x");
expr1 = expr1.add(2);
expr1 = expr1.multiply(4);
expr2 = new Expression("x");
expr2 = expr2.multiply("y");
expr2 = expr2.multiply(new Fraction(1, 3));
expr2 = expr2.add(4);
expr3 = expr1.multiply(expr2);
"(" + expr1.toString() + ")(" + expr2.toString() + ") = " + expr3.toString();
x = new Expression("x").divide(2).divide(new Fraction(1, 5));
x.toString();
let exp = new Expression("x");
exp = exp.add("y");
exp = exp.add(3);
exp.toString();
let sum = exp.summation("x", 3, 6);
sum.toString();
exp = new Expression("x").add(2);
let exp3 = exp.pow(3);
"(" + exp.toString() + ")^3 = " + exp3.toString();
let expr = new Expression("x");
expr = expr.multiply(2);
expr = expr.multiply("x");
expr = expr.add("y");
expr = expr.add(new Fraction(1, 3));
expr.toString();
let answer1 = expr.eval({ x: 2 });
let answer2 = expr.eval({ x: 2, y: new Fraction(3, 4) });
answer1.toString();
answer2.toString();
expr = new Expression("x").add(2);
expr.toString();
let sub = new Expression("y").add(4);
let answer = expr.eval({ x: sub });
answer.toString();
exp = new Expression("x").add(2);
exp.toString();
exp = exp.multiply(5, false);
exp.toString();
exp = exp.simplify();
exp.toString();
exp = exp.add(5, false);
exp.toString();
exp = exp.divide(5, false);
exp.toString();
exp = exp.simplify();
exp.toString();
exp = exp.pow(2, false);
exp.toString();
exp = exp.simplify();
exp.toString();
let z = new Expression("z");
let eq1 = new Equation(z.subtract(4).divide(9), z.add(6));
eq1.toString();
let eq2 = new Equation(z.add(4).multiply(9), 6);
eq2.toString();
let eq3 = new Equation(z.divide(2).multiply(7), new Fraction(1, 4));
eq3.toString();
}
{
let x1 = parse("1/5 * x + 2/15");
let x2 = parse("1/7 * x + 4");
let eq = new Equation(x1 as Expression, x2 as Expression);
eq.toString();
let answer = eq.solveFor("x");
"x = " + answer.toString();
let expr1 = parse("1/4 * x + 5/4");
let expr2 = parse("3 * y - 12/5");
eq = new Equation(expr1 as Expression, expr2 as Expression);
eq.toString();
let xAnswer = eq.solveFor("x");
let yAnswer = eq.solveFor("y");
"x = " + xAnswer.toString();
"y = " + yAnswer.toString();
let n1 = parse("x + 5") as Expression;
let n2 = parse("x - 3/4") as Expression;
let quad = new Equation(n1.multiply(n2), 0);
quad.toString();
let answers = quad.solveFor("x");
"x = " + answers.toString();
n1 = parse("x + 2") as Expression;
n2 = parse("x + 3") as Expression;
let n3 = parse("x + 4") as Expression;
let cubic = new Equation(n1.multiply(n2).multiply(n3), 0);
cubic.toString();
answers = cubic.solveFor("x");
"x = " + answers.toString();
let expr = new Expression("x");
expr = expr.multiply("x");
expr = expr.add("x");
expr = expr.add("y");
eq = new Equation(expr, 3);
eq.toString();
xAnswer = eq.solveFor("x");
yAnswer = eq.solveFor("y");
"x = " + xAnswer;
"y = " + yAnswer.toString();
let exp = parse("2 * x^2 + 4 * x + 4");
exp.toString();
exp = parse("x * y + 4");
exp.toString();
}
{
let eq = parse("x^2 + 4 * x + 4 = 0") as Equation;
eq.toString();
let ans = eq.solveFor("x");
"x = " + ans.toString();
let a = new Expression("x").pow(2);
let b = new Expression("x").multiply(new Fraction(5, 4));
let c = new Fraction(-21, 4);
let expr = a.add(b).add(c);
let quad = new Equation(expr, 0);
toTex(quad);
let answers = quad.solveFor("x");
toTex(answers);
let lambda = new Expression("lambda").add(3).divide(4);
let Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda);
toTex(lambda);
toTex(Phi);
}
+62
View File
@@ -0,0 +1,62 @@
// Type definitions for algebra.js 0.2
// Project: http://algebra.js.org
// Definitions by: Federico Caselli <https://github.com/CaselIT>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare class Term {
coefficients: algebra.js.Fraction[];
variables: Variable[];
coefficient(): algebra.js.Fraction;
toString(): string;
}
declare class Variable {
variable: string;
toString(): string;
}
type Union = string | number | algebra.js.Fraction | Term;
declare namespace algebra.js {
function parse(input: string): Equation | Expression;
function toTex(input: Fraction | Expression | Equation | object | Array<Fraction | object>): string;
class Equation {
lhs: Expression;
rhs: Expression;
constructor(lhs: Expression, rhs: Expression | Fraction | number)
solveFor(variable: string): Fraction | Fraction[] | number[];
toString(): string;
}
class Expression {
constants: Fraction[];
terms: Term[];
constructor(variable: Union | undefined)
add(other: Union | Expression, simplify?: boolean): Expression;
divide(other: Fraction | number, simplify?: boolean): Expression;
eval(p: object, simplify?: boolean): Expression;
multiply(other: Union | Expression, simplify?: boolean): Expression;
pow(p: number, simplify?: boolean): Expression;
constant(): Fraction;
simplify(): Expression;
subtract(other: Union | Expression, simplify?: boolean): Expression;
summation(variable: string, lower: number, upper: number, simplify?: boolean): Expression;
toString(): string;
}
class Fraction {
denom: number;
numer: number;
constructor(num: number, denom: number)
abs(): Fraction;
add(other: Fraction | number, simplify?: boolean): Fraction;
divide(other: Fraction | number, simplify?: boolean): Fraction;
multiply(other: Fraction | number, simplify?: boolean): Fraction;
subtract(other: Fraction | number, simplify?: boolean): Fraction;
toString(): string;
valueOf(): number;
}
}
export = algebra.js;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"algebra.js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -109,7 +109,7 @@ declare namespace AltJS {
flush():Object;
recycle( ...stores:Array<AltJS.AltStore<any>>):void;
rollback():void;
dispatch(action?:AltJS.Action<any>, data?:Object, details?:any):void;
dispatch(action?:AltJS.Action<any>|string, data?:Object, details?:any):void;
//Actions methods
addActions(actionsName:string, ActionsClass: ActionsClassConstructor):void;
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false,
"unified-signatures": false
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
}
@@ -0,0 +1,41 @@
let app: angular.IModule = angular.module('at', ['blockUI']);
app.config((blockUIConfig: angular.blockUI.BlockUIConfig) => {
blockUIConfig.message = 'Please stop clicking!';
blockUIConfig.delay = 100;
blockUIConfig.template = '<pre><code>{{ state | json }}</code></pre>';
blockUIConfig.templateUrl = 'my-templates/block-ui-overlay.html';
blockUIConfig.autoBlock = false;
blockUIConfig.resetOnException = false;
blockUIConfig.autoInjectBodyBlock = false;
blockUIConfig.cssClass = 'block-ui my-custom-class';
blockUIConfig.blockBrowserNavigation = true;
blockUIConfig.requestFilter = (config) => {
if (config.url.match(/^\/api\/quote($|\/).*/)) {
return false;
}
return true;
};
blockUIConfig.requestFilter = (config) => {
if (config.url.match(/^\/api\/quote($|\/).*/)) {
return 'Hello World';
}
return 'Loading...';
};
});
app.controller('Ctrl', ($scope: ng.IScope, blockUI: angular.blockUI.BlockUIService) => {
blockUI.start();
blockUI.start('Hello');
blockUI.start({});
blockUI.start({message: 'World'});
blockUI.start({delay: 100});
blockUI.stop();
blockUI.reset();
blockUI.message("Hello Types");
blockUI.done();
let b: boolean = blockUI.isBlocking();
});
+168
View File
@@ -0,0 +1,168 @@
// Type definitions for angular-block-ui 0.2
// Project: https://github.com/McNull/angular-block-ui
// Definitions by: Lasse Nørregaard <https://github.com/lassebn>, Stephan Classen <https://github.com/sclassen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as angular from "angular";
declare module 'angular' {
namespace blockUI {
interface BlockUIConfig {
/**
* Changes the default message to be used when no message
* has been provided to the start method of the service.
*
* Default value is 'Loading ...'.
*/
message?: string;
/**
* Specifies the amount in milliseconds before the block
* is visible to the user. By delaying a visible block your
* application will appear more responsive.
*
* The default value is 250.
*/
delay?: number;
/**
* Specifies a custom template to use as the overlay.
*/
template?: string;
/**
* Specifies a url to retrieve the template from.
* The current release only works with pre-cached templates,
* which means that this url should be known in the
* $templateCache service of Angular.
*
* If you're using the grunt with html2js or angular-templates,
* which I highly recommend, you're already set.
*/
templateUrl?: string;
/**
* By default the BlockUI module will start a block whenever
* the Angular $http service has an pending request.
*
* If you don't want this behaviour and want to do all the
* blocking manually you can change this value to false.
*/
autoBlock?: boolean;
/**
* By default the BlockUI module will reset the block count and
* hide the overlay whenever an exception has occurred.
*
* You can set this value to false if you don't want this behaviour.
*/
resetOnException?: boolean;
/**
* Allows you to specify a filter function to exclude certain ajax
* requests from blocking the user interface.
* The blockUI service will ignore requests when the function returns `false`.
*
* If the filter function returns a string it will be passed as the message
* argument to the start method of the service.
*
* @param {angular.IRequestConfig} config - the Angular request config object.
*
*/
requestFilter?(config: angular.IRequestConfig): (string | boolean);
/**
* When the module is started it will inject the main block element
* by adding the block-ui directive to the body element.
*/
autoInjectBodyBlock?: boolean;
/**
* A string containing the default css classes, separated by spaces,
* that should be applied to each block-ui element.
*
* The default value is `block-ui block-ui-anim-fade`
*/
cssClass?: string;
/**
* Whenever a user interface block is active, because the single page
* application is still waiting for a response from the backend server,
* the user can still navigate away using the back and forward buttons
* of the browser.
*
* Callbacks registered to handle the responses from the server will
* be executed even if a different view/controller is currently active.
* By setting the blockBrowserNavigation property to true the
* angular-block-ui module will prevent navigation while a fullscreen
* block is active.
*
* Programatic location changes via the $location service are still
* allowed however.
* The navigation block is disabled by default.
*/
blockBrowserNavigation?: boolean;
}
interface BlockUIService {
/**
* The start method will start the user interface block.
* Because multiple user interface elements can request
* a user interface block at the same time, the service
* keeps track of the number of start calls.
*
* Each call to start() will increase the count and every
* call to stop() will decrease the value.
* Whenever the count reaches 0 the block will end.
*
* Note: By default the block is immediately active after
* calling this method, but to prevent trashing the user
* interface each time a button is pressed, the block is
* visible after a short delay.
*
* This behaviour can be modified in the configuration.
*
* @param {string|IBlockUIConfig} messageOrOptions -
* Either supply the message (string) to be show in the
* overlay or specify an IBlockUIConfig object that will be
* merged/extended into the block ui instance state.
* If no argument is specified the default text message
* from the configuration is used.
*/
start(messageOrOptions?: (string | BlockUIConfig)): void;
/**
* This will decrease the block count.
*
* The block will end if the count is 0.
*/
stop(): void;
/**
* The reset will force an unblock by setting the block count to 0.
*/
reset(): void;
/**
* Queues a callback function to be called when the block has finished.
*
* This can be useful whenever you wish to redirect the user
* to a different location while there are still pending AJAX requests.
*/
done(): void;
/**
* Allows the message shown in the overlay to be updated
* while to block is active.
*
* @param {string} message - The message to show in the overlay.
*/
message(message: string): void;
/**
* Returns whether currently a block is shown for the instance or not.
*/
isBlocking(): boolean;
}
}
}
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"uk.co.workingedge.phonegap.plugin.istablet-tests.ts"
"angular-block-ui-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+46 -52
View File
@@ -1,61 +1,55 @@
// Configuring angular-gettext
// https://angular-gettext.rocketeer.be/dev-guide/configure/
//Setting the language
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
gettextCatalog.setCurrentLanguage('nl');
});
//Highlighting untranslated strings
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
gettextCatalog.debug = true;
});
namespace angular_gettext_tests {
// Marking strings in JavaScript code as translatable.
// https://angular-gettext.rocketeer.be/dev-guide/annotate-js/
angular.module("myApp").controller("helloController", function (gettext: angular.gettext.gettextFunction) {
var myString = gettext("Hello");
});
//Translating directly in JavaScript.
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var translated: string = gettextCatalog.getString("Hello");
});
// Configuring angular-gettext
// https://angular-gettext.rocketeer.be/dev-guide/configure/
//Setting the language
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
gettextCatalog.setCurrentLanguage('nl');
});
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds");
});
//Highlighting untranslated strings
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
gettextCatalog.debug = true;
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" });
});
// Setting strings manually
// https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
angular.module("myApp").run(function (gettextCatalog: angular.gettext.gettextCatalog) {
// Load the strings automatically during initialization.
gettextCatalog.setStrings("nl", {
"Hello": "Hallo",
"One boat": ["Een boot", "{{$count}} boats"]
});
});
// Marking strings in JavaScript code as translatable.
// https://angular-gettext.rocketeer.be/dev-guide/annotate-js/
angular.module("myApp").controller("helloController", function (gettext: angular.gettext.gettextFunction) {
var myString = gettext("Hello");
});
//Translating directly in JavaScript.
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var translated: string = gettextCatalog.getString("Hello");
});
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds");
});
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" });
});
// Setting strings manually
// https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
angular.module("myApp").run(function (gettextCatalog: angular.gettext.gettextCatalog) {
// Load the strings automatically during initialization.
gettextCatalog.setStrings("nl", {
"Hello": "Hallo",
"One boat": ["Een boot", "{{$count}} boats"]
});
});
interface helloControllerScope extends ng.IScope {
switchLanguage: (lang: string) => void;
}
// Lazy-loading languages
// https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/
angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular.gettext.gettextCatalog) {
$scope.switchLanguage = function (lang: string) {
gettextCatalog.setCurrentLanguage(lang);
gettextCatalog.loadRemote("/languages/" + lang + ".json");
};
});
interface helloControllerScope extends ng.IScope {
switchLanguage: (lang: string) => void;
}
// Lazy-loading languages
// https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/
angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular.gettext.gettextCatalog) {
$scope.switchLanguage = function (lang: string) {
gettextCatalog.setCurrentLanguage(lang);
gettextCatalog.loadRemote("/languages/" + lang + ".json");
};
});
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+55
View File
@@ -0,0 +1,55 @@
## What is it?
This is a typescript interface to be used with [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys/).
## What are declaration files?
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 these typings:
```sh
npm install --save-dev @types/angular-hotkeys
```
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).
### Other methods
These can be used by TypeScript 1.0.
* [Typings](https://github.com/typings/typings)
* ~~[NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
* Manually download from the `master` branch of this repository
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
## How to use
After installing a package you can import the definition file and begin using it as so:
```ts
import * as hotkeys from '../../node_modules/@types/angular-hotkeys'
class FooController {
static $inject = [
'hotkeys'
];
constructor(
private hotkeys: ng.hotkeys.HotkeysProvider
) { }
}
```
for a detailed explanation of the behavior of angular-hotkeys please refer to [its documentation](https://github.com/chieffancypants/angular-hotkeys/)
+2
View File
@@ -2,6 +2,8 @@
// Project: https://github.com/chieffancypants/angular-hotkeys
// Definitions by: Jason Zhao <https://github.com/jlz27>, Stefan Steinhart <https://github.com/reppners>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//readme written by David Valentine <https://github.com/dvalenti314/>
/// <reference types="angular" />
+20 -19
View File
@@ -1,4 +1,4 @@
// Type definitions for angular-local-storage v0.1.5
// Type definitions for angular-local-storage v0.1.6
// Project: https://github.com/grevory/angular-local-storage
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -60,19 +60,19 @@ declare module 'angular' {
*/
set(key: string, val: string): boolean;
/**
* Directly adds a value to cookies with an expiration.
* Note: Typically used as a fallback if local storage is not supported.
* Returns: Boolean
* @param key
* @param val
* @param daysToExpiry
*/
* Directly adds a value to cookies with an expiration.
* Note: Typically used as a fallback if local storage is not supported.
* Returns: Boolean
* @param key
* @param val
* @param daysToExpiry
*/
set(key: string, val: string, daysToExpiry: number): boolean;
/**
* Directly get a value from a cookie.
* Returns: value from local storage
* @param key
*/
* Directly get a value from a cookie.
* Returns: value from local storage
* @param key
*/
get(key: string): string;
/**
* Remove directly value from a cookie.
@@ -84,8 +84,9 @@ declare module 'angular' {
* Remove all data for this app from cookie.
*/
clearAll(): any;
}
type StorageType = 'localStorage' | 'sessionStorage';
interface ILocalStorageService {
/**
@@ -104,19 +105,19 @@ declare module 'angular' {
* @param key
* @param value
*/
set<T>(key: string, value: T): boolean;
set<T>(key: string, value: T, storageType?: StorageType): boolean;
/**
* Directly get a value from local storage.
* If local storage is not supported, use cookies instead.
* Returns: value from local storage
* @param key
*/
get<T>(key: string): T;
get<T>(key: string, storageType?: StorageType): T;
/**
* Return array of keys for local storage, ignore keys that not owned.
* Returns: value from local storage
*/
keys(): string[];
keys(storageType?: StorageType): string[];
/**
* Remove an item from local storage by key.
* If local storage is not supported, use cookies instead.
@@ -131,7 +132,7 @@ declare module 'angular' {
* Returns: Boolean
* @param regularExpression
*/
clearAll(regularExpression?: RegExp): boolean;
clearAll(regularExpression?: RegExp, storageType?: StorageType): boolean;
/**
* Bind $scope key to localStorageService.
* Usage: localStorageService.bind(scope, property, value[optional], key[optional])
@@ -141,7 +142,7 @@ declare module 'angular' {
* @param value optional
* @param key The corresponding key used in local storage
*/
bind(scope: angular.IScope, property: string, value?: any, key?: string): Function;
bind(scope: angular.IScope, property: string, value?: any, key?: string, storageType?: StorageType): Function;
/**
* Return the derive key
* Returns String
@@ -152,7 +153,7 @@ declare module 'angular' {
* Return localStorageService.length, ignore keys that not owned.
* Returns Number
*/
length(): number;
length(storageType?: StorageType): number;
/**
* Deal with browser's cookies directly.
*/
+140 -39
View File
@@ -1,15 +1,12 @@
var myApp = angular.module('testModule', ['ngMaterial']);
const myApp = angular.module('testModule', ['ngMaterial']);
myApp.config((
$mdThemingProvider: ng.material.IThemingProvider,
$mdIconProvider: ng.material.IIconProvider,
$mdProgressCircularProvider: ng.material.IProgressCircularProvider) => {
$mdThemingProvider.alwaysWatchTheme(true);
var neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', {
'500': 'ff0000'
const neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', {
500: 'ff0000'
});
// Register the new color palette map with the name <code>neonRed</code>
$mdThemingProvider.definePalette('neonRed', neonRedMap);
@@ -21,12 +18,13 @@ myApp.config((
.warnPalette('red')
.dark(true);
var browserColors: ng.material.IBrowserColors = {
theme: 'default',
palette: 'neonRed',
hue: '500'
const browserColors: ng.material.IBrowserColors = {
theme: 'default',
palette: 'neonRed',
hue: '500'
};
$mdThemingProvider.enableBrowserColor(browserColors);
const removeColors = $mdThemingProvider.enableBrowserColor(browserColors);
removeColors();
// Disable theming generation at runtime
$mdThemingProvider.disableTheming();
@@ -41,44 +39,67 @@ myApp.config((
$mdProgressCircularProvider.configure({
progressSize: 100,
strokeWidth: 20,
duration: 800
duration: 800,
easeFn(t, b, c, d) {
t /= d;
return c * t * t + b;
},
easeFnIndeterminate(t, b, c, d) {
return c * Math.pow(2, 10 * (t / d - 1)) + b;
}
});
});
myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService) => {
myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService, $q: ng.IQService) => {
$scope['openBottomSheet'] = () => {
$mdBottomSheet.show({
template: '<md-bottom-sheet>Hello!</md-bottom-sheet>',
clickOutsideToClose: true,
disableBackdrop: true,
disableParentScroll: false,
parent: () => {}
});
const options: ng.material.IBottomSheetOptions = {};
options.resolve = {
nativePromise: () => Promise.resolve(),
angularPromise: () => $q.resolve(),
annotatedNativePromise: ['fakeService', (fake) => Promise.resolve()],
annotatedAngularPromise: ['fakeService', (fake) => $q.resolve()]
};
options.controller = 'TestController';
options.controller = (function TestController(param: any) { });
options.controller = (class { });
options.controller = ['fakeService', function TestController(fake: any) { }];
options.controller = ['fakeService', class { }];
options.parent = (scope, element) => new Element();
options.parent = (scope, element) => angular.element(new Element());
options.parent = '#container';
options.parent = new Element();
options.parent = angular.element(new Element());
};
$scope['hideBottomSheet'] = $mdBottomSheet.hide.bind($mdBottomSheet, 'hide');
$scope['cancelBottomSheet'] = $mdBottomSheet.cancel.bind($mdBottomSheet, 'cancel');
});
myApp.controller('ColorController', ($scope: ng.IScope, $mdColor: ng.material.IColorService) => {
var colorExpression : ng.material.IColorExpression;
var element : Element;
colorExpression = { color: '#FFFFFF' }
element = new Element();
const colorExpression: ng.material.IColorExpression = { color: '#FFFFFF' };
const element: Element = new Element();
$scope['applyThemeColors'] = () => {
$mdColor.applyThemeColors(element, colorExpression);
};
$scope['getThemeColor'] = () => {
$mdColor.getThemeColor('default-neonRed')
$mdColor.getThemeColor('default-neonRed');
};
$scope['hasTheme'] = () => {
$mdColor.hasTheme();
};
});
myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService) => {
myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService, $q: ng.IQService) => {
$scope['openDialog'] = () => {
$mdDialog.show({
template: '<md-dialog>Hello!</md-dialog>'
@@ -120,16 +141,56 @@ myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.
};
$scope['hideDialog'] = $mdDialog.hide.bind($mdDialog, 'hide');
$scope['cancelDialog'] = $mdDialog.cancel.bind($mdDialog, 'cancel');
const alertPreset: ng.material.IAlertDialog = $mdDialog.alert()
.resolve({
nativePromise: () => Promise.resolve(),
angularPromise: () => $q.resolve(),
annotatedNativePromise: ['fakeService', (fake) => Promise.resolve()],
annotatedAngularPromise: ['fakeService', (fake) => $q.resolve()]
})
.controller('TestController')
.controller(function TestController(param) { })
.controller(class { })
.controller(['fakeService', function TestController(fake) { }])
.controller(['fakeService', class { }])
;
const dialogOptions: ng.material.IDialogOptions = {};
dialogOptions.resolve = {
nativePromise: () => Promise.resolve(),
angularPromise: () => $q.resolve(),
annotatedNativePromise: ['fakeService', (fake) => Promise.resolve()],
annotatedAngularPromise: ['fakeService', (fake) => $q.resolve()]
};
dialogOptions.controller = 'TestController';
dialogOptions.controller = (function TestController(param) { });
dialogOptions.controller = (class { });
dialogOptions.controller = ['fakeService', function TestController(fake) { }];
dialogOptions.controller = ['fakeService', class { }];
$mdDialog.show({
onShowing(scope, element) { },
onComplete(scope, element) { },
onRemoving(element, removePromise) { },
});
$mdDialog.show({
onShowing: (scope, element) => { },
onComplete: (scope, element) => { },
onRemoving: (element, removePromise) => { },
});
});
class IconDirective implements ng.IDirective {
private $mdIcon: ng.material.IIcon;
constructor($mdIcon: ng.material.IIcon) {
this.$mdIcon = $mdIcon;
}
public link($scope: ng.IScope, $elm: ng.IAugmentedJQuery) {
link($scope: ng.IScope, $elm: ng.IAugmentedJQuery) {
this.$mdIcon('android').then((iconEl: Element) => $elm.append(iconEl));
this.$mdIcon('work:chair').then((iconEl: Element) => $elm.append(iconEl));
// Load and cache the external SVG using a URL
@@ -150,7 +211,7 @@ myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.IM
});
myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.material.ISidenavService) => {
var componentId = 'left';
const componentId = 'left';
$scope['toggle'] = () => $mdSidenav(componentId).toggle();
$scope['open'] = () => $mdSidenav(componentId).open();
$scope['close'] = () => $mdSidenav(componentId).close();
@@ -165,41 +226,81 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia
instance.isLockedOpen();
});
$scope['onClose'] = $mdSidenav(componentId).onClose(() => {});
$scope['onClose'] = $mdSidenav(componentId).onClose(() => { });
});
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => {
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService, $q: ng.IQService) => {
$scope['openToast'] = () => {
$mdToast.show($mdToast.simple().textContent('Hello!'));
$mdToast.updateTextContent('New Content');
}
};
$scope['customToast'] = () => {
var options = {
const options: ng.material.IToastOptions = {
hideDelay: 3000,
position: 'top right',
controller : 'ToastCtrl',
templateUrl : 'toast-template.html',
toastClass: 'my-class'
controller: 'ToastCtrl',
templateUrl: 'toast-template.html',
toastClass: 'my-class',
resolve: {
nativePromise: () => Promise.resolve(),
angularPromise: () => $q.resolve(),
annotatedNativePromise: ['fakeService', (fake) => Promise.resolve()],
annotatedAngularPromise: ['fakeService', (fake) => $q.resolve()]
}
};
options.controller = 'TestController';
options.controller = (function TestController(param) { });
options.controller = (class { });
options.controller = ['fakeService', function TestController(fake) { }];
options.controller = ['fakeService', class { }];
$mdToast.show(options);
}
};
});
myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService) => {
myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService, $q: ng.IQService) => {
$scope['createPanel'] = () => {
var config = {
const config: ng.material.IPanelConfig = {
id: 'myPanel',
template: '<h1>Hello!</h1>',
hasBackdrop: true,
disableParentScroll: true,
zIndex: 150
zIndex: 150,
resolve: {
nativePromise: () => Promise.resolve(),
angularPromise: () => $q.resolve(),
annotatedNativePromise: ['fakeService', (fake) => Promise.resolve()],
annotatedAngularPromise: ['fakeService', (fake) => $q.resolve()]
}
};
config.controller = 'TestController';
config.controller = (function TestController(param) { });
config.controller = (class { });
config.controller = ['fakeService', function TestController(fake) { }];
config.controller = ['fakeService', class { }];
config.onDomAdded = (paneRef) => Promise.resolve();
config.onDomAdded = () => $q.reject();
config.onDomAdded = () => { };
config.onOpenComplete = (paneRef) => Promise.resolve();
config.onOpenComplete = () => $q.reject();
config.onOpenComplete = () => { };
config.onRemoving = (paneRef) => Promise.resolve();
config.onRemoving = () => $q.reject();
config.onRemoving = () => { };
config.onDomRemoved = (paneRef) => Promise.resolve();
config.onDomRemoved = () => $q.reject();
config.onDomRemoved = () => { };
$mdPanel.create(config);
var panelRef = $mdPanel.create(config);
let panelRef = $mdPanel.create(config);
panelRef.open()
.then((ref: ng.material.IPanelRef) => {
ref.addClass('foo');
@@ -232,6 +333,6 @@ myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IP
$scope['newPanelAnimation'] = () => {
$mdPanel.newPanelAnimation().openFrom('.some-target');
$mdPanel.newPanelAnimation().openFrom({top: 0, left: 0});
$mdPanel.newPanelAnimation().openFrom({ top: 0, left: 0 });
};
});
+35 -34
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular Material (angular.material module) 1.1
// Type definitions for angular-material 1.1
// Project: https://github.com/angular/material
// Definitions by: Blake Bigelow <https://github.com/blbigelow>, Peter Hajdu <https://github.com/PeterHajdu>, Davide Donadello <https://github.com/Dona278>, Geert Jansen <https://github.com/geertjansen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -9,21 +9,25 @@ declare var _: string;
export = _;
declare module 'angular' {
export namespace material {
namespace material {
interface ResolveObject {
[name: string]: Injectable<(...args: any[]) => PromiseLike<any>>;
}
interface IBottomSheetOptions {
templateUrl?: string;
template?: string;
scope?: angular.IScope; // default: new child scope
preserveScope?: boolean; // default: false
controller?: string | Function;
controller?: string | Injectable<IControllerConstructor>;
locals?: { [index: string]: any };
clickOutsideToClose?: boolean;
bindToController?: boolean; // default: false
disableBackdrop?: boolean;
escapeToClose?: boolean;
resolve?: { [index: string]: () => angular.IPromise<any> };
resolve?: ResolveObject;
controllerAs?: string;
parent?: Function | string | Object; // default: root node
parent?: ((scope: ng.IScope, element: JQuery) => Element | JQuery) | string | Element | JQuery; // default: root node
disableParentScroll?: boolean; // default: true
}
@@ -49,16 +53,16 @@ declare module 'angular' {
clickOutsideToClose(clickOutsideToClose?: boolean): T; // default: false
escapeToClose(escapeToClose?: boolean): T; // default: true
focusOnOpen(focusOnOpen?: boolean): T; // default: true
controller(controller?: string | Function): T;
controller(controller?: string | Injectable<IControllerConstructor>): T;
locals(locals?: { [index: string]: any }): T;
bindToController(bindToController?: boolean): T; // default: false
resolve(resolve?: { [index: string]: () => angular.IPromise<any> }): T;
resolve(resolve?: ResolveObject): T;
controllerAs(controllerAs?: string): T;
parent(parent?: string | Element | JQuery): T; // default: root node
onComplete(onComplete?: Function): T;
ariaLabel(ariaLabel: string): T;
}
// tslint:disable-next-line no-empty-interface
interface IAlertDialog extends IPresetDialog<IAlertDialog> {
}
@@ -97,15 +101,15 @@ declare module 'angular' {
clickOutsideToClose?: boolean; // default: false
escapeToClose?: boolean; // default: true
focusOnOpen?: boolean; // default: true
controller?: string | Function;
controller?: string | Injectable<IControllerConstructor>;
locals?: { [index: string]: any };
bindToController?: boolean; // default: false
resolve?: { [index: string]: () => angular.IPromise<any> }
resolve?: ResolveObject;
controllerAs?: string;
parent?: string | Element | JQuery; // default: root node
onShowing?: Function;
onComplete?: Function;
onRemoving?: Function;
onShowing?(scope: ng.IScope, element: JQuery): void;
onComplete?(scope: ng.IScope, element: JQuery): void;
onRemoving?(element: JQuery, removePromise: ng.IPromise<any>): void;
skipHide?: boolean;
multiple?: boolean;
fullscreen?: boolean; // default: false
@@ -120,9 +124,7 @@ declare module 'angular' {
cancel(response?: any): void;
}
interface IIcon {
(id: string): angular.IPromise<Element>; // id is a unique ID or URL
}
type IIcon = (id: string) => angular.IPromise<Element>; // id is a unique ID or URL
interface IIconProvider {
icon(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24
@@ -132,9 +134,7 @@ declare module 'angular' {
defaultFontSet(name: string): IIconProvider;
}
interface IMedia {
(media: string): boolean;
}
type IMedia = (media: string) => boolean;
interface ISidenavObject {
toggle(): angular.IPromise<void>;
@@ -142,7 +142,7 @@ declare module 'angular' {
close(): angular.IPromise<void>;
isOpen(): boolean;
isLockedOpen(): boolean;
onClose(onClose: Function): void;
onClose(onClose: () => void): void;
}
interface ISidenavService {
@@ -163,6 +163,7 @@ declare module 'angular' {
toastClass(toastClass: string): T;
}
// tslint:disable-next-line no-empty-interface
interface ISimpleToastPreset extends IToastPreset<ISimpleToastPreset> {
}
@@ -175,10 +176,10 @@ declare module 'angular' {
hideDelay?: number | false; // default (ms): 3000
position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left'
toastClass?: string;
controller?: string | Function;
controller?: string | Injectable<IControllerConstructor>;
locals?: { [index: string]: any };
bindToController?: boolean; // default: false
resolve?: { [index: string]: () => angular.IPromise<any> }
resolve?: ResolveObject;
controllerAs?: string;
parent?: string | Element | JQuery; // default: root node
}
@@ -263,19 +264,19 @@ declare module 'angular' {
interface IThemeConfig {
disableTheming: boolean;
generateOnDemand: boolean;
generateOnDemand: boolean;
nonce: string;
defaultTheme: string;
alwaysWatchTheme: boolean;
registeredStyles: Array<string>;
registeredStyles: string[];
}
interface IThemingProvider {
alwaysWatchTheme(alwaysWatch: boolean): void;
definePalette(name: string, palette: IPalette): IThemingProvider;
enableBrowserColor(browserColors: IBrowserColors): Function;
enableBrowserColor(browserColors: IBrowserColors): () => void;
extendPalette(name: string, palette: IPalette): IPalette;
registerStyles(styles: String): void;
registerStyles(styles: string): void;
setDefaultTheme(theme: string): void;
setNonce(nonce: string): void;
theme(name: string, inheritFrom?: string): ITheme;
@@ -328,11 +329,11 @@ declare module 'angular' {
id?: string;
template?: string;
templateUrl?: string;
controller?: string | Function;
controller?: string | Injectable<IControllerConstructor>;
controllerAs?: string;
bindToController?: boolean; // default: true
locals?: { [index: string]: any };
resolve?: { [index: string]: () => angular.IPromise<any> }
resolve?: ResolveObject;
attachTo?: string | JQuery | Element;
propagateContainerEvents?: boolean;
panelClass?: string;
@@ -346,10 +347,10 @@ declare module 'angular' {
animation?: IPanelAnimation;
hasBackdrop?: boolean; // default: false
disableParentScroll?: boolean; // default: false
onDomAdded?: Function;
onOpenComplete?: Function;
onRemoving?: Function;
onDomRemoved?: Function;
onDomAdded?(...args: any[]): PromiseLike<void> | void;
onOpenComplete?(...args: any[]): PromiseLike<void> | void;
onRemoving?(...args: any[]): PromiseLike<void> | void;
onDomRemoved?(...args: any[]): PromiseLike<void> | void;
origin?: string | JQuery | Element;
onCloseSuccess?: ((panel: IPanelRef, closeReason: string) => any);
}
@@ -442,11 +443,11 @@ declare module 'angular' {
progressSize?: number;
strokeWidth?: number;
duration?: number;
easeFn?: Function;
easeFn?(t: number, b: number, c: number, d: number): number;
durationIndeterminate?: number;
startIndeterminate?: number;
endIndeterminate?: number;
easeFnIndeterminate?: Function;
easeFnIndeterminate?(t: number, b: number, c: number, d: number): number;
}
interface IProgressCircularProvider {
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": false,
"max-line-length": false
}
}
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
@@ -1,7 +1,7 @@
angular.module('promise-tracker-tests', []).run(['$q', 'promiseTracker',
($q: angular.IQService, promiseTracker: angular.promisetracker.PromiseTrackerService) => {
const trackerWithoutOptions = promiseTracker();
const options = {
activationDelay: 10,
minDuration: 500
@@ -17,4 +17,6 @@ angular.module('promise-tracker-tests', []).run(['$q', 'promiseTracker',
const promiseToAdd = $q.defer().promise;
const addedPromise: angular.IDeferred<void> = trackerWithOptions.addPromise(promiseToAdd);
const trackerWithSomeOptions = promiseTracker({activationDelay: 500});
}]);
+2 -2
View File
@@ -10,8 +10,8 @@ import * as angular from 'angular';
declare module 'angular' {
export namespace promisetracker {
interface PromiseTrackerOptions {
activationDelay: number;
minDuration: number;
activationDelay?: number;
minDuration?: number;
}
interface PromiseTracker {
@@ -1,74 +1,72 @@
angular
.module('app', ['SignalR'])
.factory('Employees', ngSignalrTest.EmployeesFactory);
class EmployeesFactory {
static $inject = ['$rootScope', 'Hub', '$timeout'];
private hub: ngSignalr.Hub;
public all: Array<Employee>;
namespace ngSignalrTest {
export class EmployeesFactory {
static $inject = ['$rootScope', 'Hub', '$timeout'];
private hub: ngSignalr.Hub;
public all: Array<Employee>;
constructor($rootScope: ng.IRootScopeService, Hub: ngSignalr.HubFactory, $timeout: ng.ITimeoutService) {
// declaring the hub connection
this.hub = new Hub('employee', {
// client-side methods
listeners: {
'lockEmployee': (id: number) => {
var employee = this.find(id);
employee.Locked = true;
$rootScope.$apply();
},
'unlockEmployee': (id: number) => {
var employee = this.find(id);
employee.Locked = false;
$rootScope.$apply();
}
constructor($rootScope: ng.IRootScopeService, Hub: ngSignalr.HubFactory, $timeout: ng.ITimeoutService) {
// declaring the hub connection
this.hub = new Hub('employee', {
// client-side methods
listeners: {
'lockEmployee': (id: number) => {
var employee = this.find(id);
employee.Locked = true;
$rootScope.$apply();
},
// server-side methods
methods: ['lock', 'unlock'],
// query params sent on initial connection
queryParams:{
'token': 'exampletoken'
},
// handle connection error
errorHandler: (message: string) => {
console.error(message);
},
stateChanged: (state: SignalR.StateChanged) => {
// your code here
'unlockEmployee': (id: number) => {
var employee = this.find(id);
employee.Locked = false;
$rootScope.$apply();
}
});
}
},
private find(id: number) {
for (var i = 0; i < this.all.length; i++) {
if (this.all[i].Id === id) return this.all[i];
// server-side methods
methods: ['lock', 'unlock'],
// query params sent on initial connection
queryParams:{
'token': 'exampletoken'
},
// handle connection error
errorHandler: (message: string) => {
console.error(message);
},
stateChanged: (state: SignalR.StateChanged) => {
// your code here
}
return null;
}
public edit = (employee: Employee) => {
employee.Edit = true;
this.hub.invoke('lock', employee.Id);
};
public done = (employee: Employee) => {
employee.Edit = false;
this.hub.invoke('unlock', employee.Id);
}
});
}
interface Employee {
Id: number;
Name: string;
Email: string;
Salary: number;
Edit: boolean;
Locked: boolean;
private find(id: number) {
for (var i = 0; i < this.all.length; i++) {
if (this.all[i].Id === id) return this.all[i];
}
return null;
}
public edit = (employee: Employee) => {
employee.Edit = true;
this.hub.invoke('lock', employee.Id);
};
public done = (employee: Employee) => {
employee.Edit = false;
this.hub.invoke('unlock', employee.Id);
}
}
interface Employee {
Id: number;
Name: string;
Email: string;
Salary: number;
Edit: boolean;
Locked: boolean;
}
angular
.module('app', ['SignalR'])
.factory('Employees', EmployeesFactory);
@@ -2,11 +2,9 @@
var myApp = angular.module('testModule');
namespace AngularSpinnerTest {
var app = angular.module("angularSpinnerTest", ["angular-spinner"]);
var app = angular.module("angularSpinnerTest", ["angular-spinner"]);
app.config(['usSpinnerService', function(usSpinnerService: ISpinnerService) {
usSpinnerService.spin('key1');
usSpinnerService.stop('key2');
}]);
}
app.config(['usSpinnerService', function(usSpinnerService: ISpinnerService) {
usSpinnerService.spin('key1');
usSpinnerService.stop('key2');
}]);
+4 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for Angular Toastr v1.6.0
// Project: https://github.com/Foxandxss/angular-toastr
// Definitions by: Niko Kovačič <https://github.com/nkovacic>
// Definitions by: Niko Kovačič <https://github.com/nkovacic>, Troy McKinnon <https://github.com/trodi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="angular" />
@@ -15,9 +15,9 @@ declare module 'angular' {
closeHtml?: string;
extendedTimeOut?: number;
messageClass?: string;
onHidden?: Function;
onShown?: Function;
onTap?: Function;
onHidden?: (wasClicked: boolean, toast: angular.toastr.IToast) => void;
onShown?: (toast: angular.toastr.IToast) => void;
onTap?: (toast: angular.toastr.IToast) => void;
progressBar?: boolean;
tapToDismiss?: boolean;
templates?: {
@@ -1,6 +1,7 @@
import * as angular from 'angular';
import * as angularTranslate from 'angular-translate';
var app = angular.module('at', ['pascalprecht.translate']);
var app = angular.module('at', [angularTranslate]);
app.factory('customLoader', ($q:angular.IQService) => {
return (options:any) => {
+3
View File
@@ -5,6 +5,9 @@
/// <reference types="angular" />
declare var _: string;
export = _;
import * as angular from 'angular';
declare module 'angular' {
+23
View File
@@ -470,6 +470,29 @@ namespace TestInjector {
$injector.annotate(() => {});
$injector.annotate(() => {}, true);
// $injector.instantiate
{
class Foobar {
constructor($q) {}
}
let result: Foobar = $injector.instantiate(Foobar);
}
// $injector.invoke
{
function foobar(v: boolean): number {
return 7;
}
let result = $injector.invoke(foobar);
if (!(typeof result === 'number')) {
// This fails to compile if 'result' is not exactly a number.
let expectNever: never = result;
}
let anyFunction: Function = foobar;
let anyResult: string = $injector.invoke(anyFunction);
}
}
// Promise signature tests
+2 -1
View File
@@ -1978,8 +1978,9 @@ declare namespace angular {
get(name: '$window'): IWindowService;
get<T>(name: '$xhrFactory'): IXhrFactory<T>;
has(name: string): boolean;
instantiate<T>(typeConstructor: Function, locals?: any): T;
instantiate<T>(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
invoke(inlineAnnotatedFunction: any[]): any;
invoke<T>(func: (...args: any[]) => T, context?: any, locals?: any): T;
invoke(func: Function, context?: any, locals?: any): any;
strictDi: boolean;
}
+2 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
"class-name": true,
"indent": [true, "spaces"],
@@ -13,6 +13,7 @@
"jsdoc-format": false,
"max-line-length": false,
"no-empty-interface": false,
"no-namespace": false,
"unified-signatures": false,
"void-return": false
}
@@ -1,8 +1,6 @@
namespace AnimationFrameTests {
var animation = new AnimationFrame();
function frame() {
animation.request(frame);
}
var animation = new AnimationFrame();
function frame() {
animation.request(frame);
}
animation.request(frame);
-2
View File
@@ -3,8 +3,6 @@
// Definitions by: Gorgi Kosev <https://github.com/spion>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="bluebird" />
import Promise = require('bluebird');
import { Column, Table, Transaction, AnydbSql } from 'anydb-sql';
export interface Migration {
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"anydb-sql": "^0.6.53"
}
}
-70
View File
@@ -1,70 +0,0 @@
import anydbsql = require('anydb-sql');
import { Table, Column } from 'anydb-sql'
function do_not_run() {
var db = anydbsql({
url: 'postgres://user:pass@host:port/database',
connections: { min: 2, max: 20 }
});
// Table Post
interface Post {
content: string;
userId: string;
date: string;
}
interface PostTable extends Table<Post> {
content: Column<string>;
userId: Column<string>;
date: Column<string>;
}
var post = <PostTable>db.define<Post>({
name: 'posts',
columns: {
content: {},
userId: {},
date: {}
}
});
// Table User
interface User {
id: string;
email: string;
password: string;
name: string;
}
interface UserTable extends Table<User> {
id: Column<string>;
email: Column<string>;
password: Column<string>;
name: Column<string>;
}
var user = <UserTable>db.define<User>({
name: 'users',
columns: {
id: { primaryKey: true },
email: {},
password: {},
name: {},
date: {}
},
has: {
posts: { from: 'posts', many: true },
group: { from: 'groups'}
}
});
user.select(user.name, post.content)
.from(user.join(post).on(user.id.equals(post.userId)))
.where(post.date.gt('123'))
.all()
}
-193
View File
@@ -1,193 +0,0 @@
// Type definitions for anydb-sql
// Project: https://github.com/doxout/anydb-sql
// Definitions by: Gorgi Kosev <https://github.com/spion>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface AnyDBPool extends anydbSQL.DatabaseConnection {
query: (text: string, values: any[], callback: (err: Error, result: any) => void) => void
begin: () => anydbSQL.Transaction
close: (err: Error) => void
}
interface Dictionary<T> { [key: string]: T; }
declare namespace anydbSQL {
export interface OrderByValueNode { }
export interface ColumnDefinition {
primaryKey?: boolean;
dataType?: string;
references?: { table: string; column: string }
notNull?: boolean
}
export interface TableDefinition {
name: string
columns: Dictionary<ColumnDefinition>
has?: Dictionary<{ from: string; many?: boolean }>
}
export interface QueryLike {
query: string;
values: any[]
text: string
}
export interface DatabaseConnection {
queryAsync<T>(query: string, ...params: any[]): Promise<{ rowCount: number; rows: T[] }>
queryAsync<T>(query: QueryLike): Promise<{ rowCount: number; rows: T[] }>
}
export interface Transaction extends DatabaseConnection {
rollback(): void
commitAsync(): Promise<void>
}
export interface SubQuery<T> {
select(node: Column<T>): SubQuery<T>
where(...nodes: any[]): SubQuery<T>
from(table: TableNode): SubQuery<T>
group(...nodes: any[]): SubQuery<T>
order(criteria: OrderByValueNode): SubQuery<T>
notExists(subQuery: SubQuery<any>): SubQuery<T>
}
interface Executable<T> {
get(): Promise<T>
getWithin(tx: DatabaseConnection): Promise<T>
exec(): Promise<void>
all(): Promise<T[]>
execWithin(tx: DatabaseConnection): Promise<void>
allWithin(tx: DatabaseConnection): Promise<T[]>
toQuery(): QueryLike;
}
interface Queryable<T> {
where(...nodes: any[]): Query<T>
delete(): ModifyingQuery
select<U>(...nodes: any[]): Query<U>
selectDeep<U>(table: Table<T>): Query<T>
selectDeep<U>(...nodesOrTables: any[]): Query<U>
}
export interface Query<T> extends Executable<T>, Queryable<T> {
from(table: TableNode): Query<T>
update(o: Dictionary<any>): ModifyingQuery
update(o: {}): ModifyingQuery
group(...nodes: any[]): Query<T>
order(...criteria: OrderByValueNode[]): Query<T>
limit(l: number): Query<T>
offset(o: number): Query<T>
}
export interface ModifyingQuery extends Executable<void> {
returning<U>(...nodes: any[]): Query<U>
where(...nodes: any[]): ModifyingQuery
}
export interface TableNode {
join(table: TableNode): JoinTableNode
leftJoin(table: TableNode): JoinTableNode
}
export interface JoinTableNode extends TableNode {
on(filter: BinaryNode): TableNode
on(filter: string): TableNode
}
interface CreateQuery extends Executable<void> {
ifNotExists(): Executable<void>
}
interface DropQuery extends Executable<void> {
ifExists(): Executable<void>
}
export interface Table<T> extends TableNode, Queryable<T> {
create(): CreateQuery
drop(): DropQuery
as(name: string): Table<T>
update(o: any): ModifyingQuery
insert(row: T): ModifyingQuery
insert(rows: T[]): ModifyingQuery
select(): Query<T>
select<U>(...nodes: any[]): Query<U>
from<U>(table: TableNode): Query<U>
star(): Column<any>
subQuery<U>(): SubQuery<U>
eventEmitter: {
emit: (type: string, ...args: any[]) => void
on: (eventName: string, handler: Function) => void
}
columns: Column<any>[]
sql: SQL;
alter(): AlterQuery<T>
}
export interface AlterQuery<T> extends Executable<void> {
addColumn(column: Column<any>): AlterQuery<T>;
addColumn(name: string, options: string): AlterQuery<T>;
dropColumn(column: Column<any>): AlterQuery<T>;
renameColumn(column: Column<any>, newColumn: Column<any>): AlterQuery<T>;
renameColumn(column: Column<any>, newName: string): AlterQuery<T>;
renameColumn(name: string, newName: string): AlterQuery<T>;
rename(newName: string): AlterQuery<T>
}
export interface SQL {
functions: {
LOWER(c: Column<string>): Column<string>
}
}
export interface BinaryNode {
and(node: BinaryNode): BinaryNode
or(node: BinaryNode): BinaryNode
}
export interface Column<T> {
in(arr: T[]): BinaryNode
in(subQuery: SubQuery<T>): BinaryNode
notIn(arr: T[]): BinaryNode
equals(node: any): BinaryNode
notEquals(node: any): BinaryNode
gte(node: any): BinaryNode
lte(node: any): BinaryNode
gt(node: any): BinaryNode
lt(node: any): BinaryNode
like(str: string): BinaryNode
multiply: {
(node: Column<T>): Column<T>
(n: number): Column<number>
}
isNull(): BinaryNode
isNotNull(): BinaryNode
sum(): Column<number>
count(): Column<number>
count(name: string): Column<number>
distinct(): Column<T>
as(name: string): Column<T>
ascending: OrderByValueNode
descending: OrderByValueNode
asc: OrderByValueNode
desc: OrderByValueNode
}
export interface AnydbSql extends DatabaseConnection {
define<T>(map: TableDefinition): Table<T>;
transaction<T>(fn: (tx: Transaction) => Promise<T>): Promise<T>
allOf(...tables: Table<any>[]): any
models: Dictionary<Table<any>>
functions: {
LOWER: (name: Column<string>) => Column<string>
RTRIM: (name: Column<string>) => Column<string>
}
makeFunction(name: string): Function
begin(): Transaction
open(): void;
close(): void;
getPool(): AnyDBPool;
dialect(): string;
}
}
declare function anydbSQL(config: Object): anydbSQL.AnydbSql;
export = anydbSQL;
-22
View File
@@ -1,22 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"anydb-sql-tests.ts"
]
}
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -392,7 +392,7 @@ declare namespace ApplePayJS {
/**
* A set of shipping method objects that describe the available shipping methods.
*/
shippingMethods?: ApplePayShippingMethod[] | string[];
shippingMethods?: ApplePayShippingMethod[];
/**
* How the items are to be shipped.
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+2 -2
View File
@@ -1,8 +1,8 @@
{
"extends": "../tslint.json",
"extends": "dtslint/dt.json",
"rules": {
"interface-name": [ false ],
"no-internal-module": false,
"no-single-declare-module": false
}
}
}
+1 -3
View File
@@ -2,8 +2,6 @@ import Map = require("esri/Map");
import MapView = require("esri/views/MapView");
import Point = require("esri/geometry/Point");
export = MapController;
class MapController {
map: Map;
@@ -19,7 +17,7 @@ class MapController {
this.map = new Map({
basemap: "topo"
});
let view = new MapView({
center: point,
container: this.mapDiv,
+48 -48
View File
@@ -667,6 +667,8 @@ declare namespace __esri {
export type EasingFunction = (t: number, duration: number) => number;
export type EventHandler = (event: any) => void;
export interface PromisedWatchHandle extends IPromise<any> {
remove(): void;
}
@@ -1337,7 +1339,7 @@ declare namespace __esri {
maxZoom?: number;
snapToZoom?: boolean;
rotationEnabled?: boolean;
effectiveLODs?: number;
effectiveLODs?: LOD[];
effectiveMinZoom?: number;
effectiveMaxZoom?: number;
effectiveMinScale?: number;
@@ -1868,21 +1870,6 @@ declare namespace __esri {
worldScale?: boolean;
}
interface Evented {
emit(type: string, event: any): IHandle;
on(name: string, callback: Function): IHandle;
}
interface EventedConstructor {
new(): Evented;
hasEventListener(type: string): boolean;
on(type: string, listener: Function): any;
}
export const Evented: EventedConstructor;
interface Basemap extends Accessor, Loadable, JSONSupport {
baseLayers: Collection;
id: string;
@@ -1907,11 +1894,11 @@ declare namespace __esri {
export const Basemap: BasemapConstructor;
interface BasemapProperties extends LoadableProperties {
baseLayers?: Collection;
baseLayers?: Collection | any[];
id?: string;
loaded?: boolean;
portalItem?: PortalItemProperties;
referenceLayers?: Collection;
referenceLayers?: Collection | any[];
thumbnailUrl?: string;
title?: string;
}
@@ -2013,7 +2000,7 @@ declare namespace __esri {
export const Ground: GroundConstructor;
interface GroundProperties {
layers?: Collection;
layers?: Collection | any[];
}
interface Map extends Accessor, LayersMixin {
@@ -2029,7 +2016,7 @@ declare namespace __esri {
export const Map: MapConstructor;
interface MapProperties extends LayersMixinProperties {
allLayers?: Collection;
allLayers?: Collection | any[];
basemap?: BasemapProperties;
ground?: GroundProperties;
}
@@ -2053,7 +2040,7 @@ declare namespace __esri {
export const PopupTemplate: PopupTemplateConstructor;
interface PopupTemplateProperties {
actions?: Collection;
actions?: Collection | any[];
content?: string | any[] | Function;
fieldInfos?: PopupTemplateFieldInfos[];
overwriteActions?: boolean;
@@ -2718,6 +2705,7 @@ declare namespace __esri {
definitionExpression: string;
elevationInfo: FeatureLayerElevationInfo;
fields: Field[];
gdbVersion: string;
geometryType: string;
hasAttachments: boolean;
hasM: boolean;
@@ -2762,6 +2750,7 @@ declare namespace __esri {
definitionExpression?: string;
elevationInfo?: FeatureLayerElevationInfo;
fields?: FieldProperties[];
gdbVersion?: string;
geometryType?: string;
hasAttachments?: boolean;
hasM?: boolean;
@@ -2777,7 +2766,7 @@ declare namespace __esri {
renderer?: RendererProperties;
returnM?: boolean;
returnZ?: boolean;
source?: Collection;
source?: Collection | any[];
spatialReference?: SpatialReferenceProperties;
token?: string;
url?: string;
@@ -2823,7 +2812,7 @@ declare namespace __esri {
interface GraphicsLayerProperties extends LayerProperties, ScaleRangeLayerProperties {
elevationInfo?: GraphicsLayerElevationInfo;
graphics?: Collection;
graphics?: Collection | any[];
}
interface GroupLayer extends Layer, LayersMixin, JSONSupport, PortalLayer {
@@ -3419,7 +3408,7 @@ declare namespace __esri {
popupTemplate?: PopupTemplateProperties;
renderer?: RendererProperties;
source?: any | any;
sublayers?: Collection;
sublayers?: Collection | any[];
title?: string;
url?: string;
visible?: boolean;
@@ -4506,7 +4495,7 @@ declare namespace __esri {
interface Symbol3DProperties extends SymbolProperties {
styleOrigin?: Symbol3DStyleOrigin;
symbolLayers?: Collection;
symbolLayers?: Collection | any[];
}
interface Symbol3DLayer extends Accessor, JSONSupport {
@@ -6170,7 +6159,7 @@ declare namespace __esri {
goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | any, options?: MapViewGoToOptions): IPromise<any>;
hasEventListener(type: string): boolean;
hitTest(screenPoint: MapViewHitTestScreenPoint): IPromise<any>;
on(type: string | string[], modifiersOrHandler: string[] | Function, handler?: Function): any;
on(type: string | string[], modifiersOrHandler: string[] | EventHandler, handler?: EventHandler): IHandle;
toMap(screenPoint: ScreenPoint, mapPoint?: Point): Point;
toScreen(point: Point, screenPoint?: ScreenPoint): ScreenPoint;
}
@@ -6208,7 +6197,7 @@ declare namespace __esri {
goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | Camera | any, options?: SceneViewGoToOptions): IPromise<any>;
hasEventListener(type: string): boolean;
hitTest(screenPoint: SceneViewHitTestScreenPoint): IPromise<any>;
on(type: string | string[], modifiersOrHandler: string[] | Function, handler?: Function): any;
on(type: string | string[], modifiersOrHandler: string[] | EventHandler, handler?: EventHandler): IHandle;
toMap(screenPoint: ScreenPoint, mapPoint?: Point): Point;
toScreen(point: Point, screenPoint?: ScreenPoint): ScreenPoint;
}
@@ -6257,11 +6246,11 @@ declare namespace __esri {
export const View: ViewConstructor;
interface ViewProperties extends BreakpointsOwnerProperties, DOMContainerProperties {
allLayerViews?: Collection;
allLayerViews?: Collection | any[];
animation?: ViewAnimationProperties;
graphics?: Collection;
graphics?: Collection | any[];
interacting?: boolean;
layerViews?: Collection;
layerViews?: Collection | any[];
map?: MapProperties;
padding?: ViewPadding;
ready?: boolean;
@@ -6502,7 +6491,7 @@ declare namespace __esri {
export const Presentation: PresentationConstructor;
interface PresentationProperties {
slides?: Collection;
slides?: Collection | any[];
}
interface Slide extends Accessor {
@@ -6736,7 +6725,7 @@ declare namespace __esri {
interface LayerListProperties extends WidgetProperties {
createActionsFunction?: Function;
operationalItems?: Collection;
operationalItems?: Collection | any[];
view?: MapView | SceneView;
viewModel?: LayerListViewModelProperties;
}
@@ -6813,7 +6802,6 @@ declare namespace __esri {
features: Graphic[];
location: Point;
promises: IPromise<any>[];
rendered: boolean;
selectedFeature: Graphic;
selectedFeatureIndex: number;
title: string;
@@ -6836,7 +6824,7 @@ declare namespace __esri {
export const Popup: PopupConstructor;
interface PopupProperties extends WidgetteProperties {
actions?: Collection;
actions?: Collection | any[];
content?: string | any;
currentDockPosition?: string;
dockEnabled?: boolean;
@@ -6845,7 +6833,6 @@ declare namespace __esri {
features?: GraphicProperties[];
location?: PointProperties;
promises?: IPromise<any>[];
rendered?: boolean;
selectedFeature?: GraphicProperties;
selectedFeatureIndex?: number;
title?: string;
@@ -7142,7 +7129,7 @@ declare namespace __esri {
interface BasemapGalleryViewModelProperties {
activeBasemap?: BasemapProperties;
items?: Collection;
items?: Collection | any[];
source?: LocalBasemapsSource | PortalBasemapsSource;
state?: string;
view?: MapView | SceneView;
@@ -7245,7 +7232,7 @@ declare namespace __esri {
interface LayerListViewModelProperties {
createActionsFunction?: Function;
operationalItems?: Collection;
operationalItems?: Collection | any[];
state?: string;
view?: MapView | SceneView;
}
@@ -7356,7 +7343,7 @@ declare namespace __esri {
export const PopupViewModel: PopupViewModelConstructor;
interface PopupViewModelProperties {
actions?: Collection;
actions?: Collection | any[];
content?: string | any;
featureCount?: number;
features?: GraphicProperties[];
@@ -7491,6 +7478,17 @@ declare namespace __esri {
view?: MapView | SceneView;
}
interface Evented {
hasEventListener(type: string): boolean;
on(type: string, listener: EventHandler): IHandle;
}
interface EventedConstructor {
new(): Evented;
}
export const Evented: EventedConstructor;
interface JSONSupport {
toJSON(): any;
}
@@ -7627,14 +7625,14 @@ declare namespace __esri {
export const ArcGISDynamicMapService: ArcGISDynamicMapServiceConstructor;
interface ArcGISDynamicMapServiceProperties {
allSublayers?: Collection;
allSublayers?: Collection | any[];
dpi?: number;
gdbVersion?: string;
imageFormat?: string;
imageMaxHeight?: number;
imageMaxWidth?: number;
imageTransparency?: boolean;
sublayers?: Collection;
sublayers?: Collection | any[];
}
interface ArcGISImageService {
@@ -7809,7 +7807,7 @@ declare namespace __esri {
export const LayersMixin: LayersMixinConstructor;
interface LayersMixinProperties {
layers?: Collection;
layers?: Collection | any[];
}
interface BreakpointsOwner {
@@ -7833,7 +7831,7 @@ declare namespace __esri {
}
interface DOMContainer {
container: string;
container: HTMLDivElement | string;
height: number;
popup: Popup;
resizing: boolean;
@@ -7850,7 +7848,7 @@ declare namespace __esri {
export const DOMContainer: DOMContainerConstructor;
interface DOMContainerProperties {
container?: string;
container?: HTMLDivElement | string;
height?: number;
popup?: Popup;
resizing?: boolean;
@@ -8381,6 +8379,8 @@ declare module "esri" {
export import EasingFunction = __esri.EasingFunction;
export import EventHandler = __esri.EventHandler;
export import PromisedWatchHandle = __esri.PromisedWatchHandle;
export import GroundQueryElevationOptions = __esri.GroundQueryElevationOptions;
@@ -8748,11 +8748,6 @@ declare module "esri" {
export import sizeGetSchemesParams = __esri.sizeGetSchemesParams;
}
declare module "esri/core/Evented" {
import Evented = __esri.Evented;
export = Evented;
}
declare module "esri/Basemap" {
import Basemap = __esri.Basemap;
export = Basemap;
@@ -9833,6 +9828,11 @@ declare module "esri/widgets/Zoom/ZoomViewModel" {
export = ZoomViewModel;
}
declare module "esri/core/Evented" {
import Evented = __esri.Evented;
export = Evented;
}
declare module "esri/core/JSONSupport" {
import JSONSupport = __esri.JSONSupport;
export = JSONSupport;
@@ -2,8 +2,6 @@ import esri = require("esri");
import Map = require("esri/map");
import Point = require("esri/geometry/Point");
export = MapController;
class MapController {
map: Map;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for arcgis-to-geojson-utils 10.4
// Type definitions for ArcGIS REST API 10.4
// Project: http://resources.arcgis.com/en/help/arcgis-rest-api/
// Definitions by: Jeff Jacobson <https://github.com/JeffJacobson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+19 -7
View File
@@ -1,14 +1,16 @@
import Archiver = require('archiver');
import FS = require('fs');
var archiver = Archiver.create('zip');
const archiver = Archiver.create('zip');
var writeStream = FS.createWriteStream('./archiver.d.ts');
var readStream = FS.createReadStream('./archiver.d.ts');
const writeStream = FS.createWriteStream('./archiver.d.ts');
const readStream = FS.createReadStream('./archiver.d.ts');
archiver.pipe(writeStream);
archiver.append(readStream, {name: 'archiver.d.ts'});
archiver.finalize();
archiver.abort();
archiver.append(readStream, {name: 'archiver.d.ts'})
.append(readStream, {name: 'archiver.d.ts'});
archiver.bulk({ mappaing: {} });
archiver.directory('./path', './someOtherPath');
archiver.directory('./path', { name: "testName"} );
@@ -16,4 +18,14 @@ archiver.directory('./path', { name: "testName"} );
archiver.directory('./', "", {});
archiver.directory('./', {name: 'test'}, {});
archiver.bulk({ mappaing: {} });
archiver.file('./path', { name: 'test' });
archiver.glob('./path', {}, {});
archiver.finalize();
archiver.setFormat('zip');
archiver.setModule(() => {});
archiver.pointer();
archiver.use(() => {});
archiver.pipe(writeStream);
+18 -15
View File
@@ -1,4 +1,4 @@
// Type definitions for archiver v0.15.0
// Type definitions for archiver 1.3
// Project: https://github.com/archiverjs/node-archiver
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -18,30 +18,33 @@
import * as FS from 'fs';
import * as STREAM from 'stream';
declare function archiver(format: string, options?: archiver.Options): archiver.Archiver;
declare function archiver(format: string, options?: {}): archiver.Archiver;
declare namespace archiver {
function create(format: string, options?: {}): Archiver;
function registerFormat(format: string, module: Function): void;
export function create(format: string, options?: Options): Archiver;
export interface nameInterface {
interface nameInterface {
name?: string;
}
export interface Archiver extends STREAM.Transform {
append(source: STREAM.Readable | Buffer | string, name: nameInterface): void;
interface Archiver extends STREAM.Transform {
abort(): this;
append(source: STREAM.Readable | Buffer | string, name: nameInterface): this;
directory(dirpath: string, destpath: nameInterface | string): void;
directory(dirpath: string, destpath: nameInterface | string, data: any | Function): void;
bulk(mappings: any): this;
bulk(mappings: any): void;
finalize(): void;
}
directory(dirpath: string, destpath: nameInterface | string, data?: any | Function): this;
export interface Options {
file(filepath: string, data: any): this;
glob(pattern: string, options: {}, data: any): this;
finalize(): this;
setFormat(format: string): this;
setModule(module: Function): this;
pointer(): number;
use(plugin: Function): this;
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false
}
}
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,16 @@
import * as React from 'react';
import assertEqualJSX = require('assert-equal-jsx');
function sanitizeId(str: string): string {
return str.replace(/my-component-id-(\d+)/ig, 'my-component-id-0');
}
assertEqualJSX(
<div id='my-component-id-314159265' />,
// should equal:
<div id='my-component-id-0' />,
// with sanitization:
{
sanitize: sanitizeId
}
);
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for assert-equal-jsx 1.0
// Project: https://github.com/thejameskyle/assert-equal-jsx
// Definitions by: Josh Toft <https://github.com/seryl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as React from 'react';
declare namespace assertEqualJSX {
interface AsssertOptions {
sanitize?(str: string): string;
}
}
declare function assertEqualJSX(actual: JSX.Element, expected: JSX.Element, opts?: assertEqualJSX.AsssertOptions): void;
export = assertEqualJSX;
@@ -7,8 +7,9 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
@@ -18,6 +19,6 @@
},
"files": [
"index.d.ts",
"fast-json-patch-tests.ts"
"assert-equal-jsx-tests.tsx"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+6
View File
@@ -0,0 +1,6 @@
import * as autosni from "auto-sni";
let a = autosni({
agreeTos: true,
email: '',
domains: ['']
});
+25
View File
@@ -0,0 +1,25 @@
// Type definitions for auto-sni 2.1
// Project: https://www.npmjs.com/package/auto-sni
// Definitions by: Jan Wolf <https://github.com/janwo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import {Server} from "https";
declare namespace createServer {
interface Options {
email: string;
agreeTos: boolean;
domains: Array<string | string[]>;
ports?: {
http?: number,
https?: number
};
debug?: boolean;
}
}
declare function createServer(opts: createServer.Options, app?: any): Server;
export = createServer;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"auto-sni-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+2 -2
View File
@@ -1,3 +1,3 @@
{
"extends": "../tslint.json"
}
"extends": "dtslint/dt.json"
}
+54
View File
@@ -5,12 +5,17 @@ var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var apiGwEvt: AWSLambda.APIGatewayEvent;
var customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent;
var clientCtx: AWSLambda.ClientContext;
var clientContextEnv: AWSLambda.ClientContextEnv;
var clientContextClient: AWSLambda.ClientContextClient;
var context: AWSLambda.Context;
var identity: AWSLambda.CognitoIdentity;
var proxyResult: AWSLambda.ProxyResult;
var authResponse: AWSLambda.AuthResponse;
var policyDocument: AWSLambda.PolicyDocument;
var statement: AWSLambda.Statement;
var authResponseContext: AWSLambda.AuthResponseContext;
var snsEvt: AWSLambda.SNSEvent;
var snsEvtRecs: AWSLambda.SNSEventRecord[];
var snsEvtRec: AWSLambda.SNSEventRecord;
@@ -87,6 +92,11 @@ str = apiGwEvt.requestContext.resourceId;
str = apiGwEvt.requestContext.resourcePath;
str = apiGwEvt.resource;
/* API Gateway CustomAuthorizer Event */
str = customAuthorizerEvt.type;
str = customAuthorizerEvt.authorizationToken;
str = customAuthorizerEvt.methodArn;
/* SNS Event */
snsEvtRecs = snsEvt.Records;
@@ -119,6 +129,41 @@ proxyResult.headers["example"] = b;
proxyResult.headers["example"] = num;
str = proxyResult.body;
/* API Gateway CustomAuthorizer AuthResponse */
authResponseContext = {
stringKey: str,
numberKey: num,
booleanKey: b
};
statement = {
Action: str,
Effect: str,
Resource: str
};
statement = {
Action: [str, str],
Effect: str,
Resource: [str, str]
};
policyDocument = {
Version: str,
Statement: [statement]
};
authResponse = {
principalId: str,
policyDocument: policyDocument,
context: authResponseContext
};
authResponse = {
principalId: str,
policyDocument: policyDocument
};
/* Context */
b = context.callbackWaitsForEmptyEventLoop;
str = context.functionName;
@@ -170,6 +215,14 @@ function proxyCallback(cb: AWSLambda.ProxyCallback) {
cb(null, proxyResult);
}
/* CustomAuthorizerCallback */
function customAuthorizerCallback(cb: AWSLambda.CustomAuthorizerCallback) {
cb();
cb(null);
cb(error);
cb(null, authResponse);
}
/* Compatibility functions */
context.done();
context.done(error);
@@ -183,3 +236,4 @@ context.fail(str);
/* Handler */
let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => { };
let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => { };
let CustomAuthorizerHandler: AWSLambda.CustomAuthorizerHandler = (event: AWSLambda.CustomAuthorizerEvent, context: AWSLambda.Context, cb: AWSLambda.CustomAuthorizerCallback) => { };
+46
View File
@@ -39,6 +39,13 @@ interface APIGatewayEvent {
resource: string;
}
// API Gateway CustomAuthorizer "event"
interface CustomAuthorizerEvent {
type: string;
authorizationToken: string;
methodArn: string;
}
// SNS "event"
interface SNSMessageAttribute {
Type: string;
@@ -180,6 +187,43 @@ interface ProxyResult {
body: string;
}
/**
* API Gateway CustomAuthorizer AuthResponse.
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
*/
interface AuthResponse {
principalId: string;
policyDocument: PolicyDocument;
context?: AuthResponseContext;
}
/**
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
*/
interface PolicyDocument {
Version: string;
Statement: [Statement];
}
/**
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.Statement.
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
*/
interface Statement {
Action: string | [string];
Effect: string;
Resource: string | [string];
}
/**
* API Gateway CustomAuthorizer AuthResponse.PolicyDocument.Statement.
* http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output
*/
interface AuthResponseContext {
[name: string]: string | number | boolean;
}
/**
* AWS Lambda handler function.
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
@@ -190,6 +234,7 @@ interface ProxyResult {
*/
export type Handler = (event: any, context: Context, callback?: Callback) => void;
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Context, callback?: CustomAuthorizerCallback) => void;
/**
* Optional callback parameter.
@@ -200,5 +245,6 @@ export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?:
*/
export type Callback = (error?: Error, result?: any) => void;
export type ProxyCallback = (error?: Error, result?: ProxyResult) => void;
export type CustomAuthorizerCallback = (error?: Error, result?: AuthResponse) => void;
export as namespace AWSLambda;
-422
View File
@@ -1,422 +0,0 @@
import AWS = require('aws-sdk');
var str: string;
var creds: AWS.Credentials;
creds = new AWS.Credentials(str, str);
creds = new AWS.Credentials(str, str, str);
str = creds.accessKeyId;
/*
* ECS
*/
var ecs:AWS.ECS
ecs = new AWS.ECS();
ecs = new AWS.ECS({apiVersion: '2012-11-05'});
ecs.describeClusters({
clusters: ['STRING_VALUE', 'STRING_VALUE']
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
ecs.describeTasks({
cluster: 'STRING_VALUE',
tasks: ['STRING_VALUE', 'STRING_VALUE']
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
/*
* SQS
*/
var sqs:AWS.SQS
//Default constructor
sqs = new AWS.SQS();
//Locking the API Version
sqs = new AWS.SQS({apiVersion: '2012-11-05'});
// Locking the API Version Globally
AWS.config.apiVersions = {
sqs: '2012-11-05',
// other service API versions
};
sqs.addPermission({
AWSAccountIds: [ /* required */
'STRING_VALUE',
/* more items */
],
Actions: [ /* required */
'STRING_VALUE',
/* more items */
],
Label: 'STRING_VALUE', /* required */
QueueUrl: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.changeMessageVisibility({
QueueUrl: 'STRING_VALUE', /* required */
ReceiptHandle: 'STRING_VALUE', /* required */
VisibilityTimeout: 0 /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.changeMessageVisibilityBatch({
Entries: [ /* required */
{
Id: 'STRING_VALUE', /* required */
ReceiptHandle: 'STRING_VALUE', /* required */
VisibilityTimeout: 0
},
/* more items */
],
QueueUrl: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.createQueue({
QueueName: 'STRING_VALUE', /* required */
Attributes: {
someKey: 'STRING_VALUE',
/* anotherKey: ... */
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.deleteMessage({
QueueUrl: 'STRING_VALUE', /* required */
ReceiptHandle: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.deleteMessageBatch({
Entries: [ /* required */
{
Id: 'STRING_VALUE', /* required */
ReceiptHandle: 'STRING_VALUE' /* required */
},
/* more items */
],
QueueUrl: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.deleteQueue({
QueueUrl: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.getQueueAttributes({
QueueUrl: 'STRING_VALUE', /* required */
AttributeNames: [
'Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy',
/* more items */
]
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.getQueueUrl({
QueueName: 'STRING_VALUE', /* required */
QueueOwnerAWSAccountId: 'STRING_VALUE'
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.listDeadLetterSourceQueues({
QueueUrl: 'STRING_VALUE' /* required */
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.listQueues({
QueueNamePrefix: 'STRING_VALUE'
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.purgeQueue({
QueueUrl: 'STRING_VALUE' /* required */
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.receiveMessage({
QueueUrl: 'STRING_VALUE', /* required */
AttributeNames: [
'Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy',
/* more items */
],
MaxNumberOfMessages: 0,
MessageAttributeNames: [
'STRING_VALUE',
/* more items */
],
VisibilityTimeout: 0,
WaitTimeSeconds: 0
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.removePermission({
Label: 'STRING_VALUE', /* required */
QueueUrl: 'STRING_VALUE' /* required */
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.sendMessage({
MessageBody: 'STRING_VALUE', /* required */
QueueUrl: 'STRING_VALUE', /* required */
DelaySeconds: 0,
MessageAttributes: {
someKey: {
DataType: 'STRING_VALUE', /* required */
BinaryListValues: [
new Buffer('...') || 'STRING_VALUE',
/* more items */
],
BinaryValue: new Buffer('...') || 'STRING_VALUE',
StringListValues: [
'STRING_VALUE',
/* more items */
],
StringValue: 'STRING_VALUE'
},
/* anotherKey: ... */
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.sendMessageBatch({
Entries: [ /* required */
{
Id: 'STRING_VALUE', /* required */
MessageBody: 'STRING_VALUE', /* required */
DelaySeconds: 0,
MessageAttributes: {
someKey: {
DataType: 'STRING_VALUE', /* required */
BinaryListValues: [
new Buffer('...') ,
/* more items */
],
BinaryValue: new Buffer('...'),
StringListValues: [
'STRING_VALUE',
/* more items */
],
StringValue: 'STRING_VALUE'
},
/* anotherKey: ... */
}
},
/* more items */
],
QueueUrl: 'STRING_VALUE' /* required */
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
sqs.setQueueAttributes({
Attributes: { /* required */
someKey: 'STRING_VALUE',
/* anotherKey: ... */
},
QueueUrl: 'STRING_VALUE' /* required */
}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
var dynamoDBDocClient:AWS.DynamoDB.DocumentClient;
dynamoDBDocClient = new AWS.DynamoDB.DocumentClient();
dynamoDBDocClient = new AWS.DynamoDB.DocumentClient({});
dynamoDBDocClient.createSet([1, 2, 3], { validate: true });
dynamoDBDocClient.get(
{
TableName: 'TABLE_NAME',
Key: { userId: 'abc123', email: 'abc123@abc123.com' }
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
dynamoDBDocClient.put(
{
TableName: 'TABLE_NAME',
Item: {
userId: 'abc123',
email: 'abc123@abc123.com',
firstName: 'Matt',
lastName: 'Forrester the ' + new Date().getTime()
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
dynamoDBDocClient.delete(
{
TableName: 'TABLE_NAME',
Key: {
userId: 'abc123',
email: 'abc123@abc123.com'
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
dynamoDBDocClient.update(
{
TableName: 'TABLE_NAME',
Key: {
userId: 'abc123',
email: 'abc123@abc123.com'
},
AttributeUpdates: {
thingsWithWheels: {
Action: 'PUT',
Value: dynamoDBDocClient.createSet(
[
'SkateBoard',
'Skates',
'Mountain Bike',
'Evolve Electric Skateboard'
],
{ validate: true }
)
},
age: {
Action: 'PUT',
Value: 35
}
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
dynamoDBDocClient.scan(
{
TableName: 'TABLE_NAME',
KeyConditions: {
age: {
ComparisonOperator: 'EQ',
AttributeValueList: [35]
}
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
dynamoDBDocClient.query(
{
TableName: 'TABLE_NAME',
KeyConditions: {
userId: {
ComparisonOperator: 'EQ',
AttributeValueList: ['abc123']
}
}
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}
);
var kinesis = new AWS.Kinesis();
var putRecordParam = {
Data: new Buffer('...') || 'STRING_VALUE', /* required */
PartitionKey: 'STRING_VALUE', /* required */
StreamName: 'STRING_VALUE', /* required */
ExplicitHashKey: 'STRING_VALUE',
SequenceNumberForOrdering: 'STRING_VALUE'
};
kinesis.putRecord(putRecordParam, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
var putRecordParams = {
Records: [ /* required */
{
Data: new Buffer('...') || 'STRING_VALUE', /* required */
PartitionKey: 'STRING_VALUE', /* required */
ExplicitHashKey: 'STRING_VALUE'
},
/* more items */
],
StreamName: 'STRING_VALUE' /* required */
};
kinesis.putRecords(putRecordParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
var increaseStreamRetentionPeriodParams = {
RetentionPeriodHours: 0, /* required */
StreamName: 'STRING_VALUE' /* required */
};
kinesis.increaseStreamRetentionPeriod(increaseStreamRetentionPeriodParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
-2606
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
-90
View File
@@ -1,90 +0,0 @@
var context:any = document
var $fixture:any = {}
// axe.a11yCheck config
axe.a11yCheck(context, {}, (results) => {
// axe's results object
console.log(results.passes.length)
console.log(results.violations.length)
});
// axe.a11yCheck include/exclude
axe.a11yCheck({include: [['#id1'], ['#id2']]}, {}, (results) => {
console.log(results)
})
axe.a11yCheck({exclude: [$fixture[0]]}, {}, (results) => {
console.log(results)
})
var tagConfigRunOnly: axe.RunOnly = {
type: 'tag',
values: ['wcag2a']
}
var tagConfig = {
runOnly: tagConfigRunOnly
}
axe.a11yCheck(context, tagConfig, (results) => {
console.log(results)
})
var includeExcludeTagsRunOnly: axe.RunOnly = {
type: 'tags',
value: {
include: ['wcag2a', 'wcag2aa'],
exclude: ['experimental']
}
}
var includeExcludeTagsConfig = {
runOnly: includeExcludeTagsRunOnly
}
axe.a11yCheck(context, includeExcludeTagsConfig, (results) => {
console.log(results)
})
var someRulesConfig = {
rules: {
"color-contrast": {enabled: 'false'},
"heading-order": {enabled: 'true'}
}
}
axe.a11yCheck(context, someRulesConfig, (results) => {
console.log(results)
})
// axe.configure
var spec: axe.Spec = {
branding: {
brand: 'foo',
application: 'bar'
},
reporter: 'v1',
checks: [{
id: 'custom-check',
evaluate: function() {
return true
}
}],
rules: [{
id: 'custom-rule',
any: ['custom-check']
}]
}
axe.configure(spec)
axe.reset()
axe.getRules(['wcag2aa'])
typeof axe.getRules() === 'object'
// Plugins
var pluginSrc: axe.AxePlugin = {
id: 'doStuff',
run: (data:any, callback:Function) => {
callback()
},
commands: [{
id: 'run-doStuff',
callback: (data:any, callback:Function) => {
axe.plugins['doStuff'].run(data, callback)
}
}]
}
axe.registerPlugin(pluginSrc)
axe.cleanup()
-159
View File
@@ -1,159 +0,0 @@
// Type definitions for axe-core 2.0.5
// Project: https://github.com/dequelabs/axe-core
// Definitions by: Marcy Sutton <https://github.com/marcysutton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace axe {
export type ImpactValue = "minor" | "moderate" | "serious" | "critical";
export type TagValue = "wcag2a" | "wcag2aa" | "section508" | "best-practice";
export type ReporterVersion = "v1" | "v2";
export type RunOnlyType = "rule" | "rules" | "tag" | "tags";
export interface ElementContext {
node?: Object,
selector?: string,
include?: any[],
exclude?: any[]
}
export interface RunOnly {
type: RunOnlyType,
value?: {
include?: string[],
exclude?: string[]
}
values?: TagValue[]
}
export interface AxeResults {
url: string,
timestamp: string,
passes: Pass[],
violations: Violation[]
}
export interface Pass {
description: string,
help: string,
helpUrl: string,
id: string,
impact: ImpactValue,
tags: TagValue[],
nodes: NodeResult[]
}
export interface Violation {
description: string,
help: string,
helpUrl: string,
id: string,
impact: ImpactValue,
tags: TagValue[],
nodes: NodeResult[]
}
export interface NodeResult {
html: string,
impact: ImpactValue,
target: string[],
any: CheckResult[],
all: CheckResult[],
none: CheckResult[]
}
export interface CheckResult {
id: string,
impact: string,
message: string,
data: any,
relatedNodes?: RelatedNode[]
}
export interface RelatedNode {
target: string[],
html: string
}
export interface Spec {
branding?: {
brand: string,
application: string
},
reporter?: ReporterVersion,
checks?: Check[],
rules?: Rule[]
}
export interface Check {
id: string,
evaluate: Function,
after?: Function,
options?: any,
matches?: string,
enabled?: boolean
}
export interface Rule {
id: string,
selector?: string,
excludeHidden?: boolean,
enabled?: boolean,
pageLevel?: boolean,
any?: string[],
all?: string[],
none?: string[],
tags?: string[],
matches?: string
}
export interface AxePlugin {
id: string,
run(...args:any[]): any,
commands: {
id: string,
callback(...args:any[]): void
}[],
cleanup?(callback:Function): void
}
export let plugins: any
/**
* Starts analysis on the current document and its subframes
*
* @param {Object} context The `Context` specification object @see Context
* @param {Array} options Options passed into rules or checks, temporarily modifyint them.
* @param {Function} callback The function to invoke when analysis is complete.
* @returns {Object} results The aXe results object
*/
export function a11yCheck(context: ElementContext, options: {runOnly?: RunOnly, rules?: Object}, callback: (results:AxeResults) => void): AxeResults
/**
* Method for configuring the data format used by aXe. Helpful for adding new
* rules, which must be registered with the library to execute.
* @param {Spec} Spec Object with valid `branding`, `reporter`, `checks` and `rules` data
*/
export function configure(spec: Spec): void
/**
* Searches and returns rules that contain a tag in the list of tags.
* @param {Array} tags Optional array of tags
* @return {Array} Array of rules
*/
export function getRules(tags?: string[]): Object[]
/**
* Restores the default axe configuration
*/
export function reset(): void
/**
* Function to register a plugin configuration in document and its subframes
* @param {Object} plugin A plugin configuration object
*/
export function registerPlugin(plugin: AxePlugin): void
/**
* Function to clean up plugin configuration in document and its subframes
*/
export function cleanup(): void
}
// axe is also available as a module
declare module "axe-core" {
export = axe;
}
@@ -1,125 +0,0 @@
import express = require('express');
import mobileApps = require('azure-mobile-apps');
import logger = require('azure-mobile-apps/src/logger');
import queries = require('azure-mobile-apps/src/query');
var app = express(),
mobileApp = mobileApps();
// various configuration permutations
mobileApps({
debug: true,
data: {
provider: 'mssql',
server: '',
user: '',
database: '',
password: ''
},
webhook: { url: 'http://localhost/' }
});
mobileApps({
data: {
provider: 'memory'
}
})
// it would be nice to integrate with winston
mobileApps({ logging: { level: 'silly', transports: [{}] } })
// various custom middleware syntaxes
mobileApp.use(function (req: any, res: any, next: any) { next(); });
mobileApp.use([function () {}, function () {}]);
mobileApp.use(function () {}, function () {});
mobileApp.use(function () {}).use(function () {});
// basic syntax for tables and api
mobileApp.tables.add('todoitem');
mobileApp.tables.add('todoitem', { authorize: true });
mobileApp.tables.add('todoitem', mobileApps.table());
mobileApp.tables.import('tables');
mobileApp.api.add('api', { authorize: true, get: function () {}, delete: function () {} });
mobileApp.api.import('api');
// ensure the mobile app instance can be correctly mounted as an express router
app.use(mobileApp);
// Express.Table, instantiated from the mobile app
var table = mobileApp.table()
table.use(function (req: Express.Request, res: Express.Response, next: any) {
next(new Error());
});
table.use([function () {}, function () {}]);
table.read(function (context: Azure.MobileApps.Context) {
context.query.where({ p1: 'test' });
return context.execute()
.then(function (result: any) {
return result;
})
.catch(function (error: any) { })
.then(function () {});
});
table.insert(function (context: Azure.MobileApps.Context) {
context.query.id = 'anotherId';
context.query.single = true;
context.item.userId = context.user.id;
context.push.send('tag', {}, function (error, result) {});
context.push.gcm.send('tag', {}, function (error, result) {});
context.push.apns.send('tag', { payload: { } }, function (error, result) {});
context.push.wns.sendToastText01('tag', '', { headers: { } }, function (error, result) {});
context.next(new Error());
context.next('An error occurred');
});
table.read.use(function () {});
table.read.use([function () {}, function () {}]);
table.read.use(function () {}, function () {});
table.use(function () {}).use(function () {}).read(function () {}).use(function () {});
table.access = undefined;
table.access = 'authenticated';
table.read.access = 'anonymous';
table.update.access = 'disabled';
table.delete.access = 'authenticated';
table.insert.access = 'authenticated';
table.filters = [function (query, context) { }];
table.transforms = [function (item, context) { }];
table.hooks = [function (results, context) { }];
table.perUser = true;
table.recordsExpire = { milliseconds: 1, seconds: 1, minutes: 1, hours: 1, days: 1, weeks: 1, months: 1, years: 1 };
table.webhook = { url: 'http://localhost/' }
table.webhook = true;
// Express.Table, instantiated from the static require('azure-mobile-apps').table()
// This is going to be interesting if we ever support more than one provider
var table2 = mobileApps.table();
table2.read(function (context: Azure.MobileApps.Context) {});
// ApiDefinition, from the static require('azure-mobile-apps').api()
var api2 = mobileApps.api({
get: function (req, res, next) { }
});
api2.post = function (req, res, next) {};
// Logger
logger.silly('test', 'message');
logger.error('Something happened', new Error());
mobileApps.logger.debug('a debug message')
// Query
queries.create('table').where({ x: 10 }).select('col1,col2').includeDeleted().includeTotalCount();
mobileApps.query.create('table');
// Custom SQL query
mobileApp.api.add('query', { authorize: true, get: (req, res, next) => {
req.azureMobile.data.execute({
sql: "SELECT * FROM TODOITEM WHERE COMPLETE = :complete",
parameters: [
{ name: 'complete', value: 1 }
]
}).then(x => {});
}, delete: function () {} });
-326
View File
@@ -1,326 +0,0 @@
// Type definitions for azure-mobile-apps v2.1.7
// Project: https://github.com/Azure/azure-mobile-apps-node/
// Definitions by: Microsoft Azure <https://github.com/Azure/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="azure-sb" />
declare module "azure-mobile-apps" {
interface AzureMobileApps {
(configuration?: Azure.MobileApps.Configuration): Azure.MobileApps.Platforms.Express.MobileApp;
table(): Azure.MobileApps.Platforms.Express.Table;
api(definition?: Azure.MobileApps.ApiDefinition): Azure.MobileApps.ApiDefinition;
logger: Azure.MobileApps.Logger;
query: Azure.MobileApps.Query;
}
var out: AzureMobileApps;
export = out;
}
declare module "azure-mobile-apps/src/logger" {
var logger: Azure.MobileApps.Logger;
export = logger;
}
declare module "azure-mobile-apps/src/query" {
var query: Azure.MobileApps.Query;
export = query;
}
declare namespace Azure.MobileApps {
// the additional Platforms namespace is required to avoid collisions with the main Express namespace
export module Platforms {
export module Express {
interface MobileApp extends Middleware {
configuration: Configuration;
tables: Tables;
table(): Table;
api: Api;
use(...middleware: Middleware[]): MobileApp;
use(middleware: Middleware[]): MobileApp;
}
interface Api {
add(name: string, definition: ApiDefinition): void;
import(fileOrFolder: string): void;
}
interface Table extends TableDefinition {
use(...middleware: Middleware[]): Table;
use(middleware: Middleware[]): Table;
read: TableOperation;
update: TableOperation;
insert: TableOperation;
delete: TableOperation;
undelete: TableOperation;
}
interface TableOperation {
(operationHandler: (context: Context) => void): Table;
use(...middleware: Middleware[]): Table;
use(middleware: Middleware[]): Table;
access?: AccessType;
}
interface Tables {
configuration: Configuration;
add(name: string, definition?: Table | TableDefinition): void;
import(fileOrFolder: string): void;
initialize(): Thenable<any>;
}
}
}
export module Data {
interface Table {
read(query: QueryJs): Thenable<any[]>;
update(item: any, query: QueryJs): Thenable<any>;
insert(item: any): Thenable<any>;
delete(query: QueryJs, version: string): Thenable<any>;
undelete(query: QueryJs, version: string): Thenable<any>;
truncate(): Thenable<void>;
initialize(): Thenable<void>;
schema(): Thenable<Column[]>;
}
interface Column {
name: string;
type: string;
}
}
// auth
interface User {
id: string;
claims: any[];
token: string;
getIdentity(provider: string): Thenable<any>;
}
interface Auth {
validate(token: string): Thenable<User>;
decode(token: string): User;
sign(payload: any): string;
}
// configuration
interface Configuration {
platform?: string;
basePath?: string;
configFile?: string;
promiseConstructor?: (resolve: (result: any) => void, reject: (error: any) => void) => Thenable<any>;
apiRootPath?: string;
tableRootPath?: string;
notificationRootPath?: string;
swaggerPath?: string;
authStubRoute?: string;
debug?: boolean;
version?: string;
apiVersion?: string;
homePage?: boolean;
swagger?: boolean;
maxTop?: number;
pageSize?: number;
logging?: Configuration.Logging;
data?: Configuration.Data;
auth?: Configuration.Auth;
cors?: Configuration.Cors;
notifications?: Configuration.Notifications;
webhook?: Webhook;
}
export module Configuration {
// it would be nice to have the config for various providers in separate interfaces,
// but this is the simplest solution to support variations of the current setup
interface Data {
provider: string;
user?: string;
password?: string;
server?: string;
port?: number;
database?: string;
connectionTimeout?: string;
options?: { encrypt: boolean };
schema?: string;
dynamicSchema?: boolean;
filename?: string;
}
interface Auth {
secret: string;
validateTokens?: boolean;
}
interface Logging {
level?: string;
transports?: LoggingTransport[];
}
interface LoggingTransport { }
interface Cors {
exposeHeaders: string;
maxAge?: number;
hostnames: string[];
}
interface Notifications {
hubName: string;
connectionString?: string;
endpoint?: string;
sharedAccessKeyName?: string;
sharedAccessKeyValue?: string;
}
}
// query
interface Query {
create(tableName: string): QueryJs;
fromRequest(req: Express.Request): QueryJs;
toOData(query: QueryJs): OData;
}
interface QueryJs {
includeTotalCount(): QueryJs;
includeDeleted(): QueryJs;
orderBy(properties: string): QueryJs;
orderByDescending(properties: string): QueryJs;
select(properties: string): QueryJs;
skip(count: number): QueryJs;
take(count: number): QueryJs;
where(filter: any): QueryJs;
// these are properties added by the SDK
id?: string | number;
single?: boolean;
}
interface OData {
table: string;
filters?: string;
ordering?: string;
orderClauses?: string;
skip?: number;
take?: number;
selections?: string;
includeTotalCount?: boolean;
}
// general
var nh: Azure.ServiceBus.NotificationHubService;
interface Context {
query: QueryJs;
id: string | number;
item: any;
req: Express.Request;
res: Express.Response;
data: ContextData;
tables: (tableName: string) => Data.Table;
user: User;
push: typeof nh;
logger: Logger;
execute(): Thenable<any>;
next(error: string|Error): any;
}
interface ContextData {
(table: TableDefinition): Data.Table;
execute(q: SqlQueryDefinition): Thenable<any>;
}
interface SqlQueryDefinition {
sql: string;
parameters?: SqlParameterDefinition[];
}
interface SqlParameterDefinition {
name: string;
value: any;
}
interface TableDefinition {
access?: AccessType;
authorize?: boolean;
autoIncrement?: boolean;
columns?: any;
databaseTableName?: string;
dynamicSchema?: boolean;
maxTop?: number;
name?: string;
pageSize?: number;
schema?: string;
softDelete?: boolean;
userIdColumn?: string;
filters?: [(query: QueryJs, context: Context) => void | QueryJs];
transforms?: [(item: any, context: Context) => void | any];
hooks?: [(results: any, context: Context) => void];
perUser?: boolean;
recordsExpire?: Duration;
webhook?: Webhook | boolean;
}
type AccessType = 'anonymous' | 'authenticated' | 'disabled';
interface Duration {
milliseconds?: number;
seconds?: number;
minutes?: number;
hours?: number;
days?: number;
weeks?: number;
months?: number;
years?: number;
}
interface Webhook {
url: string;
}
interface ApiDefinition {
authorize?: boolean;
get?: Middleware | Middleware[];
post?: Middleware | Middleware[];
patch?: Middleware | Middleware[];
put?: Middleware | Middleware[];
delete?: Middleware | Middleware[];
}
interface Thenable<R> {
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
catch<U>(onRejected?: (error: any) => void): Thenable<U>;
}
interface Logger {
log(level: string, ...message: any[]): void;
silly(...message: any[]): void;
debug(...message: any[]): void;
verbose(...message: any[]): void;
info(...message: any[]): void;
warn(...message: any[]): void;
error(...message: any[]): void;
}
interface Middleware {
(req: Express.Request, res: Express.Response, next: NextMiddleware): void;
}
interface NextMiddleware {
(error?: any): void;
}
}
// additions to the Express modules
declare namespace Express {
interface Request {
azureMobile: Azure.MobileApps.Context
}
interface Response {
results?: any;
}
}
-22
View File
@@ -1,22 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"azure-mobile-apps-tests.ts"
]
}
+1 -1
View File
@@ -1627,7 +1627,7 @@ export interface Entity {
RowKey: string;
Timestamp?: Date;
etag?: string;
[property: string]: string | number | boolean | Date;
[property: string]: string | number | boolean | Date | undefined;
}
//#endregion
//#region BlobService Interfaces
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1 +1 @@
{ "extends": "../tslint.json" }
{ "extends": "dtslint/dt.json" }
-1
View File
@@ -1 +0,0 @@
-7260
View File
File diff suppressed because it is too large Load Diff
@@ -3,77 +3,72 @@
import * as Backbone from 'backbone';
namespace BackboneAssociationsTests {
namespace OneToOne {
class EmployeeWithManager extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.One, //nature of the relationship
key: 'manager', // attribute of Employee
relatedModel: 'Employee' //AssociatedModel for attribute key
}
];
// one-to-one tests
class EmployeeWithManager extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.One, //nature of the relationship
key: 'manager', // attribute of Employee
relatedModel: 'Employee' //AssociatedModel for attribute key
}
defaults() {
return {
age: 0,
fname: "",
lname: "",
manager: null
};
}
}
];
}
namespace OneToMany {
class Location extends Backbone.AssociatedModel {
defaults() {
return {
add1: "",
add2: null,
zip: "",
state: ""
};
}
}
class Locations extends Backbone.Collection<Location> {
comparator = (c: Backbone.Model) => {
return c.get("Number");
}
}
class Project extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.Many, //nature of the relation
key: 'locations', //attribute of Project
collectionType: Locations, //Collection to be used.
relatedModel: Location //Optional
}
];
}
defaults() {
return {
name: "",
number: 0,
locations: []
}
}
}
function reverseAssociationTest() {
var local = new Location({ state: "Hertfordshire" });
var project = new Project({ name: "The Old Pond Project" });
local.set("oddRelationTo", project);
var parents = project.parents;
}
defaults() {
return {
age: 0,
fname: "",
lname: "",
manager: null
};
}
}
// one-to-many tests
class Location extends Backbone.AssociatedModel {
defaults() {
return {
add1: "",
add2: null,
zip: "",
state: ""
};
}
}
class Locations extends Backbone.Collection<Location> {
comparator = (c: Backbone.Model) => {
return c.get("Number");
}
}
class Project extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.Many, //nature of the relation
key: 'locations', //attribute of Project
collectionType: Locations, //Collection to be used.
relatedModel: Location //Optional
}
];
}
defaults() {
return {
name: "",
number: 0,
locations: []
}
}
}
function reverseAssociationTest() {
var local = new Location({ state: "Hertfordshire" });
var project = new Project({ name: "The Old Pond Project" });
local.set("oddRelationTo", project);
var parents = project.parents;
}
@@ -1,322 +1,321 @@
import * as Marionette from 'backbone.marionette';
import * as Backbone from 'backbone';
namespace MarionetteTests {
class DestroyWarn extends Marionette.Behavior {
// you can set default options
// just like you can in your Backbone Models
// they will be overriden if you pass in an option with the same key
defaults = {
"message": "you are destroying!"
};
// behaviors have events that are bound to the views DOM
events = {
"click @ui.destroy": "warnBeforeDestroy"
};
warnBeforeDestroy() {
alert(this.options.message);
// every Behavior has a hook into the
// view that it is attached to
this.view.destroy();
}
}
Marionette.Behaviors.getBehaviorClass = (options, key) => {
if (key === "DestroyWarn")
return DestroyWarn;
return undefined;
class DestroyWarn extends Marionette.Behavior {
// you can set default options
// just like you can in your Backbone Models
// they will be overriden if you pass in an option with the same key
defaults = {
"message": "you are destroying!"
};
class MyRouter extends Marionette.AppRouter {
// "someMethod" must exist at controller.someMethod
appRoutes = {
"some/route": "someMethod"
};
/* standard routes can be mixed with appRoutes/Controllers above */
routes = {
"some/otherRoute": "someOtherMethod"
};
someOtherMethod() {
// do something here.
}
}
class MyApplication extends Marionette.Application {
initialize(options?: any) {
console.log("initializing application");
this.layoutView = new AppLayoutView();
}
layoutView: AppLayoutView;
mainRegion: Marionette.Region;
onStart() {
this.mainRegion = new Marionette.Region({ el: '#main' });
this.layoutView.addRegion('main', this.mainRegion);
this.layoutView.render();
this.layoutView.showChildView('main', new MyView(new MyModel));
let view: Backbone.View<Backbone.Model> = this.layoutView.getChildView('main');
let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions();
let prefix: string = this.layoutView.childViewEventPrefix;
let region: Marionette.Region = this.layoutView.removeRegion('main');
let layout: Marionette.View<Backbone.Model> = this.layoutView.destroy();
}
}
class AppLayoutView extends Marionette.View<Backbone.Model> {
constructor() {
super({ el: 'body' });
}
template() {
return "<div id='main'></div>";
}
initialize(options?: any) {
console.log("initializing layoutview");
}
}
class MyModel extends Backbone.Model {
constructor(options?: any) {
super(options);
}
getName(): string {
return this.get('name');
}
setName(value: string) {
this.set(value);
}
}
class MyBaseView extends Marionette.View<MyModel> {
constructor() {
super();
this.getOption<string>('foo');
this.triggers = {
'click .foo': 'bar'
};
}
}
class MyView extends Marionette.View<MyModel> {
behaviors: any;
constructor(model: MyModel) {
super({ model: model });
this.ui = {
destroy: '.destroy'
};
this.behaviors = {
DestroyWarn: {
message: 'hello'
}
};
}
template() {
return '<h1>' + this.model.getName() + '</h1> <button class="destroy">Destroy Me</button>';
}
// behaviors have events that are bound to the views DOM
events = {
"click @ui.destroy": "warnBeforeDestroy"
};
warnBeforeDestroy() {
alert(this.options.message);
// every Behavior has a hook into the
// view that it is attached to
this.view.destroy();
}
}
class MainRegion extends Marionette.Region {
constructor() {
super();
this.el = '#main';
}
Marionette.Behaviors.getBehaviorClass = (options, key) => {
if (key === "DestroyWarn")
return DestroyWarn;
return undefined;
};
class MyRouter extends Marionette.AppRouter {
// "someMethod" must exist at controller.someMethod
appRoutes = {
"some/route": "someMethod"
};
/* standard routes can be mixed with appRoutes/Controllers above */
routes = {
"some/otherRoute": "someOtherMethod"
};
someOtherMethod() {
// do something here.
}
}
class MyObject extends Marionette.Object {
name: string;
options: any;
constructor() {
super();
this.name = 'Adam';
this.options = {
name: 'Foo'
};
this.on("before:destroy", () => {
console.log("before:destroy");
});
}
onBeforeDestroy(arg: any) {
console.log("in onBeforeDestroy with arg " + arg);
}
class MyApplication extends Marionette.Application {
initialize(options?: any) {
console.log("initializing application");
this.layoutView = new AppLayoutView();
}
class MyRegion extends Marionette.Region {
constructor() {
super();
this.el = '#main-nav';
}
layoutView: AppLayoutView;
mainRegion: Marionette.Region;
onStart() {
this.mainRegion = new Marionette.Region({ el: '#main' });
this.layoutView.addRegion('main', this.mainRegion);
this.layoutView.render();
this.layoutView.showChildView('main', new MyView(new MyModel));
let view: Backbone.View<Backbone.Model> = this.layoutView.getChildView('main');
let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions();
let prefix: string = this.layoutView.childViewEventPrefix;
let region: Marionette.Region = this.layoutView.removeRegion('main');
let layout: Marionette.View<Backbone.Model> = this.layoutView.destroy();
}
}
class AppLayoutView extends Marionette.View<Backbone.Model> {
constructor() {
super({ el: 'body' });
}
class MyJQueryRegion extends Marionette.Region {
constructor() {
super();
this.el = $('#main-nav');
}
template() {
return "<div id='main'></div>";
}
class MyHtmlElRegion extends Marionette.Region {
constructor() {
super();
this.el = document.querySelector("body");
}
initialize(options?: any) {
console.log("initializing layoutview");
}
}
class MyModel extends Backbone.Model {
constructor(options?: any) {
super(options);
}
class MyCollectionView extends Marionette.CollectionView<MyModel, MyView> {
constructor() {
super();
this.childView = MyView;
this.childViewEvents = {
render: function () {
console.log("a childView has been rendered");
}
};
this.childViewOptions = function (model: any, index: any): any {
// do some calculations based on the model
return {
foo: "bar",
childIndex: index
}
};
this.childViewOptions = {
foo: "bar"
};
this.childViewEventPrefix = "some:prefix";
this.on('some:prefix:render', function () {
});
}
getName(): string {
return this.get('name');
}
export var app: MyApplication;
setName(value: string) {
this.set(value);
}
}
function ApplicationTests() {
app = new MyApplication();
class MyBaseView extends Marionette.View<MyModel> {
app.start();
var view = new MyView(new MyModel());
app.mainRegion.show(view);
constructor() {
super();
this.getOption<string>('foo');
this.triggers = {
'click .foo': 'bar'
};
}
function ObjectTests() {
var obj = new MyObject();
console.log(obj.getOption('name'));
obj.destroy("goodbye");
}
}
function RegionManagerTests() {
var rm = new Marionette.RegionManager();
rm.addRegions({
contentRegion: {
el: '#content',
regionClass: MainRegion
},
class MyView extends Marionette.View<MyModel> {
behaviors: any;
navigationRegion: {
el: '#navigation',
regionClass: MainRegion,
constructor(model: MyModel) {
super({ model: model });
// Options passed to instance of `MyOtherRegion` for
// the `navigationRegion` on `App`
navigationOption: 42,
anotherNavigationOption: 'foo'
},
this.ui = {
destroy: '.destroy'
};
footerRegion: {
regionClass: MainRegion,
someOption: 42,
someValue: 'value'
this.behaviors = {
DestroyWarn: {
message: 'hello'
}
};
}
template() {
return '<h1>' + this.model.getName() + '</h1> <button class="destroy">Destroy Me</button>';
}
};
class MainRegion extends Marionette.Region {
constructor() {
super();
this.el = '#main';
}
}
class MyObject extends Marionette.Object {
name: string;
options: any;
constructor() {
super();
this.name = 'Adam';
this.options = {
name: 'Foo'
};
this.on("before:destroy", () => {
console.log("before:destroy");
});
}
function RegionTests() {
var myView: Marionette.View<MyModel> = new MyView(new MyModel());
// render and display the view
app.mainRegion.show(myView);
// empties the current view
app.mainRegion.empty();
myView = new MyView(new MyModel());
app.mainRegion.show(myView, { preventDestroy: true, forceShow: true, triggerAttach: true, triggerBeforeAttach: false });
var hasView: boolean = app.mainRegion.hasView();
app.mainRegion.reset();
Marionette.Region.prototype.attachHtml = function (view: any): void {
this.$el.empty().append(view.el);
}
myView = new Marionette.View<MyModel>({
el: $("#existing-view-stuff")
});
app.mainRegion.attachView(myView);
app.mainRegion.on("empty", function (view: any, region: any, options: any) {
// manipulate the `view` or do something extra
// with the `region`
// you also have access to the `options` that were passed to the Region.show call
});
onBeforeDestroy(arg: any) {
console.log("in onBeforeDestroy with arg " + arg);
}
}
function CollectionViewTests() {
var cv = new MyCollectionView();
cv.collection.add(new MyModel());
app.mainRegion.attachView(cv);
cv.addEmptyView(new MyModel, MyView);
cv.proxyChildEvents(new MyView(new MyModel));
let children: Backbone.ChildViewContainer<Marionette.View<Backbone.Model>> = cv.destroyChildren();
let view: Marionette.CollectionView<Backbone.Model, Marionette.View<Backbone.Model>> = cv.destroy();
class MyRegion extends Marionette.Region {
constructor() {
super();
this.el = '#main-nav';
}
}
class MyController extends Marionette.Controller {
class MyJQueryRegion extends Marionette.Region {
constructor() {
super();
this.el = $('#main-nav');
}
}
function AppRouterTests() {
var myController = new MyController();
var router = new MyRouter();
class MyHtmlElRegion extends Marionette.Region {
constructor() {
super();
this.el = document.querySelector("body");
}
}
router.appRoute("/foo", "fooThat");
class MyCollectionView extends Marionette.CollectionView<MyModel, MyView> {
constructor() {
super();
this.childView = MyView;
this.childViewEvents = {
render: function () {
console.log("a childView has been rendered");
}
};
this.childViewOptions = function (model: any, index: any): any {
// do some calculations based on the model
return {
foo: "bar",
childIndex: index
}
};
this.childViewOptions = {
foo: "bar"
};
this.childViewEventPrefix = "some:prefix";
this.on('some:prefix:render', function () {
router.processAppRoutes(myController, {
"foo": "doFoo",
"bar/:id": "doBar"
});
}
}
var app: MyApplication;
function ApplicationTests() {
app = new MyApplication();
app.start();
var view = new MyView(new MyModel());
app.mainRegion.show(view);
}
function ObjectTests() {
var obj = new MyObject();
console.log(obj.getOption('name'));
obj.destroy("goodbye");
}
function RegionManagerTests() {
var rm = new Marionette.RegionManager();
rm.addRegions({
contentRegion: {
el: '#content',
regionClass: MainRegion
},
navigationRegion: {
el: '#navigation',
regionClass: MainRegion,
// Options passed to instance of `MyOtherRegion` for
// the `navigationRegion` on `App`
navigationOption: 42,
anotherNavigationOption: 'foo'
},
footerRegion: {
regionClass: MainRegion,
someOption: 42,
someValue: 'value'
}
});
}
function RegionTests() {
var myView: Marionette.View<MyModel> = new MyView(new MyModel());
// render and display the view
app.mainRegion.show(myView);
// empties the current view
app.mainRegion.empty();
myView = new MyView(new MyModel());
app.mainRegion.show(myView, { preventDestroy: true, forceShow: true, triggerAttach: true, triggerBeforeAttach: false });
var hasView: boolean = app.mainRegion.hasView();
app.mainRegion.reset();
Marionette.Region.prototype.attachHtml = function (view: any): void {
this.$el.empty().append(view.el);
}
myView = new Marionette.View<MyModel>({
el: $("#existing-view-stuff")
});
app.mainRegion.attachView(myView);
app.mainRegion.on("empty", function (view: any, region: any, options: any) {
// manipulate the `view` or do something extra
// with the `region`
// you also have access to the `options` that were passed to the Region.show call
});
}
function CollectionViewTests() {
var cv = new MyCollectionView();
cv.collection.add(new MyModel());
app.mainRegion.attachView(cv);
cv.addEmptyView(new MyModel, MyView);
cv.proxyChildEvents(new MyView(new MyModel));
let children: Backbone.ChildViewContainer<Marionette.View<Backbone.Model>> = cv.destroyChildren();
let view: Marionette.CollectionView<Backbone.Model, Marionette.View<Backbone.Model>> = cv.destroy();
}
class MyController extends Marionette.Controller {
}
function AppRouterTests() {
var myController = new MyController();
var router = new MyRouter();
router.appRoute("/foo", "fooThat");
router.processAppRoutes(myController, {
"foo": "doFoo",
"bar/:id": "doBar"
});
}
@@ -1,306 +1,258 @@
/// <reference types="jquery" />
import * as Backbone from 'backbone';
namespace BackbonePaginatorTests {
class TestModel extends Backbone.Model{};
class TestModel extends Backbone.Model{};
var makeFetchOptions = <TCol extends Backbone.PageableCollection<TestModel>>() => {
return {
reset: true,
url: 'example.com',
beforeSend: (jqxhr: JQueryXHR) => {},
success: (model: TestModel, response: any, options: any) => {},
error: (collection: TCol, jqxhr: JQueryXHR, options: any) => {},
parse: '',
};
var makeFetchOptions = <TCol extends Backbone.PageableCollection<TestModel>>() => {
return {
reset: true,
url: 'example.com',
beforeSend: (jqxhr: JQueryXHR) => {},
success: (model: TestModel, response: any, options: any) => {},
error: (collection: TCol, jqxhr: JQueryXHR, options: any) => {},
parse: '',
};
};
namespace InitializingWithNoOption {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(){
super();
}
namespace InitializingWithNoOption {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(){
super();
}
var testCollection = new TestCollection();
}
var testCollection = new TestCollection();
}
namespace InitializingWithOptions {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
namespace InitializingWithOptions {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[], options?: Backbone.PageableInitialOptions){
super();
}
var testCollection1 = new TestCollection();
var testCollection2 = new TestCollection([
new TestModel(),
new TestModel()
]);
var testCollection3 = new TestCollection([], {});
var testCollection4 = new TestCollection([],{
comparator: ()=>1,
full: true,
state: {},
queryParam: {},
});
var testCollection5 = new TestCollection([],{
state: {
firstPage: 0,
lastPage: 0,
currentPage: 0,
pageSize: 1,
totalPages: 1,
totalRecords: 1,
sortKey: 'id',
order: 1,
},
queryParam: {
currentPage: 'current_page',
pageSize: 'page_size',
totalPages: 'total_pages',
totalRecords: 'total_records',
sortKey: 'sort_key',
order: 'order',
directions: '',
},
});
var testCollection6 = new TestCollection([
<TestModel>{},
<TestModel>{},
]);
}
namespace Fetching {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
var testCollection1 = new TestCollection();
var testCollection2 = new TestCollection([
new TestModel(),
new TestModel()
]);
var testCollection3 = new TestCollection([], {});
var testCollection4 = new TestCollection([],{
comparator: ()=>1,
full: true,
state: {},
queryParam: {},
});
var testCollection5 = new TestCollection([],{
state: {
firstPage: 0,
lastPage: 0,
currentPage: 0,
pageSize: 1,
totalPages: 1,
totalRecords: 1,
sortKey: 'id',
order: 1,
},
queryParam: {
currentPage: 'current_page',
pageSize: 'page_size',
totalPages: 'total_pages',
totalRecords: 'total_records',
sortKey: 'sort_key',
order: 'order',
directions: '',
},
});
var testCollection6 = new TestCollection([
<TestModel>{},
<TestModel>{},
]);
}
namespace Fetching {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[], options?: Backbone.PageableInitialOptions){
super();
}
}
var testCollection = new TestCollection();
var testCollection = new TestCollection();
var result:JQueryXHR = testCollection.fetch();
var result:JQueryXHR = testCollection.fetch();
testCollection.fetch({});
testCollection.fetch({});
testCollection.fetch(makeFetchOptions<TestCollection>());
}
testCollection.fetch(makeFetchOptions<TestCollection>());
namespace Paging {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[], options?: Backbone.PageableInitialOptions){
super();
}
}
var options = makeFetchOptions<TestCollection>();
var testCollection = new TestCollection();
namespace Paging {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
}
var result:JQueryXHR|TestCollection = testCollection.getFirstPage();
var options = makeFetchOptions<TestCollection>();
testCollection.getFirstPage(options);
var testCollection = new TestCollection();
// 'silent's type is boolean. (structural subtyping)
testCollection.getFirstPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getFirstPage({url: true});
var result:JQueryXHR|TestCollection = testCollection.getFirstPage();
result = testCollection.getLastPage();
testCollection.getFirstPage(options);
testCollection.getLastPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getFirstPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getFirstPage({url: true});
// 'silent's type is boolean. (structural subtyping)
testCollection.getLastPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getLastPage({url: true});
result = testCollection.getLastPage();
result = testCollection.getNextPage();
testCollection.getLastPage(options);
testCollection.getNextPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getLastPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getLastPage({url: true});
// 'silent's type is boolean. (structural subtyping)
testCollection.getNextPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getNextPage({url: true});
result = testCollection.getNextPage();
result = testCollection.getPage(1);
testCollection.getNextPage(options);
testCollection.getPage("1", options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getNextPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getNextPage({url: true});
// 'silent's type is boolean. (structural subtyping)
testCollection.getPage(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPage(1, {url: true});
result = testCollection.getPage(1);
result = testCollection.getPageByOffset(1);
testCollection.getPage("1", options);
testCollection.getPageByOffset(1, options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getPage(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPage(1, {url: true});
// 'silent's type is boolean. (structural subtyping)
testCollection.getPageByOffset(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPageByOffset(1, {url: true});
result = testCollection.getPageByOffset(1);
result = testCollection.getPreviousPage();
testCollection.getPageByOffset(1, options);
testCollection.getPreviousPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getPageByOffset(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPageByOffset(1, {url: true});
// 'silent's type is boolean. (structural subtyping)
testCollection.getPreviousPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPreviousPage({url: true});
result = testCollection.getPreviousPage();
var hasPage:boolean = testCollection.hasNextPage();
testCollection.getPreviousPage(options);
hasPage = testCollection.hasPreviousPage();
}
// 'silent's type is boolean. (structural subtyping)
testCollection.getPreviousPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPreviousPage({url: true});
var hasPage:boolean = testCollection.hasNextPage();
hasPage = testCollection.hasPreviousPage();
namespace Parse {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
}
namespace Parse {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
var testCollection = new TestCollection();
var result:any[] = testCollection.parse({}, {});
var resultLinks:any = testCollection.parseLinks({}, {});
resultLinks = testCollection.parseLinks({}, { xhr: $.ajax({}) } );
result = testCollection.parseRecords({}, {});
var resultState: Backbone.PageableState = testCollection.parseState(
{},
{
currentPage: 'current_page',
pageSize: 'page_size',
totalPages: 'total_pages',
totalRecords: 'total_records',
sortKey: 'sort_key',
order: 'order',
directions: '',
},
{
firstPage: 0,
lastPage: 0,
currentPage: 0,
pageSize: 1,
totalPages: 1,
totalRecords: 1,
sortKey: 'id',
order: 1,
},
{});
}
namespace Setting {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[], options?: Backbone.PageableInitialOptions){
super();
}
var testCollection = new TestCollection();
var result:any[] = testCollection.parse({}, {});
var resultLinks:any = testCollection.parseLinks({}, {});
resultLinks = testCollection.parseLinks({}, { xhr: $.ajax({}) } );
result = testCollection.parseRecords({}, {});
var resultState: Backbone.PageableState = testCollection.parseState(
{},
{
currentPage: 'current_page',
pageSize: 'page_size',
totalPages: 'total_pages',
totalRecords: 'total_records',
sortKey: 'sort_key',
order: 'order',
directions: '',
},
{
firstPage: 0,
lastPage: 0,
currentPage: 0,
pageSize: 1,
totalPages: 1,
totalRecords: 1,
sortKey: 'id',
order: 1,
},
{});
}
var testCollection = new TestCollection();
namespace Setting {
var options = makeFetchOptions<TestCollection>();
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
}
var result1:JQueryXHR|TestCollection
= testCollection.setPageSize(1, options);
var testCollection = new TestCollection();
var options = makeFetchOptions<TestCollection>();
var result2:TestCollection
= testCollection.setSorting('id', 1, options);
result1 = testCollection.switchMode(
'server',
{fetch: true, resetState: true}
);
}
var result1:JQueryXHR|TestCollection
= testCollection.setPageSize(1, options);
var result2:TestCollection
= testCollection.setSorting('id', 1, options);
result1 = testCollection.switchMode(
'server',
{fetch: true, resetState: true}
);
}
namespace Syncing {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[],
options?: Backbone.PageableInitialOptions){
super();
}
namespace Syncing {
class TestCollection extends Backbone.PageableCollection<TestModel> {
constructor(models?: TestModel[], options?: Backbone.PageableInitialOptions){
super();
}
var testCollection = new TestCollection();
var result:JQueryXHR = testCollection.sync('server', new TestModel(), {});
result = testCollection.sync('server', testCollection, {});
}
var testCollection = new TestCollection();
var result:JQueryXHR = testCollection.sync('server', new TestModel(), {});
namespace Confllict {
var result:typeof Backbone.PageableCollection
= Backbone.PageableCollection.noConflict();
}
result = testCollection.sync('server', testCollection, {});
}
namespace Confllict {
var result: typeof Backbone.PageableCollection = Backbone.PageableCollection.noConflict();
}
+1 -1
View File
@@ -2,9 +2,9 @@
// Project: https://github.com/nulab/backlog-js
// Definitions by: Yuichi Watanabe <https://github.com/vvatanabe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
/// <reference types="isomorphic-fetch" />
declare class Request {
private configure;
+100
View File
@@ -0,0 +1,100 @@
import * as Bagpipes from 'bagpipes';
// test `create`
Bagpipes.create({});
Bagpipes.create({ CustomPipe: [] });
Bagpipes.create({ CustomPipe: [] }, undefined);
Bagpipes.create({ CustomPipe: [] }, {});
// test `PipeDefs` Pipe Definitions Object
const perDefsMixed: Bagpipes.PipeDefMap = {
HelloWorld: [
{ emit: 'Hello, World!' },
'StringTypeDef'
],
xxx: 'ddd'
};
const pipesDefsEmpty: Bagpipes.PipeDefMap = {};
const pipesDefs: Bagpipes.PipeDefMap = {
_router: {
name: 'swagger_router',
mockMode: false,
mockControllersDirs: [ 'api/mocks' ],
controllersDirs: [ 'api/controllers' ]
},
_swagger_validate: {
name: 'swagger_validator',
validateReponse: true
},
swagger_controllers: [
'cors',
'swagger_params_parser',
'swagger_security',
'_swagger_validate',
'express_compatibility',
'_router'
]
};
// test `Config` object
const pipesConfigA: Bagpipes.Config = {
connectMiddlewareDirs: ['some_dir', 'ssssss']
};
const pipesConfigempty: Bagpipes.Config = { };
const pipesConfigFull: Bagpipes.Config = {
connectMiddlewareDirs: ['test'],
userFittingsDirs: ['test'],
userViewsDirs: ['test']
};
const pipesConfigFullEmpty: Bagpipes.Config = {
connectMiddlewareDirs: [],
userFittingsDirs: [],
userViewsDirs: []
};
let pipesA = Bagpipes.create(perDefsMixed, {
connectMiddlewareDirs: ['some_dir', 'ssssss'],
swaggerNodeRunner: {}
});
let pipeA = pipesA.getPipe('HelloWorld');
// log the output to standard out
pipeA.fit((context, cb) => {
cb(null, context);
});
pipesA.play(pipeA, {});
// test cb with err
const pipesEnty = Bagpipes.create({
HelloWorld: []
}, {});
// test fit a registered pipe and return error
const pipeErrTest = pipesEnty.pipes['any'].fit((context, cb) => {
cb(new Error("test err"));
});
pipesEnty.play(pipeErrTest, {});
const fittingsC = ["xxxx", "aaa"].map((name) => {
let fittingDef = {} as Bagpipes.PipeDefMap;
fittingDef[name] = 'nothing';
return fittingDef;
});
const bagpipesC = Bagpipes.create({ fittings: fittingsC });
// test create with array of object literals
const pipeWithObj = [{ emit: 'something' }];
const bagpipesD = Bagpipes.create({ objPipe: pipeWithObj });
bagpipesD.play(bagpipesD.getPipe('objPipe'), {});
// Test full create
const userFittingsDirs = ['./fixtures/fittings'];
const pipeWithString = ['emit'];
let contextPlain = {};
const bagpipesWithPipeAndFittings = Bagpipes.create({ myCustomPipe: pipeWithString }, { userFittingsDirs });
bagpipesWithPipeAndFittings.play(bagpipesWithPipeAndFittings.getPipe('myCustomPipe'), contextPlain);
Vendored Executable
+177
View File
@@ -0,0 +1,177 @@
// Type definitions for bagpipes 0.1
// Project: https://github.com/apigee-127/bagpipes
// Definitions by: Michael Mrowetz <https://github.com/micmro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FittingContext {
/** The input defined in the fitting definition
* (string, number, object, array)
*/
input: any;
/** Output to be delivered to the next fitting or client */
output: any;
[prop: string]: any;
}
/**
* Fitting types has pre-defined fittings `system` and `user`
* but can be any any string for custom types like `swagger` or `node-machine`
*/
type FittingType = "system" | "user" | string;
interface FittingDef {
/**
* If type is omitted (as it must be for in-line usage), Bagpipes will
* first check the user fittings then the system fittings for the name and
* use the first fitting found.
*
* Thus be aware that if you define a fitting with the same name as a
* system one, your fitting will override it.
*/
type?: FittingType;
/** The name of the fitting of the type specified */
name?: string;
/** Static values passed to the fitting during construction */
config?: any;
/** Dynamic values passed to the fitting during execution */
input?: any;
/** The name of the context key to which the output value is assigned */
output?: any;
// allow other config settings
[prop: string]: any;
}
/**
* Fitting Execution Function
*
* Will be called called when the `Pipe` it is contained it gets 'played'
*/
type Fitting = (
context: FittingContext,
next: {(err: Error | null | undefined, res?: any): void}) => void;
/**
* Fitting creation Function
*
* Executed during parsing
* @see {@link https://github.com/apigee-127/bagpipes#fittings|Docs}
*
* @param {Object} fittingDef Fitting Definition
*/
type FittingFactory = (fittingDef: FittingDef, bagpipes: any) => Fitting;
/**
* Hashmap of `fittingType`s (the name of a fitting) and the
* `FittingFactory` functions used to create them
*/
interface FittingTypesMap {
[fittingType: string]: FittingFactory;
}
/** The Pipe Definition */
type PipeDef = any[] | string | FittingDef;
/** Hashmap of Pipe Definitons */
export interface PipeDefMap {
[name: string]: PipeDef;
}
/**
* Bagpipes Instance (a collection of pipes)
* @see {@link https://github.com/apigee-127/bagpipes#pipes|Docs}
*/
export class Bagpipes {
/**
* Hashmap of `fittingType`s (the name of a fitting) and the
* `FittingFactory` functions used to create them
*/
fittingTypes: FittingTypesMap;
/** The pipes */
pipes: {
[name: string]: Pipe;
};
/** The `Bagpipes`' configuration */
config: Config;
/**
* Creates a `Fitting`
* @throws {Error} Throws error if an invalid (not defined) fitting typ is used
* (can't find argument `fittingType` in `Bagpipes.fittingTypes`)
*/
createFitting(fittingDef: FittingDef): Fitting;
/** returns `pipeworks` Pipe instance */
createPipe(pipeDef: PipeDef): Pipe;
createPipeFromFitting(fitting: Fitting, fittingDef: FittingDef): Pipe;
/**
* Finds and returns a `Pipe` by name and lazily creates if it is not defined
* @throws {Error} Throws error if `pipeDef` pipe is not yet defined and `pipeDef` is
* not supplied
*/
getPipe(pipeName: string, pipeDef?: PipeDef): Pipe;
/** Handler for errors that occure when a `Fitting` gets 'played' */
handleError(context: FittingContext, err: Error): void;
/** Loads `FittingFactory`s from file-system and adds them to `Bagpipes.fittingTypes` */
loadFittingTypes(): FittingTypesMap;
/**
* Builds a new (wrappend) `Fitting`
* @throws {Error} Throws error if an invalid (not defined) fitting typ is used
* (can't find argument `fittingType` in `Bagpipes.fittingTypes`)
*/
newFitting(fittingType: string, fittingDef: FittingDef): Fitting;
/** Run the pipeline */
play(pipe: Pipe, context: any): void;
/**
* Wraps `Fitting` with debugging, `preflight`, `postflight`
* and error handling functionality and returns as new Fitting
*/
wrapFitting(fitting: Fitting, fittingDef: FittingDef): Fitting | null;
}
/** Configuration object for `Bagpipes` */
export interface Config {
connectMiddlewareDirs?: string[];
userFittingsDirs?: string[];
userViewsDirs?: string[];
// allow to store custom values e.g. for swagger-node-runner
// see https://github.com/theganyo/swagger-node-runner/blob/v0.7.1/index.js#L304
[name: string]: any;
}
/**
* Creates `Bagpipes`
*/
export function create(pipesDefs: PipeDefMap, conf?: Config): Bagpipes;
// Types for imports from `pipeworks` module
type Affinity = "hoist" | "sink";
/** PipeDef used in `pipeworks` module */
interface PipeworksOptions {
/**
* Adds to the pre and post queues, respectively.
* Ensures a pipe gets fitted before or after the main execution pipeline.
*/
affinity: Affinity;
}
/**
* Instance of a `Pipeworks` pipeline (in `pipeworks` module) -
* called 'pipe' in `Bagpipes`
*
* _(simplified version)_
*/
export class Pipe {
/** add a new `Fitting` (piece) to the pipe (aka. pipeline) */
fit(pipe: Fitting): Pipe;
/** add a new `Fitting` (piece) to the pipe (aka. pipeline) */
fit(options: PipeworksOptions, pipe: Fitting): Pipe;
/** Redirect the flow to another pipe (aka. pipeline). */
siphon(pipe: Fitting): Pipe;
/** Redirect the flow to another pipe (aka. pipeline). */
siphon(options: PipeworksOptions, pipe: Fitting): Pipe;
/**
* Send something down the pipe (aka. pipeline)! Any number of arguments
* can be sent, but often there's just a single `context` object.
*/
flow(...args: any[]): Pipe;
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bagpipes-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

Some files were not shown because too many files have changed in this diff Show More