mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/// <reference path="3d-bin-packing.d.ts" />
|
||||
|
||||
import packer = require("3d-bin-packing");
|
||||
import samchon = require("samchon-framework");
|
||||
|
||||
function main(): void
|
||||
{
|
||||
///////////////////////////
|
||||
// CONSTRUCT OBJECTS
|
||||
///////////////////////////
|
||||
let wrapperArray: bws.packer.WrapperArray = new packer.WrapperArray();
|
||||
let instanceArray: bws.packer.InstanceArray = new packer.InstanceArray();
|
||||
|
||||
// Wrappers
|
||||
wrapperArray.push
|
||||
(
|
||||
new packer.Wrapper("Large", 1000, 40, 40, 15, 0),
|
||||
new packer.Wrapper("Medium", 700, 20, 20, 10, 0),
|
||||
new packer.Wrapper("Small", 500, 15, 15, 8, 0)
|
||||
);
|
||||
|
||||
///////
|
||||
// Each Instance is repeated #15
|
||||
///////
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20));
|
||||
|
||||
// Wrappers also can be packed into another Wrapper.
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2));
|
||||
instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0));
|
||||
|
||||
///////////////////////////
|
||||
// BEGINS PACKING
|
||||
///////////////////////////
|
||||
// CONSTRUCT PACKER
|
||||
let my_packer: bws.packer.Packer = new packer.Packer(wrapperArray, instanceArray);
|
||||
|
||||
///////
|
||||
// PACK (OPTIMIZE)
|
||||
let result: bws.packer.WrapperArray = my_packer.optimize();
|
||||
///////
|
||||
|
||||
///////////////////////////
|
||||
// TRACE PACKING RESULT
|
||||
///////////////////////////
|
||||
let xml: samchon.library.XML = result.toXML();
|
||||
console.log(xml.toString());
|
||||
}
|
||||
|
||||
main();
|
||||
Vendored
+1500
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -401,6 +401,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](egg.js/egg.js.d.ts) [Egg.js](https://github.com/mikeflynn/egg.js) by [Markus Peloso](https://github.com/ToastHawaii)
|
||||
* [:link:](ejs-locals/ejs-locals.d.ts) [ejs-locals](https://github.com/randometc/ejs-locals) by [jt000](https://github.com/jt000)
|
||||
* [:link:](ejs/ejs.d.ts) [ejs.js](http://ejs.co) by [Ben Liddicott](https://github.com/benliddicott/DefinitelyTyped)
|
||||
* [:link:](elasticsearch/elasticsearch.d.ts) [elasticsearch](https://www.elastic.co) by [Casper Skydt](https://github.com/CasperSkydt/DefinitelyTyped), [Blake Smith](https://github.com/bfsmith/DefinitelyTyped)
|
||||
* [:link:](jquery.elang/jquery.elang.d.ts) [eLang](https://github.com/sumegizoltan/ELang) by [Zoltan Sumegi](https://github.com/sumegizoltan)
|
||||
* [:link:](github-electron/github-electron.d.ts) [Electron](http://electron.atom.io) by [jedmao](https://github.com/jedmao), [rhysd](https://rhysd.github.io), [Milan Burda](https://github.com/miniak)
|
||||
* [:link:](electron-builder/electron-builder.d.ts) [electron-builder](https://github.com/loopline-systems/electron-builder) by [Maxime LUCE](https://github.com/SomaticIT)
|
||||
@@ -1123,10 +1124,11 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](moment/moment.d.ts) [Moment.js](https://github.com/timrwood/moment) by [Michael Lakerveld](https://github.com/Lakerfield), [Aaron King](https://github.com/kingdango), [Hiroki Horiuchi](https://github.com/horiuchi), [Dick van den Brink](https://github.com/DickvdBrink), [Adi Dahiya](https://github.com/adidahiya), [Matt Brooks](https://github.com/EnableSoftware)
|
||||
* [:link:](moment-range/moment-range.d.ts) [Moment.js](https://github.com/gf3/moment-range) by [Bart van den Burg](https://github.com/Burgov), [Wilgert Velinga](https://github.com/wilgert)
|
||||
* [:link:](mongodb/mongodb.d.ts) [MongoDB](https://github.com/mongodb/node-mongodb-native/tree/2.1) by [Federico Caselli](https://github.com/CaselIT)
|
||||
* [:link:](mongoose/mongoose.d.ts) [Mongoose](http://mongoosejs.com) by [horiuchi](https://github.com/horiuchi)
|
||||
* [:link:](mongoose/mongoose.d.ts) [Mongoose](http://mongoosejs.com) by [simonxca](https://github.com/simonxca), [horiuchi](https://github.com/horiuchi)
|
||||
* [:link:](mongoose-auto-increment/mongoose-auto-increment.d.ts) [mongoose-auto-increment](https://github.com/codetunnel/mongoose-auto-increment) by [Aya Morisawa](https://github.com/AyaMorisawa)
|
||||
* [:link:](mongoose-deep-populate/mongoose-deep-populate.d.ts) [mongoose-deep-populate](https://github.com/buunguyen/mongoose-deep-populate) by [Aya Morisawa](https://github.com/AyaMorisawa)
|
||||
* [:link:](mongoose-mock/mongoose-mock.d.ts) [mongoose-mock](https://github.com/JohanObrink/mongoose-mock) by [jt000](https://github.com/jt000)
|
||||
* [:link:](mongoose-promise/mongoose-promise.d.ts) [mongoose-promise](http://mongoosejs.com/docs/api.html#promise-js) by [simonxca](https://github.com/simonxca)
|
||||
* [:link:](morgan/morgan.d.ts) [morgan](https://github.com/expressjs/morgan) by [James Roland Cabresos](https://github.com/staticfunction)
|
||||
* [:link:](mousetrap/mousetrap-global-bind.d.ts) [Mousetrap 1.4.6's global-bind extension](http://craig.is/killing/mice#extensions.global) by [Andrew Bradley](https://github.com/cspotcode)
|
||||
* [:link:](mousetrap/mousetrap.d.ts) [Mousetrap 1.5.x](http://craig.is/killing/mice) by [Dániel Tar](https://github.com/qcz)
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path='../node/node.d.ts'/>
|
||||
|
||||
/// <reference path='../redis/redis.d.ts'/>
|
||||
|
||||
Vendored
+10
@@ -319,6 +319,11 @@ declare module "agenda" {
|
||||
* The date/time the job last failed.
|
||||
*/
|
||||
failedAt: Date;
|
||||
|
||||
/**
|
||||
* Job's state
|
||||
*/
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,6 +414,11 @@ declare module "agenda" {
|
||||
* @param cb Called after the job has been saved to the database.
|
||||
*/
|
||||
touch(cb?: Callback): void;
|
||||
|
||||
/**
|
||||
* Calculates next time the job should run
|
||||
*/
|
||||
computeNextRunAt(): Job;
|
||||
}
|
||||
|
||||
interface JobOptions {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/// <reference path="ajv.d.ts" />
|
||||
|
||||
import * as Ajv from 'ajv';
|
||||
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
|
||||
var validate = ajv.compile({});
|
||||
var valid = validate({});
|
||||
if (!valid) console.log(validate.errors);
|
||||
|
||||
var valid = ajv.validate({}, {});
|
||||
if (!valid) console.log(ajv.errors);
|
||||
|
||||
ajv.addSchema({}, 'mySchema');
|
||||
var valid = ajv.validate('mySchema', {});
|
||||
if (!valid) console.log(ajv.errorsText());
|
||||
|
||||
ajv.addKeyword('range', {
|
||||
type: 'number', compile: function (sch, parentSchema) {
|
||||
var min: any = sch[0];
|
||||
var max: any = sch[1];
|
||||
|
||||
return parentSchema.exclusiveRange === true
|
||||
? function (data) { return data > min && data < max; }
|
||||
: function (data) { return data >= min && data <= max; }
|
||||
}
|
||||
});
|
||||
|
||||
var schema = { "range": [2, 4], "exclusiveRange": true };
|
||||
var validate = ajv.compile(schema);
|
||||
console.log(validate(2.01)); // true
|
||||
console.log(validate(3.99)); // true
|
||||
console.log(validate(2)); // false
|
||||
console.log(validate(4)); // false
|
||||
|
||||
declare var request: any;
|
||||
function loadSchema(uri: any, callback: any) {
|
||||
request.json(uri, function (err: any, res: any, body: any) {
|
||||
if (err || res.statusCode >= 400)
|
||||
callback(err || new Error('Loading error: ' + res.statusCode));
|
||||
else
|
||||
callback(null, body);
|
||||
});
|
||||
}
|
||||
var ajv = new Ajv({ loadSchema: loadSchema });
|
||||
|
||||
ajv.compileAsync(schema, function (err, validate) {
|
||||
if (err) return;
|
||||
var valid = validate({});
|
||||
});
|
||||
|
||||
declare var knex: any;
|
||||
function checkIdExists(schema: any, data: any) {
|
||||
return knex(schema.table)
|
||||
.select('id')
|
||||
.where('id', data)
|
||||
.then(function (rows: any) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
var validate = ajv.compile(schema);
|
||||
|
||||
(validate({ userId: 1, postId: 19 }) as PromiseLike<boolean>)
|
||||
.then(function (valid) {
|
||||
// "valid" is always true here
|
||||
console.log('Data is valid');
|
||||
}, function (err) {
|
||||
if (!(err instanceof Ajv.ValidationError)) throw err;
|
||||
// data is invalid
|
||||
console.log('Validation errors:', err.errors);
|
||||
});
|
||||
|
||||
var ajv = new Ajv({ /* async: 'es7', */ transpile: 'nodent' });
|
||||
var validate = ajv.compile(schema); // transpiled es7 async function
|
||||
(validate({}) as PromiseLike<any>).then(() => { }, () => { });
|
||||
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
// Type definitions for ajv
|
||||
// Project: https://github.com/epoberezkin/ajv
|
||||
// Definitions by: York Yao <https://github.com/plantain-00/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "ajv" {
|
||||
class Ajv {
|
||||
/**
|
||||
* Create Ajv instance.
|
||||
*/
|
||||
constructor(options?: Ajv.AjvOptions);
|
||||
/**
|
||||
* Generate validating function and cache the compiled schema for future use.
|
||||
*/
|
||||
compile(schema: any): Ajv.AjvValidate;
|
||||
/**
|
||||
* Asyncronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema.
|
||||
*/
|
||||
compileAsync(schema: any, callback: (error: Error, validate: Ajv.AjvValidate) => void): void;
|
||||
/**
|
||||
* Validate data using passed schema (it will be compiled and cached).
|
||||
*/
|
||||
validate(schema: any, data: any): boolean | PromiseLike<boolean>;
|
||||
errors: Ajv.ValidationError[];
|
||||
/**
|
||||
* Add schema(s) to validator instance.
|
||||
*/
|
||||
addSchema(schema: any, key: string): void;
|
||||
/**
|
||||
* Adds meta schema(s) that can be used to validate other schemas.
|
||||
* That function should be used instead of addSchema because there may be instance options that would compile a meta schema incorrectly (at the moment it is removeAdditional option).
|
||||
*/
|
||||
addMetaSchema(schema: any, key: string): void;
|
||||
/**
|
||||
* Validates schema.
|
||||
* This method should be used to validate schemas rather than validate due to the inconsistency of uri format in JSON-Schema standard.
|
||||
*/
|
||||
validateSchema(schema: any): Boolean;
|
||||
/**
|
||||
* Retrieve compiled schema previously added with addSchema by the key passed to addSchema or by its full reference (id).
|
||||
* Returned validating function has schema property with the reference to the original schema.
|
||||
*/
|
||||
getSchema(key: string): Ajv.AjvValidate;
|
||||
/**
|
||||
* Remove added/cached schema.
|
||||
* Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.
|
||||
*/
|
||||
removeSchema(schema: any): void;
|
||||
/**
|
||||
* Add custom format to validate strings. It can also be used to replace pre-defined formats for Ajv instance.
|
||||
*/
|
||||
addFormat(name: string, format: any): void;
|
||||
/**
|
||||
* Add custom validation keyword to Ajv instance.
|
||||
*/
|
||||
addKeyword(keyword: string, definition: Ajv.AjxKeywordDefinition): void;
|
||||
errorsText(): any;
|
||||
static ValidationError: Function;
|
||||
}
|
||||
namespace Ajv {
|
||||
type AjvOptions = {
|
||||
v5?: boolean;
|
||||
allErrors?: boolean;
|
||||
verbose?: boolean;
|
||||
jsonPointers?: boolean;
|
||||
uniqueItems?: boolean;
|
||||
unicode?: boolean;
|
||||
format?: string;
|
||||
formats?: any;
|
||||
schemas?: any;
|
||||
missingRefs?: boolean;
|
||||
loadSchema?(uri: string, callback: (error: Error, body: any) => void): void;
|
||||
removeAdditional?: boolean;
|
||||
useDefaults?: boolean;
|
||||
coerceTypes?: boolean;
|
||||
async?: any;
|
||||
transpile?: string;
|
||||
meta?: boolean;
|
||||
validateSchema?: boolean;
|
||||
addUsedSchema?: boolean;
|
||||
inlineRefs?: boolean;
|
||||
passContext?: boolean;
|
||||
loopRequired?: number;
|
||||
ownProperties?: boolean;
|
||||
multipleOfPrecision?: boolean;
|
||||
errorDataPath?: string,
|
||||
messages?: boolean;
|
||||
beautify?: boolean;
|
||||
cache?: any;
|
||||
}
|
||||
type AjvValidate = ((data: any) => boolean | PromiseLike<boolean>) & {
|
||||
errors: ValidationError[];
|
||||
}
|
||||
type AjxKeywordDefinition = {
|
||||
async?: boolean;
|
||||
type: string;
|
||||
compile?: (schema: any, parentsSchema: any) => ((data: any) => boolean | PromiseLike<boolean>);
|
||||
validate?: (schema: any, data: any) => boolean;
|
||||
}
|
||||
type ValidationError = {
|
||||
keyword: string;
|
||||
dataPath: string;
|
||||
schemaPath: string;
|
||||
params: any;
|
||||
message: string;
|
||||
schema: any;
|
||||
parentSchema: any;
|
||||
data: any;
|
||||
}
|
||||
}
|
||||
export = Ajv;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="./alexa-sdk.d.ts" />
|
||||
|
||||
import * as Alexa from "alexa-sdk";
|
||||
|
||||
exports.handler = function(event: Alexa.RequestBody, context: Alexa.Context, callback: Function) {
|
||||
let alexa = Alexa.handler(event, context);
|
||||
alexa.registerHandlers(handlers);
|
||||
alexa.execute();
|
||||
};
|
||||
|
||||
let handlers: Alexa.Handlers = {
|
||||
'LaunchRequest': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit('SayHello');
|
||||
},
|
||||
'HelloWorldIntent': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit('SayHello');
|
||||
},
|
||||
'SayHello': function () {
|
||||
var self: Alexa.Handler = this;
|
||||
self.emit(':tell', 'Hello World!');
|
||||
}
|
||||
};
|
||||
Vendored
+132
@@ -0,0 +1,132 @@
|
||||
// Type definitions for Alexa SDK for Node.js v1.0.3
|
||||
// Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
|
||||
// Definitions by: Pete Beegle <https://github.com/petebeegle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'alexa-sdk' {
|
||||
export function handler(event: RequestBody, context: Context, callback?: Function): AlexaObject;
|
||||
export function CreateStateHandler(state: string, obj: any): any;
|
||||
export var StateString: string;
|
||||
|
||||
interface AlexaObject {
|
||||
_event: any;
|
||||
_context: any;
|
||||
_callback: any;
|
||||
state: any;
|
||||
appId: any;
|
||||
response: any;
|
||||
dynamoDBTableName: any;
|
||||
saveBeforeResponse: boolean;
|
||||
registerHandlers: (...handlers: Handlers[]) => any;
|
||||
execute: () => void;
|
||||
}
|
||||
|
||||
interface Handlers {
|
||||
[intent: string]: () => void;
|
||||
}
|
||||
|
||||
interface Handler {
|
||||
on: any;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emitWithState: any;
|
||||
state: any;
|
||||
handler: any;
|
||||
event: RequestBody;
|
||||
attributes: any;
|
||||
context: any;
|
||||
name: any;
|
||||
isOverriden: any;
|
||||
}
|
||||
|
||||
interface Context {
|
||||
callbackWaitsForEmptyEventLoop: boolean;
|
||||
logGroupName: string;
|
||||
logStreamName: string;
|
||||
functionName: string;
|
||||
memoryLimitInMB: string;
|
||||
functionVersion: string;
|
||||
invokeid: string;
|
||||
awsRequestId: string;
|
||||
}
|
||||
|
||||
interface RequestBody {
|
||||
version: string;
|
||||
session: Session;
|
||||
request: LaunchRequest | IntentRequest | SessionEndedRequest;
|
||||
}
|
||||
|
||||
interface Session {
|
||||
new: boolean;
|
||||
sessionId: string;
|
||||
attributes: any;
|
||||
application: SessionApplication;
|
||||
user: SessionUser;
|
||||
}
|
||||
|
||||
interface SessionApplication {
|
||||
applicationId: string;
|
||||
}
|
||||
|
||||
interface SessionUser {
|
||||
userId: string;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
interface LaunchRequest extends IRequest {}
|
||||
|
||||
interface IntentRequest extends IRequest {
|
||||
intent: Intent;
|
||||
}
|
||||
|
||||
interface Intent {
|
||||
name: string;
|
||||
slots: any;
|
||||
}
|
||||
|
||||
interface SessionEndedRequest extends IRequest{
|
||||
reason: string;
|
||||
}
|
||||
|
||||
interface IRequest {
|
||||
type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest";
|
||||
requestId: string;
|
||||
timeStamp: string;
|
||||
}
|
||||
|
||||
interface ResponseBody {
|
||||
version: string;
|
||||
sessionAttributes?: any;
|
||||
response: Response;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
outputSpeech?: OutputSpeech;
|
||||
card?: Card;
|
||||
reprompt?: Reprompt;
|
||||
shouldEndSession: boolean;
|
||||
}
|
||||
|
||||
interface OutputSpeech {
|
||||
type: "PlainText" | "SSML";
|
||||
text?: string;
|
||||
ssml?: string;
|
||||
}
|
||||
|
||||
interface Card {
|
||||
type: "Simple" | "Standard" | "LinkAccount";
|
||||
title?: string;
|
||||
content?: string;
|
||||
text?: string;
|
||||
image?: Image;
|
||||
}
|
||||
|
||||
interface Image {
|
||||
smallImageUrl: string;
|
||||
largeImageUrl: string;
|
||||
}
|
||||
|
||||
interface Reprompt {
|
||||
outputSpeech: OutputSpeech;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -53,8 +53,8 @@ declare namespace AltJS {
|
||||
export type Source = {[name:string]: () => SourceModel<any>};
|
||||
|
||||
export interface SourceModel<S> {
|
||||
local(state:any):any;
|
||||
remote(state:any):Promise<S>;
|
||||
local(state:any, ...args: any[]):any;
|
||||
remote(state:any, ...args: any[]):Promise<S>;
|
||||
shouldFetch?(fetchFn:(...args:Array<any>) => boolean):void;
|
||||
loading?:(args:any) => void;
|
||||
success?:(state:S) => void;
|
||||
|
||||
Vendored
+23
-1
@@ -26,6 +26,22 @@ declare namespace AmCharts {
|
||||
|
||||
/** Clears all the charts on page, removes listeners and intervals. */
|
||||
function clear();
|
||||
|
||||
/** Handle ready event */
|
||||
function ready(Function): void;
|
||||
|
||||
/** Create chart by params. */
|
||||
function makeChart(selector: string, params: any, delay?: number): AmChart;
|
||||
|
||||
/** Set a method to be called before initializing the chart.
|
||||
* When the method is called, the chart instance is passed as an attribute.
|
||||
* You can use this feature to preprocess chart data or do some other things you need
|
||||
* before initializing the chart.
|
||||
* @param {Function} handler - The method to be called.
|
||||
* @param {string[]} types - Which chart types should call this method. Defaults to all
|
||||
* if none is passed.
|
||||
*/
|
||||
function addInitHandler(handler: Function, types: string[]);
|
||||
|
||||
/** AmPieChart class creates pie/donut chart. In order to display pie chart you need to set at least three properties - dataProvider, titleField and valueField.
|
||||
@example
|
||||
@@ -948,6 +964,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
@Default 150
|
||||
*/
|
||||
hideBalloonTime: number;
|
||||
/** Allows changing language easily.
|
||||
* Note, you should include the language.js file from amcharts/lang or ammap/lang folder and then use variable name used in this file, like chart.language = "de";
|
||||
* Note, for maps this works differently - you use language only for country names, as there are no other strings in the maps application. */
|
||||
language: string;
|
||||
/** Legend of a chart. */
|
||||
legend: AmLegend;
|
||||
/** Reference to the div of the legend. */
|
||||
@@ -976,6 +996,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
prefixesOfBigNumbers: any[];
|
||||
/** Prefixes which are used to make small numbers shorter: 2μ instead of 0.000002, etc. Prefixes are used on value axes and in the legend. To enable prefixes, set usePrefixes property to true. [{number:1e-24, prefix:"y"},{number:1e-21, prefix:"z"},{number:1e-18, prefix:"a"},{number:1e-15, prefix:"f"},{number:1e-12, prefix:"p"},{number:1e-9, prefix:"n"},{number:1e-6, prefix:"μ"},{number:1e-3, prefix:"m"}] */
|
||||
prefixesOfSmallNumbers: any[];
|
||||
/** A config object for Responsive plugin. */
|
||||
responsive: any;
|
||||
/** Theme of a chart. Config files of themes can be found in amcharts/themes/ folder. More info about using themes. */
|
||||
theme: string;
|
||||
/** Thousands separator.
|
||||
@@ -1003,7 +1025,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
|
||||
bold - specifies if text is bold (true/false),
|
||||
url - url
|
||||
*/
|
||||
addLabel(x: number, y: number, text: string, align: string, size: number, color: string, rotation: number, alpha: number, bold: boolean, url: string);
|
||||
addLabel(x: number|string, y: number|string, text: string, align: string, size?: number, color?: string, rotation?: number, alpha?: number, bold?: boolean, url?: string);
|
||||
/** Adds a legend to the chart.
|
||||
By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter.
|
||||
(NOTE: This method will not work on StockPanel.)
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Tests for Amplitude SDK TypeScript definitions
|
||||
|
||||
/// <reference path="amplitude-js.d.ts" />
|
||||
|
||||
module Amplitude.Tests {
|
||||
function all() {
|
||||
amplitude.init('YOUR_API_KEY_HERE', null, {
|
||||
// optional configuration options
|
||||
saveEvents: true,
|
||||
includeUtm: true,
|
||||
includeReferrer: true,
|
||||
batchEvents: true,
|
||||
eventUploadThreshold: 50
|
||||
});
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE');
|
||||
amplitude.setUserId('USER_ID_HERE');
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
|
||||
amplitude.setUserId(null); // not string 'null'
|
||||
amplitude.setVersionName('VERSION_NAME_HERE');
|
||||
|
||||
amplitude.regenerateDeviceId();
|
||||
amplitude.setDeviceId('CUSTOM_DEVICE_ID');
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
|
||||
'color': 'blue',
|
||||
'age': 20,
|
||||
'key': 'value'
|
||||
});
|
||||
amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
|
||||
|
||||
let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().unset('gender').unset('age');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('karma', 10)
|
||||
.add('karma', 1)
|
||||
.unset('karma');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('colors', ['rose', 'gold'])
|
||||
.append('ab-tests', 'campaign_a')
|
||||
.append('existing_list', [4, 5]);
|
||||
amplitude.identify(identify);
|
||||
|
||||
amplitude.setUserProperties({
|
||||
gender: 'female',
|
||||
age: 20
|
||||
});
|
||||
|
||||
amplitude.clearUserProperties();
|
||||
|
||||
amplitude.setOptOut(true);
|
||||
amplitude.setOptOut(false);
|
||||
|
||||
amplitude.setGroup('orgId', '15');
|
||||
amplitude.setGroup('sport', ['soccer', 'tennis']);
|
||||
|
||||
// TODO: Implement those.
|
||||
/*
|
||||
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
|
||||
amplitude.logRevenueV2(revenue);
|
||||
|
||||
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
*/
|
||||
}
|
||||
}
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
// Type definitions for Amplitude SDK 2.12.1
|
||||
// Project: https://github.com/amplitude/Amplitude-Javascript
|
||||
// Definitions by: Arvydas Sidorenko <https://github.com/Asido>
|
||||
// Definitions: https://github.com/Asido/DefinitelyTyped
|
||||
|
||||
declare module amplitude {
|
||||
interface Config {
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
deviceId?: string;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
sessionTimeout?: number;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export function init(apiKey: string): void;
|
||||
export function init(apiKey: string, userId: string): void;
|
||||
export function init(apiKey: string, userId: string, options: Config): void;
|
||||
export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify): void;
|
||||
|
||||
export function setUserProperties(properties: Object): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string): void;
|
||||
export function logEvent(event: string, data: Object): void;
|
||||
export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
|
||||
|
||||
export var options: Config;
|
||||
}
|
||||
@@ -14,6 +14,11 @@ declare namespace angular.environment {
|
||||
* loads the correct environment variables.
|
||||
*/
|
||||
check: () => void;
|
||||
/**
|
||||
* Retrieves the correct version of a
|
||||
* variable for the current environment.
|
||||
*/
|
||||
read: (key: string) => any;
|
||||
}
|
||||
interface Service {
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/// <reference path="./angular-es.d.ts" />
|
||||
|
||||
//
|
||||
// @Component
|
||||
//
|
||||
import { Component } from 'angular-es';
|
||||
@Component({
|
||||
selector: '',
|
||||
template: ''
|
||||
})
|
||||
class MyComponentController {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Config
|
||||
//
|
||||
import { Config } from 'angular-es';
|
||||
|
||||
@Config()
|
||||
class MyConfig {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Constant
|
||||
//
|
||||
import { Constant } from 'angular-es';
|
||||
|
||||
@Constant('MyConstant')
|
||||
class MyConstant {
|
||||
foo = 'foo';
|
||||
bar = 'bar';
|
||||
}
|
||||
|
||||
//
|
||||
// @Controller
|
||||
//
|
||||
import { Controller } from 'angular-es';
|
||||
|
||||
@Controller('MyController')
|
||||
class MyController {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Decorator
|
||||
//
|
||||
import { Decorator } from 'angular-es';
|
||||
|
||||
@Decorator('MyServiceDecorator')
|
||||
class MyServiceDecorator {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Directive
|
||||
//
|
||||
import { Directive } from 'angular-es';
|
||||
|
||||
@Directive('MyDirective')
|
||||
class MyDirective {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @Factory
|
||||
//
|
||||
import { Factory } from 'angular-es';
|
||||
|
||||
@Factory('MyFactory')
|
||||
class MyFactory {
|
||||
}
|
||||
|
||||
//
|
||||
// @Filter
|
||||
//
|
||||
import { Filter } from 'angular-es';
|
||||
|
||||
@Filter('MyFilter')
|
||||
class MyFilter {
|
||||
}
|
||||
|
||||
//
|
||||
// @Inject
|
||||
//
|
||||
import { Inject } from 'angular-es';
|
||||
|
||||
@Inject('fooBar')
|
||||
class MyFooService {
|
||||
|
||||
@Inject('bazBar')
|
||||
myMethod(bazBar: Object) {
|
||||
}
|
||||
|
||||
constructor(fooBar: Object) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @InjectAsProperty
|
||||
//
|
||||
import { InjectAsProperty } from 'angular-es';
|
||||
|
||||
@InjectAsProperty('fooBar')
|
||||
class MyFooBarService {
|
||||
fooBar: Object;
|
||||
|
||||
myMethod() {
|
||||
this.fooBar !== undefined;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @Module
|
||||
//
|
||||
import { Module } from 'angular-es';
|
||||
|
||||
@Module('my.module')
|
||||
@Service('MyModuleService')
|
||||
class MyModuleService {
|
||||
}
|
||||
|
||||
//
|
||||
// @Provider
|
||||
//
|
||||
import { Provider } from 'angular-es';
|
||||
|
||||
@Provider('MyProvider')
|
||||
class MyProvider {
|
||||
}
|
||||
|
||||
//
|
||||
// @Run
|
||||
//
|
||||
import { Run } from 'angular-es';
|
||||
|
||||
@Run()
|
||||
class MyRunBlock {
|
||||
}
|
||||
|
||||
//
|
||||
// @Service
|
||||
//
|
||||
import { Service } from 'angular-es';
|
||||
|
||||
@Service('MyService')
|
||||
class MyService {
|
||||
}
|
||||
//
|
||||
// @Value
|
||||
//
|
||||
import { Value } from 'angular-es';
|
||||
|
||||
@Value('MyValue')
|
||||
class MyValue {
|
||||
}
|
||||
Vendored
+187
@@ -0,0 +1,187 @@
|
||||
// Type definitions for angular-es v0.0.3
|
||||
// Project: https://github.com/mbutsykin/angular-es
|
||||
// Definitions by: mbutsykin <https://github.com/mbutsykin/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'angular-es' {
|
||||
|
||||
interface ClassDecorator {
|
||||
<TFunction extends Function>(target: TFunction): TFunction|void;
|
||||
}
|
||||
|
||||
interface MethodDecorator {
|
||||
<T>(target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>|void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorated target
|
||||
*/
|
||||
interface ngESDecorator extends ClassDecorator, MethodDecorator {
|
||||
(target: Object|Function,
|
||||
ngName?: string,
|
||||
ngArguments?: Array<any>,
|
||||
ngType?: string,
|
||||
injectAsProperty?: Array<string>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component interface
|
||||
* @see https://docs.angularjs.org/guide/component
|
||||
*/
|
||||
interface iComponent {
|
||||
template: string,
|
||||
selector: string,
|
||||
controllerAs?: string,
|
||||
require?: string,
|
||||
templateUrl?: string,
|
||||
transclude?: string,
|
||||
bindings?: Object
|
||||
}
|
||||
|
||||
/**
|
||||
* Register component
|
||||
*
|
||||
* @param {Object<iComponent>} component - component config
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Component(component: iComponent): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register config block
|
||||
*/
|
||||
function Config(): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register constant
|
||||
*
|
||||
* @param {string} name - constant name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Constant(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register controller
|
||||
*
|
||||
* @param {string} name - controller name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Controller(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register decorator
|
||||
*
|
||||
* @param {string} name - provider name to decorate
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Decorator(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register directive
|
||||
*
|
||||
* @param {string} name - directive selector, can be in hyphen-case
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Directive(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register factory
|
||||
*
|
||||
* @param {string} name - factory name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Factory(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register filter
|
||||
*
|
||||
* @param {string} name - filter name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Filter(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Add $inject property to target
|
||||
*
|
||||
* @param {Array<string>} dependencies - dependencies to inject
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Inject(...dependencies: Array<string>): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Inject dependencies as properties to target
|
||||
*
|
||||
* @param {Array<string>} dependencies - dependencies to inject
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function InjectAsProperty(...dependencies: Array<string>): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Attach target to the specified module
|
||||
*
|
||||
* @param {string} name - module name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Module(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register provider
|
||||
*
|
||||
* @param {string} name - provider name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Provider(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register run block
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Run(): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register service
|
||||
*
|
||||
* @param {string} name - service name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Service(name: string): ngESDecorator;
|
||||
|
||||
/**
|
||||
* Register value
|
||||
*
|
||||
* @param {string} name - value name
|
||||
*
|
||||
* @returns {ngESDecorator} - decorated class
|
||||
*/
|
||||
function Value(name: string): ngESDecorator;
|
||||
|
||||
export {
|
||||
Component,
|
||||
Config,
|
||||
Constant,
|
||||
Controller,
|
||||
Decorator,
|
||||
Directive,
|
||||
Factory,
|
||||
Filter,
|
||||
Inject,
|
||||
InjectAsProperty,
|
||||
Module,
|
||||
Provider,
|
||||
Run,
|
||||
Service,
|
||||
Value,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference path="angular-feature-flags.d.ts" />
|
||||
|
||||
let myApp = angular.module('myApp', ['feature-flags']);
|
||||
|
||||
const flagsData: Array<angular.featureflags.FlagData> = [
|
||||
{
|
||||
key: '1',
|
||||
active: true,
|
||||
name: 'flag1',
|
||||
description: 'This is the first flag'
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
active: false,
|
||||
name: 'flag2',
|
||||
description: 'This is the second flag'
|
||||
}
|
||||
];
|
||||
|
||||
myApp.config(function (featureFlagsProvider: angular.featureflags.FeatureFlagsProvider) {
|
||||
featureFlagsProvider.setInitialFlags(flagsData);
|
||||
});
|
||||
|
||||
myApp.run(function ($q: angular.IQService, $http: angular.IHttpService, featureFlags: angular.featureflags.FeatureFlagsService) {
|
||||
let deferred = $q.defer();
|
||||
deferred.resolve(flagsData);
|
||||
|
||||
featureFlags.set(deferred.promise);
|
||||
|
||||
featureFlags.set($http.get('/data/flags.json'));
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
// Type definitions for angular-feature-flags 1.4.0
|
||||
// Project: https://github.com/mjt01/angular-feature-flags
|
||||
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare namespace angular.featureflags {
|
||||
export interface FlagData {
|
||||
/**
|
||||
* Unique key that is used from the markup to resolve whether a flag is active or not.
|
||||
*/
|
||||
key: string;
|
||||
|
||||
/**
|
||||
* Boolean value for enabling/disabling the feature
|
||||
*/
|
||||
active: boolean;
|
||||
|
||||
/**
|
||||
* A short name of the flag (only visible in the list of flags)
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A long description of the flag to further explain the feature being toggled (only visible in the list of flags)
|
||||
*/
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface FeatureFlagsProvider {
|
||||
setInitialFlags(flags: Array<FlagData>): void;
|
||||
}
|
||||
|
||||
export interface FeatureFlagsService {
|
||||
set(flagsPromise: angular.IPromise<FlagData> | angular.IHttpPromise<FlagData>): void;
|
||||
}
|
||||
}
|
||||
Vendored
+3
-3
@@ -51,12 +51,12 @@ declare namespace angular.gettext {
|
||||
/** Get the correct pluralized (but untranslated) string for the value of n. */
|
||||
getStringForm(string: string, n: number): string;
|
||||
|
||||
/** Translate a string with the given context. Uses Angular.JS interpolation, so something like this will do what you expect:
|
||||
/** Translate a string with the given scope. Uses Angular.JS interpolation, so something like this will do what you expect:
|
||||
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
|
||||
* // var hello will be "Hallo Ruben!" in Dutch.
|
||||
* The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
* The scope parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
*/
|
||||
getString(string: string, context?: any): string;
|
||||
getString(string: string, scope?: any, context?: string): string;
|
||||
|
||||
/** Translate a plural string with the given context. */
|
||||
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
|
||||
|
||||
@@ -15,3 +15,18 @@ var $jwtInterceptor: ng.jwt.IJwtInterceptor;
|
||||
$jwtInterceptor.tokenGetter = () => {
|
||||
return expToken;
|
||||
}
|
||||
|
||||
|
||||
var authManager: ng.jwt.IAuthManagerServiceProvider;
|
||||
|
||||
// Indicate the user is authenticated
|
||||
authManager.authenticate();
|
||||
|
||||
// Indicate the user is unauthenticated
|
||||
authManager.unauthenticate();
|
||||
|
||||
// Keep the user authenticated
|
||||
authManager.checkAuthOnRefresh();
|
||||
|
||||
// Redirect the user on unauthorized requests
|
||||
authManager.redirectWhenUnauthenticated();
|
||||
Vendored
+7
@@ -27,4 +27,11 @@ declare namespace angular.jwt {
|
||||
interface IJwtInterceptor {
|
||||
tokenGetter(...params : any[]): string;
|
||||
}
|
||||
|
||||
interface IAuthManagerServiceProvider {
|
||||
authenticate(): void;
|
||||
unauthenticate(): void;
|
||||
checkAuthOnRefresh(): void;
|
||||
redirectWhenUnauthenticated(): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,11 @@ myApp.config((
|
||||
myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService) => {
|
||||
$scope['openBottomSheet'] = () => {
|
||||
$mdBottomSheet.show({
|
||||
template: '<md-bottom-sheet>Hello!</md-bottom-sheet>'
|
||||
template: '<md-bottom-sheet>Hello!</md-bottom-sheet>',
|
||||
clickOutsideToClose: true,
|
||||
disableBackdrop: true,
|
||||
disableParentScroll: false,
|
||||
parent: () => {}
|
||||
});
|
||||
};
|
||||
$scope['hideBottomSheet'] = $mdBottomSheet.hide.bind($mdBottomSheet, 'hide');
|
||||
@@ -115,15 +119,41 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia
|
||||
$scope['close'] = () => $mdSidenav(componentId).close();
|
||||
$scope['isOpen'] = $mdSidenav(componentId).isOpen();
|
||||
$scope['isLockedOpen'] = $mdSidenav(componentId).isLockedOpen();
|
||||
|
||||
$scope['asyncLookup'] = $mdSidenav(componentId, true).then((instance) => {
|
||||
instance.toggle();
|
||||
instance.open();
|
||||
instance.close();
|
||||
instance.isOpen();
|
||||
instance.isLockedOpen();
|
||||
});
|
||||
|
||||
$scope['onClose'] = $mdSidenav(componentId).onClose(() => {});
|
||||
});
|
||||
|
||||
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => {
|
||||
$scope['openToast'] = () => $mdToast.show($mdToast.simple().textContent('Hello!'));
|
||||
$scope['openToast'] = () => {
|
||||
$mdToast.show($mdToast.simple().textContent('Hello!'));
|
||||
$mdToast.updateTextContent('New Content');
|
||||
}
|
||||
|
||||
$scope['customToast'] = () => {
|
||||
var options = {
|
||||
hideDelay: 3000,
|
||||
position: 'top right',
|
||||
controller : 'ToastCtrl',
|
||||
templateUrl : 'toast-template.html',
|
||||
toastClass: 'my-class'
|
||||
};
|
||||
|
||||
$mdToast.show(options);
|
||||
}
|
||||
});
|
||||
|
||||
myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService) => {
|
||||
$scope['createPanel'] = () => {
|
||||
var config = {
|
||||
id: 'myPanel',
|
||||
template: '<h1>Hello!</h1>',
|
||||
hasBackdrop: true,
|
||||
disableParentScroll: true,
|
||||
|
||||
+44
-15
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular Material 1.0.0-rc5+ (angular.material module)
|
||||
// Type definitions for Angular Material 1.1.0-rc5+ (angular.material module)
|
||||
// Project: https://github.com/angular/material
|
||||
// Definitions by: Alex Staroselsky <https://github.com/AlStar01>, Blake Bigelow <https://github.com/blbigelow>, Peter Hajdu <https://github.com/PeterHajdu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -19,11 +19,12 @@ declare namespace angular.material {
|
||||
preserveScope?: boolean; // default: false
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
targetEvent?: MouseEvent;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
clickOutsideToClose?: boolean;
|
||||
disableBackdrop?: boolean;
|
||||
escapeToClose?: boolean;
|
||||
resolve?: {[index: string]: () => angular.IPromise<any>};
|
||||
controllerAs?: string;
|
||||
bindToController?: boolean;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
parent?: Function|string|Object; // default: root node
|
||||
disableParentScroll?: boolean; // default: true
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ declare namespace angular.material {
|
||||
controller(controller?: string|Function): T;
|
||||
locals(locals?: {[index: string]: any}): T;
|
||||
bindToController(bindToController?: boolean): T; // default: false
|
||||
resolve(resolve?: {[index: string]: angular.IPromise<any>}): T;
|
||||
resolve(resolve?: {[index: string]: () => angular.IPromise<any>}): T;
|
||||
controllerAs(controllerAs?: string): T;
|
||||
parent(parent?: string|Element|JQuery): T; // default: root node
|
||||
onComplete(onComplete?: Function): T;
|
||||
@@ -90,7 +91,7 @@ declare namespace angular.material {
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
resolve?: {[index: string]: () => angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
onShowing?: Function;
|
||||
@@ -131,9 +132,11 @@ declare namespace angular.material {
|
||||
close(): angular.IPromise<void>;
|
||||
isOpen(): boolean;
|
||||
isLockedOpen(): boolean;
|
||||
onClose(onClose: Function): void;
|
||||
}
|
||||
|
||||
interface ISidenavService {
|
||||
(component: string, enableWait: boolean): angular.IPromise<ISidenavObject>;
|
||||
(component: string): ISidenavObject;
|
||||
}
|
||||
|
||||
@@ -160,10 +163,11 @@ declare namespace angular.material {
|
||||
preserveScope?: boolean; // default: false
|
||||
hideDelay?: number; // default (ms): 3000
|
||||
position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left'
|
||||
toastClass?: string;
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
resolve?: {[index: string]: () => angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
}
|
||||
@@ -173,7 +177,8 @@ declare namespace angular.material {
|
||||
showSimple(content: string): angular.IPromise<any>;
|
||||
simple(): ISimpleToastPreset;
|
||||
build(): IToastPreset<any>;
|
||||
updateContent(): void;
|
||||
updateContent(newContent: string): void;
|
||||
updateTextContent(newContent: string): void
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
@@ -245,6 +250,7 @@ declare namespace angular.material {
|
||||
extendPalette(name: string, palette: IPalette): IPalette;
|
||||
setDefaultTheme(theme: string): void;
|
||||
alwaysWatchTheme(alwaysWatch: boolean): void;
|
||||
setNonce(nonce: string): void;
|
||||
}
|
||||
|
||||
interface IDateLocaleProvider {
|
||||
@@ -288,14 +294,16 @@ declare namespace angular.material {
|
||||
}
|
||||
|
||||
interface IPanelConfig {
|
||||
id?: string;
|
||||
template?: string;
|
||||
templateUrl?: string;
|
||||
controller?: string|Function;
|
||||
controllerAs?: string;
|
||||
bindToController?: boolean; // default: true
|
||||
locals?: {[index: string]: any};
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
resolve?: {[index: string]: () => angular.IPromise<any>}
|
||||
attachTo?: string|JQuery|Element;
|
||||
propagateContainerEvents?: boolean;
|
||||
panelClass?: string;
|
||||
zIndex?: number; // default: 80
|
||||
position?: IPanelPosition;
|
||||
@@ -328,16 +336,18 @@ declare namespace angular.material {
|
||||
addClass(newClass: string): void;
|
||||
removeClass(oldClass: string): void;
|
||||
toggleClass(toggleClass: string): void;
|
||||
focusOnOpen(): void;
|
||||
updatePosition(position: IPanelPosition): void;
|
||||
}
|
||||
|
||||
interface IPanelPosition {
|
||||
absolute(): IPanelPosition;
|
||||
relativeTo(someElement: string|JQuery|Element): IPanelPosition;
|
||||
top(opt_top: string): IPanelPosition; // default: '0'
|
||||
bottom(opt_bottom: string): IPanelPosition; // default: '0'
|
||||
left(opt_left: string): IPanelPosition; // default: '0'
|
||||
right(opt_right: string): IPanelPosition; // default: '0'
|
||||
top(top?: string): IPanelPosition; // default: '0'
|
||||
bottom(bottom?: string): IPanelPosition; // default: '0'
|
||||
start(start?: string): IPanelPosition; // default: '0'
|
||||
end(end?: string): IPanelPosition; // default: '0'
|
||||
left(left?: string): IPanelPosition; // default: '0'
|
||||
right(right?: string): IPanelPosition; // default: '0'
|
||||
centerHorizontally(): IPanelPosition;
|
||||
centerVertically(): IPanelPosition;
|
||||
center(): IPanelPosition;
|
||||
@@ -357,5 +367,24 @@ declare namespace angular.material {
|
||||
open(opt_config: IPanelConfig): angular.IPromise<IPanelRef>;
|
||||
newPanelPosition(): IPanelPosition;
|
||||
newPanelAnimation(): IPanelAnimation;
|
||||
xPosition: {
|
||||
CENTER: string,
|
||||
ALIGN_START: string,
|
||||
ALIGN_END: string,
|
||||
OFFSET_START: string,
|
||||
OFFSET_END: string,
|
||||
};
|
||||
yPosition: {
|
||||
CENTER: string,
|
||||
ALIGN_TOPS: string,
|
||||
ALIGN_BOTTOMS: string,
|
||||
ABOVE: string,
|
||||
BELOW: string,
|
||||
};
|
||||
animation: {
|
||||
SLIDE: string,
|
||||
SCALE: string,
|
||||
FADE: string,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/// <reference path="./angular-permission.d.ts" />
|
||||
|
||||
import permission = angular.permission;
|
||||
import permissionNamespace = angular.permission;
|
||||
import { permission, ngPermission, uiPermission } from "angular-permission";
|
||||
|
||||
angular
|
||||
.module('fooModule', ['permission', 'user'])
|
||||
.run(function (PermissionStore: permission.PermissionStore, User: any) {
|
||||
.module('fooModule', [permission, ngPermission, uiPermission, 'user'])
|
||||
.run(function (PermissionStore: permissionNamespace.PermissionStore, User: any) {
|
||||
// Define anonymous permission
|
||||
PermissionStore
|
||||
.definePermission('anonymous', function (stateParams) {
|
||||
@@ -22,8 +23,8 @@ angular
|
||||
hasPermissionDefinition(permission: string) : angular.IPromise<any>;
|
||||
}
|
||||
|
||||
angular.module('barModule', ['permission', 'user'])
|
||||
.run(function (PermissionStore: permission.PermissionStore, User: BackendUserService, $q: angular.IQService) {
|
||||
angular.module('barModule', [permission, 'user'])
|
||||
.run(function (PermissionStore: permissionNamespace.PermissionStore, User: BackendUserService, $q: angular.IQService) {
|
||||
PermissionStore
|
||||
// Define user permission calling back-end
|
||||
.definePermission('user', function (stateParams) {
|
||||
@@ -64,14 +65,14 @@ angular
|
||||
|
||||
PermissionStore.removePermissionDefinition('user');
|
||||
|
||||
let permissions: Array<permission.Permission> = PermissionStore.getStore();
|
||||
let permissions: Array<permissionNamespace.Permission> = PermissionStore.getStore();
|
||||
|
||||
|
||||
});
|
||||
|
||||
angular
|
||||
.module('fooModule', ['permission', 'user'])
|
||||
.run(function (RoleStore: permission.RoleStore, User: any) {
|
||||
.module('fooModule', [permission, 'user'])
|
||||
.run(function (RoleStore: permissionNamespace.RoleStore, User: any) {
|
||||
RoleStore
|
||||
// Permission array validated role
|
||||
// Library will internally validate if 'user' and 'editor' permissions are valid when checking if role is valid
|
||||
@@ -88,5 +89,5 @@ angular
|
||||
|
||||
RoleStore.removeRoleDefinition('user');
|
||||
|
||||
let roles: Array<permission.Role> = RoleStore.getStore();
|
||||
let roles: Array<permissionNamespace.Role> = RoleStore.getStore();
|
||||
});
|
||||
|
||||
+6
@@ -173,3 +173,9 @@ declare namespace angular.permission {
|
||||
options?: angular.ui.IStateOptions;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "angular-permission" {
|
||||
export var permission: string;
|
||||
export var ngPermission: string;
|
||||
export var uiPermission: string;
|
||||
}
|
||||
|
||||
+3
-2
@@ -13,7 +13,7 @@ declare module "angular-translate" {
|
||||
declare namespace angular.translate {
|
||||
|
||||
interface ITranslationTable {
|
||||
[key: string]: any;
|
||||
[key: string]: string | ITranslationTable;
|
||||
}
|
||||
|
||||
interface ILanguageKeyAlias {
|
||||
@@ -95,8 +95,9 @@ declare namespace angular.translate {
|
||||
use(key: string): ITranslateProvider;
|
||||
storageKey(): string;
|
||||
storageKey(key: string): void; // JeroMiya - the library should probably return ITranslateProvider but it doesn't here
|
||||
uniformLanguageTag(options: string | Object): ITranslateProvider;
|
||||
useUrlLoader(url: string): ITranslateProvider;
|
||||
useStaticFilesLoader(options: IStaticFilesLoaderOptions): ITranslateProvider;
|
||||
useStaticFilesLoader(options: IStaticFilesLoaderOptions | { files: IStaticFilesLoaderOptions[] }): ITranslateProvider;
|
||||
useLoader(loaderFactory: string, options?: any): ITranslateProvider;
|
||||
useLocalStorage(): ITranslateProvider;
|
||||
useCookieStorage(): ITranslateProvider;
|
||||
|
||||
+11
@@ -400,6 +400,17 @@ declare namespace angular.ui.bootstrap {
|
||||
* @default 'body'
|
||||
*/
|
||||
appendTo?: angular.IAugmentedJQuery;
|
||||
|
||||
/**
|
||||
* A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have `restrict: 'E'` and a template or templateUrl set.
|
||||
*
|
||||
* It supports these bindings:
|
||||
* - `close` - A method that can be used to close a modal, passing a result. The result must be passed in this format: `{$value: myResult}`
|
||||
* - `dismiss` - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: `{$value: myRejectedResult}`
|
||||
* - `modalInstance` - The modal instance. This is the same `$uibModalInstance` injectable found when using `controller`.
|
||||
* - `resolve` - An object of the modal resolve values. See [UI Router resolves] for details.
|
||||
*/
|
||||
component?: string;
|
||||
}
|
||||
|
||||
interface IModalStackService {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/// <reference path="angular-ui-notification.d.ts" />
|
||||
|
||||
function TestNotifications(NotificationProvider: angular.uiNotification.INotificationProvider, Notification: angular.uiNotification.INotificationService) {
|
||||
NotificationProvider.setOptions({
|
||||
delay: 10000,
|
||||
startTop: 20,
|
||||
startRight: 10,
|
||||
verticalSpacing: 20,
|
||||
horizontalSpacing: 20,
|
||||
positionX: 'left',
|
||||
positionY: 'bottom'
|
||||
});
|
||||
|
||||
Notification.primary('Primary notification');
|
||||
Notification('Primary notification');
|
||||
|
||||
Notification.success('Success notification');
|
||||
|
||||
Notification({message: 'Warning notification'}, 'warning');
|
||||
|
||||
Notification({message: 'Primary notification', title: 'Primary notification'});
|
||||
|
||||
Notification.error({message: 'Error notification 1s', delay: 1000});
|
||||
|
||||
Notification.success({message: 'Success notification<br>Some other <b>content</b><br><a href="https://github.com/alexcrack/angular-ui-notification">This is a link</a><br><img src="https://angularjs.org/img/AngularJS-small.png">', title: 'Html content'});
|
||||
|
||||
Notification.error({message: 'Error Bottom Right', positionY: 'bottom', positionX: 'right'});
|
||||
|
||||
Notification.error({message: 'Error notification 1s', replaceMessage: true});
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// Type definitions for angular-ui-notification
|
||||
// Project: https://github.com/alexcrack/angular-ui-notification
|
||||
// Definitions by: Kamil Rojewski <https://github.com/krojew/DefinitelyTyped>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace angular.uiNotification {
|
||||
// Taken from angular to avoid dependency
|
||||
interface IPromise<T> {
|
||||
/**
|
||||
* Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
|
||||
* The successCallBack may return IPromise<void> for when a $q.reject() needs to be returned
|
||||
* This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
|
||||
*/
|
||||
then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
|
||||
|
||||
/**
|
||||
* Shorthand for promise.then(null, errorCallback)
|
||||
*/
|
||||
catch<TResult>(onRejected: (reason: any) => IPromise<TResult>|TResult): IPromise<TResult>;
|
||||
|
||||
/**
|
||||
* Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information.
|
||||
*
|
||||
* Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
|
||||
*/
|
||||
finally(finallyCallback: () => any): IPromise<T>;
|
||||
}
|
||||
|
||||
type XPosition = 'right'|'left'|'center';
|
||||
type YPosition = 'top'|'bottom';
|
||||
|
||||
type MessageType = 'primary'|'info'|'success'|'warning'|'error';
|
||||
|
||||
interface IGlobalMessageOptions {
|
||||
delay?: number;
|
||||
startTop?: number;
|
||||
startRight?: number;
|
||||
verticalSpacing?: number;
|
||||
horizontalSpacing?: number;
|
||||
positionX?: XPosition;
|
||||
positionY?: YPosition;
|
||||
replaceMessage?: boolean;
|
||||
templateUrl?: string;
|
||||
onClose?: (element: any) => any;
|
||||
closeOnClick?: boolean;
|
||||
maxCount?: number;
|
||||
}
|
||||
|
||||
interface IMessageOptions {
|
||||
title?: string;
|
||||
message?: string;
|
||||
templateUrl?: string;
|
||||
delay?: number;
|
||||
type?: MessageType;
|
||||
positionX?: XPosition;
|
||||
positionY?: YPosition;
|
||||
replaceMessage?: boolean;
|
||||
closeOnClick?: boolean;
|
||||
}
|
||||
|
||||
interface INotificationScope {
|
||||
kill(isHard: boolean): void;
|
||||
}
|
||||
|
||||
interface INotificationProvider {
|
||||
setOptions(options: IGlobalMessageOptions): void;
|
||||
}
|
||||
|
||||
type Message = string|IMessageOptions;
|
||||
|
||||
interface INotificationService {
|
||||
primary(message: Message): IPromise<INotificationScope>;
|
||||
info(message: Message): IPromise<INotificationScope>;
|
||||
success(message: Message): IPromise<INotificationScope>;
|
||||
warning(message: Message): IPromise<INotificationScope>;
|
||||
error(message: Message): IPromise<INotificationScope>;
|
||||
|
||||
clearAll(): void;
|
||||
|
||||
(message: Message, type?: MessageType): IPromise<INotificationScope>;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="angular-ui-router.d.ts" />
|
||||
|
||||
var myApp = angular.module('testModule');
|
||||
import uiRouterModule from "angular-ui-router";
|
||||
var myApp = angular.module("testModule", [uiRouterModule]);
|
||||
|
||||
interface MyAppScope extends ng.IScope {
|
||||
items: string[];
|
||||
@@ -141,7 +142,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
private $state: ng.ui.IStateService
|
||||
) {
|
||||
$rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event));
|
||||
$rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) =>
|
||||
$rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) =>
|
||||
this.onStateNotFound(event, unfoundState, fromState, fromParams));
|
||||
}
|
||||
|
||||
@@ -164,14 +165,14 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private onStateNotFound(event: ng.IAngularEvent,
|
||||
unfoundState: ng.ui.IUnfoundState,
|
||||
fromState: ng.ui.IState,
|
||||
fromParams: {}) {
|
||||
var unfoundTo: string = unfoundState.to;
|
||||
var unfoundToParams: {} = unfoundState.toParams;
|
||||
var unfoundOptions: ng.ui.IStateOptions = unfoundState.options
|
||||
var unfoundOptions: ng.ui.IStateOptions = unfoundState.options
|
||||
}
|
||||
|
||||
private stateServiceTest() {
|
||||
|
||||
+2
-8
@@ -7,13 +7,7 @@
|
||||
|
||||
// Support for AMD require and CommonJS
|
||||
declare module 'angular-ui-router' {
|
||||
// Since angular-ui-router adds providers for a bunch of
|
||||
// injectable dependencies, it doesn't really return any
|
||||
// actual data except the plain string 'ui.router'.
|
||||
//
|
||||
// As such, I don't think anybody will ever use the actual
|
||||
// default value of the module. So I've only included the
|
||||
// the types. (@xogeny)
|
||||
export default "ui.router";
|
||||
export type IState = angular.ui.IState;
|
||||
export type IStateProvider = angular.ui.IStateProvider;
|
||||
export type IUrlMatcher = angular.ui.IUrlMatcher;
|
||||
@@ -109,7 +103,7 @@ declare namespace angular.ui {
|
||||
toParams: {},
|
||||
options: IStateOptions
|
||||
}
|
||||
|
||||
|
||||
interface IStateProvider extends angular.IServiceProvider {
|
||||
state(name:string, config:IState): IStateProvider;
|
||||
state(config:IState): IStateProvider;
|
||||
|
||||
+3
-2
@@ -42,9 +42,10 @@ declare namespace angular.ui {
|
||||
*/
|
||||
topVisibleScope: ng.IRepeatScope;
|
||||
/**
|
||||
* calling this method reinitializes and reloads the scroller content.
|
||||
* calling this method reinitializes and reloads the scroller content.
|
||||
* @param startIndex is an integer indicating what item index the scroller will use to start the load process.
|
||||
*/
|
||||
reload(): void;
|
||||
reload(startIndex?: number): void;
|
||||
/**
|
||||
* Replaces the item in the buffer at the given index with the new items.
|
||||
*
|
||||
|
||||
+1
-1
@@ -476,7 +476,7 @@ declare namespace angular {
|
||||
// Supplement IComponentOptions from angular.d.ts with router-specific
|
||||
// fields.
|
||||
interface IComponentOptions {
|
||||
$canActivate?: () => boolean;
|
||||
$canActivate?: (...args: any[]) => boolean | angular.IPromise<boolean>;
|
||||
$routeConfig?: RouteDefinition[];
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+14
-3
@@ -42,15 +42,20 @@ declare namespace angular.resource {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
actions?: IActionHash, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): U;
|
||||
actions?: IActionHash, options?: IResourceOptions): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<T>;
|
||||
actions?: IActionHash, options?: IResourceOptions): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Hash of action descriptors allows custom action names
|
||||
interface IActionHash {
|
||||
[action: string]: IActionDescriptor
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
@@ -186,6 +191,12 @@ declare namespace angular {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction<any>): IModule;
|
||||
}
|
||||
|
||||
namespace auto {
|
||||
interface IInjectorService {
|
||||
get(name: '$resource'): ng.resource.IResourceService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Array<T>
|
||||
|
||||
@@ -867,6 +867,26 @@ angular.module('docsTabsExample', [])
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('multiSlotTranscludeExample', [])
|
||||
.directive('dropDownMenu', function() {
|
||||
return {
|
||||
transclude: {
|
||||
button: 'button',
|
||||
list: 'ul',
|
||||
},
|
||||
link: function(scope, element, attrs, ctrl, transclude) {
|
||||
// without scope
|
||||
transclude().appendTo(element);
|
||||
transclude(clone => clone.appendTo(element));
|
||||
|
||||
// with scope
|
||||
transclude(scope, clone => clone.appendTo(element));
|
||||
transclude(scope, clone => clone.appendTo(element), element, 'button');
|
||||
transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('componentExample', [])
|
||||
.component('counter', {
|
||||
require: {'ctrl': '^ctrl'},
|
||||
@@ -1098,6 +1118,12 @@ function parseTyping() {
|
||||
}
|
||||
}
|
||||
|
||||
function parseWithParams() {
|
||||
var $parse: angular.IParseService;
|
||||
var compiledExp = $parse('a.b.c', () => null);
|
||||
var compiledExp = $parse('a.b.c', null, false);
|
||||
}
|
||||
|
||||
function doBootstrap(element: Element | JQuery, mode: string): ng.auto.IInjectorService {
|
||||
if (mode === 'debug') {
|
||||
return angular.bootstrap(element, ['main', function($provide: ng.auto.IProvideService) {
|
||||
|
||||
Vendored
+49
-16
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.5
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Georgii Dolzhykov <http://github.com/thorn0>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -118,14 +118,15 @@ declare namespace angular {
|
||||
fromJson(json: string): any;
|
||||
identity<T>(arg?: T): T;
|
||||
injector(modules?: any[], strictDi?: boolean): auto.IInjectorService;
|
||||
isArray(value: any): boolean;
|
||||
isDate(value: any): boolean;
|
||||
isArray(value: any): value is Array<any>;
|
||||
isDate(value: any): value is Date;
|
||||
isDefined(value: any): boolean;
|
||||
isElement(value: any): boolean;
|
||||
isFunction(value: any): boolean;
|
||||
isNumber(value: any): boolean;
|
||||
isObject(value: any): boolean;
|
||||
isString(value: any): boolean;
|
||||
isFunction(value: any): value is Function;
|
||||
isNumber(value: any): value is number;
|
||||
isObject(value: any): value is Object;
|
||||
isObject<T>(value: any): value is T;
|
||||
isString(value: any): value is string;
|
||||
isUndefined(value: any): boolean;
|
||||
lowercase(str: string): string;
|
||||
|
||||
@@ -387,6 +388,7 @@ declare namespace angular {
|
||||
$invalid: boolean;
|
||||
$submitted: boolean;
|
||||
$error: any;
|
||||
$name: string;
|
||||
$pending: any;
|
||||
$addControl(control: INgModelController | IFormController): void;
|
||||
$removeControl(control: INgModelController | IFormController): void;
|
||||
@@ -873,7 +875,7 @@ declare namespace angular {
|
||||
// see http://docs.angularjs.org/api/ng.$parseProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IParseService {
|
||||
(expression: string): ICompiledExpression;
|
||||
(expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression;
|
||||
}
|
||||
|
||||
interface IParseProvider {
|
||||
@@ -985,7 +987,10 @@ declare namespace angular {
|
||||
// DocumentService
|
||||
// see http://docs.angularjs.org/api/ng.$document
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IDocumentService extends JQuery {}
|
||||
interface IDocumentService extends JQuery {
|
||||
// Must return intersection type for index signature compatibility with JQuery
|
||||
[index: number]: HTMLElement & Document;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
@@ -1254,7 +1259,7 @@ declare namespace angular {
|
||||
// This corresponds to $transclude (and also the transclude function passed to link).
|
||||
interface ITranscludeFunction {
|
||||
// If the scope is provided, then the cloneAttachFn must be as well.
|
||||
(scope: IScope, cloneAttachFn: ICloneAttachFunction): JQuery;
|
||||
(scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
|
||||
// If one argument is provided, then it's assumed to be the cloneAttachFn.
|
||||
(cloneAttachFn?: ICloneAttachFunction): JQuery;
|
||||
}
|
||||
@@ -1407,6 +1412,16 @@ declare namespace angular {
|
||||
* Absolute or relative URL of the resource that is being requested.
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* Event listeners to be bound to the XMLHttpRequest object.
|
||||
* To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
|
||||
*/
|
||||
eventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
|
||||
/**
|
||||
* Event listeners to be bound to the XMLHttpRequest upload object.
|
||||
* To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
|
||||
*/
|
||||
uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
|
||||
}
|
||||
|
||||
interface IHttpHeadersGetter {
|
||||
@@ -1710,14 +1725,24 @@ declare namespace angular {
|
||||
* Define DOM attribute binding to component properties. Component properties are always bound to the component
|
||||
* controller and not to the scope.
|
||||
*/
|
||||
bindings?: {[binding: string]: string};
|
||||
bindings?: IComponentBindings;
|
||||
/**
|
||||
* Whether transclusion is enabled. Enabled by default.
|
||||
*/
|
||||
transclude?: boolean | string | {[slot: string]: string};
|
||||
/**
|
||||
* Requires the controllers of other directives and binds them to this component's controller.
|
||||
* The object keys specify the property names under which the required controllers (object values) will be bound.
|
||||
* Note that the required controllers will not be available during the instantiation of the controller,
|
||||
* but they are guaranteed to be available just before the $onInit method is executed!
|
||||
*/
|
||||
require?: {[controller: string]: string};
|
||||
}
|
||||
|
||||
interface IComponentBindings {
|
||||
[binding: string]: string;
|
||||
}
|
||||
|
||||
interface IComponentTemplateFn {
|
||||
( $element?: JQuery, $attrs?: IAttributes ): string;
|
||||
}
|
||||
@@ -1735,12 +1760,12 @@ declare namespace angular {
|
||||
*/
|
||||
$onInit?(): void;
|
||||
/**
|
||||
* Called whenever one-way bindings are updated. The changesObj is a hash whose keys are the names of the bound
|
||||
* properties that have changed, and the values are an {@link IChangesObject} object of the form
|
||||
* Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
|
||||
* properties that have changed, and the values are an {@link IChangesObject} object of the form
|
||||
* { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
|
||||
* cloning the bound value to prevent accidental mutation of the outer value.
|
||||
*/
|
||||
$onChanges?(changesObj: {[property:string]: IChangesObject}): void;
|
||||
$onChanges?(onChangesObj: IOnChangesObject): void;
|
||||
/**
|
||||
* Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
|
||||
* watches and event handlers.
|
||||
@@ -1756,6 +1781,10 @@ declare namespace angular {
|
||||
*/
|
||||
$postLink?(): void;
|
||||
}
|
||||
|
||||
interface IOnChangesObject {
|
||||
[property: string]: IChangesObject;
|
||||
}
|
||||
|
||||
interface IChangesObject {
|
||||
currentValue: any;
|
||||
@@ -1802,6 +1831,10 @@ declare namespace angular {
|
||||
): void | IDirectivePrePost;
|
||||
}
|
||||
|
||||
interface IDirectiveScope {
|
||||
[property: string]: string;
|
||||
}
|
||||
|
||||
interface IDirective {
|
||||
compile?: IDirectiveCompileFn;
|
||||
controller?: any;
|
||||
@@ -1815,7 +1848,7 @@ declare namespace angular {
|
||||
bindToController?: boolean | Object;
|
||||
link?: IDirectiveLinkFn | IDirectivePrePost;
|
||||
multiElement?: boolean;
|
||||
name?: string;
|
||||
directiveName?: string;
|
||||
priority?: number;
|
||||
/**
|
||||
* @deprecated
|
||||
@@ -1823,7 +1856,7 @@ declare namespace angular {
|
||||
replace?: boolean;
|
||||
require?: string | string[] | {[controller: string]: string};
|
||||
restrict?: string;
|
||||
scope?: boolean | Object;
|
||||
scope?: boolean | IDirectiveScope;
|
||||
template?: string | Function;
|
||||
templateNamespace?: string;
|
||||
templateUrl?: string | Function;
|
||||
|
||||
Vendored
+1
-1
@@ -886,7 +886,7 @@ declare namespace angular {
|
||||
// see http://docs.angularjs.org/api/ng.$parseProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IParseService {
|
||||
(expression: string): ICompiledExpression;
|
||||
(expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression;
|
||||
}
|
||||
|
||||
interface IParseProvider {
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Gorgi Kosev <https://github.com/spion>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="../anydb-sql/anydb-sql.d.ts" />
|
||||
|
||||
declare module "anydb-sql-migrations" {
|
||||
@@ -31,4 +31,4 @@ declare module "anydb-sql-migrations" {
|
||||
items: MigrationTask[];
|
||||
}) => any) => Promise<any>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="./aphrodite.d.ts" />
|
||||
|
||||
import * as React from "react";
|
||||
import { StyleSheet, css, StyleSheetServer, StyleSheetTestUtils } from "aphrodite";
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
red: {
|
||||
backgroundColor: 'red'
|
||||
},
|
||||
blue: {
|
||||
backgroundColor: 'blue'
|
||||
},
|
||||
hover: {
|
||||
':hover': {
|
||||
backgroundColor: 'red'
|
||||
}
|
||||
},
|
||||
small: {
|
||||
'@media (max-width: 600px)': {
|
||||
backgroundColor: 'red',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const coolFont = {
|
||||
fontFamily: "CoolFont",
|
||||
fontStyle: "normal",
|
||||
fontWeight: "normal",
|
||||
src: "url('coolfont.woff2') format('woff2')"
|
||||
};
|
||||
|
||||
const withFont = StyleSheet.create({
|
||||
headingText: {
|
||||
fontFamily: coolFont,
|
||||
fontSize: 20
|
||||
},
|
||||
bodyText: {
|
||||
fontFamily: [coolFont, "sans-serif"],
|
||||
fontSize: 12
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
class App extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return <div>
|
||||
<span className={css(styles.red)}>
|
||||
This is red.
|
||||
</span>
|
||||
<span className={css(styles.hover)}>
|
||||
This turns red on hover.
|
||||
</span>
|
||||
<span className={css(styles.small)}>
|
||||
This turns red when the browser is less than 600px width.
|
||||
</span>
|
||||
<span className={css(styles.red, styles.blue)}>
|
||||
This is blue.
|
||||
</span>
|
||||
<span className={css(styles.blue, styles.small)}>
|
||||
This is blue and turns red when the browser is less than
|
||||
600px width.
|
||||
</span>
|
||||
<span className={css(withFont.bodyText)}>
|
||||
With font
|
||||
</span>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const output = StyleSheetServer.renderStatic(() => {
|
||||
return "test";
|
||||
});
|
||||
|
||||
output.css.content;
|
||||
output.css.renderedClassNames;
|
||||
output.html;
|
||||
|
||||
StyleSheet.rehydrate(output.css.renderedClassNames);
|
||||
|
||||
StyleSheetTestUtils.suppressStyleInjection();
|
||||
StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
|
||||
Vendored
+76
@@ -0,0 +1,76 @@
|
||||
// Type definitions for Aphrodite 0.5.0
|
||||
// Project: https://github.com/Khan/aphrodite
|
||||
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "aphrodite" {
|
||||
import * as React from "react";
|
||||
|
||||
/**
|
||||
* Aphrodite style declaration
|
||||
*/
|
||||
export interface StyleDeclaration {
|
||||
[key: string]: React.CSSProperties;
|
||||
}
|
||||
|
||||
interface StyleSheetStatic {
|
||||
/**
|
||||
* Create style sheet
|
||||
*/
|
||||
create<T extends StyleDeclaration>(styles: T): T;
|
||||
/**
|
||||
* Rehydrate class names from server renderer
|
||||
*/
|
||||
rehydrate(renderedClassNames: string[]): void;
|
||||
}
|
||||
|
||||
export var StyleSheet: StyleSheetStatic;
|
||||
/**
|
||||
* Get class names from passed styles
|
||||
*/
|
||||
export function css(...styles: any[]): string;
|
||||
|
||||
interface StaticRendererResult {
|
||||
html: string;
|
||||
css: {
|
||||
content: string;
|
||||
renderedClassNames: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilities for using Aphrodite server-side.
|
||||
*/
|
||||
interface StyleSheetServerStatic {
|
||||
renderStatic(renderFunc: () => string): StaticRendererResult;
|
||||
}
|
||||
|
||||
export var StyleSheetServer: StyleSheetServerStatic;
|
||||
|
||||
interface StyleSheetTestUtilsStatic {
|
||||
/**
|
||||
* Prevent styles from being injected into the DOM.
|
||||
*
|
||||
* This is useful in situations where you'd like to test rendering UI
|
||||
* components which use Aphrodite without any of the side-effects of
|
||||
* Aphrodite happening. Particularly useful for testing the output of
|
||||
* components when you have no DOM, e.g. testing in Node without a fake DOM.
|
||||
*
|
||||
* Should be paired with a subsequent call to
|
||||
* clearBufferAndResumeStyleInjection.
|
||||
*/
|
||||
suppressStyleInjection(): void;
|
||||
/**
|
||||
* Opposite method of preventStyleInject.
|
||||
*/
|
||||
clearBufferAndResumeStyleInjection(): void;
|
||||
}
|
||||
|
||||
export var StyleSheetTestUtils: StyleSheetTestUtilsStatic;
|
||||
}
|
||||
|
||||
declare module "aphrodite/no-important" {
|
||||
export * from "aphrodite";
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="app-root-path.d.ts" />
|
||||
import * as root from 'app-root-path';
|
||||
|
||||
let resolvedPath: string;
|
||||
resolvedPath = root.resolve('../dir');
|
||||
resolvedPath = root.path;
|
||||
resolvedPath = root.toString();
|
||||
let resolvedModule: any = root.require('app-root-path');
|
||||
root.setPath('C:\\app-root');
|
||||
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// Type definitions for app-root-path 1.2.1
|
||||
// Project: https://github.com/inxilpro/node-app-root-path
|
||||
// Definitions by: Shant Marouti <https://github.com/shantmarouti>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'app-root-path' {
|
||||
interface RootPath {
|
||||
|
||||
/**
|
||||
* Application root directory absolute path
|
||||
* @type {string}
|
||||
*/
|
||||
path: string;
|
||||
|
||||
/**
|
||||
* Resolves relative path from root to absolute path
|
||||
* @param {string} pathToModule
|
||||
* @returns {string}
|
||||
*/
|
||||
resolve(pathToModule: string): string;
|
||||
|
||||
/**
|
||||
* Resolve module by relative addressing from root
|
||||
* @param {string} pathToModule
|
||||
* @returns {*}
|
||||
*/
|
||||
require(pathToModule: string): any;
|
||||
|
||||
/**
|
||||
* Explicitly set root path
|
||||
* @param {string} explicitlySetPath
|
||||
*/
|
||||
setPath(explicitlySetPath: string): void;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
var RootPath: RootPath;
|
||||
export = RootPath;
|
||||
}
|
||||
+7
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for ApplicationInsights-JS v0.22.14
|
||||
// Type definitions for ApplicationInsights-JS v0.23.2
|
||||
// Project: https://github.com/Microsoft/ApplicationInsights-JS
|
||||
// Definitions by: Kamil Szostak <https://github.com/kamilszostak>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -788,3 +788,9 @@ declare module Microsoft.ApplicationInsights {
|
||||
_onerror(message: string, url: string, lineNumber: number, columnNumber: number, error: Error): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'applicationinsights-js' {
|
||||
export let AppInsights: Microsoft.ApplicationInsights.IAppInsights;
|
||||
}
|
||||
|
||||
declare var appInsights: Microsoft.ApplicationInsights.IAppInsights;
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="../request/request.d.ts" />
|
||||
|
||||
declare module "asana" {
|
||||
|
||||
@@ -392,13 +392,6 @@ function (results) {
|
||||
]);
|
||||
});
|
||||
|
||||
var sys;
|
||||
var iterator = async.iterator([
|
||||
function () { sys.p('one'); },
|
||||
function () { sys.p('two'); },
|
||||
function () { sys.p('three'); }
|
||||
]);
|
||||
|
||||
async.parallel([
|
||||
async.apply(fs.writeFile, 'testfile1', 'test1'),
|
||||
async.apply(fs.writeFile, 'testfile2', 'test2'),
|
||||
|
||||
Vendored
+46
-6
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Async 1.4.2
|
||||
// Type definitions for Async 2.0.1
|
||||
// Project: https://github.com/caolan/async
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -37,6 +37,13 @@ interface AsyncQueue<T> {
|
||||
pause(): void
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
workersList(): {
|
||||
data: T,
|
||||
callback: Function
|
||||
}[];
|
||||
error(error: Error, data: any): void;
|
||||
unsaturated(): void;
|
||||
buffer: number;
|
||||
}
|
||||
|
||||
interface AsyncPriorityQueue<T> {
|
||||
@@ -54,6 +61,14 @@ interface AsyncPriorityQueue<T> {
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
workersList(): {
|
||||
data: T,
|
||||
priority: number,
|
||||
callback: Function
|
||||
}[];
|
||||
error(error: Error, data: any): void;
|
||||
unsaturated(): void;
|
||||
buffer: number;
|
||||
}
|
||||
|
||||
interface AsyncCargo {
|
||||
@@ -85,6 +100,9 @@ interface Async {
|
||||
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
mapValuesLimit<T, R>(obj: {[name: string]: T}, limit: number, iteratee: (value: string, key: T, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
|
||||
mapValues<T, R>(obj: {[name: string]: T}, iteratee: (value: string, key: T, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
|
||||
mapValuesSeries: typeof async.mapValues;
|
||||
filter<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
|
||||
select<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
|
||||
filterSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
|
||||
@@ -100,11 +118,17 @@ interface Async {
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
|
||||
find: typeof async.detect;
|
||||
detectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
|
||||
findSeries: typeof async.detectSeries;
|
||||
detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
|
||||
findLimit: typeof async.detectLimit;
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): any;
|
||||
some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
anyLimit: typeof async.someLimit;
|
||||
someSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
anySeries: typeof async.someSeries;
|
||||
any<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
|
||||
everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
|
||||
@@ -134,18 +158,35 @@ interface Async {
|
||||
queue<T>(worker: AsyncWorker<T>, concurrency?: number): AsyncQueue<T>;
|
||||
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo;
|
||||
auto(tasks: any, callback?: (error: Error, results: any) => void): void;
|
||||
auto(tasks: any, concurrency?: number, callback?: (error: Error, results: any) => void): void;
|
||||
autoInject(tasks: any, callback?: (error: Error, results: any) => void): void;
|
||||
retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: (error: Error, results: any) => void): void;
|
||||
retry<T>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: (error: Error, results: any) => void): void;
|
||||
iterator(tasks: Function[]): Function;
|
||||
retryable<T>(opts: number | {times: number, interval: number}, task: AsyncFunction<T>): AsyncFunction<T>;
|
||||
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
|
||||
nextTick(callback: Function): void;
|
||||
setImmediate(callback: Function): void;
|
||||
nextTick(callback: Function, ...args: any[]): void;
|
||||
setImmediate: typeof async.nextTick;
|
||||
|
||||
allLimit<T>(arr: T[], limit: number, iteratee: AsyncBooleanIterator<T>, cb?: (result: boolean) => any) : any;
|
||||
everySeries<T>(arr: T[], iteratee: AsyncBooleanIterator<T>, cb?: (result: boolean) => any) : any
|
||||
allSeries: typeof async.everySeries;
|
||||
|
||||
reflect<T>(fn: AsyncFunction<T>) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void;
|
||||
reflectAll<T>(tasks: AsyncFunction<T>[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[];
|
||||
|
||||
timeout<T>(fn: AsyncFunction<T>, milliseconds: number, info: any): AsyncFunction<T>;
|
||||
|
||||
times<T> (n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
timesSeries<T>(n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
timesLimit<T>(n: number, limit: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
|
||||
transform<T, R>(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void;
|
||||
transform<T, R>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void;
|
||||
transform<T, R>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void;
|
||||
transform<T, R>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void;
|
||||
|
||||
race<T>(tasks: (AsyncFunction<T>)[], callback: AsyncResultCallback<T>) : void;
|
||||
|
||||
// Utils
|
||||
memoize(fn: Function, hasher?: Function): Function;
|
||||
unmemoize(fn: Function): Function;
|
||||
@@ -155,7 +196,6 @@ interface Async {
|
||||
wrapSync(fn: Function): Function;
|
||||
log(fn: Function, ...arguments: any[]): void;
|
||||
dir(fn: Function, ...arguments: any[]): void;
|
||||
noConflict(): Async;
|
||||
}
|
||||
|
||||
declare var async: Async;
|
||||
|
||||
Vendored
+6
@@ -946,9 +946,14 @@ declare namespace AtomCore {
|
||||
registry: any;
|
||||
repository: Object;
|
||||
scopeName: string;
|
||||
tokenizeLines: (text: string) => any;
|
||||
// TBD
|
||||
|
||||
}
|
||||
|
||||
interface IGrammars {
|
||||
grammarForScopeName(scope: string): IGrammar;
|
||||
}
|
||||
|
||||
interface IPane /* extends Theorist.Model */ {
|
||||
itemForURI: (uri:string)=>IEditor;
|
||||
@@ -1302,6 +1307,7 @@ declare namespace AtomCore {
|
||||
deserializers:IDeserializerManager;
|
||||
config: IConfig;
|
||||
commands: ICommandRegistry;
|
||||
grammars: IGrammars;
|
||||
keymaps: IKeymapManager;
|
||||
keymap: IKeymapManager;
|
||||
packages: IPackageManager;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="auth0-js.d.ts" />
|
||||
|
||||
var auth0 = new Auth0({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
});
|
||||
|
||||
auth0.login({
|
||||
connection: 'google-oauth2',
|
||||
popup: true,
|
||||
popupOptions: {
|
||||
width: 450,
|
||||
height: 800
|
||||
}
|
||||
}, (err, profile, idToken, accessToken, state) => {
|
||||
if (err) {
|
||||
alert("something went wrong: " + err.message);
|
||||
return;
|
||||
}
|
||||
alert('hello ' + profile.name);
|
||||
});
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: https://github.com/auth0/auth0.js
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** Extensions to the browser Window object. */
|
||||
interface Window {
|
||||
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
|
||||
token: string;
|
||||
}
|
||||
|
||||
/** This is the interface for the main Auth0 client. */
|
||||
interface Auth0Static {
|
||||
|
||||
new(options: Auth0ClientOptions): Auth0Static;
|
||||
changePassword(options: any, callback?: Function): void;
|
||||
decodeJwt(jwt: string): any;
|
||||
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
|
||||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
logout(query: string): void;
|
||||
getConnections(callback?: Function): void;
|
||||
refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
|
||||
getSSOData(withActiveDirectories: any, callback?: Function): void;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
signup(options: Auth0SignupOptions, callback: Function): void;
|
||||
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
|
||||
}
|
||||
|
||||
/** Represents constructor options for the Auth0 client. */
|
||||
interface Auth0ClientOptions {
|
||||
clientID: string;
|
||||
callbackURL: string;
|
||||
callbackOnLocationHash?: boolean;
|
||||
domain: string;
|
||||
forceJSONP?: boolean;
|
||||
}
|
||||
|
||||
/** Represents a normalized UserProfile. */
|
||||
interface Auth0UserProfile {
|
||||
email: string;
|
||||
email_verified: boolean;
|
||||
family_name: string;
|
||||
gender: string;
|
||||
given_name: string;
|
||||
locale: string;
|
||||
name: string;
|
||||
nickname: string;
|
||||
picture: string;
|
||||
user_id: string;
|
||||
/** Represents one or more Identities that may be associated with the User. */
|
||||
identities: Auth0Identity[];
|
||||
user_metadata?: any;
|
||||
app_metadata?: any;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
|
||||
interface MicrosoftUserProfile extends Auth0UserProfile {
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
|
||||
interface Office365UserProfile extends Auth0UserProfile {
|
||||
tenantid: string;
|
||||
upn: string;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
|
||||
interface AdfsUserProfile extends Auth0UserProfile {
|
||||
issuer: string;
|
||||
}
|
||||
|
||||
/** Represents multiple identities assigned to a user. */
|
||||
interface Auth0Identity {
|
||||
access_token: string;
|
||||
connection: string;
|
||||
isSocial: boolean;
|
||||
provider: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Auth0DecodedHash {
|
||||
access_token: string;
|
||||
id_token: string;
|
||||
profile: Auth0UserProfile;
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Auth0PopupOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface Auth0LoginOptions {
|
||||
auto_login?: boolean;
|
||||
connection?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0PopupOptions;
|
||||
}
|
||||
|
||||
interface Auth0SignupOptions extends Auth0LoginOptions {
|
||||
auto_login: boolean;
|
||||
}
|
||||
|
||||
interface Auth0Error {
|
||||
code: any;
|
||||
details: any;
|
||||
name: string;
|
||||
message: string;
|
||||
status: any;
|
||||
}
|
||||
|
||||
/** Represents the response from an API Token Delegation request. */
|
||||
interface Auth0DelegationToken {
|
||||
/** The length of time in seconds the token is valid for. */
|
||||
expires_in: string;
|
||||
/** The JWT for delegated access. */
|
||||
id_token: string;
|
||||
/** The type of token being returned. Possible values: "Bearer" */
|
||||
token_type: string;
|
||||
}
|
||||
|
||||
declare var Auth0: Auth0Static;
|
||||
|
||||
declare module "auth0-js" {
|
||||
export = Auth0
|
||||
}
|
||||
@@ -1,13 +1,165 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
/// <reference path="auth0.lock.d.ts" />
|
||||
|
||||
var lock: Auth0LockStatic = new Auth0Lock("dsa7d77dsa7d7", "mine.auth0.com");
|
||||
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
|
||||
const DOMAIN = "YOUR_DOMAIN_AT.auth0.com";
|
||||
|
||||
lock.showSignin({
|
||||
connections: ["facebook", "google-oauth2", "twitter", "Username-Password-Authentication"],
|
||||
icon: "https://contoso.com/logo-32.png",
|
||||
socialBigButtons: true
|
||||
},
|
||||
() => {
|
||||
// The Auth0 Widget is now loaded.
|
||||
var lock: Auth0LockStatic = new Auth0Lock(CLIENT_ID, DOMAIN);
|
||||
|
||||
lock.show();
|
||||
lock.hide();
|
||||
lock.logout(() => {});
|
||||
|
||||
// The examples below are lifted from auth0-lock documentation on Github
|
||||
|
||||
// "on" event-driven example
|
||||
|
||||
lock.on("authenticated", function(authResult : any) {
|
||||
lock.getProfile(authResult.idToken, function(error, profile) {
|
||||
if (error) {
|
||||
// Handle error
|
||||
return;
|
||||
}
|
||||
|
||||
localStorage.setItem("idToken", authResult.idToken);
|
||||
localStorage.setItem("profile", JSON.stringify(profile));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// test theme
|
||||
|
||||
var themeOptions : Auth0LockConstructorOptions = {
|
||||
theme: {
|
||||
logo: "https://example.com/assets/logo.png",
|
||||
primaryColor: "green"
|
||||
}
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions);
|
||||
|
||||
// test authentication
|
||||
|
||||
var authOptions : Auth0LockConstructorOptions = {
|
||||
auth: {
|
||||
params: { state: "foo" },
|
||||
redirect: true,
|
||||
redirectUrl: "some url",
|
||||
responseType: "token",
|
||||
sso: true
|
||||
}
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, authOptions);
|
||||
|
||||
// test multi-variant example
|
||||
|
||||
var multiVariantOptions : Auth0LockConstructorOptions = {
|
||||
container: "myContainer",
|
||||
closable: false,
|
||||
languageDictionary: {
|
||||
signUpTerms: "I agree to the <a href='/terms' target='_new'>terms of service</a> ...",
|
||||
title: "My Company",
|
||||
},
|
||||
autofocus: false
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, multiVariantOptions);
|
||||
|
||||
// test text-field additional sign up field
|
||||
|
||||
var textFieldOptions : Auth0LockConstructorOptions = {
|
||||
additionalSignUpFields: [{
|
||||
name: "address",
|
||||
placeholder: "enter your address",
|
||||
// The following properties are optional
|
||||
icon: "https://example.com/assests/address_icon.png",
|
||||
prefill: "street 123",
|
||||
validator: function(input : string) {
|
||||
return {
|
||||
valid: input.length >= 10,
|
||||
hint: "Must have 10 or more chars" // optional
|
||||
};
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, textFieldOptions);
|
||||
|
||||
// test select-field additional sign up field
|
||||
|
||||
var selectFieldOptions : Auth0LockConstructorOptions = {
|
||||
additionalSignUpFields: [{
|
||||
type: "select",
|
||||
name: "location",
|
||||
placeholder: "choose your location",
|
||||
options: [
|
||||
{value: "us", label: "United States"},
|
||||
{value: "fr", label: "France"},
|
||||
{value: "ar", label: "Argentina"}
|
||||
],
|
||||
// The following properties are optional
|
||||
icon: "https://example.com/assests/location_icon.png",
|
||||
prefill: "us"
|
||||
}]
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptions);
|
||||
|
||||
// test select-field additional sign up field with callbacks for
|
||||
|
||||
var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = {
|
||||
additionalSignUpFields: [{
|
||||
type: "select",
|
||||
name: "location",
|
||||
placeholder: "choose your location",
|
||||
options: function(cb) {
|
||||
// obtain options, in case of error you call cb with the error in the
|
||||
// first arg instead of null
|
||||
|
||||
let options = [
|
||||
{value: "us", label: "United States"},
|
||||
{value: "fr", label: "France"},
|
||||
{value: "ar", label: "Argentina"}
|
||||
];
|
||||
|
||||
cb(null, options);
|
||||
},
|
||||
icon: "https://example.com/assests/location_icon.png",
|
||||
prefill: function(cb) {
|
||||
// obtain prefill, in case of error you call cb with the error in the
|
||||
// first arg instead of null
|
||||
|
||||
let prefill = "us";
|
||||
|
||||
cb(null, prefill);
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptionsWithCallbacks);
|
||||
|
||||
// test Avatar options
|
||||
|
||||
var avatarOptions : Auth0LockConstructorOptions = {
|
||||
avatar: {
|
||||
url: (email : string, cb : Auth0LockAvatarUrlCallback) => {
|
||||
// obtain url for email, in case of error you call cb with the error in
|
||||
// the first arg instead of null
|
||||
|
||||
let url = "url";
|
||||
|
||||
cb(null, url);
|
||||
},
|
||||
displayName: (email : string, cb : Auth0LockAvatarDisplayNameCallback) => {
|
||||
// obtain displayName for email, in case of error you call cb with the
|
||||
// error in the first arg instead of null
|
||||
|
||||
let displayName = "displayName";
|
||||
|
||||
cb(null, displayName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new Auth0Lock(CLIENT_ID, DOMAIN, avatarOptions);
|
||||
|
||||
Vendored
+99
-56
@@ -1,9 +1,69 @@
|
||||
// Type definitions for Auth0Widget.js
|
||||
// Type definitions for auth0-lock v10.0.1
|
||||
// Project: http://auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions by: Brian Caruso <https://github.com/carusology>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
|
||||
interface Auth0LockAdditionalSignUpFieldOption {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
type Auth0LockAdditionalSignUpFieldOptionsCallback =
|
||||
(error: Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void;
|
||||
|
||||
type Auth0LockAdditionalSignUpFieldOptionsFunction =
|
||||
(callback: Auth0LockAdditionalSignUpFieldOptionsCallback) => void;
|
||||
|
||||
type Auth0LockAdditionalSignUpFieldPrefillCallback =
|
||||
(error: Auth0Error, prefill: string) => void;
|
||||
|
||||
type Auth0LockAdditionalSignUpFieldPrefillFunction =
|
||||
(callback: Auth0LockAdditionalSignUpFieldPrefillCallback) => void;
|
||||
|
||||
interface Auth0LockAdditionalSignUpField {
|
||||
icon?: string;
|
||||
name: string;
|
||||
options?: Auth0LockAdditionalSignUpFieldOption[] | Auth0LockAdditionalSignUpFieldOptionsFunction;
|
||||
placeholder: string;
|
||||
prefill?: string | Auth0LockAdditionalSignUpFieldPrefillFunction;
|
||||
type?: "select" | "text";
|
||||
validator?: (input: string) => { valid: boolean; hint?: string };
|
||||
}
|
||||
|
||||
type Auth0LockAvatarUrlCallback = (error: Auth0Error, url: string) => void;
|
||||
type Auth0LockAvatarDisplayNameCallback = (error: Auth0Error, displayName: string) => void;
|
||||
|
||||
interface Auth0LockAvatarOptions {
|
||||
url: (email: string, callback: Auth0LockAvatarUrlCallback) => void;
|
||||
displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void;
|
||||
}
|
||||
|
||||
interface Auth0LockThemeOptions {
|
||||
logo?: string;
|
||||
primaryColor?: string;
|
||||
}
|
||||
|
||||
// https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters
|
||||
interface Auth0LockAuthParamsOptions {
|
||||
access_token?: any;
|
||||
connection_scopes?: any;
|
||||
device?: any;
|
||||
nonce?: any;
|
||||
protocol?: any;
|
||||
request_id?: any;
|
||||
scope?: string;
|
||||
state?: string;
|
||||
}
|
||||
|
||||
interface Auth0LockAuthOptions {
|
||||
params?: Auth0LockAuthParamsOptions;
|
||||
redirect?: boolean;
|
||||
redirectUrl?: string;
|
||||
responseType?: string;
|
||||
sso?: boolean;
|
||||
}
|
||||
|
||||
interface Auth0LockPopupOptions {
|
||||
width: number;
|
||||
@@ -12,68 +72,51 @@ interface Auth0LockPopupOptions {
|
||||
top: number;
|
||||
}
|
||||
|
||||
interface Auth0LockOptions {
|
||||
authParams?: any;
|
||||
callbackURL?: string;
|
||||
connections?: string[];
|
||||
container?: string;
|
||||
closable?: boolean;
|
||||
dict?: any;
|
||||
defaultUserPasswordConnection?: string;
|
||||
defaultADUsernameFromEmailPrefix?: boolean;
|
||||
disableResetAction?: boolean;
|
||||
disableSignupAction?: boolean;
|
||||
focusInput?: boolean;
|
||||
forceJSONP?: boolean;
|
||||
gravatar?: boolean;
|
||||
integratedWindowsLogin?: boolean;
|
||||
icon?: string;
|
||||
loginAfterSignup?: boolean;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0LockPopupOptions;
|
||||
rememberLastLogin?: boolean;
|
||||
resetLink?: string;
|
||||
responseType?: string;
|
||||
signupLink?: string;
|
||||
socialBigButtons?: boolean;
|
||||
sso?: boolean;
|
||||
theme?: string;
|
||||
usernameStyle?: any;
|
||||
}
|
||||
|
||||
interface Auth0LockConstructorOptions {
|
||||
cdn?: string;
|
||||
additionalSignUpFields?: Auth0LockAdditionalSignUpField[];
|
||||
allowedConnections?: string[];
|
||||
allowForgotPassword?: boolean;
|
||||
allowLogin?: boolean;
|
||||
allowSignUp?: boolean;
|
||||
assetsUrl?: string;
|
||||
useCordovaSocialPlugins?: boolean;
|
||||
auth?: Auth0LockAuthOptions;
|
||||
autoclose?: boolean;
|
||||
autofocus?: boolean;
|
||||
avatar?: Auth0LockAvatarOptions;
|
||||
closable?: boolean;
|
||||
container?: string;
|
||||
defaultADUsernameFromEmailPrefix?: string;
|
||||
defaultDatabaseConnection?: string;
|
||||
defaultEnterpriseConnection?: string;
|
||||
forgotPasswordLink?: string;
|
||||
initialScreen?: "login" | "signUp" | "forgotPassword";
|
||||
language?: string;
|
||||
languageDictionary?: any;
|
||||
loginAfterSignUp?: boolean;
|
||||
mustAcceptTerms?: boolean;
|
||||
popupOptions?: Auth0LockPopupOptions;
|
||||
prefill?: { email?: string, username?: string};
|
||||
rememberLastLogin?: boolean;
|
||||
signupLink?: string;
|
||||
socialButtonStyle?: "big" | "small";
|
||||
theme?: Auth0LockThemeOptions;
|
||||
usernameStyle?: string;
|
||||
}
|
||||
|
||||
interface Auth0LockStatic {
|
||||
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;
|
||||
getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void;
|
||||
|
||||
show(): void;
|
||||
show(options: Auth0LockOptions): void;
|
||||
show(callback: (error?: Auth0Error, profile?: Auth0UserProfile, token?: string) => void) : void;
|
||||
show(options: Auth0LockOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, token?: string) => void) : void;
|
||||
hide(): void;
|
||||
logout(query: any): void;
|
||||
|
||||
showSignin(): void;
|
||||
showSignin(options: Auth0LockOptions): void;
|
||||
showSignin(callback: (error?: Auth0Error, profile?: Auth0UserProfile, token?: string) => void) : void;
|
||||
showSignin(options: Auth0LockOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, token?: string) => void) : void;
|
||||
|
||||
showSignup(): void;
|
||||
showSignup(options: Auth0LockOptions): void;
|
||||
showSignup(callback: (error?: Auth0Error) => void) : void;
|
||||
showSignup(options: Auth0LockOptions, callback: (error?: Auth0Error) => void) : void;
|
||||
|
||||
showReset(): void;
|
||||
showReset(options: Auth0LockOptions): void;
|
||||
showReset(callback: (error?: Auth0Error) => void) : void;
|
||||
showReset(options: Auth0LockOptions, callback: (error?: Auth0Error) => void) : void;
|
||||
|
||||
hide(callback: () => void): void;
|
||||
logout(callback: () => void): void;
|
||||
|
||||
getClient(): Auth0Static;
|
||||
on(event: "show", callback: () => void) : void;
|
||||
on(event: "hide", callback: () => void) : void;
|
||||
on(event: "unrecoverable_error", callback: (error: Auth0Error) => void) : void;
|
||||
on(event: "authorization_error", callback: (error: Auth0Error) => void) : void;
|
||||
on(event: "authenticated", callback: (authResult: any) => void) : void;
|
||||
on(event: string, callback: (...args: any[]) => void) : void;
|
||||
}
|
||||
|
||||
declare var Auth0Lock: Auth0LockStatic;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
/// <reference path="auth0.widget.d.ts" />
|
||||
|
||||
var widget: Auth0WidgetStatic = new Auth0Widget({
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="../auth0-js/auth0-js.d.ts" />
|
||||
|
||||
|
||||
interface Auth0WidgetStatic {
|
||||
|
||||
+48
-20
@@ -1,23 +1,51 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="auth0.d.ts" />
|
||||
|
||||
var auth0 = new Auth0({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
import * as auth0 from 'auth0';
|
||||
|
||||
const management = new auth0.ManagementClient({
|
||||
token: '{YOUR_API_V2_TOKEN}',
|
||||
domain: '{YOUR_ACCOUNT}.auth0.com'
|
||||
});
|
||||
|
||||
auth0.login({
|
||||
connection: 'google-oauth2',
|
||||
popup: true,
|
||||
popupOptions: {
|
||||
width: 450,
|
||||
height: 800
|
||||
}
|
||||
}, (err, profile, idToken, accessToken, state) => {
|
||||
if (err) {
|
||||
alert("something went wrong: " + err.message);
|
||||
return;
|
||||
}
|
||||
alert('hello ' + profile.name);
|
||||
});
|
||||
const auth = new auth0.AuthenticationClient({
|
||||
domain: '{YOUR_ACCOUNT}.auth0.com',
|
||||
clientId: '{OPTIONAL_CLIENT_ID}'
|
||||
});
|
||||
|
||||
// Using a callback.
|
||||
management.getUsers((err: Error, users: auth0.User[]) => {
|
||||
if (err) {
|
||||
// Handle error.
|
||||
}
|
||||
console.log(users);
|
||||
});
|
||||
|
||||
// Using a Promise.
|
||||
management
|
||||
.getUsers()
|
||||
.then((users) => {
|
||||
console.log(users);
|
||||
})
|
||||
.catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
management
|
||||
.createUser({
|
||||
connection: 'My-Connection',
|
||||
email: 'hi@me.co',
|
||||
}).then((user) => {
|
||||
console.log(user);
|
||||
}).catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
auth
|
||||
.requestChangePasswordEmail({
|
||||
connection: 'My-Connection',
|
||||
email: 'hi@me.co',
|
||||
}).then((response) => {
|
||||
console.log(response);
|
||||
}).catch((err) => {
|
||||
// Handle the error.
|
||||
});
|
||||
|
||||
Vendored
+81
-117
@@ -1,131 +1,95 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: http://auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Type definitions for auth0 v2.3.1
|
||||
// Project: https://github.com/auth0/node-auth0
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/** Extensions to the browser Window object. */
|
||||
interface Window {
|
||||
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
|
||||
declare module "auth0" {
|
||||
|
||||
import * as Promise from 'bluebird';
|
||||
|
||||
export interface ManagementClientOptions {
|
||||
token: string;
|
||||
}
|
||||
domain?: string;
|
||||
}
|
||||
|
||||
/** This is the interface for the main Auth0 client. */
|
||||
interface Auth0Static {
|
||||
|
||||
new(options: Auth0ClientOptions): Auth0Static;
|
||||
changePassword(options: any, callback?: Function): void;
|
||||
decodeJwt(jwt: string): any;
|
||||
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
|
||||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
logout(query: string): void;
|
||||
getConnections(callback?: Function): void;
|
||||
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
|
||||
getSSOData(withActiveDirectories: any, callback?: Function): void;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
signup(options: Auth0SignupOptions, callback: Function): void;
|
||||
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
|
||||
}
|
||||
|
||||
/** Represents constructor options for the Auth0 client. */
|
||||
interface Auth0ClientOptions {
|
||||
clientID: string;
|
||||
callbackURL: string;
|
||||
callbackOnLocationHash?: boolean;
|
||||
domain: string;
|
||||
forceJSONP?: boolean;
|
||||
}
|
||||
|
||||
/** Represents a normalized UserProfile. */
|
||||
interface Auth0UserProfile {
|
||||
email: string;
|
||||
family_name: string;
|
||||
gender: string;
|
||||
given_name: string;
|
||||
locale: string;
|
||||
name: string;
|
||||
nickname: string;
|
||||
picture: string;
|
||||
user_id: string;
|
||||
/** Represents one or more Identities that may be associated with the User. */
|
||||
identities: Auth0Identity[];
|
||||
user_metadata?: any;
|
||||
app_metadata?: any;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
|
||||
interface MicrosoftUserProfile extends Auth0UserProfile {
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
|
||||
interface Office365UserProfile extends Auth0UserProfile {
|
||||
tenantid: string;
|
||||
upn: string;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
|
||||
interface AdfsUserProfile extends Auth0UserProfile {
|
||||
issuer: string;
|
||||
}
|
||||
|
||||
/** Represents multiple identities assigned to a user. */
|
||||
interface Auth0Identity {
|
||||
access_token: string;
|
||||
export interface UserData {
|
||||
connection: string;
|
||||
isSocial: boolean;
|
||||
provider: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Auth0DecodedHash {
|
||||
access_token: string;
|
||||
id_token: string;
|
||||
profile: Auth0UserProfile;
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Auth0PopupOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface Auth0LoginOptions {
|
||||
auto_login?: boolean;
|
||||
connection?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0PopupOptions;
|
||||
}
|
||||
phone_number?: string;
|
||||
user_metadata?: {};
|
||||
email_verified?: boolean;
|
||||
app_metadata?: {};
|
||||
}
|
||||
|
||||
interface Auth0SignupOptions extends Auth0LoginOptions {
|
||||
auto_login: boolean;
|
||||
}
|
||||
export interface GetUsersData {
|
||||
per_page?: number;
|
||||
page?: number;
|
||||
include_totals?: boolean;
|
||||
sort?: string;
|
||||
connection?: string;
|
||||
fields?: string;
|
||||
include_fields?: boolean;
|
||||
q?: string;
|
||||
search_engine?: string;
|
||||
}
|
||||
|
||||
interface Auth0Error {
|
||||
code: any;
|
||||
details: any;
|
||||
name: string;
|
||||
message: string;
|
||||
status: any;
|
||||
}
|
||||
export interface User {
|
||||
email?: string;
|
||||
email_verified?: boolean;
|
||||
username?: string;
|
||||
phone_number?: string;
|
||||
phone_verified?: boolean;
|
||||
user_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
identities?: Identity[];
|
||||
app_metadata?: {};
|
||||
user_metadata?: {};
|
||||
picture?: string;
|
||||
name?: string;
|
||||
nickname?: string;
|
||||
multifactor?: string[];
|
||||
last_ip?: string;
|
||||
last_login?: string;
|
||||
logins_count?: number;
|
||||
blocked?: boolean;
|
||||
}
|
||||
|
||||
/** Represents the response from an API Token Delegation request. */
|
||||
interface Auth0DelegationToken {
|
||||
/** The length of time in seconds the token is valid for. */
|
||||
expires_in: string;
|
||||
/** The JWT for delegated access. */
|
||||
id_token: string;
|
||||
/** The type of token being returned. Possible values: "Bearer" */
|
||||
token_type: string;
|
||||
}
|
||||
export interface Identity {
|
||||
connection: string;
|
||||
user_id: string;
|
||||
provider: string;
|
||||
isSocial: boolean;
|
||||
}
|
||||
|
||||
declare var Auth0: Auth0Static;
|
||||
export class ManagementClient {
|
||||
constructor(options: ManagementClientOptions);
|
||||
|
||||
getUsers(params?: GetUsersData): Promise<User[]>;
|
||||
getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
|
||||
createUser(data: UserData): Promise<User>;
|
||||
createUser(data: UserData, cb: (err: Error, data: User) => void): void;
|
||||
}
|
||||
|
||||
export interface AuthenticationClientOptions {
|
||||
clientId?: string;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
export interface RequestChangePasswordEmailData {
|
||||
connection: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export class AuthenticationClient {
|
||||
constructor(options: AuthenticationClientOptions);
|
||||
|
||||
requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise<string>;
|
||||
requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void;
|
||||
}
|
||||
|
||||
declare module "auth0" {
|
||||
export = Auth0
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -45,7 +45,7 @@ declare namespace autobahn {
|
||||
|
||||
interface IInvocation {
|
||||
caller?: number;
|
||||
progress?: boolean;
|
||||
progress?: (args : any[], kwargs : any) => void;
|
||||
procedure: string;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ declare namespace autobahn {
|
||||
}
|
||||
|
||||
interface IPublishOptions {
|
||||
acknowledge?: boolean;
|
||||
exclude?: number[];
|
||||
eligible?: number[];
|
||||
disclose_me?: Boolean;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="autobind-decorator.d.ts" />
|
||||
|
||||
import autobind = require('autobind-decorator');
|
||||
|
||||
class Test {
|
||||
public static what: string = 'static';
|
||||
|
||||
@autobind
|
||||
public static test(): void {
|
||||
console.log(this.what);
|
||||
}
|
||||
|
||||
public constructor(public what: string) {
|
||||
this.what = what;
|
||||
}
|
||||
|
||||
@autobind
|
||||
public test(): void {
|
||||
console.warn(this.what);
|
||||
}
|
||||
}
|
||||
|
||||
const tester: Test = new Test('bind');
|
||||
const { test } = tester;
|
||||
tester.test(); // warns 'bind'.
|
||||
test(); // warns 'bind'.
|
||||
Test.test(); // logs 'static'.
|
||||
|
||||
@autobind
|
||||
class Component {
|
||||
public constructor(private someMember: string) {
|
||||
this.someMember = someMember;
|
||||
}
|
||||
|
||||
public someMethod(): void {
|
||||
console.error(this.someMember);
|
||||
}
|
||||
}
|
||||
|
||||
const component: Component = new Component('React vs Angular2');
|
||||
const { someMethod } = component;
|
||||
component.someMethod(); // errors 'React vs Angular2'
|
||||
someMethod(); // errors 'React vs Angular2'
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Type definitions for autobind-decorator v1.3.3
|
||||
// Project: https://github.com/andreypopp/autobind-decorator
|
||||
// Definitions by: Ivo Stratev <https://github.com/NoHomey/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'autobind-decorator' {
|
||||
function autobind<TFunction extends Function>(target: TFunction): TFunction | void;
|
||||
function autobind<T extends Function>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
||||
export = autobind;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
--experimentalDecorators
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="autosize.d.ts" />
|
||||
|
||||
// from a NodeList
|
||||
autosize(document.querySelectorAll('textarea'));
|
||||
|
||||
// from a single Node
|
||||
autosize(document.querySelector('textarea'));
|
||||
|
||||
// from a single element
|
||||
autosize(document.getElementById('my-textarea'));
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for jquery.autosize 3.0.7
|
||||
// Project: http://www.jacklmoore.com/autosize/
|
||||
// Definitions by: Aaron T. King <https://github.com/kingdango>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace autosize {
|
||||
interface AutosizeStatic {
|
||||
(el: Element): void;
|
||||
(el: NodeList): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var autosize: autosize.AutosizeStatic;
|
||||
|
||||
declare module 'autosize' {
|
||||
export = autosize;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/// <reference path="aws-lambda.d.ts" />
|
||||
|
||||
import lambda = require('aws-lambda');
|
||||
|
||||
var str: string;
|
||||
var date: Date;
|
||||
var anyObj: any;
|
||||
var num: number;
|
||||
var identity: lambda.CognitoIdentity;
|
||||
var error: Error;
|
||||
var b: boolean;
|
||||
var clientCtx: lambda.ClientContext;
|
||||
|
||||
/* Context */
|
||||
var context: lambda.Context;
|
||||
|
||||
b = context.callbackWaitsForEmptyEventLoop;
|
||||
str = context.functionName;
|
||||
str = context.functionVersion;
|
||||
str = context.invokedFunctionArn;
|
||||
num = context.memoryLimitInMB;
|
||||
str = context.awsRequestId;
|
||||
str = context.logGroupName;
|
||||
str = context.logStreamName;
|
||||
identity = context.identity;
|
||||
clientCtx = context.clientContext;
|
||||
|
||||
/* CognitoIdentity */
|
||||
var identity: lambda.CognitoIdentity;
|
||||
|
||||
str = identity.cognitoIdentityId;
|
||||
str = identity.cognitoIdentityPoolId;
|
||||
|
||||
/* Callback */
|
||||
function callback(cb: lambda.Callback) {
|
||||
cb();
|
||||
cb(null);
|
||||
cb(error);
|
||||
cb(null, anyObj);
|
||||
}
|
||||
Vendored
+68
@@ -0,0 +1,68 @@
|
||||
// Type definitions for AWS Lambda
|
||||
// Project: http://docs.aws.amazon.com/lambda
|
||||
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "aws-lambda" {
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
|
||||
interface Context {
|
||||
// Properties
|
||||
callbackWaitsForEmptyEventLoop: boolean;
|
||||
functionName: string;
|
||||
functionVersion: string;
|
||||
invokedFunctionArn: string;
|
||||
memoryLimitInMB: number;
|
||||
awsRequestId: string;
|
||||
logGroupName: string;
|
||||
logStreamName: string;
|
||||
identity?: CognitoIdentity;
|
||||
clientContext?: ClientContext;
|
||||
|
||||
// Functions
|
||||
getRemainingTimeInMillis(): number;
|
||||
|
||||
// Functions for compatibility with earlier Node.js Runtime v0.10.42
|
||||
log(message: string, object: any): void;
|
||||
fail(message: string): void;
|
||||
succeed(message: string): void;
|
||||
succeed(object: any): void;
|
||||
succeed(message: string, object: any): void;
|
||||
}
|
||||
|
||||
interface CognitoIdentity {
|
||||
cognitoIdentityId: string;
|
||||
cognitoIdentityPoolId: string;
|
||||
}
|
||||
|
||||
interface ClientContext {
|
||||
client: ClientContextClient;
|
||||
Custom?: any;
|
||||
env: ClientContextEnv;
|
||||
}
|
||||
|
||||
interface ClientContextClient {
|
||||
installationId: string;
|
||||
appTitle: string;
|
||||
appVersionName: string;
|
||||
appVersionCode: string;
|
||||
appPackageName: string;
|
||||
}
|
||||
|
||||
interface ClientContextEnv {
|
||||
platformVersion: string;
|
||||
platform: string;
|
||||
make: string;
|
||||
model: string;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional callback parameter.
|
||||
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
|
||||
*
|
||||
* @param error – an optional parameter that you can use to provide results of the failed Lambda function execution.
|
||||
* @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
|
||||
*/
|
||||
export type Callback = (error?: Error, result?: any) => void;
|
||||
}
|
||||
Vendored
+2143
-1376
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
/// <reference path="axe-core.d.ts" />
|
||||
|
||||
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()
|
||||
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import queries = require('azure-mobile-apps/src/query');
|
||||
var app = express(),
|
||||
mobileApp = mobileApps();
|
||||
|
||||
// various configuration permutations
|
||||
// various configuration permutations
|
||||
mobileApps({
|
||||
debug: true,
|
||||
data: {
|
||||
@@ -17,7 +17,8 @@ mobileApps({
|
||||
user: '',
|
||||
database: '',
|
||||
password: ''
|
||||
}
|
||||
},
|
||||
webhook: { url: 'http://localhost/' }
|
||||
});
|
||||
|
||||
mobileApps({
|
||||
@@ -29,7 +30,7 @@ mobileApps({
|
||||
// it would be nice to integrate with winston
|
||||
mobileApps({ logging: { level: 'silly', transports: [{}] } })
|
||||
|
||||
// various custom middleware syntaxes
|
||||
// various custom middleware syntaxes
|
||||
mobileApp.use(function (req: any, res: any, next: any) { next(); });
|
||||
mobileApp.use([function () {}, function () {}]);
|
||||
mobileApp.use(function () {}, function () {});
|
||||
@@ -43,6 +44,9 @@ 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) {
|
||||
@@ -61,21 +65,45 @@ table.read(function (context: Azure.MobileApps.Context) {
|
||||
table.insert(function (context: Azure.MobileApps.Context) {
|
||||
context.query.id = 'anotherId';
|
||||
context.query.single = true;
|
||||
context.item.userId = context.user.id;
|
||||
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.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) {})
|
||||
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');
|
||||
@@ -83,5 +111,15 @@ logger.error('Something happened', new Error());
|
||||
mobileApps.logger.debug('a debug message')
|
||||
|
||||
// Query
|
||||
queries.create('table').where({ x: 10 }).select('col1,col2');
|
||||
mobileApps.query.create('table');
|
||||
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 () {} });
|
||||
|
||||
+62
-15
@@ -1,4 +1,4 @@
|
||||
// Type definitions for azure-mobile-apps v2.0.0-beta3
|
||||
// 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
|
||||
@@ -10,6 +10,7 @@ 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;
|
||||
}
|
||||
@@ -31,7 +32,7 @@ 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 {
|
||||
interface MobileApp extends Middleware {
|
||||
configuration: Configuration;
|
||||
tables: Tables;
|
||||
table(): Table;
|
||||
@@ -45,14 +46,7 @@ declare namespace Azure.MobileApps {
|
||||
import(fileOrFolder: string): void;
|
||||
}
|
||||
|
||||
interface Table {
|
||||
authorize?: boolean;
|
||||
autoIncrement?: boolean;
|
||||
dynamicSchema?: boolean;
|
||||
name: string;
|
||||
columns?: any;
|
||||
schema: string;
|
||||
|
||||
interface Table extends TableDefinition {
|
||||
use(...middleware: Middleware[]): Table;
|
||||
use(middleware: Middleware[]): Table;
|
||||
read: TableOperation;
|
||||
@@ -66,6 +60,7 @@ declare namespace Azure.MobileApps {
|
||||
(operationHandler: (context: Context) => void): Table;
|
||||
use(...middleware: Middleware[]): Table;
|
||||
use(middleware: Middleware[]): Table;
|
||||
access?: AccessType;
|
||||
}
|
||||
|
||||
interface Tables {
|
||||
@@ -132,6 +127,7 @@ declare namespace Azure.MobileApps {
|
||||
auth?: Configuration.Auth;
|
||||
cors?: Configuration.Cors;
|
||||
notifications?: Configuration.Notifications;
|
||||
webhook?: Webhook;
|
||||
}
|
||||
|
||||
export module Configuration {
|
||||
@@ -148,6 +144,7 @@ declare namespace Azure.MobileApps {
|
||||
options?: { encrypt: boolean };
|
||||
schema?: string;
|
||||
dynamicSchema?: boolean;
|
||||
filename?: string;
|
||||
}
|
||||
|
||||
interface Auth {
|
||||
@@ -163,8 +160,9 @@ declare namespace Azure.MobileApps {
|
||||
interface LoggingTransport { }
|
||||
|
||||
interface Cors {
|
||||
exposeHeaders: string;
|
||||
maxAge?: number;
|
||||
origins: string[];
|
||||
hostnames: string[];
|
||||
}
|
||||
|
||||
interface Notifications {
|
||||
@@ -184,7 +182,8 @@ declare namespace Azure.MobileApps {
|
||||
}
|
||||
|
||||
interface QueryJs {
|
||||
includeTotalCount?: boolean;
|
||||
includeTotalCount(): QueryJs;
|
||||
includeDeleted(): QueryJs;
|
||||
orderBy(properties: string): QueryJs;
|
||||
orderByDescending(properties: string): QueryJs;
|
||||
select(properties: string): QueryJs;
|
||||
@@ -209,27 +208,75 @@ declare namespace Azure.MobileApps {
|
||||
|
||||
// general
|
||||
var nh: Azure.ServiceBus.NotificationHubService;
|
||||
|
||||
interface Context {
|
||||
query: QueryJs;
|
||||
id: string | number;
|
||||
item: any;
|
||||
req: Express.Request;
|
||||
res: Express.Response;
|
||||
data: (table: TableDefinition) => Data.Table;
|
||||
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;
|
||||
dynamicSchema?: boolean;
|
||||
name?: string;
|
||||
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 {
|
||||
|
||||
@@ -17,7 +17,7 @@ declare namespace Microsoft.WindowsAzure {
|
||||
login(provider: string, token: string): asyncPromise;
|
||||
login(provider: string, callback: (error: any, user: User) => void ): void;
|
||||
login(provider: string): asyncPromise;
|
||||
logout(): void;
|
||||
logout(): asyncPromise;
|
||||
getTable(tableName: string): MobileServiceTable;
|
||||
withFilter(serviceFilter: (request: any, next: (request: any, callback: (error: any, response: any) => void) => void, callback: (error: any, response: any) => void) => void): MobileServiceClient;
|
||||
/**
|
||||
|
||||
Vendored
+26
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Backbone 1.0.0
|
||||
// Type definitions for Backbone 1.3.3
|
||||
// Project: http://backbonejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Natan Vivo <https://github.com/nvivo/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -109,9 +109,15 @@ declare namespace Backbone {
|
||||
|
||||
attributes: any;
|
||||
changed: any[];
|
||||
cidPrefix: string;
|
||||
cid: string;
|
||||
collection: Collection<any>;
|
||||
|
||||
private _changing: boolean;
|
||||
private _previousAttributes : any;
|
||||
private _pending: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Default attributes for the model. It can be an object hash or a method returning an object hash.
|
||||
* For assigning an object hash, do it like this: this.defaults = <any>{ attribute: value, ... };
|
||||
@@ -147,7 +153,14 @@ declare namespace Backbone {
|
||||
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
|
||||
set(obj: any, options?: ModelSetOptions): Model;
|
||||
|
||||
changedAttributes(attributes?: any): any[];
|
||||
/**
|
||||
* Return an object containing all the attributes that have changed, or
|
||||
* false if there are no changed attributes. Useful for determining what
|
||||
* parts of a view need to be updated and/or what attributes need to be
|
||||
* persisted to the server. Unset attributes will be set to undefined.
|
||||
* You can also pass an attributes object to diff against the model,
|
||||
* determining if there *would be* a change. */
|
||||
changedAttributes(attributes?: any): any;
|
||||
clear(options?: Silenceable): any;
|
||||
clone(): Model;
|
||||
destroy(options?: ModelDestroyOptions): any;
|
||||
@@ -178,6 +191,7 @@ declare namespace Backbone {
|
||||
omit(fn: (value: any, key: any, object: any) => any): any;
|
||||
chain(): any;
|
||||
isEmpty(): boolean;
|
||||
matches(attrs: any): boolean;
|
||||
}
|
||||
|
||||
class Collection<TModel extends Model> extends ModelBase {
|
||||
@@ -208,6 +222,7 @@ declare namespace Backbone {
|
||||
* Get a model from a collection, specified by an id, a cid, or by passing in a model.
|
||||
**/
|
||||
get(id: number|string|Model): TModel;
|
||||
has(key: number|string|Model): boolean;
|
||||
create(attributes: any, options?: ModelSaveOptions): TModel;
|
||||
pluck(attribute: string): any[];
|
||||
push(model: TModel, options?: AddOptions): TModel;
|
||||
@@ -221,10 +236,12 @@ declare namespace Backbone {
|
||||
unshift(model: TModel, options?: AddOptions): TModel;
|
||||
where(properties: any): TModel[];
|
||||
findWhere(properties: any): TModel;
|
||||
modelId(attrs: any) : any
|
||||
|
||||
private _prepareModel(attributes?: any, options?: any): any;
|
||||
private _removeReference(model: TModel): void;
|
||||
private _onModelEvent(event: string, model: TModel, collection: Collection<TModel>, options: any): void;
|
||||
private _isModel(obj: any) : obj is Model;
|
||||
|
||||
/**
|
||||
* Return a shallow copy of this collection's models, using the same options as native Array#slice.
|
||||
@@ -314,6 +331,8 @@ declare namespace Backbone {
|
||||
navigate(fragment: string, options?: NavigateOptions): Router;
|
||||
navigate(fragment: string, trigger?: boolean): Router;
|
||||
|
||||
execute(callback: Function, args: any[], name: string) : void;
|
||||
|
||||
private _bindRoutes(): void;
|
||||
private _routeToRegExp(route: string): RegExp;
|
||||
private _extractParameters(route: RegExp, fragment: string): string[];
|
||||
@@ -330,9 +349,14 @@ declare namespace Backbone {
|
||||
|
||||
getHash(window?: Window): string;
|
||||
getFragment(fragment?: string): string;
|
||||
decodeFragment(fragment: string): string;
|
||||
getSearch(): string;
|
||||
stop(): void;
|
||||
route(route: string, callback: Function): number;
|
||||
checkUrl(e?: any): void;
|
||||
getPath(): string;
|
||||
matchRoot(): boolean;
|
||||
atRoot(): boolean;
|
||||
loadUrl(fragmentOverride?: string): boolean;
|
||||
navigate(fragment: string, options?: any): boolean;
|
||||
static started: boolean;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Backbone 1.0.0
|
||||
// Type definitions for Backbone 1.3.3
|
||||
// Project: http://backbonejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Natan Vivo <https://github.com/nvivo/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/// <reference path="backlog-js.d.ts" />
|
||||
|
||||
import * as backlogjs from 'backlog-js';
|
||||
|
||||
const host = 'example.backlog.jp';
|
||||
const apiKey = 'apiKey';
|
||||
const clientId = 'clientId';
|
||||
const clientSecret = 'clientSecret';
|
||||
const redirectUri = 'redirectUri';
|
||||
const state = 'state';
|
||||
const code = 'code';
|
||||
const refreshToken = 'refreshToken';
|
||||
const configure = { host, apiKey }
|
||||
const credentials = { clientId, clientSecret }
|
||||
|
||||
const oauth2 = new backlogjs.OAuth2(credentials);
|
||||
oauth2.getAuthorizationURL({ host, redirectUri, state });
|
||||
oauth2.getAccessToken({ host, code, redirectUri }).then(data => {}).catch(err => {});
|
||||
oauth2.refreshAccessToken({ host, refreshToken }).then(data => {}).catch(err => {});
|
||||
|
||||
const backlog = new backlogjs.Backlog(configure);
|
||||
backlog.getSpace().then(data => { }).catch(err => { });
|
||||
backlog.getSpaceActivities({
|
||||
activityTypeId: [
|
||||
backlogjs.Option.ActivityType.IssueCreated,
|
||||
backlogjs.Option.ActivityType.IssueUpdated
|
||||
],
|
||||
minId: 1,
|
||||
maxId: 2,
|
||||
count: 3,
|
||||
order: "asc"
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getSpaceDiskUsage().then(data => { }).catch(err => { });
|
||||
backlog.getSpaceIcon().then(data => { }).catch(err => { });
|
||||
backlog.postSpaceAttachment(new FormData()).then(data => { }).catch(err => { });
|
||||
backlog.getUsers().then(data => { }).catch(err => { });
|
||||
backlog.getUser(1).then(data => { }).catch(err => { });
|
||||
backlog.postUser({
|
||||
userId: 'string',
|
||||
password: 'string',
|
||||
name: 'string',
|
||||
mailAddress: 'string',
|
||||
roleType: backlogjs.Option.User.RoleType.Admin
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.patchUser(1, {
|
||||
password: 'string',
|
||||
name: 'string',
|
||||
mailAddress: 'string',
|
||||
roleType: backlogjs.Option.User.RoleType.Admin
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.deleteUser(1).then(data => { }).catch(err => { });
|
||||
backlog.getMyself().then(data => { }).catch(err => { });
|
||||
backlog.getUserActivities(1, {
|
||||
activityTypeId: [
|
||||
backlogjs.Option.ActivityType.IssueCreated,
|
||||
backlogjs.Option.ActivityType.IssueUpdated
|
||||
],
|
||||
minId: 1,
|
||||
maxId: 2,
|
||||
count: 3,
|
||||
order: "asc"
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getUserStars(1, {
|
||||
minId: 1,
|
||||
maxId: 2,
|
||||
count: 3,
|
||||
order: "asc"
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getUserStarsCount(1, {
|
||||
since: 'YYYY-MM-DD',
|
||||
until: 'YYYY-MM-DD'
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getRecentlyViewedIssues({
|
||||
order: 'asc',
|
||||
offset: 1,
|
||||
count: 2
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getRecentlyViewedProjects({
|
||||
order: 'asc',
|
||||
offset: 1,
|
||||
count: 2
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getRecentlyViewedWikis({
|
||||
order: 'asc',
|
||||
offset: 1,
|
||||
count: 2
|
||||
}).then(data => { }).catch(err => { });
|
||||
backlog.getUserIcon(1).then(data => {}).catch(err => {});
|
||||
Vendored
+695
@@ -0,0 +1,695 @@
|
||||
// Type definitions for backlog-js 0.9.0
|
||||
// Project: https://github.com/nulab/backlog-js
|
||||
// Definitions by: Yuichi Watanabe <https://github.com/vvatanabe>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../isomorphic-fetch/isomorphic-fetch.d.ts" />
|
||||
/// <reference path="../node_modules/typescript/lib/lib.es6.d.ts" />
|
||||
|
||||
declare module 'backlog-js' {
|
||||
|
||||
class Request {
|
||||
private configure;
|
||||
constructor(configure: {
|
||||
host: string;
|
||||
apiKey?: string;
|
||||
accessToken?: string;
|
||||
timeout?: number;
|
||||
});
|
||||
get<T>(path: string, params?: any): Promise<T>;
|
||||
post<T>(path: string, params?: any): Promise<T>;
|
||||
put<T>(path: string, params: any): Promise<T>;
|
||||
patch<T>(path: string, params: any): Promise<T>;
|
||||
delete<T>(path: string, params?: any): Promise<T>;
|
||||
request(options: {
|
||||
method: string;
|
||||
path: string;
|
||||
params?: Params | FormData;
|
||||
}): Promise<IResponse>;
|
||||
checkStatus(response: IResponse): Promise<IResponse>;
|
||||
parseJSON<T>(response: IResponse): Promise<T>;
|
||||
private toFormData(params);
|
||||
private toQueryString(params);
|
||||
webAppBaseURL: string;
|
||||
restBaseURL: string;
|
||||
}
|
||||
|
||||
type Params = {
|
||||
[index: string]: number | string | number[] | string[];
|
||||
};
|
||||
|
||||
export class Backlog extends Request {
|
||||
constructor(configure: {
|
||||
host: string;
|
||||
apiKey?: string;
|
||||
accessToken?: string;
|
||||
timeout?: number;
|
||||
});
|
||||
getSpace(): Promise<any>;
|
||||
getSpaceActivities(params: Option.Space.GetActivitiesParams): Promise<any>;
|
||||
getSpaceNotification(): Promise<any>;
|
||||
putSpaceNotification(params: Option.Space.PutSpaceNotificationParams): Promise<any>;
|
||||
getSpaceDiskUsage(): Promise<any>;
|
||||
getSpaceIcon(): Promise<Entity.File.FileData>;
|
||||
postSpaceAttachment(form: FormData): Promise<IResponse>;
|
||||
getUsers(): Promise<any>;
|
||||
getUser(userId: number): Promise<any>;
|
||||
postUser(params: Option.User.PostUserParams): Promise<any>;
|
||||
patchUser(userId: number, params: Option.User.PatchUserParams): Promise<any>;
|
||||
deleteUser(userId: number): Promise<any>;
|
||||
getMyself(): Promise<any>;
|
||||
getUserActivities(userId: number, params: Option.User.GetUserActivitiesParams): Promise<any>;
|
||||
getUserStars(userId: number, params: Option.User.GetUserStarsParams): Promise<any>;
|
||||
getUserStarsCount(userId: number, params: Option.User.GetUserStarsCountParams): Promise<any>;
|
||||
getRecentlyViewedIssues(params: Option.User.GetRecentlyViewedParams): Promise<any>;
|
||||
getRecentlyViewedProjects(params: Option.User.GetRecentlyViewedParams): Promise<any>;
|
||||
getRecentlyViewedWikis(params: Option.User.GetRecentlyViewedParams): Promise<any>;
|
||||
getUserIcon(userId: number): Promise<Entity.File.FileData>;
|
||||
getGroups(params: Option.Group.GetGroupsParams): Promise<any>;
|
||||
postGroups(params: Option.Group.PostGroupsParams): Promise<any>;
|
||||
getGroup(groupId: number): Promise<any>;
|
||||
patchGroup(groupId: number, params: Option.Group.PatchGroupParams): Promise<any>;
|
||||
deleteGroup(groupId: number): Promise<any>;
|
||||
getStatuses(): Promise<any>;
|
||||
getResolutions(): Promise<any>;
|
||||
getPriorities(): Promise<any>;
|
||||
postProject(params: Option.Project.PostProjectParams): Promise<any>;
|
||||
getProjects(params?: Option.Project.GetProjectsParams): Promise<any>;
|
||||
getProject(projectIdOrKey: string): Promise<any>;
|
||||
patchProject(projectIdOrKey: string, params: Option.Project.PatchProjectParams): Promise<any>;
|
||||
deleteProject(projectIdOrKey: string): Promise<any>;
|
||||
getProjectActivities(projectIdOrKey: string, params: Option.Space.GetActivitiesParams): Promise<any>;
|
||||
getProjectUsers(projectIdOrKey: string): Promise<any>;
|
||||
deleteProjectUsers(projectIdOrKey: string, params: Option.Project.DeleteProjectUsersParams): Promise<any>;
|
||||
postProjectAdministrators(projectIdOrKey: string, params: Option.Project.PostProjectAdministrators): Promise<any>;
|
||||
getProjectAdministrators(projectIdOrKey: string): Promise<any>;
|
||||
deleteProjectAdministrators(projectIdOrKey: string, params: Option.Project.DeleteProjectAdministrators): Promise<any>;
|
||||
getIssueTypes(projectIdOrKey: string): Promise<any>;
|
||||
postIssueType(projectIdOrKey: string, params: Option.Project.PostIssueTypeParams): Promise<any>;
|
||||
patchIssueType(projectIdOrKey: string, id: number, params: Option.Project.PatchIssueTypeParams): Promise<any>;
|
||||
deleteIssueType(projectIdOrKey: string, id: number, params: Option.Project.DeleteIssueTypeParams): Promise<any>;
|
||||
getCategories(projectIdOrKey: string): Promise<any>;
|
||||
postCategories(projectIdOrKey: string, params: Option.Project.PostCategoriesParams): Promise<any>;
|
||||
patchCategories(projectIdOrKey: string, id: number, params: Option.Project.PatchCategoriesParams): Promise<any>;
|
||||
deleteCategories(projectIdOrKey: string, id: number): Promise<any>;
|
||||
getVersions(projectIdOrKey: string): Promise<any>;
|
||||
postVersions(projectIdOrKey: string, params: Option.Project.PostVersionsParams): Promise<any>;
|
||||
patchVersions(projectIdOrKey: string, id: number, params: Option.Project.PatchVersionsParams): Promise<any>;
|
||||
deleteVersions(projectIdOrKey: string, id: number): Promise<any>;
|
||||
getCustomFields(projectIdOrKey: string): Promise<any>;
|
||||
postCustomField(projectIdOrKey: string, params: Option.Project.PostCustomFieldParams | Option.Project.PostCustomFieldWithNumericParams | Option.Project.PostCustomFieldWithDateParams | Option.Project.PostCustomFieldWithListParams): Promise<any>;
|
||||
patchCustomField(projectIdOrKey: string, id: number, params: Option.Project.PatchCustomFieldParams | Option.Project.PatchCustomFieldWithNumericParams | Option.Project.PatchCustomFieldWithDateParams | Option.Project.PatchCustomFieldWithListParams): Promise<any>;
|
||||
deleteCustomField(projectIdOrKey: string, id: number): Promise<any>;
|
||||
postCustomFieldItem(projectIdOrKey: string, id: number, params: Option.Project.PostCustomFieldItemParams): Promise<any>;
|
||||
patchCustomFieldItem(projectIdOrKey: string, id: number, itemId: number, params: Option.Project.PatchCustomFieldItemParams): Promise<any>;
|
||||
deleteCustomFieldItem(projectIdOrKey: string, id: number, params: Option.Project.PostCustomFieldItemParams): Promise<any>;
|
||||
getSharedFiles(projectIdOrKey: string, path: string, params: Option.Project.GetSharedFilesParams): Promise<any>;
|
||||
getProjectsDiskUsage(projectIdOrKey: string): Promise<any>;
|
||||
getWebhooks(projectIdOrKey: string): Promise<any>;
|
||||
postWebhook(projectIdOrKey: string, params: Option.Project.PostWebhookParams): Promise<any>;
|
||||
getWebhook(projectIdOrKey: string, webhookId: string): Promise<any>;
|
||||
patchWebhook(projectIdOrKey: string, webhookId: string, params: Option.Project.PatchWebhookParams): Promise<any>;
|
||||
deleteWebhook(projectIdOrKey: string, webhookId: string): Promise<any>;
|
||||
postIssue(params: Option.Issue.PostIssueParams): Promise<any>;
|
||||
patchIssue(issueIdOrKey: string, params: Option.Issue.PatchIssueParams): Promise<any>;
|
||||
getIssues(params?: Option.Issue.GetIssuesParams): Promise<any>;
|
||||
getIssue(issueIdOrKey: string): Promise<any>;
|
||||
getIssuesCount(params?: Option.Issue.GetIssuesParams): Promise<any>;
|
||||
deleteIssuesCount(issueIdOrKey: string): Promise<any>;
|
||||
getIssueComments(issueIdOrKey: string, params: Option.Issue.GetIssueCommentsParams): Promise<any>;
|
||||
postIssueComments(issueIdOrKey: string, params: Option.Issue.PostIssueCommentsParams): Promise<any>;
|
||||
getIssueCommentsCount(issueIdOrKey: string): Promise<any>;
|
||||
getIssueComment(issueIdOrKey: string, commentId: number): Promise<any>;
|
||||
patchIssueComment(issueIdOrKey: string, commentId: number, params: Option.Issue.PatchIssueCommentParams): Promise<any>;
|
||||
getIssueCommentNotifications(issueIdOrKey: string, commentId: number): Promise<any>;
|
||||
postIssueCommentNotifications(issueIdOrKey: string, commentId: number, prams: Option.Issue.IssueCommentNotifications): Promise<any>;
|
||||
getIssueAttachments(issueIdOrKey: string): Promise<any>;
|
||||
deleteIssueAttachment(issueIdOrKey: string, attachmentId: string): Promise<any>;
|
||||
getIssueSharedFiles(issueIdOrKey: string): Promise<any>;
|
||||
linkIssueSharedFiles(issueIdOrKey: string, params: Option.Issue.LinkIssueSharedFilesParams): Promise<any>;
|
||||
unlinkIssueSharedFile(issueIdOrKey: string, id: number): Promise<any>;
|
||||
getWikis(projectIdOrKey: number): Promise<any>;
|
||||
getWikisCount(projectIdOrKey: number): Promise<any>;
|
||||
getWikisTags(projectIdOrKey: number): Promise<any>;
|
||||
postWiki(params: Option.Wiki.PostWikiParams): Promise<any>;
|
||||
getWiki(wikiId: number): Promise<any>;
|
||||
patchWiki(wikiId: number, params: Option.Wiki.PatchWikiParams): Promise<any>;
|
||||
deleteWiki(wikiId: number, mailNotify: boolean): Promise<any>;
|
||||
getWikisAttachments(wikiId: number): Promise<any>;
|
||||
postWikisAttachments(wikiId: number, attachmentId: number[]): Promise<any>;
|
||||
deleteWikisAttachments(wikiId: number, attachmentId: number): Promise<any>;
|
||||
getWikisSharedFiles(wikiId: number): Promise<any>;
|
||||
linkWikisSharedFiles(wikiId: number, fileId: number[]): Promise<any>;
|
||||
unlinkWikisSharedFiles(wikiId: number, id: number): Promise<any>;
|
||||
getWikisHistory(wikiId: number, params: Option.Wiki.GetWikisHistoryParams): Promise<any>;
|
||||
getWikisStars(wikiId: number): Promise<any>;
|
||||
postStar(params: Option.Project.PostStarParams): Promise<any>;
|
||||
getNotifications(params: Option.Notification.GetNotificationsParams): Promise<any>;
|
||||
getNotificationsCount(params: Option.Notification.GetNotificationsCountParams): Promise<any>;
|
||||
resetNotificationsMarkAsRead(): Promise<any>;
|
||||
markAsReadNotification(id: number): Promise<any>;
|
||||
getGitRepositories(projectIdOrKey: string): Promise<any>;
|
||||
getGitRepository(projectIdOrKey: string, repoIdOrName: string): Promise<any>;
|
||||
getPullRequests(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<any>;
|
||||
getPullRequestsCount(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise<any>;
|
||||
postPullRequest(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.PostPullRequestParams): Promise<any>;
|
||||
getPullRequest(projectIdOrKey: string, repoIdOrName: string, number: number): Promise<any>;
|
||||
patchPullRequest(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.PatchPullRequestParams): Promise<any>;
|
||||
getPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.GetPullRequestCommentsParams): Promise<any>;
|
||||
postPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.PostPullRequestCommentsParams): Promise<any>;
|
||||
getPullRequestCommentsCount(projectIdOrKey: string, repoIdOrName: string, number: number): Promise<any>;
|
||||
patchPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, commentId: number, params: Option.PullRequest.PatchPullRequestCommentsParams): Promise<any>;
|
||||
getPullRequestAttachments(projectIdOrKey: string, repoIdOrName: string, number: number): Promise<any>;
|
||||
deletePullRequestAttachment(projectIdOrKey: string, repoIdOrName: string, number: number, attachmentId: number): Promise<any>;
|
||||
getProjectIcon(projectIdOrKey: string): Promise<Entity.File.FileData>;
|
||||
getSharedFile(projectIdOrKey: string, sharedFileId: number): Promise<Entity.File.FileData>;
|
||||
getIssueAttachment(issueIdOrKey: string, attachmentId: number): Promise<Entity.File.FileData>;
|
||||
getWikiAttachment(wikiId: number, attachmentId: number): Promise<Entity.File.FileData>;
|
||||
getPullRequestAttachment(projectIdOrKey: string, repoIdOrName: string, number: number, attachmentId: number): Promise<Entity.File.FileData>;
|
||||
private download(path);
|
||||
private upload(path, params);
|
||||
private parseFileData(response);
|
||||
}
|
||||
|
||||
export class OAuth2 {
|
||||
private credentials;
|
||||
private timeout;
|
||||
constructor(credentials: Option.OAuth2.Credentials, timeout?: number);
|
||||
getAuthorizationURL(options: {
|
||||
host: string;
|
||||
redirectUri?: string;
|
||||
state?: string;
|
||||
}): string;
|
||||
getAccessToken(options: {
|
||||
host: string;
|
||||
code: string;
|
||||
redirectUri?: string;
|
||||
}): Promise<Entity.OAuth2.AccessToken>;
|
||||
refreshAccessToken(options: {
|
||||
host: string;
|
||||
refreshToken: string;
|
||||
}): Promise<Entity.OAuth2.AccessToken>;
|
||||
}
|
||||
|
||||
import { PassThrough } from 'stream';
|
||||
export namespace Entity {
|
||||
export namespace File {
|
||||
export type FileData = NodeFileData | BrowserFileData;
|
||||
export interface NodeFileData {
|
||||
body: PassThrough;
|
||||
url: string;
|
||||
filename: string;
|
||||
}
|
||||
export interface BrowserFileData {
|
||||
body: any;
|
||||
url: string;
|
||||
blob?: () => Promise<Blob>;
|
||||
}
|
||||
}
|
||||
export namespace OAuth2 {
|
||||
export interface AccessToken {
|
||||
access_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
refresh_token: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export namespace Option {
|
||||
export type Order = "asc" | "desc";
|
||||
export enum ActivityType {
|
||||
Undefined = -1,
|
||||
IssueCreated = 1,
|
||||
IssueUpdated = 2,
|
||||
IssueCommented = 3,
|
||||
IssueDeleted = 4,
|
||||
WikiCreated = 5,
|
||||
WikiUpdated = 6,
|
||||
WikiDeleted = 7,
|
||||
FileAdded = 8,
|
||||
FileUpdated = 9,
|
||||
FileDeleted = 10,
|
||||
SvnCommitted = 11,
|
||||
GitPushed = 12,
|
||||
GitRepositoryCreated = 13,
|
||||
IssueMultiUpdated = 14,
|
||||
ProjectUserAdded = 15,
|
||||
ProjectUserRemoved = 16,
|
||||
NotifyAdded = 17,
|
||||
PullRequestAdded = 18,
|
||||
PullRequestUpdated = 19,
|
||||
PullRequestCommented = 20,
|
||||
PullRequestMerged = 21,
|
||||
}
|
||||
export namespace Notification {
|
||||
export interface GetNotificationsParams {
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface GetNotificationsCountParams {
|
||||
alreadyRead: boolean;
|
||||
resourceAlreadyRead: boolean;
|
||||
}
|
||||
}
|
||||
export namespace Space {
|
||||
export interface GetActivitiesParams {
|
||||
activityTypeId?: ActivityType[];
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface PutSpaceNotificationParams {
|
||||
content: string;
|
||||
}
|
||||
}
|
||||
export namespace User {
|
||||
export interface PostUserParams {
|
||||
userId: string;
|
||||
password: string;
|
||||
name: string;
|
||||
mailAddress: string;
|
||||
roleType: RoleType;
|
||||
}
|
||||
export interface PatchUserParams {
|
||||
password?: string;
|
||||
name?: string;
|
||||
mailAddress?: string;
|
||||
roleType?: RoleType;
|
||||
}
|
||||
export enum RoleType {
|
||||
Admin = 1,
|
||||
User = 2,
|
||||
Reporter = 3,
|
||||
Viewer = 4,
|
||||
GuestReporter = 5,
|
||||
GuestViewer = 6,
|
||||
}
|
||||
export interface GetUserActivitiesParams {
|
||||
activityTypeId?: ActivityType[];
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface GetUserStarsParams {
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface GetUserStarsCountParams {
|
||||
since?: string;
|
||||
until?: string;
|
||||
}
|
||||
export interface GetRecentlyViewedParams {
|
||||
order?: Order;
|
||||
offset?: number;
|
||||
count?: number;
|
||||
}
|
||||
}
|
||||
export namespace Group {
|
||||
export interface GetGroupsParams {
|
||||
order?: Order;
|
||||
offset?: number;
|
||||
count?: number;
|
||||
}
|
||||
export interface PostGroupsParams {
|
||||
name: string;
|
||||
members?: string[];
|
||||
}
|
||||
export interface PatchGroupParams {
|
||||
name?: string;
|
||||
members?: string[];
|
||||
}
|
||||
}
|
||||
export namespace Project {
|
||||
export type TextFormattingRule = "backlog" | "markdown";
|
||||
export interface PostProjectParams {
|
||||
name: string;
|
||||
key: string;
|
||||
chartEnabled: boolean;
|
||||
projectLeaderCanEditProjectLeader?: boolean;
|
||||
subtaskingEnabled: boolean;
|
||||
textFormattingRule: TextFormattingRule;
|
||||
}
|
||||
export interface PatchProjectParams {
|
||||
name?: string;
|
||||
key?: string;
|
||||
chartEnabled?: boolean;
|
||||
subtaskingEnabled?: boolean;
|
||||
projectLeaderCanEditProjectLeader?: boolean;
|
||||
textFormattingRule?: TextFormattingRule;
|
||||
archived?: boolean;
|
||||
}
|
||||
export interface GetProjectsParams {
|
||||
archived?: boolean;
|
||||
all?: boolean;
|
||||
}
|
||||
export interface DeleteProjectUsersParams {
|
||||
userId: number;
|
||||
}
|
||||
export interface PostProjectAdministrators {
|
||||
userId: number;
|
||||
}
|
||||
export interface DeleteProjectAdministrators {
|
||||
userId: number;
|
||||
}
|
||||
export type IssueTypeColor = "#e30000" | "#990000" | "#934981" | "#814fbc" | "#2779ca" | "#007e9a" | "#7ea800" | "#ff9200" | "#ff3265" | "#666665";
|
||||
export interface PostIssueTypeParams {
|
||||
name: string;
|
||||
color: IssueTypeColor;
|
||||
}
|
||||
export interface PatchIssueTypeParams {
|
||||
name?: string;
|
||||
color?: IssueTypeColor;
|
||||
}
|
||||
export interface DeleteIssueTypeParams {
|
||||
substituteIssueTypeId: number;
|
||||
}
|
||||
export interface PostCategoriesParams {
|
||||
name: string;
|
||||
}
|
||||
export interface PatchCategoriesParams {
|
||||
name: string;
|
||||
}
|
||||
export interface PostVersionsParams {
|
||||
name: string;
|
||||
description: string;
|
||||
startDate: string;
|
||||
releaseDueDate: string;
|
||||
}
|
||||
export interface PatchVersionsParams {
|
||||
name: string;
|
||||
description?: string;
|
||||
startDate?: string;
|
||||
releaseDueDate?: string;
|
||||
archived?: boolean;
|
||||
}
|
||||
export interface PostCustomFieldParams {
|
||||
typeId: FieldType;
|
||||
name: string;
|
||||
applicableIssueTypes?: number[];
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
export interface PostCustomFieldWithNumericParams extends PostCustomFieldParams {
|
||||
min?: number;
|
||||
max?: number;
|
||||
initialValue?: number;
|
||||
unit?: string;
|
||||
}
|
||||
export interface PostCustomFieldWithDateParams extends PostCustomFieldParams {
|
||||
min?: string;
|
||||
max?: string;
|
||||
initialValueType?: number;
|
||||
initialDate?: string;
|
||||
initialShift?: number;
|
||||
}
|
||||
export interface PostCustomFieldWithListParams extends PostCustomFieldParams {
|
||||
items?: string[];
|
||||
allowInput?: boolean;
|
||||
allowAddItem?: boolean;
|
||||
}
|
||||
export interface PatchCustomFieldParams {
|
||||
name?: string;
|
||||
applicableIssueTypes?: number[];
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
export interface PatchCustomFieldWithNumericParams extends PatchCustomFieldParams {
|
||||
min?: number;
|
||||
max?: number;
|
||||
initialValue?: number;
|
||||
unit?: string;
|
||||
}
|
||||
export interface PatchCustomFieldWithDateParams extends PatchCustomFieldParams {
|
||||
min?: string;
|
||||
max?: string;
|
||||
initialValueType?: number;
|
||||
initialDate?: string;
|
||||
initialShift?: number;
|
||||
}
|
||||
export interface PatchCustomFieldWithListParams extends PatchCustomFieldParams {
|
||||
items?: string[];
|
||||
allowInput?: boolean;
|
||||
allowAddItem?: boolean;
|
||||
}
|
||||
export interface PostCustomFieldItemParams {
|
||||
name: string;
|
||||
}
|
||||
export interface PatchCustomFieldItemParams {
|
||||
name: string;
|
||||
}
|
||||
export interface GetSharedFilesParams {
|
||||
order?: Order;
|
||||
offset?: number;
|
||||
count?: number;
|
||||
}
|
||||
export interface PostWebhookParams {
|
||||
name?: string;
|
||||
description?: string;
|
||||
hookUrl?: string;
|
||||
allEvent?: boolean;
|
||||
activityTypeIds?: number[];
|
||||
}
|
||||
export interface PatchWebhookParams {
|
||||
name?: string;
|
||||
description?: string;
|
||||
hookUrl?: string;
|
||||
allEvent?: boolean;
|
||||
activityTypeIds?: number[];
|
||||
}
|
||||
export enum FieldType {
|
||||
Text = 1,
|
||||
TextArea = 2,
|
||||
Numeric = 3,
|
||||
Date = 4,
|
||||
SingleList = 5,
|
||||
MultipleList = 6,
|
||||
CheckBox = 7,
|
||||
Radio = 8,
|
||||
}
|
||||
export interface PostStarParams {
|
||||
issueId?: number;
|
||||
commentId?: number;
|
||||
wikiId?: number;
|
||||
pullRequestId?: number;
|
||||
pullRequestCommentId?: number;
|
||||
}
|
||||
}
|
||||
export namespace Issue {
|
||||
export interface PostIssueParams {
|
||||
projectId: number;
|
||||
summary: string;
|
||||
priorityId: number;
|
||||
issueTypeId: number;
|
||||
parentIssueId?: number;
|
||||
description?: string;
|
||||
startDate?: string;
|
||||
dueDate?: string;
|
||||
estimatedHours?: number;
|
||||
actualHours?: number;
|
||||
categoryId?: number[];
|
||||
versionId?: number[];
|
||||
milestoneId?: number[];
|
||||
assigneeId?: number;
|
||||
notifiedUserId?: number[];
|
||||
attachmentId?: number[];
|
||||
[customField_: string]: any;
|
||||
}
|
||||
export interface PatchIssueParams {
|
||||
summary?: string;
|
||||
parentIssueId?: number;
|
||||
description?: string;
|
||||
statusId?: number;
|
||||
resolutionId?: number;
|
||||
startDate?: string;
|
||||
dueDate?: string;
|
||||
estimatedHours?: number;
|
||||
actualHours?: number;
|
||||
issueTypeId?: number;
|
||||
categoryId?: number[];
|
||||
versionId?: number[];
|
||||
milestoneId?: number[];
|
||||
priorityId?: number;
|
||||
assigneeId?: number;
|
||||
notifiedUserId?: number[];
|
||||
attachmentId?: number[];
|
||||
comment?: string;
|
||||
[customField_: string]: any;
|
||||
}
|
||||
export interface GetIssuesParams {
|
||||
projectId?: number[];
|
||||
issueTypeId?: number[];
|
||||
categoryId?: number[];
|
||||
versionId?: number[];
|
||||
milestoneId?: number[];
|
||||
statusId?: number[];
|
||||
priorityId?: number[];
|
||||
assigneeId?: number[];
|
||||
createdUserId?: number[];
|
||||
resolutionId?: number[];
|
||||
parentChild?: ParentChildType;
|
||||
attachment?: boolean;
|
||||
sharedFile?: boolean;
|
||||
sort?: SortKey;
|
||||
order?: Order;
|
||||
offset?: number;
|
||||
count?: number;
|
||||
createdSince?: string;
|
||||
createdUntil?: string;
|
||||
updatedSince?: string;
|
||||
updatedUntil?: string;
|
||||
startDateSince?: string;
|
||||
startDateUntil?: string;
|
||||
dueDateSince?: string;
|
||||
dueDateUntil?: string;
|
||||
id?: number[];
|
||||
parentIssueId?: number[];
|
||||
keyword: string;
|
||||
[customField_: string]: any;
|
||||
}
|
||||
export enum ParentChildType {
|
||||
All = 0,
|
||||
NotChild = 1,
|
||||
Child = 2,
|
||||
NotChildNotParent = 3,
|
||||
Parent = 4,
|
||||
}
|
||||
export type SortKey = "issueType" | "category" | "version" | "milestone" | "summary" | "status" | "priority" | "attachment" | "sharedFile" | "created" | "createdUser" | "updated" | "updatedUser" | "assignee" | "startDate" | "dueDate" | "estimatedHours" | "actualHours" | "childIssue";
|
||||
export interface GetIssueCommentsParams {
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface PostIssueCommentsParams {
|
||||
content: string;
|
||||
notifiedUserId?: number[];
|
||||
attachmentId?: number[];
|
||||
}
|
||||
export interface PatchIssueCommentParams {
|
||||
content: string;
|
||||
}
|
||||
export interface IssueCommentNotifications {
|
||||
notifiedUserId: number[];
|
||||
}
|
||||
export interface LinkIssueSharedFilesParams {
|
||||
fileId: number[];
|
||||
}
|
||||
}
|
||||
export namespace PullRequest {
|
||||
export interface GetPullRequestsParams {
|
||||
statusId?: number[];
|
||||
assigneeId?: number[];
|
||||
issueId?: number[];
|
||||
createdUserId?: number[];
|
||||
offset?: number;
|
||||
count?: number;
|
||||
}
|
||||
export interface PostPullRequestParams {
|
||||
summary: string;
|
||||
description: string;
|
||||
base: string;
|
||||
branch: string;
|
||||
issueId?: number;
|
||||
assigneeId?: number;
|
||||
notifiedUserId?: number[];
|
||||
attachmentId?: number[];
|
||||
}
|
||||
export interface PatchPullRequestParams {
|
||||
summary?: string;
|
||||
description?: string;
|
||||
issueId?: number;
|
||||
assigneeId?: number;
|
||||
notifiedUserId?: number[];
|
||||
comment?: string[];
|
||||
}
|
||||
export interface GetPullRequestCommentsParams {
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
export interface PostPullRequestCommentsParams {
|
||||
content: string;
|
||||
notifiedUserId?: number[];
|
||||
}
|
||||
export interface PatchPullRequestCommentsParams {
|
||||
content: string;
|
||||
}
|
||||
}
|
||||
export namespace Wiki {
|
||||
export interface PostWikiParams {
|
||||
projectId: number;
|
||||
name: string;
|
||||
content: string;
|
||||
mailNotify?: boolean;
|
||||
}
|
||||
export interface PatchWikiParams {
|
||||
name?: string;
|
||||
content?: string;
|
||||
mailNotify?: boolean;
|
||||
}
|
||||
export interface GetWikisHistoryParams {
|
||||
minId?: number;
|
||||
maxId?: number;
|
||||
count?: number;
|
||||
order?: Order;
|
||||
}
|
||||
}
|
||||
export namespace OAuth2 {
|
||||
export interface Credentials {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Error {
|
||||
export class BacklogError extends global.Error {
|
||||
private _name;
|
||||
private _url;
|
||||
private _status;
|
||||
private _body;
|
||||
private _response;
|
||||
constructor(name: BacklogErrorNameType, response: IResponse, body?: {
|
||||
errors: BacklogErrorMessage[];
|
||||
});
|
||||
name: BacklogErrorNameType;
|
||||
url: string;
|
||||
status: number;
|
||||
body: {
|
||||
errors: BacklogErrorMessage[];
|
||||
};
|
||||
response: IResponse;
|
||||
}
|
||||
export class BacklogApiError extends BacklogError {
|
||||
constructor(response: IResponse, body?: {
|
||||
errors: BacklogErrorMessage[];
|
||||
});
|
||||
}
|
||||
export class BacklogAuthError extends BacklogError {
|
||||
constructor(response: IResponse, body?: {
|
||||
errors: BacklogErrorMessage[];
|
||||
});
|
||||
}
|
||||
export class UnexpectedError extends BacklogError {
|
||||
constructor(response: IResponse);
|
||||
}
|
||||
export interface BacklogErrorMessage {
|
||||
message: string;
|
||||
code: number;
|
||||
errorInfo: string;
|
||||
moreInfo: string;
|
||||
}
|
||||
export type BacklogErrorNameType = 'BacklogApiError' | 'BacklogAuthError' | 'UnexpectedError';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="./base16.d.ts" />
|
||||
|
||||
import * as base16 from 'base16';
|
||||
|
||||
const colorScheme: base16.ColorScheme = base16.solarized
|
||||
|
||||
const scheme: string = colorScheme.scheme
|
||||
const author: string = colorScheme.author
|
||||
const base00: string = colorScheme.base00
|
||||
const base01: string = colorScheme.base01
|
||||
const base02: string = colorScheme.base02
|
||||
const base03: string = colorScheme.base03
|
||||
const base04: string = colorScheme.base04
|
||||
const base05: string = colorScheme.base05
|
||||
const base06: string = colorScheme.base06
|
||||
const base07: string = colorScheme.base07
|
||||
const base08: string = colorScheme.base08
|
||||
const base09: string = colorScheme.base09
|
||||
const base0A: string = colorScheme.base0A
|
||||
const base0B: string = colorScheme.base0B
|
||||
const base0C: string = colorScheme.base0C
|
||||
const base0D: string = colorScheme.base0D
|
||||
const base0E: string = colorScheme.base0E
|
||||
const base0F: string = colorScheme.base0F
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
// Type definitions for base16-js 1.0.0
|
||||
// Project: https://github.com/gaearon/base16-js
|
||||
// Definitions by: Alec Hill <https://github.com/alechill>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'base16' {
|
||||
|
||||
/**
|
||||
* Type describing a syntax highlighting scheme as a JS object, as used in redux dev tools
|
||||
* Based on https://github.com/chriskempson/base16
|
||||
*/
|
||||
export interface ColorScheme {
|
||||
scheme: string
|
||||
author: string
|
||||
base00: string
|
||||
base01: string
|
||||
base02: string
|
||||
base03: string
|
||||
base04: string
|
||||
base05: string
|
||||
base06: string
|
||||
base07: string
|
||||
base08: string
|
||||
base09: string
|
||||
base0A: string
|
||||
base0B: string
|
||||
base0C: string
|
||||
base0D: string
|
||||
base0E: string
|
||||
base0F: string
|
||||
}
|
||||
|
||||
// predefined schemes...
|
||||
export var threezerotwofour: ColorScheme
|
||||
export var apathy: ColorScheme
|
||||
export var ashes: ColorScheme
|
||||
export var atelierDune: ColorScheme
|
||||
export var atelierForest: ColorScheme
|
||||
export var atelierHeath: ColorScheme
|
||||
export var atelierLakeside: ColorScheme
|
||||
export var atelierSeaside: ColorScheme
|
||||
export var bespin: ColorScheme
|
||||
export var brewer: ColorScheme
|
||||
export var bright: ColorScheme
|
||||
export var chalk: ColorScheme
|
||||
export var codeschool: ColorScheme
|
||||
export var colors: ColorScheme
|
||||
export var eighties: ColorScheme
|
||||
export var embers: ColorScheme
|
||||
export var flat: ColorScheme
|
||||
export var google: ColorScheme
|
||||
export var grayscale: ColorScheme
|
||||
export var greenscreen: ColorScheme
|
||||
export var harmonic: ColorScheme
|
||||
export var hopscotch: ColorScheme
|
||||
export var isotope: ColorScheme
|
||||
export var marrakesh: ColorScheme
|
||||
export var monokai: ColorScheme
|
||||
export var ocean: ColorScheme
|
||||
export var paraiso: ColorScheme
|
||||
export var pop: ColorScheme
|
||||
export var railscasts: ColorScheme
|
||||
export var shapeshifter: ColorScheme
|
||||
export var solarized: ColorScheme
|
||||
export var summerfruit: ColorScheme
|
||||
export var tomorrow: ColorScheme
|
||||
export var tube: ColorScheme
|
||||
export var twilight: ColorScheme
|
||||
|
||||
}
|
||||
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
// Type definitions for base64url v2.0.0
|
||||
// Project: https://github.com/brianloveswords/base64url
|
||||
// Definitions by: Stepan Miroshin <https://github.com/microshine>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
/**
|
||||
* For encoding and decoding base64url!
|
||||
* v2.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Encoding type
|
||||
*/
|
||||
declare type Encoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "utf16le" | "base64" | "binary" | "hex"
|
||||
|
||||
interface IBase64Url {
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {string} input Incoming input
|
||||
* @param {Encoding} encoding Default 'utf8'
|
||||
* @return {string}
|
||||
*/
|
||||
(input: string, encoding?: Encoding): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {Buffer} input Incoming value
|
||||
*/
|
||||
(inout: Buffer): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
*
|
||||
* @param {string} input Incoming input
|
||||
* @param {Encoding} encoding Default 'utf8'
|
||||
* @returns {string}
|
||||
*/
|
||||
encode(input: string, encoding?: Encoding): string;
|
||||
/**
|
||||
* Encode input to base64url
|
||||
* @param {Buffer} input Incoming value
|
||||
*/
|
||||
encode(input: Buffer): string;
|
||||
/**
|
||||
* Convert a base64url encoded string into a raw string.
|
||||
* @param {string} base64url base64url encoded string
|
||||
* @param {Encoding} encoding Encoding defaults to 'utf8'
|
||||
* @returns {string}
|
||||
*/
|
||||
decode(base64url: string, encoding?: string): string;
|
||||
/**
|
||||
* Convert a base64url encoded string to a base64 encoded string
|
||||
* @param {string | Buffer} base64url base64url encoded value
|
||||
* @returns {string}
|
||||
*/
|
||||
toBase64(base64url: string | Buffer): string;
|
||||
/**
|
||||
* Convert a base64 encoded string to a base64url encoded string
|
||||
* @param {string} base64 encoded string
|
||||
* @returns {string}
|
||||
*/
|
||||
fromBase64(base64: string): string;
|
||||
/**
|
||||
* Convert a base64url encoded string to a Buffer
|
||||
* @param {string} base64url encoded string
|
||||
* @returns {Buffer}
|
||||
*/
|
||||
toBuffer(base64url: string): Buffer;
|
||||
}
|
||||
|
||||
declare module "base64url" {
|
||||
const base64url: IBase64Url;
|
||||
export = base64url;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="./base64url.d.ts" />
|
||||
|
||||
import * as base64url from "base64url";
|
||||
|
||||
// default
|
||||
let str = base64url("some value");
|
||||
str = base64url("some value", "hex");
|
||||
str = base64url(new Buffer("some value"));
|
||||
|
||||
// encode
|
||||
str = base64url.encode("some value");
|
||||
str = base64url.encode("some value", "hex");
|
||||
str = base64url.encode(new Buffer("some value"));
|
||||
|
||||
// decode
|
||||
str = base64url.decode("ADA=");
|
||||
str = base64url.decode("ADA=", "binary");
|
||||
|
||||
// toBase64
|
||||
str = base64url.toBase64("ADA=");
|
||||
str = base64url.toBase64(new Buffer("ADA=", "base64"));
|
||||
|
||||
// fromBase64
|
||||
str = base64url.fromBase64("ADA=");
|
||||
|
||||
let buf = base64url.toBase64("ADA=");
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="bazinga-translator.d.ts" />
|
||||
|
||||
Translator.fallback = 'en';
|
||||
Translator.defaultDomain = 'messages';
|
||||
|
||||
Translator.add("test", "it work", "frontend", "en");
|
||||
|
||||
Translator.trans('key', {}, 'frontend');
|
||||
Translator.trans('key', {"foo": "bar"}, 'DOMAIN_NAME');
|
||||
|
||||
Translator.transChoice('key', 1, {}, 'frontend');
|
||||
Translator.transChoice('key', 123, {"foo": "bar"}, 'DOMAIN_NAME');
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// Type definitions for Translator
|
||||
// Project: https://github.com/willdurand/BazingaJsTranslationBundle
|
||||
// Definitions by: Alex <https://github.com/alexndlm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface BazingaTranslator {
|
||||
/**
|
||||
* The current locale.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
locale: string;
|
||||
|
||||
/**
|
||||
* Fallback locale.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
fallback: string;
|
||||
|
||||
/**
|
||||
* Placeholder prefix.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
placeHolderPrefix: string;
|
||||
|
||||
/**
|
||||
* Placeholder suffix.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
placeHolderSuffix: string;
|
||||
|
||||
/**
|
||||
* Default domain.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
defaultDomain: string;
|
||||
|
||||
/**
|
||||
* Plural separator.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
pluralSeparator: string;
|
||||
|
||||
/**
|
||||
* Adds a translation entry.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {String} message The message to register for the given id
|
||||
* @param {String} [domain] The domain for the message or null to use the default
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {Object} Translator
|
||||
*/
|
||||
add(id: string, message: string, domain: string, locale: string): BazingaTranslator;
|
||||
|
||||
|
||||
/**
|
||||
* Translates the given message.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {Object} [parameters] An array of parameters for the message
|
||||
* @param {String} [domain] The domain for the message or null to guess it
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {String} The translated string
|
||||
*/
|
||||
trans(id: string, parameters: any, domain: string, locale?: string): string;
|
||||
|
||||
/**
|
||||
* Translates the given choice message by choosing a translation according to a number.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {Number} number The number to use to find the indice of the message
|
||||
* @param {Object} [parameters] An array of parameters for the message
|
||||
* @param {String} [domain] The domain for the message or null to guess it
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {String} The translated string
|
||||
*/
|
||||
transChoice(id: string, number: number, parameters: any, domain: string, locale?: string): string,
|
||||
|
||||
/**
|
||||
* Loads translations from JSON.
|
||||
*
|
||||
* @param {String} data A JSON string or object literal
|
||||
*
|
||||
* @return {Object} Translator
|
||||
*/
|
||||
fromJSON(data: string): BazingaTranslator;
|
||||
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
declare var Translator: BazingaTranslator;
|
||||
+17
-1
@@ -12,6 +12,7 @@
|
||||
|
||||
*/
|
||||
|
||||
import BigJS = BigJsLibrary.BigJS;
|
||||
function constructorTests() {
|
||||
var x = new Big(9) // '9'
|
||||
var y = new Big(x) // '9'
|
||||
@@ -247,4 +248,19 @@ function testMultipleConstructors() {
|
||||
|
||||
x.div(3) // 1.667
|
||||
y.div(3) // 1.6666666667
|
||||
}
|
||||
}
|
||||
|
||||
function multipleTypesAccepted(n: number | BigJS | string) {
|
||||
var y = Big(n)
|
||||
.minus(n)
|
||||
.mod(n)
|
||||
.plus(n)
|
||||
.times(n);
|
||||
y.cmp(n);
|
||||
y.eq(n);
|
||||
y.gt(n);
|
||||
y.gte(n);
|
||||
y.lt(n);
|
||||
y.lte(n);
|
||||
y.div(n)
|
||||
}
|
||||
|
||||
Vendored
+16
-82
@@ -25,23 +25,11 @@ declare namespace BigJsLibrary {
|
||||
RM: RoundingMode;
|
||||
}
|
||||
|
||||
type BigNumberInputType = number | string | BigJS;
|
||||
|
||||
interface BigJS_Constructors {
|
||||
/** A decimal value. */
|
||||
new (value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
new (value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
new (value: BigJS): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
(value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: BigJS): BigJS;
|
||||
new (value: BigNumberInputType): BigJS;
|
||||
(value: BigNumberInputType): BigJS;
|
||||
|
||||
/** A decimal value. */
|
||||
(): BigJS;
|
||||
@@ -57,85 +45,35 @@ declare namespace BigJsLibrary {
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: number): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: string): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: BigJS): number;
|
||||
cmp(n: BigNumberInputType): number;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: BigJS): BigJS;
|
||||
div(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: number): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: string): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: BigJS): boolean;
|
||||
eq(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: BigJS): boolean;
|
||||
gt(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: BigJS): boolean;
|
||||
gte(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: BigJS): boolean;
|
||||
lt(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: BigJS): boolean;
|
||||
lte(n: BigNumberInputType): boolean;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: BigJS): BigJS;
|
||||
minus(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: BigJS): BigJS;
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: BigJS): BigJS;
|
||||
plus(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number raised to the power exp.
|
||||
If exp is negative and the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM.
|
||||
@@ -156,11 +94,7 @@ declare namespace BigJsLibrary {
|
||||
sqrt(): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: BigJS): BigJS;
|
||||
times(n: BigNumberInputType): BigJS;
|
||||
|
||||
/** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp. */
|
||||
toExponential(): string;
|
||||
|
||||
@@ -0,0 +1,773 @@
|
||||
///<reference path="blessed.d.ts" />
|
||||
|
||||
import * as blessed from 'blessed';
|
||||
|
||||
let screen: blessed.Widgets.Screen = null;
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-autopad.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/autopad.log',
|
||||
smartCSR: true,
|
||||
autoPadding: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: box1,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-bigtext.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/bigtext.log',
|
||||
smartCSR: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var box = blessed.bigtext({
|
||||
parent: screen,
|
||||
content: 'Hello',
|
||||
shrink: true,
|
||||
width: '80%',
|
||||
// height: '80%',
|
||||
height: 'shrink',
|
||||
// width: 'shrink',
|
||||
border: 'line',
|
||||
fch: ' ',
|
||||
ch: '\u2592',
|
||||
style: {
|
||||
fg: 'red',
|
||||
bg: 'blue',
|
||||
bold: false
|
||||
}
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-csr.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/csr.log',
|
||||
smartCSR: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8');
|
||||
|
||||
var cleanSides = screen.cleanSides;
|
||||
function expectClean(value: any) {
|
||||
screen.cleanSides = function(el: blessed.widget.Element) {
|
||||
var ret = cleanSides.apply(this, arguments);
|
||||
if (ret !== value) {
|
||||
throw new Error('Failed. Expected '
|
||||
+ value + ' from cleanSides. Got '
|
||||
+ ret + '.');
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
var btext = blessed.box({
|
||||
parent: screen,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
width: '80%',
|
||||
height: '80%',
|
||||
style: {
|
||||
bg: 'green'
|
||||
},
|
||||
border: 'line',
|
||||
content: 'CSR should still work.'
|
||||
});
|
||||
let _oscroll = btext.scroll;
|
||||
btext.scroll = function(offset, always) {
|
||||
expectClean(true);
|
||||
return _oscroll(offset, always);
|
||||
};
|
||||
|
||||
var text = blessed.scrollabletext({
|
||||
parent: screen,
|
||||
content: lorem,
|
||||
border: 'line',
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
draggable: true,
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
mouse: true,
|
||||
keys: true,
|
||||
vi: true
|
||||
});
|
||||
|
||||
_oscroll = text.scroll;
|
||||
text.scroll = function(offset, always) {
|
||||
var el = this;
|
||||
var value = true;
|
||||
if (el.left < 0) value = true;
|
||||
if (el.top < 0) value = false;
|
||||
if (el.left + el.width > screen.width) value = true;
|
||||
if (el.top + el.height > screen.height) value = false;
|
||||
expectClean(value);
|
||||
return _oscroll(offset, always);
|
||||
};
|
||||
|
||||
text.focus();
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-dock-noborder.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/dock.log',
|
||||
smartCSR: true,
|
||||
dockBorders: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: -1,
|
||||
top: -1,
|
||||
width: '50%+1',
|
||||
height: '50%+1',
|
||||
border: 'line',
|
||||
content: 'Foo'
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: '50%-1',
|
||||
top: -1,
|
||||
width: '50%+3',
|
||||
height: '50%+1',
|
||||
content: 'Bar',
|
||||
border: 'line'
|
||||
});
|
||||
|
||||
blessed.box({
|
||||
parent: screen,
|
||||
left: -1,
|
||||
top: '50%-1',
|
||||
width: '50%+1',
|
||||
height: '50%+3',
|
||||
border: 'line',
|
||||
content: 'Foo'
|
||||
});
|
||||
|
||||
blessed.listtable({
|
||||
parent: screen,
|
||||
left: '50%-1',
|
||||
top: '50%-1',
|
||||
width: '50%+3',
|
||||
height: '50%+3',
|
||||
border: 'line',
|
||||
align: 'center',
|
||||
tags: true,
|
||||
keys: true,
|
||||
vi: true,
|
||||
mouse: true,
|
||||
style: {
|
||||
header: {
|
||||
fg: 'blue',
|
||||
bold: true
|
||||
},
|
||||
cell: {
|
||||
fg: 'magenta',
|
||||
selected: {
|
||||
bg: 'blue'
|
||||
}
|
||||
}
|
||||
},
|
||||
data: [
|
||||
[ 'Animals', 'Foods', 'Times', 'Numbers' ],
|
||||
[ 'Elephant', 'Apple', '1:00am', 'One' ],
|
||||
[ 'Bird', 'Orange', '2:15pm', 'Two' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am', 'Three' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am', 'Four' ]
|
||||
]
|
||||
}).focus();
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://raw.githubusercontent.com/chjj/blessed/master/example/simple-form.js
|
||||
|
||||
var form = blessed.form({
|
||||
parent: screen,
|
||||
keys: true,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 30,
|
||||
height: 4,
|
||||
bg: 'green',
|
||||
content: 'Submit or cancel?'
|
||||
});
|
||||
|
||||
var submit = blessed.button({
|
||||
parent: form,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 10,
|
||||
top: 2,
|
||||
shrink: true,
|
||||
name: 'submit',
|
||||
content: 'submit',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
},
|
||||
hover: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var cancel = blessed.button({
|
||||
parent: form,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 20,
|
||||
top: 2,
|
||||
shrink: true,
|
||||
name: 'cancel',
|
||||
content: 'cancel',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
},
|
||||
hover: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-layout.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/layout.log',
|
||||
smartCSR: true,
|
||||
autoPadding: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var layout = blessed.layout({
|
||||
parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
border: 'line',
|
||||
layout: process.argv[2] === 'grid' ? 'grid' : 'inline',
|
||||
style: {
|
||||
bg: 'red',
|
||||
border: {
|
||||
fg: 'blue'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '1'
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '2'
|
||||
});
|
||||
|
||||
var box3 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '3'
|
||||
});
|
||||
|
||||
var box4 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '4'
|
||||
});
|
||||
|
||||
var box5 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '5'
|
||||
});
|
||||
|
||||
var box6 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '6'
|
||||
});
|
||||
|
||||
var box7 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '7'
|
||||
});
|
||||
|
||||
var box8 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '8'
|
||||
});
|
||||
|
||||
var box9 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '9'
|
||||
});
|
||||
|
||||
var box10 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '10'
|
||||
});
|
||||
|
||||
var box11 = blessed.box({
|
||||
parent: layout,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 10,
|
||||
height: 5,
|
||||
border: 'line',
|
||||
content: '11'
|
||||
});
|
||||
|
||||
var box12 = blessed.box({
|
||||
parent: layout,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
width: 20,
|
||||
height: 10,
|
||||
border: 'line',
|
||||
content: '12'
|
||||
});
|
||||
|
||||
if (process.argv[2] !== 'grid') {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
blessed.box({
|
||||
parent: layout,
|
||||
// width: i % 2 === 0 ? 10 : 20,
|
||||
// height: i % 2 === 0 ? 5 : 10,
|
||||
width: Math.random() > 0.5 ? 10 : 20,
|
||||
height: Math.random() > 0.5 ? 5 : 10,
|
||||
border: 'line',
|
||||
content: (i + 1 + 12) + ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-form.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/form.log',
|
||||
warnings: true
|
||||
});
|
||||
|
||||
type FormData = {
|
||||
radio1: boolean;
|
||||
radio2: boolean;
|
||||
text: string;
|
||||
check: boolean;
|
||||
};
|
||||
|
||||
var form2 = blessed.form<FormData>({
|
||||
parent: screen,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
vi: true,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: '100%',
|
||||
//height: 12,
|
||||
style: {
|
||||
bg: 'green',
|
||||
border: {
|
||||
inverse: true
|
||||
},
|
||||
scrollbar: {
|
||||
inverse: true
|
||||
}
|
||||
},
|
||||
content: 'foobar',
|
||||
scrollable: true,
|
||||
scrollbar: {
|
||||
ch: ' '
|
||||
}
|
||||
//alwaysScroll: true
|
||||
});
|
||||
|
||||
form2.on('submit', (data) => {
|
||||
output.setContent(JSON.stringify(data, null, 2));
|
||||
screen.render();
|
||||
});
|
||||
|
||||
form2.key('d', function() {
|
||||
form2.scroll(1, true);
|
||||
screen.render();
|
||||
});
|
||||
|
||||
form2.key('u', function() {
|
||||
form2.scroll(-1, true);
|
||||
screen.render();
|
||||
});
|
||||
|
||||
var set = blessed.radioset({
|
||||
parent: form2,
|
||||
left: 1,
|
||||
top: 1,
|
||||
shrink: true,
|
||||
//padding: 1,
|
||||
//content: 'f',
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
}
|
||||
});
|
||||
|
||||
var radio1 = blessed.radiobutton({
|
||||
parent: set,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 0,
|
||||
top: 0,
|
||||
name: 'radio1',
|
||||
content: 'radio1'
|
||||
});
|
||||
|
||||
var radio2 = blessed.radiobutton({
|
||||
parent: set,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 15,
|
||||
top: 0,
|
||||
name: 'radio2',
|
||||
content: 'radio2'
|
||||
});
|
||||
|
||||
var text2 = blessed.textbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
style: {
|
||||
bg: 'blue'
|
||||
},
|
||||
height: 1,
|
||||
width: 20,
|
||||
left: 1,
|
||||
top: 3,
|
||||
name: 'text'
|
||||
});
|
||||
|
||||
text2.on('focus', function() {
|
||||
text2.readInput();
|
||||
});
|
||||
|
||||
var check = blessed.checkbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 28,
|
||||
top: 1,
|
||||
name: 'check',
|
||||
content: 'check'
|
||||
});
|
||||
|
||||
var check2 = blessed.checkbox({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
},
|
||||
height: 1,
|
||||
left: 28,
|
||||
top: 14,
|
||||
name: 'foooooooo2',
|
||||
content: 'foooooooo2'
|
||||
});
|
||||
|
||||
var submit = blessed.button({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
shrink: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
right: 1
|
||||
},
|
||||
left: 29,
|
||||
top: 3,
|
||||
name: 'submit',
|
||||
content: 'submit',
|
||||
style: {
|
||||
bg: 'blue',
|
||||
focus: {
|
||||
bg: 'red'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submit.on('press', function() {
|
||||
form2.submit();
|
||||
});
|
||||
|
||||
var box1 = blessed.box({
|
||||
parent: form2,
|
||||
left: 1,
|
||||
top: 10,
|
||||
height: 10,
|
||||
width: 10,
|
||||
content: 'one',
|
||||
style: {
|
||||
bg: 'cyan'
|
||||
}
|
||||
});
|
||||
|
||||
var box2 = blessed.box({
|
||||
parent: box1,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 8,
|
||||
width: 9,
|
||||
content: 'two',
|
||||
style: {
|
||||
bg: 'magenta'
|
||||
}
|
||||
});
|
||||
|
||||
var box3 = blessed.box({
|
||||
parent: box2,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 6,
|
||||
width: 8,
|
||||
content: 'three',
|
||||
style: {
|
||||
bg: 'yellow'
|
||||
}
|
||||
});
|
||||
|
||||
var box4 = blessed.box({
|
||||
parent: box3,
|
||||
left: 1,
|
||||
top: 2,
|
||||
height: 4,
|
||||
width: 7,
|
||||
content: 'four',
|
||||
style: {
|
||||
bg: 'blue'
|
||||
}
|
||||
});
|
||||
|
||||
var output = blessed.scrollabletext({
|
||||
parent: form2,
|
||||
mouse: true,
|
||||
keys: true,
|
||||
left: 0,
|
||||
top: 20,
|
||||
height: 5,
|
||||
right: 0,
|
||||
style: {
|
||||
bg: 'red'
|
||||
},
|
||||
content: 'foobar'
|
||||
});
|
||||
|
||||
var bottom = blessed.line({
|
||||
parent: form2,
|
||||
type: 'line',
|
||||
orientation: 'horizontal',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 50,
|
||||
style: {
|
||||
fg: 'blue'
|
||||
}
|
||||
});
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
form2.focus();
|
||||
|
||||
form2.submit();
|
||||
|
||||
screen.render();
|
||||
|
||||
// https://github.com/chjj/blessed/blob/master/test/widget-table.js
|
||||
|
||||
screen = blessed.screen({
|
||||
dump: __dirname + '/logs/table.log',
|
||||
autoPadding: false,
|
||||
fullUnicode: true,
|
||||
warnings: true
|
||||
});
|
||||
|
||||
var DU = '杜';
|
||||
var JUAN = '鹃';
|
||||
|
||||
var table = blessed.table({
|
||||
//parent: screen,
|
||||
top: 'center',
|
||||
left: 'center',
|
||||
data: null,
|
||||
border: 'line',
|
||||
align: 'center',
|
||||
tags: true,
|
||||
//width: '80%',
|
||||
width: 'shrink',
|
||||
style: {
|
||||
border: {
|
||||
fg: 'red'
|
||||
},
|
||||
header: {
|
||||
fg: 'blue',
|
||||
bold: true
|
||||
},
|
||||
cell: {
|
||||
fg: 'magenta'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var data1 = [
|
||||
[ 'Animals', 'Foods', 'Times' ],
|
||||
[ 'Elephant', 'Apple', '1:00am' ],
|
||||
[ 'Bird', 'Orange', '2:15pm' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am' ]
|
||||
];
|
||||
|
||||
data1[1][0] = '{red-fg}' + data1[1][0] + '{/red-fg}';
|
||||
data1[2][0] += ' (' + DU + JUAN + ')';
|
||||
|
||||
var data2 = [
|
||||
[ 'Animals', 'Foods', 'Times', 'Numbers' ],
|
||||
[ 'Elephant', 'Apple', '1:00am', 'One' ],
|
||||
[ 'Bird', 'Orange', '2:15pm', 'Two' ],
|
||||
[ 'T-Rex', 'Taco', '8:45am', 'Three' ],
|
||||
[ 'Mouse', 'Cheese', '9:05am', 'Four' ]
|
||||
];
|
||||
|
||||
data2[1][0] = '{red-fg}' + data2[1][0] + '{/red-fg}';
|
||||
data2[2][0] += ' (' + DU + JUAN + ')';
|
||||
|
||||
screen.key('q', function() {
|
||||
return screen.destroy();
|
||||
});
|
||||
|
||||
table.setData(data2);
|
||||
screen.append(table);
|
||||
screen.render();
|
||||
|
||||
setTimeout(function() {
|
||||
table.setData(data1);
|
||||
screen.render();
|
||||
}, 3000);
|
||||
Vendored
+2812
-1247
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path="blue-tape.d.ts" />
|
||||
|
||||
import tape = require('blue-tape');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="bluebird-retry.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
import Promise = require('bluebird');
|
||||
import retry = require('bluebird-retry');
|
||||
|
||||
@@ -32,4 +32,4 @@ var options:retry.Options = {
|
||||
interval: 500
|
||||
};
|
||||
|
||||
retry(logFail, options);
|
||||
retry(logFail, options);
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Pascal Vomhoff <https://github.com/pvomhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
declare module "bluebird-retry" {
|
||||
import Promise = require('bluebird');
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+773
@@ -0,0 +1,773 @@
|
||||
// Type definitions for bluebird 2.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, falsandtru <https://github.com/falsandtru>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
|
||||
// By: Campredon <https://github.com/fdecampredon/>
|
||||
|
||||
// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code):
|
||||
// - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1563
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// TODO fix remaining TODO annotations in both definition and test
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
|
||||
interface PromiseCancelHandlerSetter {
|
||||
(handler: () => void): void;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions
|
||||
* `resolve` and `reject` as its arguments which can be called to seal the
|
||||
* fate of the created promise.
|
||||
*
|
||||
* If configured appropriately, it will also receive an `onCancel`
|
||||
* function that can be used to configure a promise cancellation handler.
|
||||
*/
|
||||
new <T>(callback: (
|
||||
resolve: (thenableOrResult?: T | PromiseLike<T>) => void,
|
||||
reject: (error: any) => void,
|
||||
onCancel?: PromiseCancelHandlerSetter
|
||||
) => void): Promise<T>;
|
||||
|
||||
config(options: {
|
||||
warnings?: boolean | {wForgottenReturn?: boolean};
|
||||
longStackTraces?: boolean;
|
||||
cancellation?: boolean;
|
||||
monitoring?: boolean;
|
||||
}): void;
|
||||
|
||||
// Ideally, we'd define e.g. "export class RangeError extends Error {}",
|
||||
// but as Error is defined as an interface (not a class), TypeScript doesn't
|
||||
// allow extending Error, only implementing it.
|
||||
// However, if we want to catch() only a specific error type, we need to pass
|
||||
// a constructor function to it. So, as a workaround, we define them here as such.
|
||||
RangeError(): RangeError;
|
||||
CancellationError(): Promise.CancellationError;
|
||||
TimeoutError(): Promise.TimeoutError;
|
||||
TypeError(): Promise.TypeError;
|
||||
RejectionError(): Promise.RejectionError;
|
||||
OperationalError(): Promise.OperationalError;
|
||||
|
||||
/**
|
||||
* Changes how bluebird schedules calls a-synchronously.
|
||||
*
|
||||
* @param scheduler Should be a function that asynchronously schedules
|
||||
* the calling of the passed in function
|
||||
*/
|
||||
setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
*
|
||||
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
|
||||
*
|
||||
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
try<T>(fn: () => T | PromiseLike<T>, args?: any[], ctx?: any): Promise<T>;
|
||||
|
||||
attempt<T>(fn: () => T | PromiseLike<T>, args?: any[], ctx?: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
|
||||
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
|
||||
*/
|
||||
method(fn: Function): Function;
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
resolve(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Create a promise that is rejected with the given `reason`.
|
||||
*/
|
||||
reject(reason: any): Promise<any>;
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
|
||||
*/
|
||||
defer<T>(): Promise.Resolver<T>;
|
||||
|
||||
/**
|
||||
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
|
||||
*/
|
||||
cast<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
|
||||
*/
|
||||
bind(thisArg: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* See if `value` is a trusted Promise.
|
||||
*/
|
||||
is(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
|
||||
*/
|
||||
longStackTraces(): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
delay<T>(ms: number, value: T | PromiseLike<T>): Promise<T>;
|
||||
delay(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
|
||||
*
|
||||
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
|
||||
*
|
||||
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
|
||||
*/
|
||||
promisify<T>(func: (callback: (err: any, result: T) => void) => void, receiver?: any): () => Promise<T>;
|
||||
promisify<T, A1>(func: (arg1: A1, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1) => Promise<T>;
|
||||
promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2) => Promise<T>;
|
||||
promisify<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3) => Promise<T>;
|
||||
promisify<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Promise<T>;
|
||||
promisify<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Promise<T>;
|
||||
promisify(nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
/**
|
||||
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
|
||||
*
|
||||
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
|
||||
*/
|
||||
// TODO how to model promisifyAll?
|
||||
promisifyAll(target: Object, options?: Promise.PromisifyAllOptions): any;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a promise that is resolved by a node style callback function.
|
||||
*/
|
||||
fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise<any>;
|
||||
fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise<any>;
|
||||
|
||||
/**
|
||||
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix coroutine GeneratorFunction
|
||||
coroutine<T>(generatorFunction: Function): Function;
|
||||
|
||||
/**
|
||||
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix spawn GeneratorFunction
|
||||
spawn<T>(generatorFunction: Function): Promise<T>;
|
||||
|
||||
/**
|
||||
* This is relevant to browser environments with no module loader.
|
||||
*
|
||||
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
|
||||
*/
|
||||
noConflict(): typeof Promise;
|
||||
|
||||
/**
|
||||
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
|
||||
*
|
||||
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
|
||||
*/
|
||||
onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
// promise of array with promises of value
|
||||
all<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T[]>;
|
||||
// promise of array with values
|
||||
all<T>(values: PromiseLike<T[]>): Promise<T[]>;
|
||||
// array with promises of value
|
||||
all<T>(values: PromiseLike<T>[]): Promise<T[]>;
|
||||
// array with promises of different types
|
||||
all<T1, T2, T3, T4, T5>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>, PromiseLike<T4>, PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
all<T1, T2, T3, T4>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>, PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
all<T1, T2, T3>(values: [PromiseLike<T1>, PromiseLike<T2>, PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
all<T1, T2>(values: [PromiseLike<T1>, PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
// array with values
|
||||
all<T>(values: T[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
|
||||
*
|
||||
* *The original object is not modified.*
|
||||
*/
|
||||
// TODO verify this is correct
|
||||
// trusted promise for object
|
||||
props(object: Promise<Object>): Promise<Object>;
|
||||
// object
|
||||
props(object: Object): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
|
||||
*
|
||||
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
settle<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<Promise.Inspection<T>[]>;
|
||||
// promise of array with values
|
||||
settle<T>(values: PromiseLike<T[]>): Promise<Promise.Inspection<T>[]>;
|
||||
// array with promises of value
|
||||
settle<T>(values: PromiseLike<T>[]): Promise<Promise.Inspection<T>[]>;
|
||||
// array with values
|
||||
settle<T>(values: T[]): Promise<Promise.Inspection<T>[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
any<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T>;
|
||||
// promise of array with values
|
||||
any<T>(values: PromiseLike<T[]>): Promise<T>;
|
||||
// array with promises of value
|
||||
any<T>(values: PromiseLike<T>[]): Promise<T>;
|
||||
// array with values
|
||||
any<T>(values: T[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
|
||||
*
|
||||
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
race<T>(values: PromiseLike<PromiseLike<T>[]>): Promise<T>;
|
||||
// promise of array with values
|
||||
race<T>(values: PromiseLike<T[]>): Promise<T>;
|
||||
// array with promises of value
|
||||
race<T>(values: PromiseLike<T>[]): Promise<T>;
|
||||
// array with values
|
||||
race<T>(values: T[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
|
||||
*
|
||||
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
some<T>(values: PromiseLike<PromiseLike<T>[]>, count: number): Promise<T[]>;
|
||||
// promise of array with values
|
||||
some<T>(values: PromiseLike<T[]>, count: number): Promise<T[]>;
|
||||
// array with promises of value
|
||||
some<T>(values: PromiseLike<T>[], count: number): Promise<T[]>;
|
||||
// array with values
|
||||
some<T>(values: T[], count: number): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
|
||||
*/
|
||||
// variadic array with promises of value
|
||||
join<T>(...values: PromiseLike<T>[]): Promise<T[]>;
|
||||
// variadic array with values
|
||||
join<T>(...values: T[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
map<T, U>(values: PromiseLike<PromiseLike<T>[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
map<T, U>(values: PromiseLike<T[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
map<T, U>(values: PromiseLike<T>[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
map<T, U>(values: T[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
mapSeries<R, U>(values: PromiseLike<PromiseLike<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
mapSeries<R, U>(values: PromiseLike<R[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
mapSeries<R, U>(values: PromiseLike<R>[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
mapSeries<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
|
||||
/**
|
||||
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*
|
||||
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
reduce<T, U>(values: PromiseLike<PromiseLike<T>[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// promise of array with values
|
||||
reduce<T, U>(values: PromiseLike<T[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with promises of value
|
||||
reduce<T, U>(values: PromiseLike<T>[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with values
|
||||
reduce<T, U>(values: T[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
|
||||
*
|
||||
* *The original array is not modified.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
filter<T>(values: PromiseLike<PromiseLike<T>[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// promise of array with values
|
||||
filter<T>(values: PromiseLike<T[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// array with promises of value
|
||||
filter<T>(values: PromiseLike<T>[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
// array with values
|
||||
filter<T>(values: T[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Promise.ConcurrencyOption): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
each<T, U>(values: PromiseLike<PromiseLike<T>[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
// array with promises of value
|
||||
each<T, U>(values: PromiseLike<T>[], iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
// array with values OR promise of array with values
|
||||
each<T, U>(values: T[] | PromiseLike<T[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
}
|
||||
|
||||
interface Promise<T> extends PromiseLike<T>, Promise.Inspection<T> {
|
||||
/**
|
||||
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => U | PromiseLike<U>, onReject?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: T) => U | PromiseLike<U>, onReject?: (error: any) => void | PromiseLike<void>, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch(onReject?: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(onReject?: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(onReject?: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(onReject?: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
/**
|
||||
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
|
||||
*
|
||||
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
catch(ErrorClass: Function, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
caught(ErrorClass: Function, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Promise<T>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => U | PromiseLike<U>): Promise<U | T>;
|
||||
|
||||
|
||||
/**
|
||||
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
|
||||
*/
|
||||
error<U>(onReject: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
error<U>(onReject: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally<U>(handler: () => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
lastly<U>(handler: () => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
*/
|
||||
bind(thisArg: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled?: (value: T) => PromiseLike<U>, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): void;
|
||||
|
||||
/**
|
||||
* Like `.finally()`, but not called for rejections.
|
||||
*/
|
||||
tap<U>(onFulFill: (value: T) => U | PromiseLike<U>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
*/
|
||||
progressed(handler: (note: any) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
delay(ms: number): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
|
||||
*
|
||||
* You may specify a custom error message with the `message` parameter.
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<T>;
|
||||
|
||||
/**
|
||||
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
|
||||
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
|
||||
*/
|
||||
nodeify(callback: (err: any, value?: T) => void, options?: Promise.SpreadOption): Promise<T>;
|
||||
nodeify(...sink: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
|
||||
*/
|
||||
cancellable(): Promise<T>;
|
||||
|
||||
/**
|
||||
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
|
||||
*
|
||||
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
|
||||
*
|
||||
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
|
||||
*
|
||||
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
|
||||
*/
|
||||
// TODO what to do with this?
|
||||
cancel<U>(reason?: any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
|
||||
*/
|
||||
fork<U>(onFulfilled?: (value: T) => U | PromiseLike<U>, onRejected?: (error: any) => U | PromiseLike<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Create an uncancellable promise based on this promise.
|
||||
*/
|
||||
uncancellable(): Promise<T>;
|
||||
|
||||
/**
|
||||
* See if this promise can be cancelled.
|
||||
*/
|
||||
isCancellable(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been fulfilled.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been rejected.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is still defer.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is resolved -> either fulfilled or rejected.
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): T;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
inspect(): Promise.Inspection<T>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName].call(obj, arg...);
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
call(propertyName: string, ...args: any[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName];
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
// TODO find way to fix get()
|
||||
// get<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
|
||||
*
|
||||
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
return(): Promise<any>;
|
||||
thenReturn(): Promise<any>;
|
||||
return<U>(value: U): Promise<U>;
|
||||
thenReturn<U>(value: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.return()`.
|
||||
*
|
||||
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
throw(reason: Error): Promise<T>;
|
||||
thenThrow(reason: Error): Promise<T>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
|
||||
/**
|
||||
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
|
||||
*/
|
||||
// TODO how to model instance.spread()? like Q?
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => U | PromiseLike<U>): Promise<U>;
|
||||
/*
|
||||
// TODO or something like this?
|
||||
spread<U, W>(onFulfill: (...values: W[]) => PromiseLike<U>, onReject?: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => PromiseLike<U>, onReject?: (reason: any) => U): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => PromiseLike<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
|
||||
*/
|
||||
/**
|
||||
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
all<U>(): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO how to model instance.props()?
|
||||
props(): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
settle<U>(): Promise<Promise.Inspection<U>[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
any<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
some<U>(count: number): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
race<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as `Promise.mapSeries(thisPromise, mapper)`.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
mapSeries<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, options?: Promise.ConcurrencyOption): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
each<T, U>(iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike<U>): Promise<T[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use variable namespace such as variables, functions, and classes.
|
||||
* If you use this namespace, it will conflict in es6.
|
||||
*/
|
||||
declare namespace Promise {
|
||||
export interface RangeError extends Error {
|
||||
}
|
||||
export interface CancellationError extends Error {
|
||||
}
|
||||
export interface TimeoutError extends Error {
|
||||
}
|
||||
export interface TypeError extends Error {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
export interface OperationalError extends Error {
|
||||
}
|
||||
|
||||
export interface ConcurrencyOption {
|
||||
concurrency: number;
|
||||
}
|
||||
export interface SpreadOption {
|
||||
spread: boolean;
|
||||
}
|
||||
export interface PromisifyAllOptions {
|
||||
suffix?: string;
|
||||
filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean;
|
||||
// The promisifier gets a reference to the original method and should return a function which returns a promise
|
||||
promisifier?: (originalMethod: Function) => () => PromiseLike<any>;
|
||||
}
|
||||
|
||||
export interface Resolver<T> {
|
||||
/**
|
||||
* Returns a reference to the controlled promise that can be passed to clients.
|
||||
*/
|
||||
promise: Promise<T>;
|
||||
|
||||
/**
|
||||
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
|
||||
*/
|
||||
resolve(value: T): void;
|
||||
resolve(): void;
|
||||
|
||||
/**
|
||||
* Reject the underlying promise with `reason` as the rejection reason.
|
||||
*/
|
||||
reject(reason: any): void;
|
||||
|
||||
/**
|
||||
* Progress the underlying promise with `value` as the progression value.
|
||||
*/
|
||||
progress(value: any): void;
|
||||
|
||||
/**
|
||||
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
|
||||
*
|
||||
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
|
||||
*/
|
||||
// TODO specify resolver callback
|
||||
callback: (err: any, value: T, ...values: T[]) => void;
|
||||
}
|
||||
|
||||
export interface Inspection<T> {
|
||||
/**
|
||||
* See if the underlying promise was fulfilled at the creation time of this inspection object.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was rejected at the creation time of this inspection object.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was defer at the creation time of this inspection object.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): T;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
+10
-128
@@ -7,6 +7,8 @@
|
||||
|
||||
// Note: try to maintain the ordering and separators, and keep to the pattern
|
||||
|
||||
import Promise = require("bluebird");
|
||||
|
||||
var obj: Object;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
@@ -80,6 +82,7 @@ var voidProm: Promise<void>;
|
||||
|
||||
var fooProm: Promise<Foo>;
|
||||
var barProm: Promise<Bar>;
|
||||
var barOrVoidProm: Promise<Bar | void>;
|
||||
var fooOrBarProm: Promise<Foo|Bar>;
|
||||
var bazProm: Promise<Baz>;
|
||||
|
||||
@@ -141,7 +144,7 @@ var fooResolver: Promise.Resolver<Foo>;
|
||||
var barResolver: Promise.Resolver<Bar>;
|
||||
|
||||
var fooInspection: Promise.Inspection<Foo>;
|
||||
var barInspection: Promise.Inspection<Bar>;
|
||||
var fooInspectionPromise: Promise<Promise.Inspection<Foo>>;
|
||||
|
||||
var fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
|
||||
var barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
|
||||
@@ -195,8 +198,6 @@ fooResolver.resolve(foo);
|
||||
|
||||
fooResolver.reject(err);
|
||||
|
||||
fooResolver.progress(bar);
|
||||
|
||||
fooResolver.callback = (err: any, value: Foo) => {
|
||||
|
||||
};
|
||||
@@ -204,24 +205,13 @@ fooResolver.callback = (err: any, value: Foo) => {
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooInspection.isFulfilled();
|
||||
|
||||
bool = fooInspection.isRejected();
|
||||
|
||||
bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.reason();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
@@ -232,12 +222,12 @@ barProm = fooProm.then((value: Foo) => {
|
||||
}, (reason: any) => {
|
||||
return barProm;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
barOrVoidProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
barOrVoidProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return voidProm;
|
||||
@@ -384,13 +374,6 @@ fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
@@ -402,13 +385,6 @@ voidVar = fooProm.done((value: Foo) => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
@@ -436,11 +412,6 @@ fooProm = fooProm.tap(() => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
return foo;
|
||||
});
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -460,52 +431,11 @@ fooProm = fooProm.nodeify((err: any, foo?: Foo) => { }, { spread: true });
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
voidVar = fooProm.cancel();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.cancel<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.cancellable();
|
||||
fooProm = fooProm.uncancellable();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooProm.isCancellable();
|
||||
bool = fooProm.isCancelled();
|
||||
bool = fooProm.isFulfilled();
|
||||
bool = fooProm.isRejected();
|
||||
bool = fooProm.isPending();
|
||||
@@ -513,8 +443,6 @@ bool = fooProm.isResolved();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooInspection = fooProm.inspect();
|
||||
|
||||
anyProm = fooProm.call(str);
|
||||
anyProm = fooProm.call(str, 1, 2, 3);
|
||||
|
||||
@@ -543,22 +471,12 @@ obj = fooProm.toJSON();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
@@ -568,15 +486,10 @@ barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.all<Bar>();
|
||||
|
||||
objProm = fooProm.props();
|
||||
|
||||
barInspectionArrProm = fooProm.settle<Bar>();
|
||||
|
||||
fooInspectionPromise = fooProm.reflect();
|
||||
barProm = fooProm.any<Bar>();
|
||||
|
||||
barArrProm = fooProm.some<Bar>(num);
|
||||
|
||||
barProm = fooProm.race<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -686,24 +599,12 @@ fooProm = Promise.try<Foo>(() => {
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -725,12 +626,6 @@ fooProm = Promise.attempt<Foo>(() => {
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -746,12 +641,6 @@ fooProm = Promise.attempt(() => {
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -847,6 +736,7 @@ obj = Promise.promisifyAll(obj, {
|
||||
*/
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
BlueBird = Promise.getNewLibraryCopy();
|
||||
BlueBird = Promise.noConflict();
|
||||
|
||||
Promise.onPossiblyUnhandledRejection((reason: any) => {
|
||||
@@ -868,14 +758,6 @@ objProm = Promise.props(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooInspectionArrProm = Promise.settle(fooThenArrThen);
|
||||
fooInspectionArrProm = Promise.settle(fooArrProm);
|
||||
fooInspectionArrProm = Promise.settle(fooThenArr);
|
||||
fooInspectionArrProm = Promise.settle(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.any(fooThenArrThen);
|
||||
fooProm = Promise.any(fooArrProm);
|
||||
|
||||
Vendored
+732
-730
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Andrew Schurman <http://github.com/arcticwaters>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird-2.0.d.ts" />
|
||||
/// <reference path='../lodash/lodash-3.10.d.ts' />
|
||||
/// <reference path="../knex/knex.d.ts" />
|
||||
/// <reference path="../create-error/create-error.d.ts" />
|
||||
|
||||
Vendored
+5
-2
@@ -44,14 +44,17 @@ declare namespace Boom {
|
||||
export function rangeNotSatisfiable(message?: string, data?: any): BoomError;
|
||||
export function expectationFailed(message?: string, data?: any): BoomError;
|
||||
export function badData(message?: string, data?: any): BoomError;
|
||||
export function locked(message?: string, data?: any): BoomError;
|
||||
export function preconditionRequired(message?: string, data?: any): BoomError;
|
||||
export function tooManyRequests(message?: string, data?: any): BoomError;
|
||||
export function illegal(message?: string, data?: any): BoomError;
|
||||
|
||||
// 5xx
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
export function notImplemented(message?: string, data?: any): BoomError;
|
||||
export function badGateway(message?: string, data?: any): BoomError;
|
||||
export function serverTimeout(message?: string, data?: any): BoomError;
|
||||
export function serverUnavailable(message?: string, data?: any): BoomError;
|
||||
export function gatewayTimeout(message?: string, data?: any): BoomError;
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
}
|
||||
|
||||
declare module "boom" {
|
||||
|
||||
Vendored
+1
-1
@@ -9,7 +9,7 @@
|
||||
interface BootboxBaseOptions {
|
||||
title?: string | Element;
|
||||
callback?: (result: boolean | string) => any;
|
||||
onEscape?: () => any | boolean;
|
||||
onEscape?: (() => any) | boolean;
|
||||
show?: boolean;
|
||||
backdrop?: boolean;
|
||||
closeButton?: boolean;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/// <reference path="bootstrap.datepicker.d.ts"/>
|
||||
/// <reference path="bootstrap-datepicker.d.ts"/>
|
||||
|
||||
function tests_simple() {
|
||||
$('#datepicker').datepicker();
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bootstrap.datepicker
|
||||
// Type definitions for bootstrap-datepicker
|
||||
// Project: https://github.com/eternicode/bootstrap-datepicker
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
+1
-1
@@ -35,7 +35,7 @@ interface SliderOptions {
|
||||
* Default: 'horizontal'
|
||||
* set the orientation. Accepts 'vertical' or 'horizontal'
|
||||
*/
|
||||
orientation?: number;
|
||||
orientation?: string;
|
||||
/**
|
||||
* Default: 5
|
||||
* initial value. Use array to have a range slider.
|
||||
|
||||
@@ -7,3 +7,13 @@ Bowser.test(['msie']) === true;
|
||||
Bowser.a === Bowser.c;
|
||||
Bowser.osversion > 10;
|
||||
Bowser.osversion === '10.1A';
|
||||
|
||||
bowser.msedge === true;
|
||||
bowser.test(['msie']) === true;
|
||||
bowser.a === bowser.c;
|
||||
bowser.osversion > 10;
|
||||
bowser.osversion === '10.1A';
|
||||
bowser.compareVersions(['9.0', '10']);
|
||||
bowser() === <BowserModule.IBowserDetection>{android: true, x: true};
|
||||
bowser.check({msie: "11"}, window.navigator.userAgent);
|
||||
bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);
|
||||
Vendored
+71
-19
@@ -3,52 +3,104 @@
|
||||
// Definitions by: Paulo Cesar <https://github.com/pocesar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var bowser: BowserModule.IBowser;
|
||||
|
||||
declare module 'bowser' {
|
||||
var def: BowserModule.IBowser;
|
||||
export = def;
|
||||
export = bowser;
|
||||
}
|
||||
|
||||
declare namespace BowserModule {
|
||||
|
||||
export interface IBowserUA {
|
||||
msie: boolean;
|
||||
export interface IBowserOS {
|
||||
mac: boolean;
|
||||
/**other than Windows Phone */
|
||||
windows: boolean;
|
||||
windowsphone: boolean;
|
||||
/**other than android, chromeos, webos, tizen, and sailfish */
|
||||
linux: boolean;
|
||||
chromeos: boolean;
|
||||
android: boolean;
|
||||
/** also sets one of iphone/ipad/ipod */
|
||||
ios: boolean;
|
||||
blackberry: boolean;
|
||||
firefoxos: boolean;
|
||||
/** may also set touchpad */
|
||||
webos: boolean;
|
||||
bada: boolean;
|
||||
tizen: boolean;
|
||||
sailfish: boolean;
|
||||
}
|
||||
|
||||
export interface IBowserVersions {
|
||||
chrome: boolean;
|
||||
webkit: boolean;
|
||||
phantom: boolean;
|
||||
opera: boolean;
|
||||
firefox: boolean;
|
||||
msie: boolean;
|
||||
msedge: boolean;
|
||||
safari: boolean;
|
||||
android: boolean;
|
||||
ios: boolean;
|
||||
webos: boolean;
|
||||
msedge: boolean;
|
||||
seamonkey: boolean;
|
||||
firefox: boolean;
|
||||
yandexbrowser: boolean;
|
||||
opera: boolean;
|
||||
phantom: boolean;
|
||||
blackberry: boolean;
|
||||
tablet: boolean;
|
||||
mobile: boolean;
|
||||
webos: boolean;
|
||||
silk: boolean;
|
||||
bada: boolean;
|
||||
tizen: boolean;
|
||||
windowsphone: boolean;
|
||||
firefoxos: boolean;
|
||||
gecko: boolean;
|
||||
seamonkey: boolean;
|
||||
sailfish: boolean;
|
||||
chromeBook: boolean;
|
||||
ucbrowser: boolean;
|
||||
qupzilla: boolean;
|
||||
vivaldi: boolean;
|
||||
sleipnir: boolean;
|
||||
kMeleon: boolean;
|
||||
}
|
||||
|
||||
export interface IBowserEngines {
|
||||
/** IE <= 11 */
|
||||
msie: boolean;
|
||||
/**Chrome 0-27, Android <4.4, iOs, BB, etc. */
|
||||
webkit: boolean;
|
||||
/**Chrome >=28, Android >=4.4, Opera, etc. */
|
||||
blink: boolean;
|
||||
/**Firefox, etc. */
|
||||
gecko: boolean;
|
||||
/** IE > 11 */
|
||||
msedge: boolean;
|
||||
/** If a tablet device is detected, the flag tablet is set instead of mobile. */
|
||||
tablet: boolean;
|
||||
/** All detected mobile OSes are additionally flagged mobile, unless it's a tablet */
|
||||
mobile: boolean;
|
||||
|
||||
}
|
||||
|
||||
export interface IBowserGrade {
|
||||
/** Grade A browser */
|
||||
a: boolean;
|
||||
/** Grade C browser */
|
||||
c: boolean;
|
||||
/** Grade X browser */
|
||||
x: boolean;
|
||||
/**A human readable name for this browser. E.g. 'Chrome', '' */
|
||||
name: string;
|
||||
/**Version number for the browser. E.g. '32.0' */
|
||||
version: string|number;
|
||||
osversion: string|number;
|
||||
}
|
||||
|
||||
export interface IBowser extends IBowserUA {
|
||||
export interface IBowserDetection extends IBowserGrade, IBowserEngines, IBowserOS, IBowserVersions { }
|
||||
|
||||
export interface IBowserMinVersions {
|
||||
// { msie: "11", "firefox": "4" }
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
export interface IBowser extends IBowserDetection {
|
||||
(): IBowserDetection;
|
||||
test(browserList: string[]): boolean;
|
||||
_detect(ua: string): IBowser;
|
||||
compareVersions(versions: string[]): number;
|
||||
check(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): Boolean;
|
||||
isUnsupportedBrowser(minVersions: IBowserMinVersions, strictMode?: boolean|string, ua?: string): boolean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
/// <reference path="braintree-web.d.ts" />
|
||||
|
||||
let version: string = braintree.VERSION;
|
||||
|
||||
let clientToken: string = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiI0YjlhYzVmYmI4ZTNkYzQzMmFkZjJhNzBlNjZlMWNjY2M5ODRkYzE4ZTM4YmY4NjYzZTM5NjM3NWZjYmQzY2U5fGNyZWF0ZWRfYXQ9MjAxNi0wOS0wOFQwNTowMzo0MC4xNjk1NTUwMzUrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
|
||||
|
||||
braintree.client.create({
|
||||
authorization: clientToken
|
||||
}, function (error: BraintreeError, clientInstance: any) {
|
||||
|
||||
var form: HTMLFormElement = document.getElementById('my-form-id') as HTMLFormElement;
|
||||
var data: { creditCard: BraintreeWeb.CreditCardInfo } = {
|
||||
creditCard: {
|
||||
number: form['cc-number'].value,
|
||||
cvv: form['cc-cvv'].value,
|
||||
expirationDate: form['cc-date'].value,
|
||||
billingAddress: {
|
||||
postalCode: form['cc-postal'].value
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
clientInstance.request({
|
||||
endpoint: 'payment_methods/credit_cards',
|
||||
method: 'post',
|
||||
data: data
|
||||
}, function (requestErr: BraintreeError, response: { creditCards: any[]; }) {
|
||||
if (requestErr) { throw new Error(requestErr.message); }
|
||||
|
||||
console.log('Got nonce:', response.creditCards[0].nonce);
|
||||
});
|
||||
|
||||
braintree.hostedFields.create({
|
||||
client: clientInstance,
|
||||
styles: {
|
||||
'input': {
|
||||
'font-size': '16pt',
|
||||
'color': '#3A3A3A'
|
||||
},
|
||||
|
||||
'.number': {
|
||||
'font-family': 'monospace'
|
||||
},
|
||||
'.valid': {
|
||||
'color': 'green'
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
number: {
|
||||
selector: '#card-number'
|
||||
},
|
||||
cvv: {
|
||||
selector: '#cvv'
|
||||
},
|
||||
expirationDate: {
|
||||
selector: '#expiration-date'
|
||||
}
|
||||
}
|
||||
}, function (hostedFieldsErr?: BraintreeError, hostedFieldsInstance?: any) {
|
||||
|
||||
if (hostedFieldsErr) {
|
||||
// Handle error in Hosted Fields creation
|
||||
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let form = new HTMLFormElement();
|
||||
|
||||
form.addEventListener('submit', function (event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
hostedFieldsInstance.tokenize(function (tokenizeErr: BraintreeError, payload: BraintreeWeb.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
// Handle error in Hosted Fields tokenization
|
||||
switch (tokenizeErr.code) {
|
||||
case 'HOSTED_FIELDS_FIELDS_EMPTY':
|
||||
console.error('All fields are empty! Please fill out the form.');
|
||||
break;
|
||||
case 'HOSTED_FIELDS_FIELDS_INVALID':
|
||||
console.error('Some fields are invalid:', tokenizeErr.details.invalidFieldKeys);
|
||||
break;
|
||||
case 'HOSTED_FIELDS_FAILED_TOKENIZATION':
|
||||
console.error('Tokenization failed server side. Is the card valid?');
|
||||
break;
|
||||
case 'HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR':
|
||||
console.error('Network error occurred when tokenizing.');
|
||||
break;
|
||||
default:
|
||||
console.error('Something bad happened!', tokenizeErr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Put `payload.nonce` into the `payment-method-nonce` input, and then
|
||||
// submit the form. Alternatively, you could send the nonce to your server
|
||||
// with AJAX.
|
||||
(document.querySelector('input[name="payment-method-nonce"]') as HTMLInputElement).value = payload.nonce;
|
||||
form.submit();
|
||||
});
|
||||
}, false);
|
||||
|
||||
hostedFieldsInstance.on('focus', function (event: BraintreeWeb.HostedFieldsStateObject) {
|
||||
console.log(event.emittedBy, 'has been focused');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.teardown(function (teardownErr: BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down Hosted Fields!');
|
||||
} else {
|
||||
console.info('Hosted Fields has been torn down!');
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.tokenize({
|
||||
vault: true
|
||||
}, function (tokenizeErr: BraintreeError, payload: BraintreeWeb.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
} else {
|
||||
console.log('Got nonce:', payload.nonce);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
return;
|
||||
}
|
||||
|
||||
// some time later...
|
||||
hostedFieldsInstance.removeClass('number', 'custom-class');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (placeholderErr: BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
console.error(placeholderErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.on('cardTypeChange', function (event: BraintreeWeb.HostedFieldsStateObject) {
|
||||
// Update the placeholder value if there is only one possible card type
|
||||
if (event.cards.length === 1) {
|
||||
braintree.hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (placeholderErr: BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
// Handle errors, such as invalid field name
|
||||
console.error(placeholderErr);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.clear('number', function (clearErr: BraintreeError) {
|
||||
if (clearErr) {
|
||||
console.error(clearErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.clear('number');
|
||||
hostedFieldsInstance.clear('cvv');
|
||||
hostedFieldsInstance.clear('expirationDate');
|
||||
|
||||
var state = braintree.hostedFields.getState();
|
||||
|
||||
var formValid = Object.keys(state.fields).every(function (key) {
|
||||
return state.fields[key].isValid;
|
||||
});
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr?: BraintreeError, applePayInstance?: any) {
|
||||
if (createErr) {
|
||||
// Handle error in client creation
|
||||
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var paymentRequest = braintree.applePay.createPaymentRequest(request);
|
||||
|
||||
console.log(paymentRequest);
|
||||
// { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr, applePayInstance) {
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new ApplePaySession(1, request);
|
||||
|
||||
session.onvalidatemerchant = function (event: { validationURL: string }) {
|
||||
braintree.applePay.performValidation({
|
||||
validationURL: event.validationURL
|
||||
}, function (err, validationData) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
session.abort();
|
||||
return;
|
||||
}
|
||||
session.completeMerchantValidation(validationData);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr, applePayInstance) {
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new ApplePaySession(1, request);
|
||||
|
||||
session.onpaymentauthorized = function (event) {
|
||||
braintree.applePay.tokenize({
|
||||
token: event.payment.token
|
||||
}, function (err, tokenizedPayload) {
|
||||
if (err) {
|
||||
session.completePayment(ApplePayStatusCodes.STATUS_FAILURE);
|
||||
return;
|
||||
}
|
||||
session.completePayment(ApplePayStatusCodes.STATUS_SUCCESS);
|
||||
|
||||
// Send the tokenizedPayload to your server.
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
braintree.paypal.create({
|
||||
client: clientInstance
|
||||
}, function (createErr, paypalInstance) {
|
||||
if (createErr) {
|
||||
if (createErr.code === 'PAYPAL_BROWSER_NOT_SUPPORTED') {
|
||||
console.error('This browser is not supported.');
|
||||
} else {
|
||||
console.error('Error!', createErr);
|
||||
}
|
||||
}
|
||||
|
||||
let button = new HTMLButtonElement();
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
// Disable the button so that we don't attempt to open multiple popups.
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
|
||||
// Because PayPal tokenization opens a popup, this must be called
|
||||
// as a result of a user action, such as a button click.
|
||||
paypalInstance.tokenize({
|
||||
flow: 'vault' // Required
|
||||
// Any other tokenization options
|
||||
}, function (tokenizeErr: BraintreeError, payload: BraintreeWeb.PayPalTokenizePayload) {
|
||||
button.removeAttribute('disabled');
|
||||
|
||||
if (tokenizeErr) {
|
||||
// Handle tokenization errors or premature flow closure
|
||||
|
||||
switch (tokenizeErr.code) {
|
||||
case 'PAYPAL_POPUP_CLOSED':
|
||||
console.error('Customer closed PayPal popup.');
|
||||
break;
|
||||
case 'PAYPAL_ACCOUNT_TOKENIZATION_FAILED':
|
||||
console.error('PayPal tokenization failed. See details:', tokenizeErr.details);
|
||||
break;
|
||||
case 'PAYPAL_FLOW_FAILED':
|
||||
console.error('Unable to initialize PayPal flow. Are your options correct?', tokenizeErr.details);
|
||||
break;
|
||||
default:
|
||||
console.error('Error!', tokenizeErr);
|
||||
}
|
||||
} else {
|
||||
// Submit payload.nonce to your server
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
braintree.unionpay.create({ client: clientInstance }, function (createErr, unionpayInstance) {
|
||||
if (createErr) {
|
||||
console.error(createErr);
|
||||
return;
|
||||
}
|
||||
|
||||
unionpayInstance.fetchCapabilities({
|
||||
card: {
|
||||
number: '4111111111111111'
|
||||
}
|
||||
}, function (fetchErr: BraintreeError, cardCapabilities: BraintreeWeb.UnionPayFetchCapabilitiesPayload) {
|
||||
if (fetchErr) {
|
||||
console.error(fetchErr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardCapabilities.isUnionPay) {
|
||||
if (cardCapabilities.unionPay && !cardCapabilities.unionPay.isSupported) {
|
||||
// Braintree cannot process this UnionPay card.
|
||||
// Ask the user for a different card.
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardCapabilities.isDebit) {
|
||||
// CVV and expiration date are not required
|
||||
} else {
|
||||
// CVV and expiration date are required
|
||||
}
|
||||
|
||||
// Show mobile phone number field for enrollment
|
||||
}
|
||||
});
|
||||
|
||||
unionpayInstance.enroll({
|
||||
card: {
|
||||
number: '4111111111111111',
|
||||
expirationMonth: '12',
|
||||
expirationYear: '2038'
|
||||
},
|
||||
mobile: {
|
||||
countryCode: '62',
|
||||
number: '111111111111'
|
||||
}
|
||||
}, function (enrollErr: BraintreeError, response: BraintreeWeb.UnionPayEnrollPayload) {
|
||||
if (enrollErr) {
|
||||
console.error(enrollErr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.smsCodeRequired) {
|
||||
// If smsCodeRequired, wait for SMS auth code from customer
|
||||
// Then use response.enrollmentId during {@link UnionPay#tokenize}
|
||||
} else {
|
||||
// SMS code is not required from the user.
|
||||
// {@link UnionPay#tokenize} can be called immediately
|
||||
}
|
||||
});
|
||||
|
||||
let enrollResponse: {
|
||||
enrollmentId: string
|
||||
};
|
||||
|
||||
unionpayInstance.tokenize({
|
||||
card: {
|
||||
number: '4111111111111111',
|
||||
expirationMonth: '12',
|
||||
expirationYear: '2038',
|
||||
cvv: '123'
|
||||
},
|
||||
enrollmentId: enrollResponse.enrollmentId, // Returned from enroll
|
||||
smsCode: '11111' // Received by customer's phone, if SMS enrollment was required. Otherwise it should be omitted
|
||||
}, function (tokenizeErr: BraintreeError, response: BraintreeWeb.UnionPayTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send response.nonce to your server
|
||||
});
|
||||
|
||||
unionpayInstance.teardown(function (teardownErr: BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down UnionPay.');
|
||||
} else {
|
||||
console.log('UnionPay has been torn down.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
let existingNonce = "fake-valid-nonce";
|
||||
let submitNonceToServer: (nonce: string) => void;
|
||||
|
||||
braintree.threeDSecure.verifyCard({
|
||||
nonce: existingNonce,
|
||||
amount: 123.45,
|
||||
addFrame: function (err, iframe) {
|
||||
// Set up your UI and add the iframe.
|
||||
let my3DSContainer = document.createElement('div');
|
||||
my3DSContainer.appendChild(iframe);
|
||||
document.body.appendChild(my3DSContainer);
|
||||
},
|
||||
removeFrame: function () {
|
||||
let my3DSContainer = document.createElement('div');
|
||||
|
||||
// Remove UI that you added in addFrame.
|
||||
document.body.removeChild(my3DSContainer);
|
||||
}
|
||||
}, function (err: BraintreeError, payload: BraintreeWeb.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.liabilityShifted) {
|
||||
// Liablity has shifted
|
||||
submitNonceToServer(payload.nonce);
|
||||
} else if (payload.liabilityShiftPossible) {
|
||||
// Liablity may still be shifted
|
||||
// Decide if you want to submit the nonce
|
||||
} else {
|
||||
// Liablity has not shifted and will not shift
|
||||
// Decide if you want to submit the nonce
|
||||
}
|
||||
});
|
||||
|
||||
braintree.threeDSecure.cancelVerifyCard(function (err: BraintreeError, verifyPayload: BraintreeWeb.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
// Handle error
|
||||
console.log(err.message); // No verification payload available
|
||||
return;
|
||||
}
|
||||
|
||||
verifyPayload.nonce; // The nonce returned from the 3ds lookup call
|
||||
verifyPayload.liabilityShifted; // boolean
|
||||
verifyPayload.liabilityShiftPossible; // boolean
|
||||
});
|
||||
Vendored
+1738
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user