Merge branch 'master_x' into heredatalens

This commit is contained in:
Bernd Hacker
2017-06-08 08:51:25 +02:00
803 changed files with 99559 additions and 16634 deletions
+10 -2
View File
@@ -12,7 +12,6 @@
*.map
*.swp
.DS_Store
npm-debug.log
_Resharper.DefinitelyTyped
bin
@@ -25,19 +24,28 @@ Properties
# test folder
_infrastructure/tests/build
# IntelliJ based IDEs
.idea
*.iml
*.js.map
!*.js/
!scripts/new-package.js
!scripts/not-needed.js
!scripts/lint.js
# npm
node_modules
package-lock.json
npm-debug.log
# Sublime
.sublimets
.settings/launch.json
# Visual Studio Code
.settings/launch.json
.vs
.vscode
# yarn
yarn.lock
+18
View File
@@ -54,6 +54,12 @@
"sourceRepoURL": "http://www.babylonjs.com/",
"asOfVersion": "2.4.1"
},
{
"libraryName": "BigInteger.js",
"typingsPackageName": "big-integer",
"sourceRepoURL": "https://github.com/peterolson/BigInteger.js",
"asOfVersion": "0.0.31"
},
{
"libraryName": "Bugsnag Browser",
"typingsPackageName": "bugsnag-js",
@@ -132,6 +138,12 @@
"sourceRepoURL": "https://github.com/primus/eventemitter3",
"asOfVersion": "2.0.2"
},
{
"libraryName": "express-validator",
"typingsPackageName": "express-validator",
"sourceRepoURL": "https://github.com/ctavan/express-validator",
"asOfVersion": "3.0.0"
},
{
"libraryName": "JSON-Patch",
"typingsPackageName": "fast-json-patch",
@@ -222,6 +234,12 @@
"sourceRepoURL": "https://github.com/blakeembrey/is-upper-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "jquery.ajaxfile",
"typingsPackageName": "jquery.ajaxfile",
"sourceRepoURL": "https://github.com/fpellet/jquery.ajaxFile",
"asOfVersion": "0.2.29"
},
{
"libraryName": "JSNLog",
"typingsPackageName": "jsnlog",
+3 -1
View File
@@ -2643,7 +2643,9 @@ declare namespace AceAjax {
characterWidth: number;
lineHeight: number;
setScrollMargin(top:number, bottom:number, left: number, right: number): void;
screenToTextCoordinates(left: number, top: number): void;
/**
+1
View File
@@ -15,6 +15,7 @@ const aceVirtualRendererTests = {
var renderer = new AceAjax.VirtualRenderer(el);
renderer.setPadding(0);
renderer.setScrollMargin(0,0,0,0)
renderer.setSession(new AceAjax.EditSession("1234"));
var r = renderer.scroller.getBoundingClientRect();
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/optimalbits/node_acl
// Definitions by: Qubo <https://github.com/tkQubo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="bluebird" />
/// <reference types="node"/>
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/rschmukler/agenda
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
+17 -7
View File
@@ -1,13 +1,17 @@
// Type definitions for Alexa SDK for Node.js v1.0.3
// Type definitions for Alexa SDK for Node.js v1.1.0
// Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
// Definitions by: Pete Beegle <https://github.com/petebeegle>
// Definitions by: Pete Beegle <https://github.com/petebeegle>, Huw <https://github.com/hoo29>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export function handler(event: RequestBody, context: Context, callback?: Function): AlexaObject;
export function CreateStateHandler(state: string, obj: any): any;
export var StateString: string;
interface AlexaObject {
type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED";
type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED";
interface AlexaObject extends Handler {
_event: any;
_context: any;
_callback: any;
@@ -74,12 +78,20 @@ interface SessionUser {
interface LaunchRequest extends IRequest { }
interface IntentRequest extends IRequest {
dialogState: DialogStates;
intent: Intent;
}
interface Intent {
interface SlotValue {
confirmationStatus: ConfirmationStatuses;
name: string;
slots: any;
value?: any;
}
interface Intent {
confirmationStatus: ConfirmationStatuses;
name: string;
slots: Record<string, SlotValue>;
}
interface SessionEndedRequest extends IRequest {
@@ -127,5 +139,3 @@ interface Image {
interface Reprompt {
outputSpeech: OutputSpeech;
}
@@ -0,0 +1,34 @@
import * as AVS from "alexa-voice-service";
const options = {
debug: true,
clientId: "",
clientSecret: "",
deviceId: "",
refreshToken: "",
};
const avsInstance = new AVS(options);
avsInstance.on(AVS.EventTypes.RECORD_START, () => {
});
avsInstance.on(AVS.EventTypes.RECORD_STOP, () => {
});
avsInstance.player.on(AVS.Player.EventTypes.PLAY, () => {
});
avsInstance.refreshToken().then((tokens) => {
}).catch((error: Error) => {
});
avsInstance.requestMic();
avsInstance.startRecording();
avsInstance.stopRecording().then((dataView: any) => { });
const dataView = new DataView(new ArrayBuffer(1));
avsInstance.sendAudio(dataView).then(({ xhr, response }: any) => { });
+60
View File
@@ -0,0 +1,60 @@
// Type definitions for alexa-voice-service 0.0
// Project: https://github.com/miguelmota/alexa-voice-service.js
// Definitions by: Dolan Miu <https://github.com/dolanmiu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace AVS;
export = AVS;
declare namespace AVS {
enum EventTypes {
RECORD_STOP, RECORD_START, ERROR, TOKEN_INVALID, LOG, LOGIN, LOGOUT, TOKEN_SET, REFRESH_TOKEN_SET
}
interface AVSParams {
debug: boolean;
clientId: string;
clientSecret: string;
deviceId: string;
refreshToken: string;
}
interface TokenResponse {
token: string;
refreshToken: string;
}
class Player {
on(eventType: Player.EventTypes, callback?: () => void): void;
}
namespace Player {
enum EventTypes {
LOG, ERROR, PLAY, REPLAY, PAUSE, STOP, ENQUEUE, DEQUE
}
}
}
declare class AVS {
player: AVS.Player;
constructor(params: AVS.AVSParams);
on(eventType: AVS.EventTypes, callback?: () => void): void;
refreshToken(): Promise<AVS.TokenResponse>;
requestMic(): Promise<any>;
startRecording(): Promise<void>;
stopRecording(): Promise<DataView | undefined>;
sendAudio(dataView: DataView): Promise<{
xhr: any, response: {
httpVersion: string,
statusCode: string,
statusMessage: string,
method: string,
url: string,
headers: string,
body: string,
boundary: string,
multipart: string
}
}>;
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"alexa-voice-service-tests.ts"
]
}
+66 -57
View File
@@ -1,41 +1,52 @@
import algoliasearch = require('algoliasearch');
import { ClientOptions, SynonymOption, AlgoliaUserKeyOptions, SearchSynonymOptions,
import * as algoliasearch from "algoliasearch";
import { ClientOptions, SynonymOption, AlgoliaUserKeyOptions, SearchSynonymOptions, AlgoliaResponse,
AlgoliaSecuredApiOptions, AlgoliaIndexSettings, AlgoliaQueryParameters, AlgoliaIndex } from "algoliasearch";
var _clientOptions: ClientOptions = {
timeout : 12,
let _algoliaResponse: AlgoliaResponse = {
hits: [{}, {}],
page: 0,
nbHits: 12,
nbPages: 6,
hitsPerPage: 2,
processingTimeMS: 32,
query: "",
params: "",
};
let _clientOptions: ClientOptions = {
timeout: 12,
protocol: "",
httpAgent: ""
httpAgent: "",
};
var _synonymOption: SynonymOption = {
let _synonymOption: SynonymOption = {
forwardToSlaves: false,
replaceExistingSynonyms: false
replaceExistingSynonyms: false,
};
var _algoliaUserKeyOptions : AlgoliaUserKeyOptions = {
let _algoliaUserKeyOptions: AlgoliaUserKeyOptions = {
validity: 0,
maxQueriesPerIPPerHour: 0,
indexes: [""],
queryParameters: { attributesToRetrieve: ["algolia"] },
description: ""
description: "",
};
var _searchSynonymOptions : SearchSynonymOptions = {
let _searchSynonymOptions: SearchSynonymOptions = {
query: "",
page: 0,
type: "",
hitsPerPage: 0
hitsPerPage: 0,
};
var _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
let _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
filters: "",
validUntil: 0,
restrictIndices: "",
userToken: ""
userToken: "",
};
var _algoliaIndexSettings : AlgoliaIndexSettings = {
let _algoliaIndexSettings: AlgoliaIndexSettings = {
attributesToIndex: [""],
attributesforFaceting: [""],
unretrievableAttributes: [""],
@@ -43,12 +54,12 @@ var _algoliaIndexSettings : AlgoliaIndexSettings = {
ranking: [""],
customRanking: [""],
slaves: [""],
maxValuesPerFacet: '',
maxValuesPerFacet: "",
attributesToHighlight: [""],
attributesToSnippet: [""],
highlightPreTag: '',
highlightPostTag: '',
snippetEllipsisText: '',
highlightPreTag: "",
highlightPostTag: "",
snippetEllipsisText: "",
restrictHighlightAndSnippetArrays: false,
hitsPerPage: 0,
minWordSizefor1Typo: 0,
@@ -56,16 +67,16 @@ var _algoliaIndexSettings : AlgoliaIndexSettings = {
typoTolerance: false,
allowTyposOnNumericTokens: false,
ignorePlurals: false,
disableTypoToleranceOnAttributes: '',
separatorsToIndex: '',
queryType: '',
removeWordsIfNoResults: '',
disableTypoToleranceOnAttributes: "",
separatorsToIndex: "",
queryType: "",
removeWordsIfNoResults: "",
advancedSyntax: false,
optionalWords: [""],
removeStopWords: [""],
disablePrefixOnAttributes: [""],
disableExactOnAttributes: [""],
exactOnSingleWordQuery: '',
exactOnSingleWordQuery: "",
alternativesAsExact: false,
attributeForDistinct: "",
distinct: false,
@@ -73,21 +84,21 @@ var _algoliaIndexSettings : AlgoliaIndexSettings = {
allowCompressionOfIntegerArray: false,
altCorrections: [{}],
minProximity: 0,
placeholders: ''
placeholders: "",
};
var _algoliaQueryParameters : AlgoliaQueryParameters = {
query: '',
filters: '',
let _algoliaQueryParameters: AlgoliaQueryParameters = {
query: "",
filters: "",
attributesToRetrieve: [""],
restrictSearchableAttributes: [""],
facets: '',
maxValuesPerFacet: '',
attributesToHighlight: [''],
attributesToSnippet: [''],
highlightPreTag: '',
highlightPostTag: '',
snippetEllipsisText: '',
facets: "",
maxValuesPerFacet: "",
attributesToHighlight: [""],
attributesToSnippet: [""],
highlightPreTag: "",
highlightPostTag: "",
snippetEllipsisText: "",
restrictHighlightAndSnippetArrays: false,
hitsPerPage: 0,
page: 0,
@@ -98,38 +109,36 @@ var _algoliaQueryParameters : AlgoliaQueryParameters = {
typoTolerance: false,
allowTyposOnNumericTokens: false,
ignorePlurals: false,
disableTypoToleranceOnAttributes: '',
aroundLatLng: '',
aroundLatLngViaIP: '',
aroundRadius: '',
disableTypoToleranceOnAttributes: "",
aroundLatLng: "",
aroundLatLngViaIP: "",
aroundRadius: "",
aroundPrecision: 0,
minimumAroundRadius: 0,
insideBoundingBox: '',
queryType: '',
insidePolygon: '',
removeWordsIfNoResults: '',
insideBoundingBox: "",
queryType: "",
insidePolygon: "",
removeWordsIfNoResults: "",
advancedSyntax: false,
optionalWords: [''],
removeStopWords: [''],
disableExactOnAttributes: [''],
exactOnSingleWordQuery: '',
optionalWords: [""],
removeStopWords: [""],
disableExactOnAttributes: [""],
exactOnSingleWordQuery: "",
alternativesAsExact: true,
distinct: 0,
getRankingInfo: false,
numericAttributesToIndex: [''],
numericFilters: [''],
tagFilters: '',
facetFilters: '',
numericAttributesToIndex: [""],
numericFilters: [""],
tagFilters: "",
facetFilters: "",
analytics: false,
analyticsTags: [''],
analyticsTags: [""],
synonyms: true,
replaceSynonymsInHighlight: false,
minProximity: 0
minProximity: 0,
};
var index: AlgoliaIndex = algoliasearch('', '').initIndex('');
var search = index.search({query: ""});
index.search({query: ""}, function(err, res){});
let index: AlgoliaIndex = algoliasearch("", "").initIndex("");
let search = index.search({query: ""});
index.search({query: ""}, (err, res) => {});
+3 -3
View File
@@ -24,7 +24,7 @@ declare namespace algoliasearch {
* Number of pages
* https://github.com/algolia/algoliasearch-client-js#response-format
*/
nbPage: number;
nbPages: number;
/**
* Number of hits per pages
* https://github.com/algolia/algoliasearch-client-js#response-format
@@ -407,7 +407,7 @@ declare namespace algoliasearch {
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#save-synonym---savesynonym
*/
saveSynonym(synonym: AlgoliaSynonym, option: SynonymOption, cb: (err: Error, res: any) => void): void;
saveSynonym(synonym: AlgoliaSynonym, options: SynonymOption, cb: (err: Error, res: any) => void): void;
/**
* Save a synonym object
* @param synonyms
@@ -659,7 +659,7 @@ declare namespace algoliasearch {
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#save-synonym---savesynonym
*/
saveSynonym(synonym: AlgoliaSynonym, option: SynonymOption): Promise<any> ;
saveSynonym(synonym: AlgoliaSynonym, options: SynonymOption): Promise<any> ;
/**
* Save a synonym object
* @param synonyms
+1 -1
View File
@@ -119,7 +119,7 @@ interface ExtendedTestStore extends AltJS.AltStore<AltTestState> {
split():Array<string>;
}
var testStore = <ExtendedTestStore>alt.createStore<AltTestState>(TestStore);
var testStore = <ExtendedTestStore>alt.createStore<AltTestState>(new TestStore());
function testCallback(state:AltTestState) {
console.log(state);
+4
View File
@@ -2271,6 +2271,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
hideBulletsCount: number;
/** Name of the high field (used by candlesticks and ohlc) in your dataProvider. */
highField: string;
/** Unique id of a graph. It is not required to set one, unless you want to use this graph for as your scrollbar's graph and need to indicate which graph should be used.*/
id?: string;
/** Whether to include this graph when calculating min and max value of the axis.
@default true
*/
+69
View File
@@ -0,0 +1,69 @@
import * as amqp from 'amqp';
async function connect() {
const promise = new Promise<amqp.AMQPClient>((resolve, reject) => {
const client = amqp.createConnection({
url: 'amqp://admin:password@localhost:5672'
});
client.once('error', reject);
client.once('ready', resolve);
});
return promise;
}
async function start() {
try {
const client = await connect();
console.log('Connected');
const queue = client.queue('perth-now',
{
autoDelete: false,
durable: true,
}, q => {
console.log('Queue opened');
console.log('Name: %s Channel: %s', q.name, q.channel);
queue.bind('amq.fanout', '#', () => {
queue.subscribe(
{ ack: true },
(msg, _, __, ack) => {
ack.acknowledge(true);
});
});
});
const exchange = client.exchange('amq.fanout', { confirm: true });
exchange.once('open', () => {
exchange.publish(
'content',
{ message: new Date().toLocaleTimeString() },
{ deliveryMode: 2 },
(err, msg) => {
if (!err) {
return;
}
throw new Error(`Failed to publish: ${msg}`);
}
);
exchange.publish('content', { message: 'content message' }, () => {
console.log('Published');
});
});
} catch (ex) {
console.log(ex);
process.exit(1);
}
}
async function wait(ms: number) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
start();
+419
View File
@@ -0,0 +1,419 @@
// Type definitions for amqp 0.2
// Project: https://github.com/postwait/node-amqp
// Definitions by: Carl Winkler <https://github.com/seikho>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as net from 'net';
import * as events from 'events';
export type Callback<T> = (value: T) => void;
export interface AMQPClient extends net.Socket {
publish(routingKey: string, body: any, options: {}, callback: (err?: boolean, msg?: string) => void): void;
disconnect(): void;
queue(queueName: string, callback?: Callback<QueueCallback>): AMQPQueue;
queue(queueName: string, options: QueueOptions, callback?: Callback<QueueCallback>): AMQPQueue;
exchange(callback?: Callback<void>): AMQPExchange;
exchange(exchangeName: string, callback?: Callback<void>): AMQPExchange;
exchange(exchangeName: string, options: ExchangeOptions, callback?: Callback<void>): AMQPExchange;
}
export interface AMQPQueue extends events.EventEmitter {
subscribe(callback: SubscribeCallback): void;
subscribe(options: SubscribeOptions, callback: SubscribeCallback): void;
unsubscribe(consumerTag: string): void;
bind(exchangeName: string, routingKey: string, callback?: Callback<AMQPQueue>): void;
bind(routingKey: string, callback?: Callback<AMQPQueue>): void;
unbind(exchangeName: string, routingKey: string): void;
unbind(routingKey: string): void;
bind_headers(exchangeName: string, routingKey: string): void;
bind_headers(routingKey: string): void;
unbind_headers(exchangeName: string, routingKey: string): void;
unbind_headers(routingKey: string): void;
shift(reject: boolean): void;
shift(reject: boolean, requeue: boolean): void;
destroy(options?: DestroyOptions): void;
}
export interface AMQPExchange extends events.EventEmitter {
on(event: 'open' | 'ack' | 'error' | 'exchangeBindOk' | 'exchangeUnbindOk', callback: Callback<void>): this;
publish(routingKey: string, message: Buffer | {}, options: ExchangePublishOptions, callback?: (err?: boolean, msg?: string) => void): void;
/**
* ifUnused default: true
*
* Deletes an exchange.
*
* If the optional boolean second argument is set, the server will only delete the exchange if it has no queue bindings.
*
* If the exchange has queue bindings the server does not delete it but raises a channel exception instead
*/
destroy(ifUnused: boolean): void;
bind(sourceExchange: string, routingKey: string, callback?: Callback<void>): void;
unbind(sourceExchange: string, routingKey: string, callback?: Callback<void>): void;
bind_headers(exchange: string, routing: string, callback?: Callback<void>): void;
}
export function createConnection(options: ConnectionOptions): AMQPClient;
export interface DeliveryInfo {
contentType: string;
consumerTag: string;
deliveryTag: Uint8Array;
exchange: string;
queue: string;
redelivered: boolean;
routingKey: string;
}
export interface Ack extends DeliveryInfo {
acknowledge(all: boolean): void;
reject(requeue: boolean): void;
}
export interface ConnectionOptions {
host?: string;
url?: string;
port?: number;
login?: string;
passowrd?: string;
connectionTimeout?: number;
authMechanism?: string;
vhost?: string;
noDelay?: boolean;
ssl?: {
enabled: boolean;
keyFile?: string;
certFile?: string;
caFile?: string;
rejectUnauthorized?: boolean;
};
/** Default: 'node-amqp' */
product?: string;
/** Default: 'node-{NODE_VERSION}' */
platform?: string;
/** Default: node-amqp/package.json version */
version?: string;
defaultExchangeName?: string;
/** Default: true */
reconnect?: boolean;
/** Default: 'linear' */
reconnectBackoffStrategy?: string;
/** Default: 120000 */
reconnectExponentialLimit?: number;
/** Default: 1000 */
reconnectBackoffTime?: number;
}
export interface QueueOptions {
/**
* Default: false
*
* If set, the server will not create the queue.
*
* The client can use this to check whether a queue exists without modifying the server state
*/
passive?: boolean;
/**
* Default: false
*
* Durable queues remain active when a server restarts.
*
* Non-durable queues (transient queues) are purged if/when a server restarts.
*
* Note that durable queues do not necessarily hold persistent messages,
* although it does not make sense to send persistent messages to a transient queue
*/
durable?: boolean;
/**
* Default: false
*
* Exclusive queues may only be consumed from by the current connection.
*
* Setting the 'exclusive' flag always implies 'autoDelete'
*/
exclusive?: boolean;
/**
* Default: true
*
* If set, the queue is deleted when all consumers have finished using it.
*
* Last consumer can be cancelled either explicitly or because its channel is closed.
*
* If there was no consumer ever on the queue, it won't be deleted
*/
autoDelete?: boolean;
/**
* Default: false
*
* If set, the queue will not be declared, this will allow a queue to be deleted if you don't know its previous options
*/
noDeclare?: boolean;
/**
* a map of additional arguments to pass in when creating a queue
*/
arguments?: { [arg: string]: any };
/**
* Default: false
*
* when true the channel will close on unsubscribe
*/
closeChannelOnUnsubscribe?: boolean;
}
export interface ExchangeOptions {
/**
* Default: 'topic'
*/
type?: 'direct' | 'fanout' | 'topic';
/**
* Default: false
*
* f set, the server will not create the exchange. The client can use this to check whether an exchange exists without modifying the server state
*/
passive?: boolean;
/**
* Default: true
*
* If set when creating a new exchange, the exchange will be marked as durable.
*
* Durable exchanges remain active when a server restarts.
*
* Non-durable exchanges (transient exchanges) are purged if/when a server restarts
*/
durable?: boolean;
/**
* Default: true
*
* If set, the exchange is deleted when there are no longer queues bound to it
*/
autoDelete?: boolean;
/**
* Default: false
*
* If set, the exchange will not be declared,
* this will allow the exchange to be deleted if you dont know its previous options
*/
noDeclare?: boolean;
/**
* Default: false
*
* If set, the exchange will be in confirm mode, and you will get a 'ack'|'error' event emitted on a publish,
* or the callback on the publish will be called
*/
confirm?: boolean;
/**
* a map of additional arguments to pass in when creating an exchange
*/
arguments?: { [arg: string]: any };
}
export interface SubscribeOptions {
/**
* Default: false
*
* If set to true, only one subscriber is allowed at a time
*/
exclusive?: boolean;
/**
* Default: false
*
* Make it so that the AMQP server only delivers single messages at a time.
* When you want the next message, call queue.shift()
*
* When false, you will receive messages as fast as they are emitted
*/
ack?: boolean;
/**
* Default: 1
*
* Will only send you N messages before you 'ack'.
*
* Setting to zero will widen that window to 'unlimited'. If this is set, queue.shift() should not be used
*/
prefetchCount?: number;
/**
* Default: undefined
*
* Will inject the routingKey into the payload received
*/
routingKeyInPayload?: boolean;
/**
* Default: undefined
*
* Will inject the routingKey into the payload received
*/
deliveryKeyInPayload?: boolean;
}
export interface DestroyOptions {
/**
* Default: false
*
* Will only destroy the queue if it has no consumers
*/
ifUnused?: boolean;
/**
* Default: false
*
* Will ony be deleted if the queue has no messages
*/
ifEmpty?: boolean;
}
export type SubscribeCallback = (
message: any,
headers: { [key: string]: any },
deliveryInfo: DeliveryInfo,
ack: Ack
) => void;
export interface QueueCallback {
name: string;
consumerTagListeners: { [tag: string]: any };
consumerTagOptions: { [option: string]: any };
options: QueueOptions;
state: string;
channel: number;
}
export interface ExchangePublishOptions {
/**
* Default: false
*
* This flag tells the server how to react if the message cannot be routed to a queue.
*
* If this flag is set, the server will return an unroutable message with a Return method.
*
* If this flag is false, the server silently drops the message
*/
mandatory?: boolean;
/**
* Default: false
*
* This flag tells the server how to react if the message cannot be routed to a queue consumer immediately.
*
* If this flag is set, the server will return an undeliverable message with a Return method.
*
* If this flag is false, the server will queue the message, but with no guarantee that it will ever be consumed
*/
immediate?: boolean;
/**
* Default: 'application/octet-stream'
*/
contentType?: string;
/**
* Default: null
*/
contentEncoding?: string;
/**
* Default: {}
*
* Arbitrary application-specific message headers
*/
headers?: any;
/**
* 1: Non-persistent
* 2: Persistent
*/
deliveryMode?: 1 | 2;
priority?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
/**
* Application correlation identifier
*/
correlationId?: string;
/**
* Usually used to name a reply queue for a request message
*/
replyTo?: string;
/**
* Default: null
*
* Message expiration specification -- ISO date string?
*/
expiration?: string;
/**
* Default: null
*
* Application message identifier
*/
messageId?: string;
/**
* Default: null
*
* Message timestamp
*
* ISO date string?
*/
timestamp?: string;
/**
* Default: null
*
* Message type name
*/
type?: string;
/**
* Default: null
*
* Creating user id
*/
userId?: string;
/**
* Default: null
*
* Creating application id
*/
appId?: string;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"amqp-tests.ts"
]
}
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"unified-signatures": [
"false"
]
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ export interface Channel extends events.EventEmitter {
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | false) => void): void;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
+1 -1
View File
@@ -42,7 +42,7 @@ export interface Channel extends events.EventEmitter {
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): Promise<Replies.Consume>;
cancel(consumerTag: string): Promise<Replies.Empty>;
get(queue: string, options?: Options.Get): Promise<Message | boolean>;
get(queue: string, options?: Options.Get): Promise<Message | false>;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
@@ -0,0 +1,21 @@
import * as angular from 'angular';
import * as angularTooltips from 'angular-tooltips';
angular
.module('test.angular-tooltips', [
angularTooltips
])
.config((tooltipsConfProvider: angularTooltips.TooltipsConfProvider) => {
tooltipsConfProvider.configure({
side: 'left',
showTrigger: 'click',
hideTrigger: 'click',
class: 'class',
smart: true,
closeButton: false,
size: 'small',
speed: 'slow',
tooltipTemplateUrlCache: true,
show: false
});
});
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for angular-tooltips 1.2
// Project: http://720kb.github.io/angular-tooltips
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const AngularTooltips: '720kb.tooltips';
export = AngularTooltips;
declare namespace AngularTooltips {
interface TooltipsConfProvider {
configure(options: TooltipsConfProviderOptions): void;
}
interface TooltipsConfProviderOptions {
side?: 'left' | 'right' | 'top' | 'bottom' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
showTrigger?: string;
hideTrigger?: string;
class?: string;
smart?: boolean;
closeButton?: boolean;
size?: 'small' | 'medium' | 'large';
speed?: 'slow' | 'medium' | 'fast';
tooltipTemplateUrlCache?: boolean;
show?: boolean;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-tooltips-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -591,7 +591,7 @@ namespace TestPromise {
assertPromiseType<TResult>(promise.catch((err) => anyOf2(tresult, reject)));
assertPromiseType<TResult>(promise.catch((err) => anyOf3(tresult, tresultPromise, reject)));
assertPromiseType<TResult>(promise.catch((err) => tresultPromise));
assertPromiseType<ng.IHttpPromiseCallbackArg<TResult>>(promise.catch((err) => tresultHttpPromise));
assertPromiseType<TResult | ng.IHttpPromiseCallbackArg<TResult>>(promise.catch((err) => tresultHttpPromise));
assertPromiseType<TResult | TOther>(promise.catch((err) => tother));
assertPromiseType<TResult | TOther>(promise.catch((err) => totherPromise));
assertPromiseType<TResult | ng.IHttpPromiseCallbackArg<TOther>>(promise.catch((err) => totherHttpPromise));
+2 -2
View File
@@ -487,8 +487,8 @@ declare namespace angular {
$eval(expression: (scope: IScope) => any, locals?: Object): any;
$evalAsync(): void;
$evalAsync(expression: string): void;
$evalAsync(expression: (scope: IScope) => any): void;
$evalAsync(expression: string, locals?: Object): void;
$evalAsync(expression: (scope: IScope) => void, locals?: Object): void;
// Defaults to false by the implementation checking strategy
$new(isolate?: boolean, parent?: IScope): IScope;
@@ -15,6 +15,8 @@ class TestController {
storage.clearAll();
}
$onInit() {
}
}
var app = angular.module('angularLocalStorageTests', ['angularLocalStorage']);
@@ -44,7 +44,7 @@ appInsights = {
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) { return null; },
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null; },
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null; },
trackTrace(message: string, properties?: { [name: string]: string; }) { return null; },
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel) { return null; },
flush() { return null; },
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string) { return null; },
clearAuthenticatedUserContext() { return null; },
@@ -77,6 +77,7 @@ appInsights.trackException(new Error("sample error"), "handledAt", null, null);
// trackTrace
appInsights.trackTrace("message");
appInsights.trackTrace("message", null);
appInsights.trackTrace("message", { a: '1', b: '2' }, AI.SeverityLevel.Error);
// trackDependency
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null);
+1 -1
View File
@@ -763,7 +763,7 @@ declare module Microsoft.ApplicationInsights {
* @param message A message string
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
*/
trackTrace(message: string, properties?: { [name: string]: string }): any;
trackTrace(message: string, properties?: { [name: string]: string }, severityLevel?: AI.SeverityLevel): any;
/**
* Immediately send all queued telemetry.
*/
@@ -0,0 +1,25 @@
import { Tracker, TrackerStream, TrackerGroup } from "are-we-there-yet";
let simple = new Tracker("simple");
simple.addListener("change", (name, completed, tracker) => {
console.log(`name: ${name}, completed: ${completed}`);
});
simple.addWork(10);
simple.completeWork(1);
console.log(simple.completed() < 1);
let group = new TrackerGroup("group");
group.addUnit(simple);
let subgroup = group.newGroup("subgroup");
console.log(group.completed());
let stream = new TrackerStream("stream", 100, { encoding: "utf8" });
subgroup.addUnit(stream);
stream.addListener("change", (name, completed, tracker) => {
console.log(`name: ${name}, completed: ${completed}`);
});
simple.finish();
console.log(group.debug());
+90
View File
@@ -0,0 +1,90 @@
// Type definitions for are-we-there-yet 1.1
// Project: https://github.com/iarna/are-we-there-yet
// Definitions by: Brian J Brennan <https://github.com/brianloveswords>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from "events";
import { Transform, TransformOptions } from "stream";
export type TrackerObject = Tracker | TrackerGroup | TrackerStream;
export type TrackerEventListener = (name: string, completed: number, tracker: TrackerObject) => void;
export type GenericEventListener = (...args: any[]) => void;
export class TrackerBase extends EventEmitter {
constructor(name?: string);
addListener(event: "change", listener: TrackerEventListener): this;
addListener(event: string, listener: GenericEventListener): this;
on(event: "change", listener: TrackerEventListener): this;
on(event: string, listener: GenericEventListener): this;
once(event: "change", listener: TrackerEventListener): this;
once(event: string, listener: GenericEventListener): this;
prependListener(event: "change", listener: TrackerEventListener): this;
prependListener(event: string, listener: GenericEventListener): this;
prependOnceListener(event: "change", listener: TrackerEventListener): this;
prependOnceListener(event: string, listener: GenericEventListener): this;
removeListener(event: "change", listener: TrackerEventListener): this;
removeListener(event: string, listener: GenericEventListener): this;
}
export class Tracker extends TrackerBase {
constructor(name?: string, todo?: number);
addWork(work: number): void;
completeWork(completed: number): void;
completed(): number;
finish(): void;
}
export class TrackerGroup extends TrackerBase {
constructor(name?: string);
addUnit(tracker: TrackerBase, weight?: number): TrackerObject;
completed(): number;
debug(): string;
finish(): void;
newGroup(name?: string, weight?: number): TrackerGroup;
newItem(name?: string, todo?: number, weight?: number): Tracker;
newStream(name?: string, todo?: number, weight?: number): TrackerStream;
}
export class TrackerStream extends Transform {
constructor(name?: string, size?: number, options?: TransformOptions);
addWork(work: number): void;
completed(): number;
addListener(event: "change", listener: TrackerEventListener): this;
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
addListener(event: "readable" | "end" | "close", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: string, listener: GenericEventListener): this;
on(event: "change", listener: TrackerEventListener): this;
on(event: "data", listener: (chunk: Buffer | string) => void): this;
on(event: "readable" | "end" | "close", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: string, listener: GenericEventListener): this;
once(event: "change", listener: TrackerEventListener): this;
once(event: "data", listener: (chunk: Buffer | string) => void): this;
once(event: "readable" | "end" | "close", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: string, listener: GenericEventListener): this;
prependListener(event: "change", listener: TrackerEventListener): this;
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
prependListener(event: "readable" | "end" | "close", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: string, listener: GenericEventListener): this;
prependOnceListener(event: "change", listener: TrackerEventListener): this;
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
prependOnceListener(event: "readable" | "end" | "close", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: string, listener: GenericEventListener): this;
removeListener(event: "change", listener: TrackerEventListener): this;
removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
removeListener(event: "readable" | "end" | "close", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: string, listener: GenericEventListener): this;
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"are-we-there-yet-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+76 -9
View File
@@ -12,7 +12,64 @@ webAuth.authorize({
redirectUri: 'https://example.com/auth/callback'
});
webAuth.parseHash(window.location.hash, (err, authResult) => {
webAuth.parseHash((err, authResult) => {
if (err) {
return console.log(err);
}
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
webAuth.client.userInfo(authResult.accessToken, (err, user) => {
// Now you have the user's information
});
});
webAuth.parseHash((err, authResult) => {
if (err) {
return console.log(err);
}
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
webAuth.client.userInfo(authResult.accessToken, (err, user) => {
// Now you have the user's information
});
});
webAuth.parseHash(
{
nonce: 'asfd',
hash: '#access_token=VjubIMBmpgQ2W2&id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlF6RTROMFpCTTBWRFF6RTJSVVUwTnpJMVF6WTFNelE0UVRrMU16QXdNRUk0UkRneE56RTRSZyJ9.eyJpc3MiOiJodHRwczovL3dwdGVzdC5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NTVkNDhjNTdkNWIwYWQwMjIzYzQwOGQ3IiwiYXVkIjoiZ1lTTmxVNFlDNFYxWVBkcXE4elBRY3VwNnJKdzFNYnQiLCJleHAiOjE0ODI5NjkwMzEsImlhdCI6MTQ4MjkzMzAzMSwibm9uY2UiOiJhc2ZkIn0.PPoh-pITcZ8qbF5l5rMZwXiwk5efbESuqZ0IfMUcamB6jdgLwTxq-HpOT_x5q6-sO1PBHchpSo1WHeDYMlRrOFd9bh741sUuBuXdPQZ3Zb0i2sNOAC2RFB1E11mZn7uNvVPGdPTg-Y5xppz30GSXoOJLbeBszfrVDCmPhpHKGGMPL1N6HV-3EEF77L34YNAi2JQ-b70nFK_dnYmmv0cYTGUxtGTHkl64UEDLi3u7bV-kbGky3iOOCzXKzDDY6BBKpCRTc2KlbrkO2A2PuDn27WVv1QCNEFHvJN7HxiDDzXOsaUmjrQ3sfrHhzD7S9BcCRkekRfD9g95SKD5J0Fj8NA&token_type=Bearer&state=theState&refresh_token=kajshdgfkasdjhgfas&scope=foo'
},
(err, authResult) => {
if (err) {
return console.log(err);
}
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
webAuth.client.userInfo(authResult.accessToken, (err, user) => {
// Now you have the user's information
});
});
webAuth.parseHash(
{
nonce: 'asfd'
},
(err, authResult) => {
if (err) {
return console.log(err);
}
@@ -29,14 +86,21 @@ webAuth.parseHash(window.location.hash, (err, authResult) => {
});
webAuth.renewAuth({
audience: 'https://mystore.com/api/v2',
scope: 'read:order write:order',
redirectUri: 'https://example.com/auth/silent-callback',
}, function (err, authResult) {
// Renewed tokens or error
});
// this will use postMessage to comunicate between the silent callback
// and the SPA. When false the SDK will attempt to parse the url hash
// should ignore the url hash and no extra behaviour is needed.
usePostMessage: true
webAuth.renewAuth({
nonce: '123',
state: '456'
}, function (err, authResult) {
// Renewed tokens or error
});
webAuth.renewAuth({
nonce: '123',
state: '456',
postMessageDataType: 'auth0:silent-authentication'
}, function (err, authResult) {
// Renewed tokens or error
});
@@ -90,6 +154,9 @@ webAuth.popup.signupAndLogin({}, (err, data) => {
// do something with data
});
webAuth.login({username: 'bar', password: 'foo'}, (err, data) => {});
webAuth.crossOriginAuthenticationCallback();
let authentication = new auth0.Authentication({
domain: 'me.auth0.com',
@@ -150,7 +217,7 @@ authentication.dbConnection.signup({connection: 'bla', email: 'blabla', password
authentication.dbConnection.changePassword({connection: 'bla', email: 'blabla', password: '123456'}, () => {});
authentication.passwordless.start({ connection: 'bla', send: 'blabla' }, () => {});
authentication.passwordless.verify({ connection: 'bla', send: 'link', verificationCode: 'asdfasd', email: 'me@example.com' }, () => {});
authentication.passwordless.verify({ connection: 'bla', verificationCode: 'asdfasd', email: 'me@example.com' }, () => {});
authentication.loginWithResourceOwner({
username: 'the username',
+234 -91
View File
@@ -1,4 +1,4 @@
// Type definitions for Auth0.js 8.3
// Type definitions for Auth0.js 8.6
// Project: https://github.com/auth0/auth0.js
// Definitions by: Adrian Chia <https://github.com/adrianchia>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -15,7 +15,6 @@ export class Authentication {
/**
* Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction
*
* @method buildAuthorizeUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
buildAuthorizeUrl(options: any): string;
@@ -23,34 +22,32 @@ export class Authentication {
/**
* Builds and returns the Logout url in order to initialize a new authN/authZ transaction
*
* @method buildLogoutUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
*/
buildLogoutUrl(options?: any): string;
buildLogoutUrl(options?: LogoutOptions): string;
/**
* Makes a call to the `oauth/token` endpoint with `password` grant type
*
* @method loginWithDefaultDirectory
* @param {Object} options: https://auth0.com/docs/api-auth/grant/password
* @param {DefaultDirectoryLoginOptions} options: https://auth0.com/docs/api-auth/grant/password
* @param {Function} callback
*/
loginWithDefaultDirectory(options: any, callback: Auth0Callback<any>): void;
loginWithDefaultDirectory(options: DefaultDirectoryLoginOptions, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `/ro` endpoint
* @param {any} options
* @param {ResourceOwnerLoginOptions} options
* @param {Function} callback
* @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead.
*/
loginWithResourceOwner(options: any, callback: Auth0Callback<any>): void;
loginWithResourceOwner(options: ResourceOwnerLoginOptions, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `oauth/token` endpoint with `password-realm` grant type
* @param {any} options
* @param {DefaultLoginOptions} options
* @param {Function} callback
*/
login(options: any, callback: Auth0Callback<any>): void;
login(options: DefaultLoginOptions, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `oauth/token` endpoint
@@ -62,7 +59,6 @@ export class Authentication {
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Function} callback
*/
getSSOData(callback?: Auth0Callback<any>): void;
@@ -70,7 +66,6 @@ export class Authentication {
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Boolean} withActiveDirectories
* @param {Function} callback
*/
@@ -79,25 +74,22 @@ export class Authentication {
/**
* Makes a call to the `/userinfo` endpoint and returns the user profile
*
* @method userInfo
* @param {String} accessToken
* @param {Function} callback
*/
userInfo(token: string, callback: Auth0Callback<Auth0UserProfile>): void;
userInfo(accessToken: string, callback: Auth0Callback<Auth0UserProfile>): void;
/**
* Makes a call to the `/delegation` endpoint
*
* @method delegation
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation
* @param {DelegationOptions} options: https://auth0.com/docs/api/authentication#!#post--delegation
* @param {Function} callback
*/
delegation(options: any, callback: Auth0Callback<Auth0DelegationToken>): any;
delegation(options: DelegationOptions, callback: Auth0Callback<Auth0DelegationToken>): any;
/**
* Fetches the user country based on the ip.
*
* @method getUserCountry
* @param {Function} callback
*/
getUserCountry(callback: Auth0Callback<{ countryCode: string }>): void;
@@ -109,16 +101,14 @@ export class PasswordlessAuthentication {
/**
* Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction
*
* @method buildVerifyUrl
* @param {Object} options
* @param {PasswordlessVerifyOptions} options
* @param {Function} callback
*/
buildVerifyUrl(options: any): string;
buildVerifyUrl(options: PasswordlessVerifyOptions): string;
/**
* Initializes a new passwordless authN/authZ transaction
*
* @method start
* @param {Object} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Function} callback
*/
@@ -127,11 +117,10 @@ export class PasswordlessAuthentication {
/**
* Verifies the passwordless TOTP and returns an error if any.
*
* @method buildVerifyUrl
* @param {Object} options
* @param {PasswordlessVerifyOptions} options
* @param {Function} callback
*/
verify(options: any, callback: Auth0Callback<any>): void;
verify(options: PasswordlessVerifyOptions, callback: Auth0Callback<any>): void;
}
export class DBConnection {
@@ -140,17 +129,15 @@ export class DBConnection {
/**
* Signup a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {DbSignUpOptions} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} calback
*/
signup(options: any, callback: Auth0Callback<any>): void;
signup(options: DbSignUpOptions, callback: Auth0Callback<any>): void;
/**
* Initializes the change password flow
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {ChangePasswordOptions} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: ChangePasswordOptions, callback: Auth0Callback<any>): void;
@@ -162,7 +149,6 @@ export class Management {
/**
* Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id
*
* @method getUser
* @param {String} userId
* @param {Function} callback
*/
@@ -172,7 +158,6 @@ export class Management {
* Updates the user metdata. It will patch the user metdata with the attributes sent.
* https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
*
* @method patchUserMetadata
* @param {String} userId
* @param {Object} userMetadata
* @param {Function} callback
@@ -182,7 +167,6 @@ export class Management {
/**
* Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities
*
* @method linkUser
* @param {String} userId
* @param {String} secondaryUserToken
* @param {Function} callback
@@ -195,14 +179,14 @@ export class WebAuth {
client: Authentication;
popup: Popup;
redirect: Redirect;
crossOriginAuthentication: CrossOriginAuthentication;
/**
* Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
* @param {AuthorizeOptions} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
authorize(options: any): void;
authorize(options: AuthorizeOptions): void;
/**
* Parse the url hash and extract the returned tokens depending on the transaction.
@@ -211,82 +195,99 @@ export class WebAuth {
* by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be
* accepted.
*
* @method parseHash
* @param {Object} options:
* @param {String} options._idTokenVerification [OPTIONAL] Default: true
* @param {String} options.state [OPTIONAL] to verify the response
* @param {String} options.nonce [OPTIONAL] to verify the id_token
* @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash
* @param {ParseHashOptions} options
* @param {Function} callback: any(err, token_payload)
*/
parseHash(options: any, callback: Auth0Callback<Auth0DecodedHash>): void;
parseHash(callback: Auth0Callback<Auth0DecodedHash>): void;
/**
* Parse the url hash and extract the returned tokens depending on the transaction.
*
* Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed
* by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be
* accepted.
*
* @param {ParseHashOptions} options
* @param {Function} callback: any(err, token_payload)
*/
parseHash(options: ParseHashOptions, callback: Auth0Callback<Auth0DecodedHash>): void;
/**
* Decodes the id_token and verifies the nonce.
*
* @method validateToken
* @param {String} token
* @param {String} state
* @param {String} nonce
* @param {Function} callback: function(err, {payload, transaction})
*/
validateToken(token: string, state: string, nonce: string, callback: Auth0Callback<any>): void;
validateToken(token: string, nonce: string, callback: Auth0Callback<any>): void;
/**
* Executes a silent authentication transaction under the hood in order to fetch a new token.
* Executes a silent authentication transaction under the hood in order to fetch a new tokens for the current session.
* This method requires that all Auth is performed with {@link authorize}
* Watch out! If you're not using the hosted login page to do social logins, you have to use your own [social connection keys](https://manage.auth0.com/#/connections/social). If you use Auth0's dev keys, you'll always get `login_required` as an error when calling this method.
*
* @method renewAuth
* @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint
* @param {RenewAuthOptions} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint
* @param {Function} callback
*/
renewAuth(options: any, callback: Auth0Callback<any>): void;
renewAuth(options: RenewAuthOptions, callback: Auth0Callback<any>): void;
/**
* Initialices a change password transaction
*
* @method changePassword
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {ChangePasswordOptions} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: any, callback: Auth0Callback<any>): void;
changePassword(options: ChangePasswordOptions, callback: Auth0Callback<any>): void;
/**
* Signs up a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {DbSignUpOptions} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signup(options: any, callback: Auth0Callback<any>): void;
signup(options: DbSignUpOptions, callback: Auth0Callback<any>): void;
/**
* Signs up a new user, automatically logs the user in after the signup and returns the user token.
* The login will be done using /oauth/token with password-realm grant type.
*
* @method signupAndAuthorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {DbSignUpOptions} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndAuthorize(options: any, callback: Auth0Callback<any>): void;
signupAndAuthorize(options: DbSignUpOptions, callback: Auth0Callback<any>): void;
/**
* Redirects to the auth0 logout page
* Logs in the user with username and password using the cross origin authentication (/co/authenticate) flow. You can use either `username` or `email` to identify the user, but `username` will take precedence over `email`.
* This only works when 3rd party cookies are enabled in the browser. After the /co/authenticate call, you'll have to use the {@link parseHash} function at the `redirectUri` specified in the constructor.
*
* @method logout
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
* @param {CrossOriginLoginOptions} options options used in the {@link authorize} call after the login_ticket is acquired
* @param {crossOriginLoginCallback} cb Callback function called only when an authentication error, like invalid username or password, occurs. For other types of errors, there will be a redirect to the `redirectUri`.
*/
logout(options: any): void;
login(options: CrossOriginLoginOptions, callback: Auth0Callback<any>): void;
/**
* Runs the callback code for the cross origin authentication call. This method is meant to be called by the cross origin authentication callback url.
*
*/
crossOriginAuthenticationCallback(): void;
/**
* Redirects to the auth0 logout endpoint
*
* If you want to navigate the user to a specific URL after the logout, set that URL at the returnTo parameter. The URL should be included in any the appropriate Allowed Logout URLs list:
*
* - If the client_id parameter is included, the returnTo URL must be listed in the Allowed Logout URLs set at the client level (see Setting Allowed Logout URLs at the App Level).
* - If the client_id parameter is NOT included, the returnTo URL must be listed in the Allowed Logout URLs set at the account level (see Setting Allowed Logout URLs at the Account Level).
*
* @param {LogoutOptions} options
* @see {@link https://auth0.com/docs/api/authentication#logout}
*/
logout(options: LogoutOptions): void;
/**
* Initialices a passwordless authentication transaction
*
* @method passwordlessStart
* @param {Object} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Object} options.send: `link` or `code`
* @param {Object} options.phoneNumber: send should be code and email not set
* @param {Object} options.email: phoneNumber should be ignored
* @param {Object} options.connection
* @param {Object} options.authParams
* @param {PasswordlessStartOptions} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Function} callback
*/
passwordlessStart(options: PasswordlessStartOptions, callback: Auth0Callback<any>): void;
@@ -295,27 +296,28 @@ export class WebAuth {
* Verifies the passwordless TOTP and redirects to finish the passwordless transaction
*
* @method passwordlessVerify
* @param {Object} options:
* @param {Object} options.type: `sms` or `email`
* @param {Object} options.phoneNumber: only if type = sms
* @param {Object} options.email: only if type = email
* @param {Object} options.connection: the connection name
* @param {Object} options.verificationCode: the TOTP code
* @param {PasswordlessVerifyOptions} options:
* @param {Function} callback
*/
passwordlessVerify(options: any, callback: Auth0Callback<any>): void;
passwordlessVerify(options: PasswordlessVerifyOptions, callback: Auth0Callback<any>): void;
}
export class Redirect {
constructor(client: any, options: any);
/**
* Initializes the legacy Lock login flow in a popup
* Performs authentication with username/email and password with a database connection
*
* This method is not compatible with API Auth so if you need to fetch API tokens with audience
* you should use {@link authorize} or {@link login}.
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
* @param {String} [options.redirectUri] url that the Auth0 will redirect after Auth with the Authorization Response
* @param {String} [options.responseType] type of the response used. It can be any of the values `code` and `token`
* @param {String} [options.responseMode] how the AuthN response is encoded and redirected back to the client. Supported values are `query` and `fragment`
* @param {String} [options.scope] scopes to be requested during AuthN. e.g. `openid email`
* @param {credentialsCallback} cb
*/
loginWithCredentials(options: any, callback: Auth0Callback<any>): void;
@@ -323,8 +325,11 @@ export class Redirect {
* Signs up a new user and automatically logs the user in after the signup.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
* @param {Object} options
* @param {String} options.email user email address
* @param {String} options.password user password
* @param {String} options.connection name of the connection where the user will be created
* @param {credentialsCallback} cb
*/
signupAndLogin(options: any, callback: Auth0Callback<any>): void;
}
@@ -348,21 +353,51 @@ export class Popup {
preload(options: any): any;
/**
* Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
* Handles the popup logic for the callback page.
*
* @method callback
* @param {Object} options
* @param {String} options.hash the url hash. If not provided it will extract from window.location.hash
* @param {String} [options.state] value originally sent in `state` parameter to {@link authorize} to mitigate XSRF
* @param {String} [options.nonce] value originally sent in `nonce` parameter to {@link authorize} to prevent replay attacks
* @param {String} [options._idTokenVerification] makes parseHash perform or skip `id_token` verification. We **strongly** recommend validating the `id_token` yourself if you disable the verification.
* @see {@link parseHash}
*/
callback(options: any): void;
/**
* Shows inside a new window the hosted login page (`/authorize`) in order to start a new authN/authZ transaction and post its result using `postMessage`.
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
* @param {Function} callback
* @param {Object} options
* @param {String} [options.domain] your Auth0 domain
* @param {String} [options.clientID] your Auth0 client identifier obtained when creating the client in the Auth0 Dashboard
* @param {String} options.redirectUri url that the Auth0 will redirect after Auth with the Authorization Response
* @param {String} options.responseType type of the response used by OAuth 2.0 flow. It can be any space separated list of the values `code`, `token`, `id_token`. {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0}
* @param {String} [options.responseMode] how the Auth response is encoded and redirected back to the client. Supported values are `query`, `fragment` and `form_post`. {@link https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes}
* @param {String} [options.state] value used to mitigate XSRF attacks. {@link https://auth0.com/docs/protocols/oauth2/oauth-state}
* @param {String} [options.nonce] value used to mitigate replay attacks when using Implicit Grant. {@link https://auth0.com/docs/api-auth/tutorials/nonce}
* @param {String} [options.scope] scopes to be requested during Auth. e.g. `openid email`
* @param {String} [options.audience] identifier of the resource server who will consume the access token issued after Auth
* @param {Boolean} [options.owp] determines if Auth0 should render the relay page or not and the caller is responsible of handling the response.
* @param {authorizeCallback} cb
* @see {@link https://auth0.com/docs/api/authentication#authorize-client}
*/
authorize(options: any, callback: Auth0Callback<any>): void;
/**
* Initializes the legacy Lock login flow in a popup
* Performs authentication with username/email and password with a database connection inside a new window
*
* This method is not compatible with API Auth so if you need to fetch API tokens with audience
* you should use {@link authorize} or {@link login}.
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
* @param {String} [options.redirectUri] url that the Auth0 will redirect after Auth with the Authorization Response
* @param {String} [options.responseType] type of the response used. It can be any of the values `code` and `token`
* @param {String} [options.responseMode] how the AuthN response is encoded and redirected back to the client. Supported values are `query` and `fragment`
* @param {String} [options.scope] scopes to be requested during AuthN. e.g. `openid email`
* @param {credentialsCallback} cb
*/
loginWithCredentials(options: any, callback: Auth0Callback<any>): void;
@@ -383,13 +418,38 @@ export class Popup {
/**
* Signs up a new user and automatically logs the user in after the signup.
*
* This method is not compatible with API Auth so if you need to fetch API tokens with audience
* you should use {@link authorize} or {@link signupAndAuthorize}.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
* @param {Object} options
* @param {String} options.email user email address
* @param {String} options.password user password
* @param {String} options.connection name of the connection where the user will be created
* @param {credentialsCallback} cb
*/
signupAndLogin(options: any, callback: Auth0Callback<any>): void;
}
export class CrossOriginAuthentication {
constructor(webAuth: any, options: any);
/**
* Logs in the user with username and password using the cross origin authentication (/co/authenticate) flow. You can use either `username` or `email` to identify the user, but `username` will take precedence over `email`.
* This only works when 3rd party cookies are enabled in the browser. After the /co/authenticate call, you'll have to use the {@link parseHash} function at the `redirectUri` specified in the constructor.
*
* @param {CrossOriginLoginOptions} options options used in the {@link authorize} call after the login_ticket is acquired
* @param {crossOriginLoginCallback} cb Callback function called only when an authentication error, like invalid username or password, occurs. For other types of errors, there will be a redirect to the `redirectUri`.
*/
login(options: CrossOriginLoginOptions, callback: Auth0Callback<any>): void;
/**
* Runs the callback code for the cross origin authentication call. This method is meant to be called by the cross origin authentication callback url.
*
*/
callback(): void;
}
type Auth0Callback<T> = (error: null | Auth0Error, result: T) => void;
interface ManagementOptions {
@@ -472,6 +532,7 @@ interface PasswordlessVerifyOptions {
verificationCode: string;
phoneNumber?: string;
email?: string;
send?: string;
}
interface Auth0UserProfile {
@@ -514,3 +575,85 @@ interface Auth0Identity {
provider: string;
user_id: string;
}
interface LoginOptions {
username: string;
password: string;
scope?: string;
}
interface DefaultLoginOptions extends LoginOptions {
audience?: string;
realm: string;
}
interface DefaultDirectoryLoginOptions extends LoginOptions {
audience?: string;
}
interface ResourceOwnerLoginOptions extends LoginOptions {
connection: string;
device?: string;
}
interface CrossOriginLoginOptions {
username?: string;
email?: string;
password: string;
realm?: string;
}
interface LogoutOptions {
clientID?: string;
returnTo?: string;
federated?: boolean;
}
interface DelegationOptions {
client_id?: string;
grant_type: string;
id_token?: string;
refresh_token?: string;
target?: string;
scope?: string;
api_type?: string;
}
interface DbSignUpOptions {
email: string;
password: string;
connection: string;
scope?: string;
}
interface ParseHashOptions {
hash?: string;
state?: string;
nonce?: string;
_idTokenVerification?: boolean;
}
interface RenewAuthOptions {
domain?: string;
clientID?: string;
redirectUri?: string;
responseType?: string;
responseMode?: string;
state?: string;
nonce?: string;
scope?: string;
audience?: string;
postMessageDataType?: string;
}
interface AuthorizeOptions {
domain?: string;
clientID?: string;
redirectUri: string;
responseType: string;
responseMode?: string;
state?: string;
nonce?: string;
scope?: string;
audience?: string;
}
+35 -2
View File
@@ -61,11 +61,22 @@ lock.on("authenticated", function(authResult : any) {
});
});
// test theme
var themeOptions : Auth0LockConstructorOptions = {
theme: {
authButtons: {
fooProvider: {
displayName: 'foo'
},
barProvider: {
displayName: 'foo',
primaryColor: '#FF0000',
foregroundColor: '#00FF00',
icon: 'http://baz.com/icon.png'
}
},
labeledSubmitButton: false,
logo: "https://example.com/assets/logo.png",
primaryColor: "green"
}
@@ -73,6 +84,14 @@ var themeOptions : Auth0LockConstructorOptions = {
new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions);
// test empty theme
var themeOptionsEmpty : Auth0LockConstructorOptions = {
theme: { }
};
new Auth0Lock(CLIENT_ID, DOMAIN, themeOptions);
// test authentication
var authOptions : Auth0LockConstructorOptions = {
@@ -170,7 +189,7 @@ var selectFieldOptionsWithCallbacks : Auth0LockConstructorOptions = {
cb(null, prefill);
}
}]
}
};
new Auth0Lock(CLIENT_ID, DOMAIN, selectFieldOptionsWithCallbacks);
@@ -198,3 +217,17 @@ var avatarOptions : Auth0LockConstructorOptions = {
};
new Auth0Lock(CLIENT_ID, DOMAIN, avatarOptions);
var authResult : AuthResult = {
accessToken: 'fake_access_token',
idToken: 'fake_id_token',
idTokenPayload: {
aud: "EaQzyHt1Dy57l-r5iHcMeT-lh1fFZntg",
exp: 1494393724,
iat: 1494357724,
iss: "https://www.foo.com",
sub: "auth0|aksjfkladsf"
},
refreshToken: undefined,
state: "923jf092j3.FFSDJFDSKLDF"
};
+30 -3
View File
@@ -1,6 +1,7 @@
// Type definitions for auth0-lock 10.10
// Type definitions for auth0-lock 10.16
// Project: http://auth0.com
// Definitions by: Brian Caruso <https://github.com/carusology>
// Dan Caddigan <https://github.com/goldcaddy77>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="auth0-js" />
@@ -40,7 +41,19 @@ interface Auth0LockAvatarOptions {
displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void;
}
interface Auth0LockThemeButton {
displayName: string;
primaryColor?: string;
foregroundColor?: string;
icon?: string;
}
interface Auth0LockThemeButtonOptions {
[provider: string]: Auth0LockThemeButton;
}
interface Auth0LockThemeOptions {
authButtons?: Auth0LockThemeButtonOptions;
labeledSubmitButton?: boolean;
logo?: string;
primaryColor?: string;
}
@@ -121,6 +134,20 @@ interface Auth0LockShowOptions {
rememberLastLogin?: boolean;
}
interface AuthResult {
accessToken: string;
idToken: string;
idTokenPayload: {
aud: string;
exp: number;
iat: number;
iss: string;
sub: string;
};
refreshToken?: string;
state: string;
}
interface Auth0LockStatic {
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;
@@ -128,14 +155,14 @@ interface Auth0LockStatic {
getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
// https://github.com/auth0/lock#resumeauthhash-callback
resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: any) => void): void;
resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: AuthResult) => void): void;
show(options?: Auth0LockShowOptions): void;
hide(): void;
logout(query: any): void;
on(event: "show" | "hide", callback: () => void): void;
on(event: "unrecoverable_error" | "authorization_error", callback: (error: auth0.Auth0Error) => void): void;
on(event: "authenticated", callback: (authResult: any) => void): void;
on(event: "authenticated", callback: (authResult: AuthResult) => void): void;
on(event: string, callback: (...args: any[]) => void): void;
}
+12
View File
@@ -0,0 +1,12 @@
{
"extends": "dtslint/dt.json",
"rules": {
"only-arrow-functions": false,
"no-misused-new": false,
"no-single-declare-module": false,
"prefer-method-signature": false,
"object-literal-shorthand": false,
"typedef-whitespace": false,
"no-var": false
}
}
+50 -1
View File
@@ -60,7 +60,7 @@ var S3CreateEvent: AWSLambda.S3CreateEvent = {
}
]
};
var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent;
/* API Gateway Event */
str = apiGwEvt.body;
@@ -164,6 +164,55 @@ authResponse = {
policyDocument: policyDocument
};
// CognitoUserPoolEvent
num = cognitoUserPoolEvent.version;
cognitoUserPoolEvent.triggerSource === "PreSignUp_SignUp";
cognitoUserPoolEvent.triggerSource === "PostConfirmation_ConfirmSignUp";
cognitoUserPoolEvent.triggerSource === "PreAuthentication_Authentication";
cognitoUserPoolEvent.triggerSource === "PostAuthentication_Authentication";
cognitoUserPoolEvent.triggerSource === "CustomMessage_SignUp";
cognitoUserPoolEvent.triggerSource === "CustomMessage_AdminCreateUser";
cognitoUserPoolEvent.triggerSource === "CustomMessage_ResendCode";
cognitoUserPoolEvent.triggerSource === "CustomMessage_ForgotPassword";
cognitoUserPoolEvent.triggerSource === "CustomMessage_UpdateUserAttribute";
cognitoUserPoolEvent.triggerSource === "CustomMessage_VerifyUserAttribute";
cognitoUserPoolEvent.triggerSource === "CustomMessage_Authentication";
cognitoUserPoolEvent.triggerSource === "DefineAuthChallenge_Authentication";
cognitoUserPoolEvent.triggerSource === "CreateAuthChallenge_Authentication";
cognitoUserPoolEvent.triggerSource === "VerifyAuthChallengeResponse_Authentication";
str = cognitoUserPoolEvent.region;
str = cognitoUserPoolEvent.userPoolId;
str = cognitoUserPoolEvent.userName;
str = cognitoUserPoolEvent.callerContext.awsSdkVersion;
str = cognitoUserPoolEvent.callerContext.clientId;
str = cognitoUserPoolEvent.request.userAttributes["email"];
str = cognitoUserPoolEvent.request.validationData["k1"];
str = cognitoUserPoolEvent.request.codeParameter;
str = cognitoUserPoolEvent.request.usernameParameter;
b = cognitoUserPoolEvent.request.newDeviceUsed;
cognitoUserPoolEvent.request.session[0].challengeName === "CUSTOM_CHALLENGE";
cognitoUserPoolEvent.request.session[0].challengeName === "PASSWORD_VERIFIER";
cognitoUserPoolEvent.request.session[0].challengeName === "SMS_MFA";
cognitoUserPoolEvent.request.session[0].challengeName === "DEVICE_SRP_AUTH";
cognitoUserPoolEvent.request.session[0].challengeName === "DEVICE_PASSWORD_VERIFIER";
cognitoUserPoolEvent.request.session[0].challengeName === "ADMIN_NO_SRP_AUTH";
b = cognitoUserPoolEvent.request.session[0].challengeResult;
str = cognitoUserPoolEvent.request.session[0].challengeMetaData;
str = cognitoUserPoolEvent.request.challengeName;
str = cognitoUserPoolEvent.request.privateChallengeParameters["answer"];
str = cognitoUserPoolEvent.request.challengeAnswer["answer"];
b = cognitoUserPoolEvent.response.answerCorrect;
str = cognitoUserPoolEvent.response.smsMessage;
str = cognitoUserPoolEvent.response.emailMessage;
str = cognitoUserPoolEvent.response.emailSubject;
str = cognitoUserPoolEvent.response.challengeName;
b = cognitoUserPoolEvent.response.issueTokens;
b = cognitoUserPoolEvent.response.failAuthentication;
str = cognitoUserPoolEvent.response.publicChallengeParameters["captchaUrl"];
str = cognitoUserPoolEvent.response.privateChallengeParameters["answer"];
str = cognitoUserPoolEvent.response.challengeMetaData;
b = cognitoUserPoolEvent.response.answerCorrect;
/* Context */
b = context.callbackWaitsForEmptyEventLoop;
str = context.functionName;
+45 -1
View File
@@ -1,6 +1,6 @@
// 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>, Toby Hede <https://github.com/tobyhede>, Rich Buggy <https://github.com/buggy>, Simon Ramsay <https://github.com/nexus-uw>
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>, Rich Buggy <https://github.com/buggy>, Simon Ramsay <https://github.com/nexus-uw>, Yoriki Yamaguchi <https://github.com/y13i>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// API Gateway "event"
@@ -124,6 +124,50 @@ interface S3CreateEvent {
];
}
/**
* Cognito User Pool event
* http://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html
*/
interface CognitoUserPoolEvent {
version: number;
triggerSource: "PreSignUp_SignUp" | "PostConfirmation_ConfirmSignUp" | "PreAuthentication_Authentication" | "PostAuthentication_Authentication" | "CustomMessage_SignUp" | "CustomMessage_AdminCreateUser" | "CustomMessage_ResendCode" | "CustomMessage_ForgotPassword" | "CustomMessage_UpdateUserAttribute" | "CustomMessage_VerifyUserAttribute" | "CustomMessage_Authentication" | "DefineAuthChallenge_Authentication" | "CreateAuthChallenge_Authentication" | "VerifyAuthChallengeResponse_Authentication";
region: string;
userPoolId: string;
userName?: string;
callerContext: {
awsSdkVersion: string;
clientId: string;
};
request: {
userAttributes: {[key: string]: string};
validationData?: {[key: string]: string};
codeParameter?: string;
usernameParameter?: string;
newDeviceUsed?: boolean;
session?: {
challengeName: "CUSTOM_CHALLENGE" | "PASSWORD_VERIFIER" | "SMS_MFA" | "DEVICE_SRP_AUTH" | "DEVICE_PASSWORD_VERIFIER" | "ADMIN_NO_SRP_AUTH";
challengeResult: boolean;
challengeMetaData?: string;
}[];
challengeName?: string;
privateChallengeParameters?: {[key: string]: string};
challengeAnswer?: {[key: string]: string};
};
response: {
autoConfirmUser?: boolean;
smsMessage?: string;
emailMessage?: string;
emailSubject?: string;
challengeName?: string;
issueTokens?: boolean;
failAuthentication?: boolean;
publicChallengeParameters?: {[key: string]: string};
privateChallengeParameters?: {[key: string]: string};
challengeMetaData?: string;
answerCorrect?: boolean;
};
}
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {
@@ -120,3 +120,15 @@ const BindingKindTest: Visitor = {
// kind === 'anythingElse';
},
};
// https://github.com/babel/babel/blob/d33d02359474296402b1577ef53f20d94e9085c4/packages/babel-plugin-transform-es2015-block-scoping/test/fixtures/exec/scope-bindings.js#L15-L25
const vScope: Visitor = {
Scope: {
enter(path) {
console.log(`Entering scope: ${path.node.type}`);
},
exit(path) {
console.log(`Exiting scope: ${path.node.type}`);
}
}
};
+1
View File
@@ -305,6 +305,7 @@ export interface Visitor extends VisitNodeObject<Node> {
FlowBaseAnnotation?: VisitNode<t.FlowBaseAnnotation>;
FlowDeclaration?: VisitNode<t.FlowDeclaration>;
JSX?: VisitNode<t.JSX>;
Scope?: VisitNode<t.Scopable>;
}
export type VisitNode<T> = VisitNodeFunction<T> | VisitNodeObject<T>;
@@ -107,60 +107,48 @@ namespace Paging {
testCollection.getFirstPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getFirstPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getFirstPage({url: true});
testCollection.getFirstPage({silent: false});
testCollection.getFirstPage({url: 'zombocom'});
result = testCollection.getLastPage();
testCollection.getLastPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getLastPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getLastPage({url: true});
testCollection.getLastPage({silent: true});
testCollection.getLastPage({url: 'chickensnack'});
result = testCollection.getNextPage();
testCollection.getNextPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getNextPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getNextPage({url: true});
testCollection.getNextPage({silent: false});
testCollection.getNextPage({url: 'hampsterdance'});
result = testCollection.getPage(1);
testCollection.getPage("1", options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getPage(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPage(1, {url: true});
testCollection.getPage(1, {silent: true});
testCollection.getPage(1, {url: 'badcandy'});
result = testCollection.getPageByOffset(1);
testCollection.getPageByOffset(1, options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getPageByOffset(1, {silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPageByOffset(1, {url: true});
testCollection.getPageByOffset(1, {silent: false});
testCollection.getPageByOffset(1, {url: 'oldmanmurray'});
result = testCollection.getPreviousPage();
testCollection.getPreviousPage(options);
// 'silent's type is boolean. (structural subtyping)
testCollection.getPreviousPage({silent: 'aa'});
// 'url's type is string. (structural subtyping)
testCollection.getPreviousPage({url: true});
testCollection.getPreviousPage({silent: false});
testCollection.getPreviousPage({url: 'uncyclopedia'});
var hasPage:boolean = testCollection.hasNextPage();
@@ -231,7 +219,7 @@ namespace Setting {
var result2:TestCollection
= testCollection.setSorting('id', 1, options);
= testCollection.setSorting('id', 1, { full: true});
result1 = testCollection.switchMode(
'server',
+10 -10
View File
@@ -3,7 +3,7 @@
// Definitions by: Michael Mrowetz <https://github.com/micmro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FittingContext {
export interface FittingContext {
/** The input defined in the fitting definition
* (string, number, object, array)
*/
@@ -17,9 +17,9 @@ interface FittingContext {
* Fitting types has pre-defined fittings `system` and `user`
* but can be any any string for custom types like `swagger` or `node-machine`
*/
type FittingType = "system" | "user" | string;
export type FittingType = "system" | "user" | string;
interface FittingDef {
export interface FittingDef {
/**
* If type is omitted (as it must be for in-line usage), Bagpipes will
* first check the user fittings then the system fittings for the name and
@@ -46,8 +46,8 @@ interface FittingDef {
*
* Will be called called when the `Pipe` it is contained it gets 'played'
*/
type Fitting = (
context: FittingContext,
export type Fitting = (
context: FittingContext,
next: {(err: Error | null | undefined, res?: any): void}) => void;
/**
@@ -58,18 +58,18 @@ type Fitting = (
*
* @param {Object} fittingDef Fitting Definition
*/
type FittingFactory = (fittingDef: FittingDef, bagpipes: any) => Fitting;
export type FittingFactory = (fittingDef: FittingDef, bagpipes: any) => Fitting;
/**
* Hashmap of `fittingType`s (the name of a fitting) and the
* `FittingFactory` functions used to create them
*/
interface FittingTypesMap {
export interface FittingTypesMap {
[fittingType: string]: FittingFactory;
}
/** The Pipe Definition */
type PipeDef = any[] | string | FittingDef;
export type PipeDef = any[] | string | FittingDef;
/** Hashmap of Pipe Definitons */
export interface PipeDefMap {
@@ -143,10 +143,10 @@ export function create(pipesDefs: PipeDefMap, conf?: Config): Bagpipes;
// Types for imports from `pipeworks` module
type Affinity = "hoist" | "sink";
export type Affinity = "hoist" | "sink";
/** PipeDef used in `pipeworks` module */
interface PipeworksOptions {
export interface PipeworksOptions {
/**
* Adds to the pre and post queues, respectively.
* Ensures a pipe gets fitted before or after the main execution pipeline.
+6 -1
View File
@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"callable-types": false
}
}
+10 -2
View File
@@ -1,4 +1,12 @@
import {IncomingMessage} from 'http';
import auth = require('basic-auth');
auth(null);
const loginData = auth(undefined! as IncomingMessage);
if (loginData) {
const {name, pass} = loginData;
}
const parsed = auth.parse('Basic QmFzaWM6QXV0aA==');
if (parsed) {
const {name, pass} = parsed;
}
+9 -3
View File
@@ -1,19 +1,25 @@
// Type definitions for basic-auth
// Type definitions for basic-auth 1.1
// Project: https://github.com/jshttp/basic-auth
// Definitions by: Clément Bourgeois <https://github.com/moonpyk>
// Definitions by: Clément Bourgeois <https://github.com/moonpyk>, Vesa Poikajärvi <https://github.com/vesse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as http from 'http';
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult;
// See https://github.com/jshttp/basic-auth/blob/v1.1.0/index.js#L49
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult | undefined;
declare namespace auth {
interface BasicAuthResult {
name: string;
pass: string;
}
/**
* Parse basic auth to object.
*/
function parse(authorizationHeader: string): auth.BasicAuthResult | undefined;
}
export = auth;
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
-118
View File
@@ -1,118 +0,0 @@
// constructor tests
var noArgument = bigInt(),
numberArgument = bigInt( 93 ),
stringArgument = bigInt( "75643564363473453456342378564387956906736546456235345" ),
baseArgumentInt = bigInt( "101010", 2 ),
baseArgumentStr = bigInt( "101010", "2" ),
baseArgumentBi = bigInt( "101010", bigInt( 2 ) ),
bigIntArgument = bigInt( noArgument );
// method tests
var x = bigInt(),
isBigInteger: BigInteger,
isNumber: number,
isBoolean: boolean,
isString: string,
isDivmod: {
quotient: BigInteger;
remainder: BigInteger;
};
isBigInteger = x.abs();
isBigInteger = x.add( 0 );
isBigInteger = x.add( x );
isBigInteger = x.add( "100" );
isNumber = x.compare( 0 );
isNumber = x.compare( x );
isNumber = x.compare( "100" );
isNumber = x.compareAbs( 0 );
isNumber = x.compareAbs( x );
isNumber = x.compareAbs( "100" );
isBigInteger = x.divide( 0 );
isBigInteger = x.divide( x );
isBigInteger = x.divide( "100" );
isDivmod = x.divmod( 0 );
isDivmod = x.divmod( x );
isDivmod = x.divmod( "100" );
isBoolean = x.equals( 0 );
isBoolean = x.equals( x );
isBoolean = x.equals( "100" );
isBoolean = x.greater( 0 );
isBoolean = x.greater( x );
isBoolean = x.greater( "100" );
isBoolean = x.greaterOrEquals( 0 );
isBoolean = x.greaterOrEquals( x );
isBoolean = x.greaterOrEquals( "100" );
isBoolean = x.isEven();
isBoolean = x.isNegative();
isBoolean = x.isOdd();
isBoolean = x.isPositive();
isBoolean = x.lesser( 0 );
isBoolean = x.lesser( x );
isBoolean = x.lesser( "100" );
isBoolean = x.lesserOrEquals( 0 );
isBoolean = x.lesserOrEquals( x );
isBoolean = x.lesserOrEquals( "100" );
isBigInteger = x.minus( 0 );
isBigInteger = x.minus( x );
isBigInteger = x.minus( "100" );
isBigInteger = x.mod( 0 );
isBigInteger = x.mod( x );
isBigInteger = x.mod( "100" );
isBigInteger = x.multiply( 0 );
isBigInteger = x.multiply( x );
isBigInteger = x.multiply( "100" );
isBigInteger = x.next();
isBoolean = x.notEquals( 0 );
isBoolean = x.notEquals( x );
isBoolean = x.notEquals( "100" );
isBigInteger = x.over( 0 );
isBigInteger = x.over( x );
isBigInteger = x.over( "100" );
isBigInteger = x.plus( 0 );
isBigInteger = x.plus( x );
isBigInteger = x.plus( "100" );
isBigInteger = x.pow( 0 );
isBigInteger = x.pow( x );
isBigInteger = x.pow( "100" );
isBigInteger = x.prev();
isBigInteger = x.subtract( 0 );
isBigInteger = x.subtract( x );
isBigInteger = x.subtract( "100" );
isBigInteger = x.times( 0 );
isBigInteger = x.times( x );
isBigInteger = x.times( "100" );
isNumber = x.toJSNumber();
isString = x.toString();
isString = x.toString(36);
isNumber = x.valueOf();
-226
View File
@@ -1,226 +0,0 @@
// Type definitions for BigInteger.js
// Project: https://github.com/peterolson/BigInteger.js
// Definitions by: Ingo Bürk <https://github.com/Airblader>, Roel van Uden <https://github.com/Deathspike>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface BigInteger {
/** Returns the absolute value of a bigInt. */
abs(): BigInteger;
/** Performs addition */
add( number: number ): BigInteger;
/** Performs addition */
add( number: BigInteger ): BigInteger;
/** Performs addition */
add( number: string ): BigInteger;
/** Alias for the add method. */
plus( number: number ): BigInteger;
/** Alias for the add method. */
plus( number: BigInteger ): BigInteger;
/** Alias for the add method. */
plus( number: string ): BigInteger;
/** Alias for the subtract method. */
minus( number: number ): BigInteger;
/** Alias for the subtract method. */
minus( number: BigInteger ): BigInteger;
/** Alias for the subtract method. */
minus( number: string ): BigInteger;
/** Performs subtraction. */
subtract( number: number ): BigInteger;
/** Performs subtraction. */
subtract( number: BigInteger ): BigInteger;
/** Performs subtraction. */
subtract( number: string ): BigInteger;
/** Performs multiplication. */
multiply( number: number ): BigInteger;
/** Performs multiplication. */
multiply( number: BigInteger ): BigInteger;
/** Performs multiplication. */
multiply( number: string ): BigInteger;
/** Alias for the multiply method. */
times( number: number ): BigInteger;
/** Alias for the multiply method. */
times( number: BigInteger ): BigInteger;
/** Alias for the multiply method. */
times( number: string ): BigInteger;
/** Performs integer division, disregarding the remainder. */
divide( number: number ): BigInteger;
/** Performs integer division, disregarding the remainder. */
divide( number: BigInteger ): BigInteger;
/** Performs integer division, disregarding the remainder. */
divide( number: string ): BigInteger;
/** Alias for the divide method. */
over( number: number ): BigInteger;
/** Alias for the divide method. */
over( number: BigInteger ): BigInteger;
/** Alias for the divide method. */
over( number: string ): BigInteger;
/** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */
pow( number: number ): BigInteger;
/** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */
pow( number: BigInteger ): BigInteger;
/** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */
pow( number: string ): BigInteger;
/** Adds one to the number. */
next(): BigInteger;
/** Subtracts one from the number. */
prev(): BigInteger;
/** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */
mod( number: number ): BigInteger;
/** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */
mod( number: BigInteger ): BigInteger;
/** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */
mod( number: string ): BigInteger;
/** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */
divmod( number: number ): { quotient: BigInteger; remainder: BigInteger };
/** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */
divmod( number: BigInteger ): { quotient: BigInteger; remainder: BigInteger };
/** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */
divmod( number: string ): { quotient: BigInteger; remainder: BigInteger };
/** Checks if the first number is greater than the second. */
greater( number: number ): boolean;
/** Checks if the first number is greater than the second. */
greater( number: BigInteger ): boolean;
/** Checks if the first number is greater than the second. */
greater( number: string ): boolean;
/** Checks if the first number is greater than or equal to the second. */
greaterOrEquals( number: number ): boolean;
/** Checks if the first number is greater than or equal to the second. */
greaterOrEquals( number: BigInteger ): boolean;
/** Checks if the first number is greater than or equal to the second. */
greaterOrEquals( number: string ): boolean;
/** Checks if the first number is lesser than the second. */
lesser( number: number ): boolean;
/** Checks if the first number is lesser than the second. */
lesser( number: BigInteger ): boolean;
/** Checks if the first number is lesser than the second. */
lesser( number: string ): boolean;
/** Checks if the first number is less than or equal to the second. */
lesserOrEquals( number: number ): boolean;
/** Checks if the first number is less than or equal to the second. */
lesserOrEquals( number: BigInteger ): boolean;
/** Checks if the first number is less than or equal to the second. */
lesserOrEquals( number: string ): boolean;
/** Returns true if the number is even, false otherwise. */
isEven(): boolean;
/** Returns true if the number is odd, false otherwise. */
isOdd(): boolean;
/** Return true if the number is positive, false otherwise. Returns true for 0 and false for -0. */
isPositive(): boolean;
/** Returns true if the number is negative, false otherwise. Returns false for 0 and true for -0. */
isNegative(): boolean;
/**
* Performs a comparison between two numbers. If the numbers are equal, it returns 0.
* If the first number is greater, it returns 1. If the first number is lesser, it returns -1.
*/
compare( number: number ): number;
/**
* Performs a comparison between two numbers. If the numbers are equal, it returns 0.
* If the first number is greater, it returns 1. If the first number is lesser, it returns -1.
*/
compare( number: BigInteger ): number;
/**
* Performs a comparison between two numbers. If the numbers are equal, it returns 0.
* If the first number is greater, it returns 1. If the first number is lesser, it returns -1.
*/
compare( number: string ): number;
/** Performs a comparison between the absolute value of two numbers. */
compareAbs( number: number ): number;
/** Performs a comparison between the absolute value of two numbers. */
compareAbs( number: BigInteger ): number;
/** Performs a comparison between the absolute value of two numbers. */
compareAbs( number: string ): number;
/** Checks if two numbers are equal. */
equals( number: number ): boolean;
/** Checks if two numbers are equal. */
equals( number: BigInteger ): boolean;
/** Checks if two numbers are equal. */
equals( number: string ): boolean;
/** Checks if two numbers are not equal. */
notEquals( number: number ): boolean;
/** Checks if two numbers are not equal. */
notEquals( number: BigInteger ): boolean;
/** Checks if two numbers are not equal. */
notEquals( number: string ): boolean;
/** Performs the bitwise AND operation. */
and( number: number ): BigInteger;
/** Performs the bitwise AND operation. */
and( number: BigInteger ): BigInteger;
/** Performs the bitwise AND operation. */
and( number: string ): BigInteger;
/** Performs the bitwise NOT operation. */
not(): BigInteger;
/** Performs the bitwise OR operation. */
or( number: number ): BigInteger;
/** Performs the bitwise OR operation. */
or( number: BigInteger ): BigInteger;
/** Performs the bitwise OR operation. */
or( number: string ): BigInteger;
/** Performs the bitwise XOR operation. */
xor( number: number ): BigInteger;
/** Performs the bitwise XOR operation. */
xor( number: BigInteger ): BigInteger;
/** Performs the bitwise XOR operation. */
xor( number: string ): BigInteger;
/** Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range. */
toJSNumber(): number;
/** Converts a bigInt to a string. */
toString( radix?: number ): string;
/** Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion. */
valueOf(): number;
}
interface BigIntegerStatic {
/** Equivalent to bigInt(1) */
one: BigInteger;
/** Equivalent to bigInt(0) */
zero: BigInteger;
/** Equivalent to bigInt(-1) */
minusOne: BigInteger;
/** Equivalent to bigInt(0) */
(): BigInteger;
/** Parse a Javascript number into a bigInt */
( number: number ): BigInteger;
/** Parse a string into a bigInt */
( string: string, base?: string | number | BigInteger): BigInteger;
/** no-op */
( bigInt: BigInteger ): BigInteger;
}
declare var bigInt: BigIntegerStatic;
declare module "big-integer" {
export = bigInt;
}
+17
View File
@@ -0,0 +1,17 @@
import * as blobUtil from 'blob-util';
const testBlob = new Blob(['abcd']);
blobUtil.base64StringToBlob('abcd'); // $ExpectType Promise<Blob>
blobUtil.createObjectURL(testBlob); // $ExpectType string
blobUtil.imgSrcToBlob('test.jpg'); // $ExpectType Promise<Blob>
blobUtil.createBlob(['abcd']); // $ExpectType Blob
blobUtil.arrayBufferToBlob(new ArrayBuffer(0)); // $ExpectType Promise<Blob>
blobUtil.binaryStringToBlob('0101'); // $ExpectType Promise<Blob>
blobUtil.blobToArrayBuffer(testBlob); // $ExpectType Promise<ArrayBuffer>
blobUtil.blobToBase64String(testBlob); // $ExpectType Promise<string>
blobUtil.blobToBinaryString(testBlob); // $ExpectType Promise<string>
blobUtil.canvasToBlob(new HTMLCanvasElement()); // $ExpectType Promise<Blob>
blobUtil.dataURLToBlob('data:abcd'); // $ExpectType Promise<Blob>
blobUtil.imgSrcToDataURL('test.jpg'); // $ExpectType Promise<string>
blobUtil.revokeObjectURL('blob:example'); // $ExpectType void
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for blob-util 1.2
// Project: https://github.com/nolanlawson/blob-util#readme
// Definitions by: Max Battcher <https://github.com/WorldMaker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export function createBlob(parts: any[], options?: { type: string }): Blob;
export function createObjectURL(blob: Blob): string;
export function revokeObjectURL(url: string): void;
export function blobToBinaryString(blob: Blob): Promise<string>;
export function binaryStringToBlob(binary: string, type?: string): Promise<Blob>;
export function blobToBase64String(blob: Blob): Promise<string>;
export function base64StringToBlob(base64: string, type?: string): Promise<Blob>;
export function dataURLToBlob(dataURL: string): Promise<Blob>;
export function imgSrcToDataURL(src: string, type?: string, crossOrigin?: string): Promise<string>;
export function canvasToBlob(canvas: HTMLCanvasElement, type?: string): Promise<Blob>;
export function imgSrcToBlob(src: string, type?: string, crossOrigin?: string): Promise<Blob>;
export function arrayBufferToBlob(arrayBuff: ArrayBuffer, type?: string): Promise<Blob>;
export function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer>;
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"state-machine-tests.ts"
"blob-util-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+16
View File
@@ -361,6 +361,22 @@ fooProm = fooProm.catch(CustomError, reason => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
class CustomError1 extends Error {}
class CustomError2 extends Error {}
class CustomError3 extends Error {}
class CustomError4 extends Error {}
class CustomError5 extends Error {}
fooProm = fooProm.catch(CustomError1, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, CustomError4, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, CustomError4, CustomError5, error => {});
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.error((reason: any) => {
return bar;
});
+218 -22
View File
@@ -65,24 +65,133 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* 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.
*
* TODO: disallow non-objects
*/
catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
catch<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
catch<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
caught<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
): Bluebird<R>;
catch<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
): Bluebird<U | R>;
/**
* 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.
@@ -116,11 +225,40 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Like `.catch()` but rethrows the error
* TODO: disallow non-objects
*/
tapCatch<U>(onReject: (error?: any) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
tapCatch<U, E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
tapCatch<U>(predicate: (error?: any) => boolean, onReject: (error?: any) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
tapCatch<U>(onReject: (error?: any) => U | Bluebird.Thenable<U>): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
): Bluebird<R>;
/**
* Same as calling `Promise.delay(ms, this)`.
@@ -258,11 +396,40 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* </code>
*
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()`
* TODO: disallow non-objects
*/
catchReturn<U>(value: U): Bluebird<U>;
catchReturn<U>(predicate: (error: any) => boolean, value: U): Bluebird<U | R>;
catchReturn<E extends Error, U>(ErrorClass: new (...args: any[]) => E, value: U): Bluebird<U | R>;
catchReturn<U>(predicate: Object, value: U): Bluebird<U | R>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
value: U,
): Bluebird<U>;
catchReturn<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
value: U,
): Bluebird<U>;
/**
* Convenience method for:
@@ -273,11 +440,40 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* });
* </code>
* Same limitations apply as with `.catchReturn()`.
* TODO: disallow non-objects
*/
catchThrow(reason: Error): Bluebird<R>;
catchThrow(predicate: (error: any) => boolean, reason: Error): Bluebird<R>;
catchThrow<E extends Error, U>(ErrorClass: new (...args: any[]) => E, reason: Error): Bluebird<R>;
catchThrow(predicate: Object, reason: Error): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
reason: Error,
): Bluebird<R>;
catchThrow<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
reason: Error,
): Bluebird<R>;
/**
* Convert to String.
+2 -1
View File
@@ -2,7 +2,8 @@
// Project: https://github.com/watson/bonjour
// Definitions by: Quentin Lampin <https://github.com/quentin-ol/>, Nicolas Voigt <https://github.com/octo-sniffle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="node" />
/// <reference types="node" />
declare function bonjour(opts?: bonjour.BonjourOptions): bonjour.Bonjour;
export = bonjour;
+2 -1
View File
@@ -40,7 +40,8 @@ declare namespace Bookshelf {
tableName?: string;
}
abstract class ModelBase<T extends Model<any>> extends Events<T | Collection<T>> implements IModelBase {
interface ModelBase<T extends Model<any>> extends IModelBase { }
abstract class ModelBase<T extends Model<any>> extends Events<T | Collection<T>> {
/** If overriding, must use a getter instead of a plain property. */
idAttribute: string;
+115 -35
View File
@@ -1,44 +1,124 @@
import Boom = require('boom');
var bo = Boom.wrap(new Error('test'), 400, 'some message');
var a: string = bo.output.headers['some header'];
// 4xx and data type
Boom.create(500, 'Internal server error', { timestamp: Date.now() });
const badRequestError = Boom.badRequest('message', {some: 'data'});
badRequestError.data.some;
Boom.badRequest('message', {some: 'data'});
Boom.unauthorized('message', <string | string[]> 'scheme', {some: 'data'});
Boom.unauthorized(null, <string | string[]> 'scheme', 'data');
Boom.paymentRequired('message', {some: 'data'});
Boom.forbidden('message', {some: 'data'});
Boom.notFound('message', {some: 'data'});
Boom.methodNotAllowed('message', {some: 'data'});
Boom.notAcceptable('message', {some: 'data'});
Boom.proxyAuthRequired('message', {some: 'data'});
Boom.clientTimeout('message', {some: 'data'});
Boom.conflict('message', {some: 'data'});
Boom.resourceGone('message', {some: 'data'});
Boom.lengthRequired('message', {some: 'data'});
Boom.preconditionFailed('message', {some: 'data'});
Boom.entityTooLarge('message', {some: 'data'});
Boom.uriTooLong('message', {some: 'data'});
Boom.unsupportedMediaType('message', {some: 'data'});
Boom.rangeNotSatisfiable('message', {some: 'data'});
Boom.expectationFailed('message', {some: 'data'});
Boom.teapot('message', {some: 'data'});
Boom.badData('message', {some: 'data'});
Boom.locked('message', {some: 'data'});
Boom.preconditionRequired('message', {some: 'data'});
Boom.tooManyRequests('message', {some: 'data'});
Boom.illegal('message', {some: 'data'});
const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'});
unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' };
unauthorizedError1.output.headers === { 'WWW-Authenticate': 'scheme some="attribute", error="message"' };
Boom.badImplementation('message', {some: 'data'});
Boom.notImplemented('message', {some: 'data'});
Boom.badGateway('message', {some: 'data'});
Boom.serverUnavailable('message', {some: 'data'});
Boom.gatewayTimeout('message', {some: 'data'});
const unauthorizedError2 = Boom.unauthorized('message', ['scheme']);
unauthorizedError2.output.payload.attributes === undefined;
unauthorizedError2.output.headers === { 'WWW-Authenticate': 'scheme' };
Boom.unauthorized() as Error;
const unauthorizedError3 = Boom.unauthorized(null, 'scheme', 'attribute');
unauthorizedError3.output.payload.attributes === 'attribute';
unauthorizedError3.output.headers === { 'WWW-Authenticate': 'scheme attribute' };
const unauthorizedError4 = Boom.unauthorized(null, 'scheme', {some: 'attribute'});
unauthorizedError4.output.payload.attributes === { some: 'attribute' };
unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attribute"' };
const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'});
paymentRequiredError.data.some;
const forbiddenError = Boom.forbidden('message', {some: 'data'});
forbiddenError.data.some;
const notFoundError = Boom.notFound('message', {some: 'data'});
notFoundError.data.some;
const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'});
methodNotAllowedError.data.some;
const notAcceptableError = Boom.notAcceptable('message', {some: 'data'});
notAcceptableError.data.some;
const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'});
proxyAuthRequiredError.data.some;
const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'});
clientTimeoutError.data.some;
const conflictError = Boom.conflict('message', {some: 'data'});
conflictError.data.some;
const resourceGoneError = Boom.resourceGone('message', {some: 'data'});
resourceGoneError.data.some;
const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'});
lengthRequiredError.data.some;
const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'});
preconditionFailedError.data.some;
const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'});
entityTooLargeError.data.some;
const uriTooLongError = Boom.uriTooLong('message', {some: 'data'});
uriTooLongError.data.some;
const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'});
unsupportedMediaTypeError.data.some;
const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'});
rangeNotSatisfiableError.data.some;
const expectationFailedError = Boom.expectationFailed('message', {some: 'data'});
expectationFailedError.data.some;
const teapotError = Boom.teapot('message', {some: 'data'});
teapotError.data.some;
const badDataError = Boom.badData('message', {some: 'data'});
badDataError.data.some;
const lockedError = Boom.locked('message', {some: 'data'});
lockedError.data.some;
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
preconditionRequiredError.data.some;
const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'});
tooManyRequestsError.data.some;
const illegalError = Boom.illegal('message', {some: 'data'});
illegalError.data.some;
// 5xx and data type
const badImplementationError = Boom.badImplementation('message', {some: 'data'});
badImplementationError.data.some;
const internalError = Boom.internal('message', {some: 'data'});
internalError.data.some;
const notImplementedError = Boom.notImplemented('message', {some: 'data'});
notImplementedError.data.some;
const badGatewayError = Boom.badGateway('message', {some: 'data'});
badGatewayError.data.some;
const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'});
serverUnavailableError.data.some;
const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'});
gatewayTimeoutError.data.some;
// wrap and create
const wrappedError = Boom.wrap(new Error('test'), 400, 'some message');
const error1 = Boom.create(500, 'Internal server error', { timestamp: Date.now() });
error1.data.timestamp;
// type widden asserting
const unauthorizedError = Boom.unauthorized() as Error;
// status code and reformat
const error = Boom.badRequest('Cannot feed after midnight');
error.output.statusCode = 499; // Assign a custom error code
+52 -32
View File
@@ -2,6 +2,7 @@
// Project: http://github.com/hapijs/boom
// Definitions by: Igor Rogatty <http://github.com/rogatty>, AJP <http://github.com/AJamesPhillips>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export = Boom;
@@ -11,7 +12,7 @@ declare namespace Boom {
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
* @see {@link https://github.com/hapijs/boom#boom}
*/
export interface BoomError extends Error {
export interface BoomError<Data = null> extends Error {
/** isBoom - if true, indicates this is a Boom object instance. */
isBoom: boolean;
/** isServer - convenience bool indicating status code >= 500. */
@@ -24,6 +25,8 @@ declare namespace Boom {
reformat: () => string;
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
isMissing?: boolean;
/** https://github.com/hapijs/boom#createstatuscode-message-data */
data: Data;
}
export interface Output {
@@ -34,6 +37,7 @@ declare namespace Boom {
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
payload: Payload;
}
export interface Payload {
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
statusCode: number;
@@ -41,6 +45,11 @@ declare namespace Boom {
error: string;
/** message - the error message derived from error.message. */
message: string;
/**
* "Every key/value pair will be included ... in the response payload under the attributes key."
* [see docs](https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes)
*/
attributes?: any;
// Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload
// [anyContent: string]: any;
}
@@ -61,7 +70,7 @@ declare namespace Boom {
* @param data additional error data set to error.data property.
* @see {@link https://github.com/hapijs/boom#createstatuscode-message-data}
*/
export function create(statusCode: number, message?: string, data?: any): BoomError;
export function create<Data>(statusCode: number, message?: string, data?: Data): BoomError<Data>;
// 4xx
/**
@@ -70,7 +79,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
*/
export function badRequest(message?: string, data?: any): BoomError;
export function badRequest<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 401 Unauthorized error
@@ -81,8 +90,10 @@ declare namespace Boom {
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
*/
export function unauthorized(message?: string, scheme?: string | string[], attributes?: {[index: string]: string}): BoomError;
export function unauthorized(message?: null, scheme?: string | string[], attributes?: string): BoomError;
export function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): BoomError;
export function unauthorized(message?: string, scheme?: string[]): BoomError;
export function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): BoomError;
export function unauthorized(message?: null, scheme?: string[]): BoomError;
/**
* Returns a 402 Payment Required error
@@ -90,7 +101,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
*/
export function paymentRequired(message?: string, data?: any): BoomError;
export function paymentRequired<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 403 Forbidden error
@@ -98,7 +109,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
*/
export function forbidden(message?: string, data?: any): BoomError;
export function forbidden<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 404 Not Found error
@@ -106,7 +117,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
*/
export function notFound(message?: string, data?: any): BoomError;
export function notFound<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 405 Method Not Allowed error
@@ -115,7 +126,7 @@ declare namespace Boom {
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
*/
export function methodNotAllowed(message?: string, data?: any, allow?: string | string[]): BoomError;
export function methodNotAllowed<Data>(message?: string, data?: Data, allow?: string | string[]): BoomError<Data>;
/**
* Returns a 406 Not Acceptable error
@@ -123,7 +134,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
*/
export function notAcceptable(message?: string, data?: any): BoomError;
export function notAcceptable<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 407 Proxy Authentication Required error
@@ -131,7 +142,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
*/
export function proxyAuthRequired(message?: string, data?: any): BoomError;
export function proxyAuthRequired<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 408 Request Time-out error
@@ -139,7 +150,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
*/
export function clientTimeout(message?: string, data?: any): BoomError;
export function clientTimeout<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 409 Conflict error
@@ -147,7 +158,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
*/
export function conflict(message?: string, data?: any): BoomError;
export function conflict<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 410 Gone error
@@ -155,7 +166,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
*/
export function resourceGone(message?: string, data?: any): BoomError;
export function resourceGone<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 411 Length Required error
@@ -163,7 +174,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
*/
export function lengthRequired(message?: string, data?: any): BoomError;
export function lengthRequired<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 412 Precondition Failed error
@@ -171,7 +182,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
*/
export function preconditionFailed(message?: string, data?: any): BoomError;
export function preconditionFailed<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 413 Request Entity Too Large error
@@ -179,7 +190,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
*/
export function entityTooLarge(message?: string, data?: any): BoomError;
export function entityTooLarge<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 414 Request-URI Too Large error
@@ -187,7 +198,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
*/
export function uriTooLong(message?: string, data?: any): BoomError;
export function uriTooLong<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 415 Unsupported Media Type error
@@ -195,7 +206,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
*/
export function unsupportedMediaType(message?: string, data?: any): BoomError;
export function unsupportedMediaType<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 416 Requested Range Not Satisfiable error
@@ -203,7 +214,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
*/
export function rangeNotSatisfiable(message?: string, data?: any): BoomError;
export function rangeNotSatisfiable<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 417 Expectation Failed error
@@ -211,7 +222,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
*/
export function expectationFailed(message?: string, data?: any): BoomError;
export function expectationFailed<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 418 I'm a Teapot error
@@ -219,7 +230,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
*/
export function teapot(message?: string, data?: any): BoomError;
export function teapot<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 422 Unprocessable Entity error
@@ -227,7 +238,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
*/
export function badData(message?: string, data?: any): BoomError;
export function badData<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 423 Locked error
@@ -235,7 +246,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
*/
export function locked(message?: string, data?: any): BoomError;
export function locked<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 428 Precondition Required error
@@ -243,7 +254,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
*/
export function preconditionRequired(message?: string, data?: any): BoomError;
export function preconditionRequired<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 429 Too Many Requests error
@@ -251,7 +262,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
*/
export function tooManyRequests(message?: string, data?: any): BoomError;
export function tooManyRequests<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 451 Unavailable For Legal Reasons error
@@ -259,7 +270,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
*/
export function illegal(message?: string, data?: any): BoomError;
export function illegal<Data>(message?: string, data?: Data): BoomError<Data>;
// 5xx
/**
@@ -269,7 +280,16 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
*/
export function badImplementation(message?: string, data?: any): BoomError;
export function badImplementation<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 500 Internal Server Error error
* Only 500 errors will hide your message from the end user. Your message is recorded in the server log.
* @param message optional message.
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
*/
export function internal<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 501 Not Implemented error with your error message to the user
@@ -277,7 +297,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
*/
export function notImplemented(message?: string, data?: any): BoomError;
export function notImplemented<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 502 Bad Gateway error with your error message to the user
@@ -285,7 +305,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
*/
export function badGateway(message?: string, data?: any): BoomError;
export function badGateway<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 503 Service Unavailable error with your error message to the user
@@ -293,7 +313,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
*/
export function serverUnavailable(message?: string, data?: any): BoomError;
export function serverUnavailable<Data>(message?: string, data?: Data): BoomError<Data>;
/**
* Returns a 504 Gateway Time-out error with your error message to the user
@@ -301,5 +321,5 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
*/
export function gatewayTimeout(message?: string, data?: any): BoomError;
export function gatewayTimeout<Data>(message?: string, data?: Data): BoomError<Data>;
}
+36 -8
View File
@@ -17,25 +17,28 @@
interface DatepickerOptions {
format?: string | DatepickerCustomFormatOptions;
weekStart?: number;
startDate?: any;
endDate?: any;
startDate?: Date|string;
endDate?: Date|string;
autoclose?: boolean;
startView?: number;
todayBtn?: any;
todayBtn?: boolean|"linked";
todayHighlight?: boolean;
keyboardNavigation?: boolean;
language?: string;
beforeShowDay?: (date: any) => any;
beforeShowDay?: (date: Date) => undefined|string|boolean|DatepickerBeforeShowDayResponse;
beforeShowYear?: (date: Date) => undefined|string|boolean|DatepickerBeforeShowResponse;
beforeShowDecade?: (date: Date) => undefined|string|boolean|DatepickerBeforeShowResponse;
beforeShowCentury?: (date: Date) => undefined|string|boolean|DatepickerBeforeShowResponse;
calendarWeeks?: boolean;
clearBtn?: boolean;
daysOfWeekDisabled?: number[];
forceParse?: boolean;
inputs?: any[];
minViewMode?: any;
multidate?: any;
minViewMode?: 0|"days"|1|"months"|2|"years"|3|"decades"|4|"centuries"|"millenium";
multidate?: boolean|number;
multidateSeparator?: string;
orientation?: string;
assumeNearbyYear?: any;
orientation?: "auto"|"left top"|"left bottom"|"right top"|"right bottom";
assumeNearbyYear?: boolean|number;
viewMode?: string;
templates?: any;
zIndexOffset?: number;
@@ -43,6 +46,28 @@ interface DatepickerOptions {
immediateUpdates?: boolean;
title?: string;
container?: string;
datesDisabled?:string|string[];
daysOfWeekHighlighted?:string|number[];
defaultViewDate?:Date|string|DatepickerViewDate;
updateViewDate?:boolean;
}
interface DatepickerViewDate {
year:number;
/** Month starting with 0 */
month:number;
/** Day of the month starting with 1 */
day:number;
}
interface DatepickerBeforeShowResponse {
enabled?:boolean;
classes?: string;
tooltip?: string;
}
interface DatepickerBeforeShowDayResponse extends DatepickerBeforeShowResponse {
content?: string;
}
interface DatepickerCustomFormatOptions {
@@ -52,7 +77,10 @@ interface DatepickerCustomFormatOptions {
interface DatepickerEventObject extends JQueryEventObject {
date: Date;
dates: Date[];
format(ix?:number): string;
format(format?: string): string;
format(ix?:number, format?: string): string;
}
interface JQuery {
+5
View File
@@ -7,6 +7,11 @@ function test_dataType() {
var typ = breeze.DataType.DateTime;
var nm = typ.getName();
var dv = typ.defaultValue;
var isDate = typ.isDate;
var isFloat = typ.isFloat;
var isInteger = typ.isInteger;
var isNumeric = typ.isNumeric;
var qjod = typ.quoteJsonOData;
var symbs = breeze.DataType.getSymbols();
var x = typ.parentEnum === <breeze.core.IEnum> breeze.DataType;
var isFalse = breeze.DataType.contains(breeze.DataType.Double);
+36 -26
View File
@@ -16,7 +16,7 @@
// Updated Jul 15 2016 - Added methods to JsonResultsAdapter - Steve Schmitt
// Updated Sep 23 2016 - Added core methods
// Updated March 5 2017 - Eliminate promises.IPromise<T> and replace with Promise<T>
// Updated Apr 28 2017 - Fixed DataType
declare namespace breeze.core {
export interface ErrorCallback {
@@ -266,9 +266,33 @@ declare namespace breeze {
export class DataTypeSymbol extends breeze.core.EnumSymbol {
defaultValue: any;
isNumeric: boolean;
isDate: boolean;
isDate?: boolean;
isFloat?: boolean;
isInteger?: boolean;
isNumeric?: boolean;
quoteJsonOData?: boolean;
validatorCtor: (context: any) => Validator;
/** Function to convert a value from string to this DataType. Note that this will be called each time a property is changed, so make it fast. */
parse?: (val: any, sourceTypeName?: string) => any;
/** Function to format this DataType for OData queries. */
fmtOData: (val: any) => any;
/** Optional function to get the next value for key generation, if this datatype is used as a key. Uses an internal table of previous values. */
getNext?: () => any;
/** Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast. */
normalize?: (val: any) => any;
/** Optional function to get the next value when the datatype is used as a concurrency property. */
getConcurrencyValue?: (val: any) => any;
/** Optional function to convert a raw (server) value from string to this DataType. */
parseRawValue?: (val: any) => any;
}
export interface DataType extends breeze.core.IEnum {
Binary: DataTypeSymbol;
Boolean: DataTypeSymbol;
@@ -285,30 +309,16 @@ declare namespace breeze {
String: DataTypeSymbol;
Time: DataTypeSymbol;
Undefined: DataTypeSymbol;
toDataType(typeName: string): DataTypeSymbol;
constants: { nextNumber: number, nextNumberIncrement: number, stringPrefix: string };
fromEdmDataType(typeName: string): DataTypeSymbol;
fromValue(val: any): DataTypeSymbol;
getComparableFn(dataType: DataTypeSymbol): (value: any) => any;
parseDateAsUTC(source: any): Date;
parseDateFromServer(date: any): Date;
defaultValue: any;
isNumeric: boolean;
isInteger: boolean;
/** Function to convert a value from string to this DataType. Note that this will be called each time a property is changed, so make it fast. */
parse: (val: any, sourceTypeName: string) => any;
/** Function to format this DataType for OData queries. */
fmtOData: (val: any) => any;
/** Optional function to get the next value for key generation, if this datatype is used as a key. Uses an internal table of previous values. */
getNext?: () => any;
/** Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast. */
normalize?: (val: any) => any;
/** Optional function to get the next value when the datatype is used as a concurrency property. */
getConcurrencyValue?: (val: any) => any;
/** Optional function to convert a raw (server) value from string to this DataType. */
parseRawValue?: (val: any) => any;
parseRawValue(val: any, dataType?: DataTypeSymbol): any;
parseTimeFromServer(source: any): string;
}
export var DataType: DataType;
+12
View File
@@ -1,6 +1,7 @@
import browserify = require("browserify");
import fs = require("fs");
import stream = require('stream');
import insertGlobals = require("insert-module-globals");
var bNoArg = browserify();
@@ -47,4 +48,15 @@ var record_pipeline = b.pipeline.get('record');
b.bundle().pipe(process.stdout);
var argv = { igv: "__filename,__dirname" };
var insertGlobalVars: insertGlobals.VarsOption = {};
var wantedGlobalVars = argv.igv.split(',');
Object.keys(insertGlobals.vars).forEach((x) => {
if (wantedGlobalVars.indexOf(x) === -1) {
insertGlobalVars[x] = undefined;
}
});
var b = browserify('./browser/main.js', {
insertGlobalVars: insertGlobalVars
});
+5 -3
View File
@@ -1,10 +1,12 @@
// Type definitions for Browserify v12.0.1
// Type definitions for Browserify 12.0
// Project: http://browserify.org/
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>, John Vilk <https://github.com/jvilk>
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>, John Vilk <https://github.com/jvilk>, Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import insertGlobals = require('insert-module-globals');
declare var browserify: browserify.BrowserifyConstructor;
export = browserify;
@@ -74,7 +76,7 @@ interface Options {
// The global export will be sanitized and camel cased.
standalone?: string;
// will be passed to insert-module-globals as the opts.vars parameter.
insertGlobalVars?: {[globalName: string]: (file: string, basedir: string) => any};
insertGlobalVars?: insertGlobals.VarsOption;
// defaults to 'require' in expose mode but you can use another name.
externalRequireName?: string;
}
+1 -1
View File
@@ -8,5 +8,5 @@ declare class PostBuffer extends BufferStream {
/** set a callback to get all post data from a http server request */
onEnd(callback: (data: any) => void): void;
/** pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe */
pipe(stream: NodeJS.WritableStream, options?: BufferStream.Opts): NodeJS.ReadableStream;
pipe(stream: NodeJS.WritableStream, options?: { end?: boolean }): NodeJS.ReadableStream;
}
+17 -19
View File
@@ -1,16 +1,15 @@
import Logger = require('bunyan');
var ringBufferOptions: Logger.RingBufferOptions = {
let ringBufferOptions: Logger.RingBufferOptions = {
limit: 100
};
var ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
let ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
ringBuffer.write("hello");
ringBuffer.end();
ringBuffer.destroy();
ringBuffer.destroySoon();
var level: number;
let level: number;
level = Logger.resolveLevel("trace");
level = Logger.resolveLevel("debug");
level = Logger.resolveLevel("info");
@@ -24,7 +23,7 @@ level = Logger.resolveLevel(Logger.WARN);
level = Logger.resolveLevel(Logger.ERROR);
level = Logger.resolveLevel(Logger.FATAL);
var options: Logger.LoggerOptions = {
let options: Logger.LoggerOptions = {
name: 'test-logger',
serializers: Logger.stdSerializers,
streams: [{
@@ -54,13 +53,13 @@ var options: Logger.LoggerOptions = {
}]
};
var log = Logger.createLogger(options);
let log = Logger.createLogger(options);
var customSerializer = function(anything: any) {
return { obj: anything};
let customSerializer = (anything: any) => {
return { obj: anything };
};
log.addSerializers({anything: customSerializer});
log.addSerializers({ anything: customSerializer });
log.addSerializers(Logger.stdSerializers);
log.addSerializers(
{
@@ -70,9 +69,9 @@ log.addSerializers(
}
);
var child = log.child({name: 'child'});
let child = log.child({ name: 'child' });
child.reopenFileStreams();
log.addStream({path: '/dev/null'});
log.addStream({ path: '/dev/null' });
child.level(Logger.DEBUG);
child.level('debug');
child.levels(0, Logger.ERROR);
@@ -80,9 +79,9 @@ child.levels(0, 'error');
child.levels('stream1', Logger.FATAL);
child.levels('stream1', 'fatal');
var buffer = new Buffer(0);
var error = new Error('');
var object = {
let buffer = new Buffer(0);
let error = new Error('');
let object = {
test: 123
};
@@ -117,12 +116,11 @@ log.fatal(error);
log.fatal(object);
log.fatal('Hello, %s', 'world!');
var recursive: any = {
let recursive: any = {
hello: 'world',
whats: {
huh: recursive
}
}
whats: {}
};
recursive.whats['huh'] = recursive;
JSON.stringify(recursive, Logger.safeCycles());
+117 -124
View File
@@ -1,4 +1,4 @@
// Type definitions for node-bunyan
// Type definitions for node-bunyan 1.8
// Project: https://github.com/trentm/node-bunyan
// Definitions by: Alex Mikhalev <https://github.com/amikhalev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -10,21 +10,24 @@ import { EventEmitter } from 'events';
declare class Logger extends EventEmitter {
constructor(options: Logger.LoggerOptions);
addStream(stream: Logger.Stream): void;
addSerializers(serializers: Logger.Serializers | Logger.StdSerializers): void;
child(options: Logger.LoggerOptions, simple?: boolean): Logger;
child(obj: Object, simple?: boolean): Logger;
addSerializers(serializers: Logger.Serializers): void;
child(options: Object, simple?: boolean): Logger;
reopenFileStreams(): void;
level(): string | number;
level(value: number | string): void;
levels(name: number | string, value: number | string): void;
level(): number;
level(value: Logger.LogLevel): void;
levels(): number[];
levels(name: number | string): number;
levels(name: number | string, value: Logger.LogLevel): void;
fields: any;
src: boolean;
/* tslint:disable:unified-signatures */
/**
* Returns a boolean: is the `trace` level enabled?
*
*
* This is equivalent to `log.isTraceEnabled()` or `log.isEnabledFor(TRACE)` in log4j.
*/
trace(): boolean;
@@ -35,27 +38,25 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
trace(error: Error, format?: any, ...params: any[]): void;
trace(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
trace(format: string | number, ...params: any[]): void;
trace(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
trace(obj: Object, format?: any, ...params: any[]): void;
trace(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
trace(format: any, ...params: any[]): void;
/**
* Returns a boolean: is the `debug` level enabled?
*
*
* This is equivalent to `log.isDebugEnabled()` or `log.isEnabledFor(DEBUG)` in log4j.
*/
debug(): boolean;
@@ -66,27 +67,25 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
debug(error: Error, format?: any, ...params: any[]): void;
debug(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
debug(format: string | number, ...params: any[]): void;
debug(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
debug(obj: Object, format?: any, ...params: any[]): void;
debug(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
debug(format: any, ...params: any[]): void;
/**
* Returns a boolean: is the `info` level enabled?
*
*
* This is equivalent to `log.isInfoEnabled()` or `log.isEnabledFor(INFO)` in log4j.
*/
info(): boolean;
@@ -97,27 +96,25 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
info(error: Error, format?: any, ...params: any[]): void;
info(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
info(format: string | number, ...params: any[]): void;
info(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
info(obj: Object, format?: any, ...params: any[]): void;
info(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
info(format: any, ...params: any[]): void;
/**
* Returns a boolean: is the `warn` level enabled?
*
*
* This is equivalent to `log.isWarnEnabled()` or `log.isEnabledFor(WARN)` in log4j.
*/
warn(): boolean;
@@ -128,27 +125,25 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
warn(error: Error, format?: any, ...params: any[]): void;
warn(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
warn(format: string | number, ...params: any[]): void;
warn(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
warn(obj: Object, format?: any, ...params: any[]): void;
warn(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
warn(format: any, ...params: any[]): void;
/**
* Returns a boolean: is the `error` level enabled?
*
*
* This is equivalent to `log.isErrorEnabled()` or `log.isEnabledFor(ERROR)` in log4j.
*/
error(): boolean;
@@ -159,27 +154,25 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
error(error: Error, format?: any, ...params: any[]): void;
error(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
error(format: string | number, ...params: any[]): void;
error(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
error(obj: Object, format?: any, ...params: any[]): void;
error(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
error(format: any, ...params: any[]): void;
/**
* Returns a boolean: is the `fatal` level enabled?
*
*
* This is equivalent to `log.isFatalEnabled()` or `log.isEnabledFor(FATAL)` in log4j.
*/
fatal(): boolean;
@@ -190,90 +183,90 @@ declare class Logger extends EventEmitter {
* (including the stack) and sets `msg` to the exception
* message or you can specify the `msg`.
*/
fatal(error: Error, format?: any, ...params: any[]): void;
fatal(buffer: Buffer, format?: any, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
fatal(format: string | number, ...params: any[]): void;
fatal(error: Error, ...params: any[]): void;
/**
* The first field can optionally be a "fields" object, which
* is merged into the log record.
*
*
* To pass in an Error *and* other fields, use the `err`
* field name for the Error instance.
*/
fatal(obj: Object, format?: any, ...params: any[]): void;
fatal(obj: Object, ...params: any[]): void;
/**
* Uses `util.format` for msg formatting.
*/
fatal(format: any, ...params: any[]): void;
/* tslint:enable:unified-signatures */
}
declare namespace Logger {
const TRACE: number;
const DEBUG: number;
const INFO: number;
const WARN: number;
const ERROR: number;
const FATAL: number;
const TRACE: number;
const DEBUG: number;
const INFO: number;
const WARN: number;
const ERROR: number;
const FATAL: number;
const stdSerializers: StdSerializers;
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | number;
function createLogger(options: LoggerOptions): Logger;
const stdSerializers: StdSerializers;
function safeCycles(): (key: string, value: any) => any;
function createLogger(options: LoggerOptions): Logger;
function resolveLevel(value: number | string): number;
function safeCycles(): (key: string, value: any) => any;
interface Stream {
type?: string;
level?: number | string;
path?: string;
stream?: NodeJS.WritableStream | Stream;
closeOnExit?: boolean;
period?: string;
count?: number;
}
function resolveLevel(value: LogLevel): number;
interface LoggerOptions {
name: string;
streams?: Stream[];
level?: string | number;
stream?: NodeJS.WritableStream;
serializers?: Serializers | StdSerializers;
src?: boolean;
[custom: string]: any;
}
interface Stream {
type?: string;
level?: LogLevel;
path?: string;
stream?: NodeJS.WritableStream | Stream;
closeOnExit?: boolean;
period?: string;
count?: number;
}
interface Serializer {
(input:any): any;
}
interface LoggerOptions {
name: string;
streams?: Stream[];
level?: LogLevel;
stream?: NodeJS.WritableStream;
serializers?: Serializers;
src?: boolean;
[custom: string]: any;
}
interface Serializers {
[key: string]: Serializer
}
type Serializer = (input: any) => any;
interface StdSerializers {
err: Serializer;
res: Serializer;
req: Serializer;
}
interface Serializers {
[key: string]: Serializer;
}
interface RingBufferOptions {
limit?: number;
}
interface StdSerializers extends Serializers {
err: Serializer;
res: Serializer;
req: Serializer;
}
class RingBuffer extends EventEmitter {
constructor(options: RingBufferOptions);
interface RingBufferOptions {
limit?: number;
}
writable: boolean;
records: any[];
class RingBuffer extends EventEmitter implements NodeJS.WritableStream {
constructor(options: RingBufferOptions);
write(record: any): void;
end(record?: any): void;
destroy(): void;
destroySoon(): void;
}
writable: boolean;
records: any[];
write(record: any): boolean;
end(record?: any): void;
destroy(): void;
destroySoon(): void;
}
}
export = Logger;
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
// ban-types needs to be disabled to support TypeScript <2.2
"ban-types": false
}
}
+2 -1
View File
@@ -9,8 +9,9 @@ console.log(bytes.format(104857, { thousandsSeparator: ' ' }));
console.log(bytes.format(104857, { decimalPlaces: 2 }));
console.log(bytes.format(104857, { fixedDecimals: true }));
console.log(bytes.format(104857, { unitSeparator: '-' }));
console.log(bytes.format(104857, { unit: 'GB' }));
console.log(bytes('1024kb'));
console.log(bytes(1024));
console.log(bytes.parse('1024kb'));
console.log(bytes.parse(1024));
console.log(bytes.parse(1024));
+3 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for bytes v2.4.0
// Type definitions for bytes v2.5.0
// Project: https://github.com/visionmedia/bytes.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -7,7 +7,8 @@ interface BytesOptions {
decimalPlaces?: number,
thousandsSeparator?: string,
unitSeparator?: string,
fixedDecimals?: boolean
fixedDecimals?: boolean,
unit?: string
}
/**
*Convert the given value in bytes into a string.
+2 -1
View File
@@ -620,7 +620,8 @@ function chart_bar() {
},
bar: {
width: {
ratio: 0.5 // this makes bar width 50% of length between ticks
ratio: 0.5, // this makes bar width 50% of length between ticks
max: 50 // this limits maximum width of bar to 50px
}
// or
//width: 100 // this makes bar width 100px
+11 -1
View File
@@ -1,6 +1,7 @@
// Type definitions for C3js v0.4
// Project: http://c3js.org/
// Definitions by: Marc Climent <https://github.com/mcliment>
// Gerin Jacob <https://github.com/gerinjacob>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as d3 from "d3";
@@ -161,7 +162,16 @@ declare namespace c3 {
/**
* Change the width of bar chart. If ratio is specified, change the width of bar chart by ratio.
*/
width?: number | { ratio: number };
width?: number | {
/**
* Set the width of each bar by ratio
*/
ratio: number,
/**
* Set max width of each bar
*/
max?: number
};
/**
* Set if min or max value will be 0 on bar chart.
*/
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/hapijs/catbox
// Definitions by: Jason Swearingen <http://github.com/jasonswearingen>, AJP <https://github.com/AJamesPhillips>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
import * as Boom from 'boom';
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Clément Prévot <https://github.com/clementprevot/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="chai" />
/// <reference types="chai" />
declare global {
namespace Chai {
@@ -7,7 +7,7 @@ class TestClass {}
// ReSharper disable WrongExpressionStatement
// BDD API (expect)
var thenableNum: PromiseLike<number>;
var thenableNum: PromiseLike<number> = Promise.resolve(3);
thenableNum = chai.expect(thenableNum).to.eventually.equal(3);
thenableNum = chai.expect(thenableNum).to.eventually.have.property('foo');
thenableNum = chai.expect(thenableNum).to.become(3);
@@ -40,8 +40,8 @@ thenableNum = thenableNum.should.eventually.equal(3).notify(() => console.log('d
thenableNum = thenableNum.should.be.fulfilled.and.notify(() => console.log('done'));
// Complex examples on https://github.com/domenic/chai-as-promised#working-with-non-promisefriendly-test-runners
thenableNum.should.be.fulfilled.then(function () {
thenableNum.should.equal("after");
thenableNum.should.be.fulfilled.then(() => {
thenableNum.should.equal("after");
}).should.notify(() => console.log('done'));
Promise.all([
@@ -63,3 +63,15 @@ thenableVoid = chai.assert.isRejected(thenableNum, /error message matcher/, "opt
// Check that original chai assertions are not broken
var undef: void;
undef = chai.assert.equal(10, 4, 'Message');
chaiAsPromised.transferPromiseness = (assertion, promise) => {
assertion.then = promise.then.bind(promise);
};
chaiAsPromised.transformAsserterArgs = (args) => {
return args.map((x) => x + 1);
};
chaiAsPromised.transformAsserterArgs = (args) => {
return Promise.all(args);
};
+9 -3
View File
@@ -1,13 +1,19 @@
// Type definitions for chai-as-promised
// Project: https://github.com/domenic/chai-as-promised/
// Definitions by: jt000 <https://github.com/jt000>, Yuki Kokubun <https://github.com/Kuniwak>
// Definitions by: jt000 <https://github.com/jt000>, Yuki Kokubun <https://github.com/Kuniwak>, Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="chai" />
declare module 'chai-as-promised' {
function chaiAsPromised(chai: any, utils: any): void;
namespace chaiAsPromised {}
namespace chaiAsPromised {
function transferPromiseness(assertion: Chai.PromisedAssertion, promise: PromiseLike<any>): void;
function transformAsserterArgs(values: any[]): any;
}
export = chaiAsPromised;
}
@@ -59,7 +65,7 @@ declare namespace Chai {
haveOwnProperty: PromisedOwnProperty;
length: PromisedLength;
lengthOf: PromisedLength;
match(regexp: RegExp|string, message?: string): PromisedAssertion;
match(regexp: RegExp | string, message?: string): PromisedAssertion;
string(string: string, message?: string): PromisedAssertion;
keys: PromisedKeys;
key(string: string): PromisedAssertion;
+2 -2
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +20,4 @@
"index.d.ts",
"chai-as-promised-tests.ts"
]
}
}
+17 -17
View File
@@ -490,20 +490,20 @@ function property() {
({ foo: { bar: 'baz' } }).should.have.property('foo.bar');
}
function deepProperty() {
function nestedProperty() {
expect({ 'foo.bar': 'baz' })
.to.not.have.deep.property('foo.bar');
.to.not.have.nested.property('foo.bar');
({ 'foo.bar': 'baz' }).should
.not.have.deep.property('foo.bar');
.not.have.nested.property('foo.bar');
expect({ foo: { bar: 'baz' } })
.to.have.deep.property('foo.bar');
.to.have.nested.property('foo.bar');
({ foo: { bar: 'baz' } }).should
.have.deep.property('foo.bar');
.have.nested.property('foo.bar');
expect({ 'foo.bar': 'baz' })
.to.have.deep.property('foo.bar');
.to.have.nested.property('foo.bar');
({ 'foo.bar': 'baz' }).should
.have.deep.property('foo.bar');
.have.nested.property('foo.bar');
}
function property2() {
@@ -525,24 +525,24 @@ function property2() {
'asd'.should.have.property('constructor', Number, 'blah');
}
function deepProperty2() {
function nestedProperty2() {
expect({ foo: { bar: 'baz' } })
.to.have.deep.property('foo.bar', 'baz');
.to.have.nested.property('foo.bar', 'baz');
({ foo: { bar: 'baz' } }).should
.have.deep.property('foo.bar', 'baz');
.have.nested.property('foo.bar', 'baz');
expect({ foo: { bar: 'baz' } })
.to.have.deep.property('foo.bar', 'quux', 'blah');
.to.have.nested.property('foo.bar', 'quux', 'blah');
({ foo: { bar: 'baz' } }).should
.have.deep.property('foo.bar', 'quux', 'blah');
.have.nested.property('foo.bar', 'quux', 'blah');
expect({ foo: { bar: 'baz' } })
.to.not.have.deep.property('foo.bar', 'baz', 'blah');
.to.not.have.nested.property('foo.bar', 'baz', 'blah');
({ foo: { bar: 'baz' } }).should
.not.have.deep.property('foo.bar', 'baz', 'blah');
.not.have.nested.property('foo.bar', 'baz', 'blah');
expect({ foo: 5 })
.to.not.have.deep.property('foo.bar', 'baz', 'blah');
.to.not.have.nested.property('foo.bar', 'baz', 'blah');
({ foo: 5 }).should
.not.have.deep.property('foo.bar', 'baz', 'blah');
.not.have.nested.property('foo.bar', 'baz', 'blah');
}
function ownProperty() {
@@ -1659,4 +1659,4 @@ suite('assert', () => {
assert.notFrozen(obj);
assert.notFrozen(obj, 'message');
});
});
});
+107 -100
View File
@@ -1,4 +1,4 @@
// Type definitions for chai 3.5.0
// Type definitions for chai 4.0.0
// Project: http://chaijs.com/
// Definitions by: Jed Mao <https://github.com/jedmao/>,
// Bart van der Schoor <https://github.com/Bartvds>,
@@ -61,6 +61,7 @@ declare namespace Chai {
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
not: Assertion;
deep: Deep;
nested: Nested;
any: KeyFilter;
all: KeyFilter;
a: TypeComparison;
@@ -167,6 +168,12 @@ declare namespace Chai {
(expected: number, delta: number, message?: string): Assertion;
}
interface Nested {
include: Include;
property: Property;
members: Members;
}
interface Deep {
equal: Equal;
equals: Equal;
@@ -256,7 +263,7 @@ declare namespace Chai {
/**
* Throws a failure.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -268,7 +275,7 @@ declare namespace Chai {
/**
* Asserts that object is truthy.
*
*
* @type T Type of object.
* @param object Object to test.
* @param message Message to display on error.
@@ -277,7 +284,7 @@ declare namespace Chai {
/**
* Asserts that object is truthy.
*
*
* @type T Type of object.
* @param object Object to test.
* @param message Message to display on error.
@@ -286,7 +293,7 @@ declare namespace Chai {
/**
* Asserts that object is falsy.
*
*
* @type T Type of object.
* @param object Object to test.
* @param message Message to display on error.
@@ -295,7 +302,7 @@ declare namespace Chai {
/**
* Asserts that object is falsy.
*
*
* @type T Type of object.
* @param object Object to test.
* @param message Message to display on error.
@@ -304,7 +311,7 @@ declare namespace Chai {
/**
* Asserts non-strict equality (==) of actual and expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -314,7 +321,7 @@ declare namespace Chai {
/**
* Asserts non-strict inequality (==) of actual and expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -324,7 +331,7 @@ declare namespace Chai {
/**
* Asserts strict equality (===) of actual and expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -334,7 +341,7 @@ declare namespace Chai {
/**
* Asserts strict inequality (==) of actual and expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -344,7 +351,7 @@ declare namespace Chai {
/**
* Asserts that actual is deeply equal to expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -354,7 +361,7 @@ declare namespace Chai {
/**
* Asserts that actual is not deeply equal to expected.
*
*
* @type T Type of the objects.
* @param actual Actual value.
* @param expected Potential expected value.
@@ -364,7 +371,7 @@ declare namespace Chai {
/**
* Asserts valueToCheck is strictly greater than (>) valueToBeAbove.
*
*
* @param valueToCheck Actual value.
* @param valueToBeAbove Minimum Potential expected value.
* @param message Message to display on error.
@@ -373,7 +380,7 @@ declare namespace Chai {
/**
* Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast.
*
*
* @param valueToCheck Actual value.
* @param valueToBeAtLeast Minimum Potential expected value.
* @param message Message to display on error.
@@ -382,7 +389,7 @@ declare namespace Chai {
/**
* Asserts valueToCheck is strictly less than (<) valueToBeBelow.
*
*
* @param valueToCheck Actual value.
* @param valueToBeBelow Minimum Potential expected value.
* @param message Message to display on error.
@@ -391,7 +398,7 @@ declare namespace Chai {
/**
* Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost.
*
*
* @param valueToCheck Actual value.
* @param valueToBeAtMost Minimum Potential expected value.
* @param message Message to display on error.
@@ -400,7 +407,7 @@ declare namespace Chai {
/**
* Asserts that value is true.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -409,7 +416,7 @@ declare namespace Chai {
/**
* Asserts that value is false.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -418,7 +425,7 @@ declare namespace Chai {
/**
* Asserts that value is not true.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -427,7 +434,7 @@ declare namespace Chai {
/**
* Asserts that value is not false.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -436,7 +443,7 @@ declare namespace Chai {
/**
* Asserts that value is null.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -445,7 +452,7 @@ declare namespace Chai {
/**
* Asserts that value is not null.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -454,7 +461,7 @@ declare namespace Chai {
/**
* Asserts that value is not null.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -463,7 +470,7 @@ declare namespace Chai {
/**
* Asserts that value is not null.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -472,7 +479,7 @@ declare namespace Chai {
/**
* Asserts that value is undefined.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -481,7 +488,7 @@ declare namespace Chai {
/**
* Asserts that value is not undefined.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -490,7 +497,7 @@ declare namespace Chai {
/**
* Asserts that value is a function.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -499,7 +506,7 @@ declare namespace Chai {
/**
* Asserts that value is not a function.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -509,7 +516,7 @@ declare namespace Chai {
/**
* Asserts that value is an object of type 'Object'
* (as revealed by Object.prototype.toString).
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -520,7 +527,7 @@ declare namespace Chai {
/**
* Asserts that value is not an object of type 'Object'
* (as revealed by Object.prototype.toString).
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -529,7 +536,7 @@ declare namespace Chai {
/**
* Asserts that value is an array.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -538,7 +545,7 @@ declare namespace Chai {
/**
* Asserts that value is not an array.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -547,7 +554,7 @@ declare namespace Chai {
/**
* Asserts that value is a string.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -556,7 +563,7 @@ declare namespace Chai {
/**
* Asserts that value is not a string.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -565,7 +572,7 @@ declare namespace Chai {
/**
* Asserts that value is a number.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -574,7 +581,7 @@ declare namespace Chai {
/**
* Asserts that value is not a number.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -583,7 +590,7 @@ declare namespace Chai {
/**
* Asserts that value is a boolean.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -592,7 +599,7 @@ declare namespace Chai {
/**
* Asserts that value is not a boolean.
*
*
* @type T Type of value.
* @param value Actual value.
* @param message Message to display on error.
@@ -601,7 +608,7 @@ declare namespace Chai {
/**
* Asserts that value's type is name, as determined by Object.prototype.toString.
*
*
* @type T Type of value.
* @param value Actual value.
* @param name Potential expected type name of value.
@@ -611,7 +618,7 @@ declare namespace Chai {
/**
* Asserts that value's type is not name, as determined by Object.prototype.toString.
*
*
* @type T Type of value.
* @param value Actual value.
* @param name Potential expected type name of value.
@@ -621,7 +628,7 @@ declare namespace Chai {
/**
* Asserts that value is an instance of constructor.
*
*
* @type T Type of value.
* @param value Actual value.
* @param constructor Potential expected contructor of value.
@@ -631,7 +638,7 @@ declare namespace Chai {
/**
* Asserts that value is not an instance of constructor.
*
*
* @type T Type of value.
* @param value Actual value.
* @param constructor Potential expected contructor of value.
@@ -641,7 +648,7 @@ declare namespace Chai {
/**
* Asserts that haystack includes needle.
*
*
* @param haystack Container string.
* @param needle Potential expected substring of haystack.
* @param message Message to display on error.
@@ -650,7 +657,7 @@ declare namespace Chai {
/**
* Asserts that haystack includes needle.
*
*
* @type T Type of values in haystack.
* @param haystack Container array.
* @param needle Potential value contained in haystack.
@@ -660,7 +667,7 @@ declare namespace Chai {
/**
* Asserts that haystack does not include needle.
*
*
* @param haystack Container string.
* @param needle Potential expected substring of haystack.
* @param message Message to display on error.
@@ -669,7 +676,7 @@ declare namespace Chai {
/**
* Asserts that haystack does not include needle.
*
*
* @type T Type of values in haystack.
* @param haystack Container array.
* @param needle Potential value contained in haystack.
@@ -679,7 +686,7 @@ declare namespace Chai {
/**
* Asserts that value matches the regular expression regexp.
*
*
* @param value Actual value.
* @param regexp Potential match of value.
* @param message Message to display on error.
@@ -688,7 +695,7 @@ declare namespace Chai {
/**
* Asserts that value does not match the regular expression regexp.
*
*
* @param value Actual value.
* @param regexp Potential match of value.
* @param message Message to display on error.
@@ -697,7 +704,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property.
*
*
* @type T Type of object.
* @param object Container object.
* @param property Potential contained property of object.
@@ -707,7 +714,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property.
*
*
* @type T Type of object.
* @param object Container object.
* @param property Potential contained property of object.
@@ -718,7 +725,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property, which can be a string
* using dot- and bracket-notation for deep reference.
*
*
* @type T Type of object.
* @param object Container object.
* @param property Potential contained property of object.
@@ -729,7 +736,7 @@ declare namespace Chai {
/**
* Asserts that object does not have a property named by property, which can be a
* string using dot- and bracket-notation for deep reference.
*
*
* @type T Type of object.
* @param object Container object.
* @param property Potential contained property of object.
@@ -739,7 +746,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property with value given by value.
*
*
* @type T Type of object.
* @type V Type of value.
* @param object Container object.
@@ -751,7 +758,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property with value given by value.
*
*
* @type T Type of object.
* @type V Type of value.
* @param object Container object.
@@ -764,7 +771,7 @@ declare namespace Chai {
/**
* Asserts that object has a property named by property, which can be a string
* using dot- and bracket-notation for deep reference.
*
*
* @type T Type of object.
* @type V Type of value.
* @param object Container object.
@@ -777,7 +784,7 @@ declare namespace Chai {
/**
* Asserts that object does not have a property named by property, which can be a
* string using dot- and bracket-notation for deep reference.
*
*
* @type T Type of object.
* @type V Type of value.
* @param object Container object.
@@ -789,7 +796,7 @@ declare namespace Chai {
/**
* Asserts that object has a length property with the expected value.
*
*
* @type T Type of object.
* @param object Container object.
* @param length Potential expected length of object.
@@ -799,7 +806,7 @@ declare namespace Chai {
/**
* Asserts that fn will throw an error.
*
*
* @param fn Function that may throw.
* @param message Message to display on error.
*/
@@ -807,7 +814,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param regExp Potential expected message match.
* @param message Message to display on error.
@@ -816,7 +823,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -826,7 +833,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor
* and an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -835,7 +842,7 @@ declare namespace Chai {
/**
* Asserts that fn will throw an error.
*
*
* @param fn Function that may throw.
* @param message Message to display on error.
*/
@@ -843,7 +850,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param regExp Potential expected message match.
* @param message Message to display on error.
@@ -852,7 +859,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -862,7 +869,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor
* and an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -871,7 +878,7 @@ declare namespace Chai {
/**
* Asserts that fn will throw an error.
*
*
* @param fn Function that may throw.
* @param message Message to display on error.
*/
@@ -879,7 +886,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param regExp Potential expected message match.
* @param message Message to display on error.
@@ -888,7 +895,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -898,7 +905,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor
* and an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -907,7 +914,7 @@ declare namespace Chai {
/**
* Asserts that fn will not throw an error.
*
*
* @param fn Function that may throw.
* @param message Message to display on error.
*/
@@ -915,7 +922,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param regExp Potential expected message match.
* @param message Message to display on error.
@@ -924,7 +931,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -934,7 +941,7 @@ declare namespace Chai {
/**
* Asserts that function will throw an error that is an instance of constructor
* and an error with message matching regexp.
*
*
* @param fn Function that may throw.
* @param constructor Potential expected error constructor.
* @param message Message to display on error.
@@ -943,7 +950,7 @@ declare namespace Chai {
/**
* Compares two values using operator.
*
*
* @param val1 Left value during comparison.
* @param operator Comparison operator.
* @param val2 Right value during comparison.
@@ -953,7 +960,7 @@ declare namespace Chai {
/**
* Asserts that the target is equal to expected, to within a +/- delta range.
*
*
* @param actual Actual value
* @param expected Potential expected value.
* @param delta Maximum differenced between values.
@@ -963,7 +970,7 @@ declare namespace Chai {
/**
* Asserts that the target is equal to expected, to within a +/- delta range.
*
*
* @param actual Actual value
* @param expected Potential expected value.
* @param delta Maximum differenced between values.
@@ -973,7 +980,7 @@ declare namespace Chai {
/**
* Asserts that set1 and set2 have the same members. Order is not take into account.
*
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
@@ -984,7 +991,7 @@ declare namespace Chai {
/**
* Asserts that set1 and set2 have the same members using deep equality checking.
* Order is not take into account.
*
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
@@ -994,7 +1001,7 @@ declare namespace Chai {
/**
* Asserts that subset is included in superset. Order is not take into account.
*
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
@@ -1005,7 +1012,7 @@ declare namespace Chai {
/**
* Asserts that subset is included in superset using deep equality checking.
* Order is not take into account.
*
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
@@ -1015,7 +1022,7 @@ declare namespace Chai {
/**
* Asserts that non-object, non-array value inList appears in the flat array list.
*
*
* @type T Type of list values.
* @param inList Value expected to be in the list.
* @param list List of values.
@@ -1025,7 +1032,7 @@ declare namespace Chai {
/**
* Asserts that a function changes the value of a property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1036,7 +1043,7 @@ declare namespace Chai {
/**
* Asserts that a function does not change the value of a property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1047,7 +1054,7 @@ declare namespace Chai {
/**
* Asserts that a function increases an object property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1058,7 +1065,7 @@ declare namespace Chai {
/**
* Asserts that a function does not increase an object property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1069,7 +1076,7 @@ declare namespace Chai {
/**
* Asserts that a function decreases an object property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1080,7 +1087,7 @@ declare namespace Chai {
/**
* Asserts that a function does not decrease an object property.
*
*
* @type T Type of object.
* @param modifier Function to run.
* @param object Container object.
@@ -1091,7 +1098,7 @@ declare namespace Chai {
/**
* Asserts if value is not a false value, and throws if it is a true value.
*
*
* @type T Type of object.
* @param object Actual value.
* @param message Message to display on error.
@@ -1102,7 +1109,7 @@ declare namespace Chai {
/**
* Asserts that object is extensible (can have new properties added to it).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1111,7 +1118,7 @@ declare namespace Chai {
/**
* Asserts that object is extensible (can have new properties added to it).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1120,7 +1127,7 @@ declare namespace Chai {
/**
* Asserts that object is not extensible.
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1129,7 +1136,7 @@ declare namespace Chai {
/**
* Asserts that object is not extensible.
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1139,7 +1146,7 @@ declare namespace Chai {
/**
* Asserts that object is sealed (can have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1149,7 +1156,7 @@ declare namespace Chai {
/**
* Asserts that object is sealed (can have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1158,7 +1165,7 @@ declare namespace Chai {
/**
* Asserts that object is not sealed.
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1167,7 +1174,7 @@ declare namespace Chai {
/**
* Asserts that object is not sealed.
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1177,7 +1184,7 @@ declare namespace Chai {
/**
* Asserts that object is frozen (cannot have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1187,7 +1194,7 @@ declare namespace Chai {
/**
* Asserts that object is frozen (cannot have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1197,7 +1204,7 @@ declare namespace Chai {
/**
* Asserts that object is not frozen (cannot have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
@@ -1207,7 +1214,7 @@ declare namespace Chai {
/**
* Asserts that object is not frozen (cannot have new properties added to it
* and its existing properties cannot be removed).
*
*
* @type T Type of object
* @param object Actual value.
* @param message Message to display on error.
+39
View File
@@ -24,11 +24,50 @@ declare class Chart {
getElementAtEvent: (e: any) => {};
getElementsAtEvent: (e: any) => {}[];
getDatasetAtEvent: (e: any) => {}[];
static pluginService: PluginServiceStatic;
static defaults: {
global: Chart.ChartOptions;
}
}
declare class PluginServiceStatic {
register(plugin?: PluginServiceRegistrationOptions): void;
}
declare interface PluginServiceRegistrationOptions {
beforeInit?: (chartInstance: Chart) => void,
afterInit?: (chartInstance: Chart) => void,
resize?: (chartInstance: Chart, newChartSize: Size) => void,
beforeUpdate?: (chartInstance: Chart) => void,
afterScaleUpdate?: (chartInstance: Chart) => void,
beforeDatasetsUpdate?: (chartInstance: Chart) => void,
afterDatasetsUpdate?: (chartInstance: Chart) => void,
afterUpdate?: (chartInstance: Chart) => void,
// This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw
// to do something on each animation frame
beforeRender?: (chartInstance: Chart) => void,
// Easing is for animation
beforeDraw?: (chartInstance: Chart, easing: string) => void,
afterDraw?: (chartInstance: Chart, easing: string) => void,
// Before the datasets are drawn but after scales are drawn
beforeDatasetsDraw?: (chartInstance: Chart, easing: string) => void,
afterDatasetsDraw?: (chartInstance: Chart, easing: string) => void,
destroy?: (chartInstance: Chart) => void,
// Called when an event occurs on the chart
beforeEvent?: (chartInstance: Chart, event: Event) => void,
afterEvent?: (chartInstance: Chart, event: Event) => void
}
declare interface Size {
height: number;
width: number;
}
declare namespace Chart {
export type ChartType = 'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble';
+7 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for chokidar 1.6.1
// Type definitions for chokidar 1.7.0
// Project: https://github.com/paulmillr/chokidar
// Definitions by: Stefan Steinhart <https://github.com/reppners/>, Felix Becker <https://github.com/felixfbecker/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -79,6 +79,12 @@ export interface WatchOptions {
* be relative to this.
*/
cwd?: string;
/**
* If set to true then the strings passed to .watch() and .add() are treated as literal path
* names, even if they look like globs. Default: false.
*/
disableGlobbing?: boolean;
/**
* Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
+11 -15
View File
@@ -1,13 +1,9 @@
import * as myChroma from "chroma-js";
function test_chroma() {
chroma('hotpink');
chroma('#ff3399');
chroma('F39');
chroma.hex("#fff");
chroma(0xff3399);
chroma(0xff, 0x33, 0x99);
chroma(255, 51, 153);
@@ -37,15 +33,15 @@ function test_chroma() {
chroma.contrast('pink', 'hotpink');
chroma.contrast('pink', 'purple');
chroma.brewer.OrRd;
var data = [3.0, 3.5, 3.6, 3.8, 3.8, 4.1, 4.3, 4.4,
const data = [3.0, 3.5, 3.6, 3.8, 3.8, 4.1, 4.3, 4.4,
4.6, 4.9, 5.2, 5.3, 5.4, 5.7, 5.8, 5.9,
6.2, 6.5, 6.8, 7.2, 9];
chroma.limits(data, 'e', 5);
chroma.limits(data, 'q', 5);
chroma.limits(data, 'k', 5);
myChroma(0xff3399);
myChroma.limits(data, 'k', 5);
chroma(0xff3399);
chroma.limits(data, 'k', 5);
}
function test_color() {
@@ -105,13 +101,13 @@ function test_color() {
chroma('#b3ccff').temperature();
chroma('33cc00').gl();
myChroma('teal').alpha(0.5).css();
myChroma('teal').css('hsl');
myChroma('orange').rgb();
chroma('teal').alpha(0.5).css();
chroma('teal').css('hsl');
chroma('orange').rgb();
}
function test_scale() {
var f = chroma.scale();
const f = chroma.scale();
f(0.25);
f(0.5);
f(0.75);
@@ -173,7 +169,7 @@ function test_scale() {
chroma.scale('OrRd').classes(5);
chroma.scale('OrRd').classes(8);
myChroma.cubehelix()
chroma.cubehelix()
.start(200)
.rotations(-0.35)
.gamma(0.7)
@@ -183,6 +179,6 @@ function test_scale() {
.correctLightness()
.colors(5);
myChroma.scale('RdYlBu');
myChroma.scale('RdYlBu').padding(0.15);
chroma.scale('RdYlBu');
chroma.scale('RdYlBu').padding(0.15);
}
+193 -103
View File
@@ -1,29 +1,35 @@
// Type definitions for Chroma.js v1.1.1
// Type definitions for Chroma.js 1.3
// Project: https://github.com/gka/chroma.js
// Definitions by: Sebastian Brückner <https://github.com/invliD>, Marcin Pacholec <https://github.com/mpacholec>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/**
* Chroma.js is a tiny library for all kinds of color conversions and color scales.
*/
declare namespace Chroma {
export interface ChromaStatic {
interface ColorSpaces {
rgb: [number, number, number];
rgba: [number, number, number, number];
hsl: [number, number, number];
hsv: [number, number, number];
hsi: [number, number, number];
lab: [number, number, number];
lch: [number, number, number];
hcl: [number, number, number];
cmyk: [number, number, number, number];
gl: [number, number, number, number];
}
interface ChromaStatic {
/**
* Creates a color from a string representation (as supported in CSS).
* Creates a color from a number representation [0; 16777215]
*
* @param color The string to convert to a color.
* @return the color object.
*/
(color: string): Color;
/**
* Creates a color from a number representation [0; 16777215]
*
* @param color The number to convert to a color.
* @return the color object.
*/
(number: number): Color;
(color: string | number): Color;
/**
* Create a color in the specified color space using a, b and c as values.
@@ -31,21 +37,21 @@ declare namespace Chroma {
* @param a
* @param b
* @param c
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
* @param colorSpace The color space to use. Defaults to "rgb".
* @return the color object.
*/
(a: number, b: number, c: number, colorSpace?: string): Color;
*/
(a: number, b: number, c: number, colorSpace?: keyof ColorSpaces): Color;
(a: number, b: number, c: number, d: number, colorSpace?: string): Color;
(a: number, b: number, c: number, d: number, colorSpace?: keyof ColorSpaces): Color;
/**
* Create a color in the specified color space using values.
*
* @param values An array of values (e.g. [r, g, b, a?]).
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
* @return the color object.
*/
(values: number[], colorSpace?: string): Color;
* Create a color in the specified color space using values.
*
* @param values An array of values (e.g. [r, g, b, a?]).
* @param colorSpace The color space to use. Defaults to "rgb".
* @return the color object.
*/
(values: number[], colorSpace?: keyof ColorSpaces): Color;
/**
* Create a color from a hex or string representation (as supported in CSS).
@@ -67,25 +73,43 @@ declare namespace Chroma {
rgb(r: number, g: number, b: number): Color;
/**
/**
* GL is a variant of RGB(A), with the only difference that the components are normalized to the range of 0..1.
*/
*/
gl(red: number, green: number, blue: number, alpha?: number): Color;
/**
* light 2000K, bright sunlight 6000K. Based on Neil Bartlett's implementation.
/**
* Returns a color from the color temperature scale.
* light 2000K, bright sunlight 6000K.
* Based on Neil Bartlett's implementation.
* https://github.com/neilbartlett/color-temperature
*/
*/
temperature(t: number): Color;
mix(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color;
interpolate(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color;
/**
* Mixes two colors. The mix ratio is a value between 0 and 1.
* The color mixing produces different results based the color space used for interpolation.
* @example chroma.mix('red', 'blue', 0.25) // => #bf0040
* @example chroma.mix('red', 'blue', 0.5, 'hsl') // => #ff00ff
*/
mix(color1: string | Color, color2: string | Color, f?: number, colorSpace?: keyof ColorSpaces): Color;
/**
* Blends two colors using RGB channel-wise blend functions. Valid blend modes are multiply, darken, lighten, screen, overlay, burn, and dogde.
* Alias for {@see mix}.
*/
blend(col1: string, col2: string, blendMode: string): Color;
interpolate(color1: string | Color, color2: string | Color, f?: number, colorSpace?: keyof ColorSpaces): Color;
/**
* Similar to {@link mix}, but accepts more than two colors. Simple averaging of R,G,B components and the alpha
* channel.
*/
average(colors: Array<string | Color>, colorSpace?: keyof ColorSpaces): Color;
/**
* Blends two colors using RGB channel-wise blend functions.
*/
blend(color1: string | Color, color2: string | Color,
blendMode: 'multiply' | 'darken' | 'lighten' | 'screen' | 'overlay' | 'burn' | 'dogde'): Color;
/**
* Returns a random color.
@@ -93,19 +117,29 @@ declare namespace Chroma {
random(): Color;
/**
* Computes the WCAG contrast ratio between two colors.
* A minimum contrast of 4.5:1 is recommended to ensure that text is still readable against a background color.
*
* @param color1 The first color.
* @param color2 The second color.
* @return the contrast ratio.
* Computes the WCAG contrast ratio between two colors.
* A minimum contrast of 4.5:1 is recommended {@link https://www.w3.org/TR/WCAG20-TECHS/G18.html}
* to ensure that text is still readable against a background color.
*/
contrast(col1: string | Color, col2: string | Color): number;
bezier(colors: string[]): Scale;
contrast(color1: string | Color, color2: string | Color): number;
/**
* chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience.
* Computes the eucledian distance between two colors in a given color space (default is 'lab').
* {@link https://en.wikipedia.org/wiki/Euclidean_distance#Three_dimensions}
*/
distance(color1: string | Color, color2: string | Color, colorSpace?: keyof ColorSpaces): Color;
/**
* Computes color difference {@link https://en.wikipedia.org/wiki/Color_difference#CMC_l:c_.281984.29} as
* developed by the Colour Measurement Committee of the Society of Dyers and Colourists (CMC) in 1984.
* The implementation is adapted from Bruce Lindbloom.
* {@link https://web.archive.org/web/20160306044036/http://www.brucelindbloom.com/javascript/ColorDiff.js}
* The parameters L (default 1) and C (default 1) are weighting factors for lightness and chromacity.
*/
deltaE(color1: string | Color, color2: string | Color, L?: number, C?: number): Color;
/**
* chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience.
* chroma.scale uses the colors to construct.
*/
brewer: {
@@ -147,123 +181,179 @@ declare namespace Chroma {
};
/**
* Helper function that computes class breaks for you, based on actual data.
* Supports three different modes: equidistant breaks, quantiles breaks and breaks based on k-means clusting.
* Helper function that computes class breaks based on data.
* Mode:
* <li>equidistant <code>'e'</code> breaks are computed by dividing the total range of the data into n groups
* of equal size.
* <li>quantile <code>'q'</code> input domain is divided by quantile ranges.
* <li>logarithmic <code>'l'</code> breaks are equidistant breaks but on a logarithmic scale.
* <li>k-means <code>'k'</code> breaks use the 1-dimensional
* [k-means clustering algorithm]{@link https://en.wikipedia.org/wiki/K-means_clustering} to find (roughly) n
* groups of "similar" values. Note that this k-means implementation does not guarantee to find exactly n groups.
*/
limits(data: number[], mode: string, c: number): number[];
limits(data: number[], mode: 'e' | 'q' | 'l' | 'k', c: number): number[];
scale(name: string): Scale;
/**
* Returns a function that
* [bezier-interpolates]{@link https://www.vis4.net/blog/posts/mastering-multi-hued-color-scales/} between
* colors in Lab space. The input range of the function is [0..1].
* You can convert it to a scale instance by calling <code>chroma.bezier(...).scale()</code>
*/
bezier(colors: string[]): { (t: number): Color, scale(): Scale};
scale(colors?: string[]): Scale;
scale(name: string | Color): Scale;
scale(colors?: Array<string | Color>): Scale;
cubehelix(): Cubehelix;
cmyk(c: number, m: number, y: number, k: number): Color;
/**
* Create a color from a hex or string representation (as supported in CSS).
*
* This is an alias of chroma.hex().
*
* @param color The string to convert to a color.
* @return the color object.
*/
css(col: string, mode?: string): string;
css(col: string): Color;
}
export interface Color {
type Color = {
/**
* Get and set the color opacity.
*/
alpha(a?: number): Color;
darken(f?: number): Color;
brighten(f?: number): Color;
/**
* Changes the saturation of a color by manipulating the Lch chromacity.
*/
saturate(s?: number): Color;
/**
* Similar to saturate, but the opposite direction.
*/
desaturate(s?: number): Color;
/**
* Changes a single channel and returns the result a new chroma object.
* @example
* // half Lab lightness
* chroma('orangered').set('lab.l', '*0.5')
* @example
* // double Lch saturation
* chroma('darkseagreen').set('lch.c', '*2')
*/
set(modechan: string, v: number | string): Color;
/**
* Returns a single channel value.
* @see set
*/
get(modechan: string): number;
/**
* Relative brightness, according to the
* [WCAG]{@link http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef} definition. Normalized to
* 0 for darkest black and 1 for lightest white.
*/
luminance(): number;
luminance(l: number, mode?: string): Color;
/**
* Set luminance of color. The source color will be interpolated with black or white until the correct luminance is found.
* The color space used defaults to RGB.
*/
luminance(l: number, colorSpace?: keyof ColorSpaces): Color;
/**
* Get color as hexadecimal string. E.g. '#ffa500'
*/
hex(): string;
/**
* Returns the named color. Falls back to hexadecimal RGB string, if the color isn't present.
*/
name(): string;
/**
* Create a color from a hex or string representation (as supported in CSS).
*
* This is an alias of chroma.hex().
*
* @param color The string to convert to a color.
* @return the color object.
* Returns a RGB() or HSL() string representation that can be used as CSS-color definition.
* mode defaults to <code>'rgb'</code>
*/
css(mode?: string): string;
rgb(): number[];
rgba(): number[];
hsl(): number[];
hsv(): number[];
hsi(): number[];
lab(): number[];
lch(): number[];
hcl(): number[];
css(mode?: 'hsl'): string;
/**
* Estimate the temperature in Kelvin of any given color, though this makes the only sense for colors from the
* [temperature gradient]{@link ChromaStatic.temperature} above.
*/
temperature(): number;
} & {
[K in keyof ColorSpaces]: () => ColorSpaces[K];
};
gl(): number[];
}
export interface Scale {
interface Scale<OutType = Color> {
(c: string[]): Scale;
(value: number): any;
(value: number): OutType;
domain(d?: number[], n?: number, mode?: string): Scale;
domain(d?: number[], n?: number, mode?: string): this;
mode(mode: string): Scale;
mode(mode: keyof ColorSpaces): this;
correctLightness(enable?: boolean): Scale;
cache(use: boolean): boolean;
bezier(colors: string[]): Scale;
correctLightness(enable?: boolean): this;
padding(p: number | number[]): Scale;
padding(p: number | number[]): this;
colors(c?: number): string[];
/**
* You can call scale.colors(n) to quickly grab `c` equi-distant colors from a color scale. If called with no
* arguments, scale.colors returns the original array of colors used to create the scale.
*/
colors(c?: number, format?: 'hex' | 'name'): string[];
colors(c?: number, format?: null | 'alpha' | 'darken' | 'brighten' | 'saturate' | 'desaturate'): Color[];
colors(c?: number, format?: 'luminance' | 'temperature'): number[];
colors<K extends keyof ColorSpaces>(c?: number, format?: K): Array<ColorSpaces[K]>;
classes(c: number | number[]): (t: number) => Color;
/**
* If you want the scale function to return a distinct set of colors instead of a continuous gradient, you can
* use scale.classes. If you pass a number the scale will broken into equi-distant classes.
* You can also define custom class breaks by passing them as array
*/
classes(c: number | number[]): this;
range(arg: string[]): Scale;
scale(): Scale;
out(mode: string): Scale;
/**
* Set out format for scale() call. Passing null will result in a scale which outputs colors.
*/
out(format: null): Scale;
out<K extends keyof ColorSpaces>(format: K): Scale<ColorSpaces[K]>;
}
export interface Cubehelix extends Scale {
interface Cubehelix {
/**
* Set start color for hue rotation, default=300
*/
start(s: number): Cubehelix;
/**
* number (and direction) of hue rotations (e.g. 1=360°, 1.5=`540°``), default=-1.5
*/
rotations(r: number): Cubehelix;
/**
* gamma factor can be used to emphasise low or high intensity values, default=1
*/
gamma(g: number): Cubehelix;
/**
* lightness range: default: [0,1] (black -> white)
*/
lightness(l: number[]): Cubehelix;
/**
* You can call cubehelix.scale() to use the cube-helix through the chroma.scale interface.
*/
scale(): Scale;
}
}
declare var chroma: Chroma.ChromaStatic;
declare module "chroma-js" {
export = chroma;
}
export = chroma;
export as namespace chroma;
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -77,7 +77,7 @@ declare namespace CKEDITOR {
function addCss(css: string): void;
function addTemplate(name: string, source: string): template;
function appendTo(element: string, config?: config, data?: string): editor;
function appendTo(element: HTMLTextAreaElement, config?: config, data?: string): editor;
function appendTo(element: HTMLElement, config?: config, data?: string): editor;
function domReady(): void;
function dialogCommand(dialogName: string): void;
function editorConfig(config: config): void;
+232
View File
@@ -0,0 +1,232 @@
import * as Table from "cli-table2";
// Code snippets from README.md
// Horizontal table
const table1 = new Table({ head: ['TH 1 label', 'TH 2 label'], colWidths: [100, 200] }) as Table.HorizontalTable;
table1.push(
['First value', 'Second value'],
['First value', 'Second value']
);
// Vertical table
const table2 = new Table() as Table.VerticalTable;
table2.push(
{ 'Some key': 'Some value' },
{ 'Another key': 'Another value' }
);
// Cross table
const table3 = new Table({ head: ["", "Top Header 1", "Top Header 2"] }) as Table.CrossTable;
table3.push(
{ 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] },
{ 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] }
);
// Custom styles
const table4 = new Table({
chars: {
top: '═', 'top-mid': '╤', 'top-left': '╔', 'top-right': '╗',
bottom: '═', 'bottom-mid': '╧', 'bottom-left': '╚', 'bottom-right': '╝',
left: '║', 'left-mid': '╟', mid: '─', 'mid-mid': '┼',
right: '║', 'right-mid': '╢', middle: '│'
}
}) as Table.HorizontalTable;
table4.push(
['foo', 'bar', 'baz'],
['frob', 'bar', 'quuz']
);
const table5 = new Table({ chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' } }) as Table.HorizontalTable;
table5.push(
['foo', 'bar', 'baz'],
['frobnicate', 'bar', 'quuz']
);
const table6 = new Table({
chars: {
top: '', 'top-mid': '', 'top-left': '', 'top-right': '',
bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '',
left: '', 'left-mid': '', mid: '', 'mid-mid': '',
right: '', 'right-mid': '', middle: ' '
},
style: { 'padding-left': 0, 'padding-right': 0 }
}) as Table.HorizontalTable;
table6.push(
['foo', 'bar', 'baz'],
['frobnicate', 'bar', 'quuz']
);
// Code snippets from basic-usage.md
// Basic Usage
const table7 = new Table({ head: ['a', 'b'] }) as Table.HorizontalTable;
table7.push(['c', 'd']);
// Basic Usage - disable colors - (used often in the examples and tests)
const table8 = new Table({
head: ['Rel', 'Change', 'By', 'When'],
style: { head: [], border: [] },
colWidths: [6, 21, 25, 17]
}) as Table.HorizontalTable;
table8.push(
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'],
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
);
// Create vertical tables by adding objects a that specify key-value pairs
const table9 = new Table({ style: { 'padding-left': 0, 'padding-right': 0, head: [], border: [] } }) as Table.VerticalTable;
table9.push(
{ 'v0.1': 'Testing something cool' },
{ 'v0.1': 'Testing something cool' }
);
// Cross tables are similar to vertical tables, but include an empty string for the first header
const table10 = new Table({
head: ["", "Header 1", "Header 2"],
style: { 'padding-left': 0, 'padding-right': 0, head: [], border: [] }
}) as Table.CrossTable;
table10.push(
{ "Header 3": ['v0.1', 'Testing something cool'] },
{ "Header 4": ['v0.1', 'Testing something cool'] }
);
// Stylize the table with custom border characters
const table11 = new Table({
chars: {
top: '═',
'top-mid': '╤',
'top-left': '╔',
'top-right': '╗',
bottom: '═',
'bottom-mid': '╧',
'bottom-left': '╚',
'bottom-right': '╝',
left: '║',
'left-mid': '╟',
right: '║',
'right-mid': '╢'
},
style: { head: [], border: [] }
}) as Table.HorizontalTable;
table11.push(
['foo', 'bar', 'baz'],
['frob', 'bar', 'quuz']
);
// Use ansi colors (i.e. colors.js) to style text within the cells at will, even across multiple lines
const table12 = new Table({ style: { border: [], head: [] } }) as Table.HorizontalTable;
table12.push([
/*colors.red(*/'Hello\nhow\nare\nyou?'/*)*/,
/*colors.blue(*/'I\nam\nfine\nthanks!'/*)*/
]);
// Set wordWrap to true to make lines of text wrap instead of being truncated
const table13 = new Table({
style: { border: [], head: [] },
colWidths: [7, 9],
wordWrap: true
}) as Table.HorizontalTable;
table13.push([
'Hello how are you?',
'I am fine thanks!'
]);
// Code snippets from advanced-usage.md
// use colSpan to span columns - (colSpan above normal cell)
const table14 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table14.push(
[{ colSpan: 2, content: 'greetings' }],
[{ colSpan: 2, content: 'greetings' }],
['hello', 'howdy']
);
// use colSpan to span columns - (colSpan below normal cell)
const table15 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table15.push(
['hello', 'howdy'],
[{ colSpan: 2, content: 'greetings' }],
[{ colSpan: 2, content: 'greetings' }]
);
// use rowSpan to span rows - (rowSpan on the left side)
const table16 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table16.push(
[{ rowSpan: 2, content: 'greetings' }, { rowSpan: 2, content: 'greetings', vAlign: 'center' }, 'hello'],
['howdy']
);
// use rowSpan to span rows - (rowSpan on the right side)
const table17 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table17.push(
['hello', { rowSpan: 2, content: 'greetings' }, { rowSpan: 2, content: 'greetings', vAlign: 'bottom' }],
['howdy']
);
// mix rowSpan and colSpan together for complex table layouts
const table18 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table18.push(
[{ content: 'hello', colSpan: 2 }, { rowSpan: 2, colSpan: 2, content: 'sup' }, { rowSpan: 3, content: 'hi' }],
[{ content: 'howdy', colSpan: 2 }],
['o', 'k', '', '']
);
// multi-line content will flow across rows in rowSpan cells
const table19 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table19.push(
['hello', { rowSpan: 2, content: 'greetings\nfriends' }, { rowSpan: 2, content: 'greetings\nfriends' }],
['howdy']
);
// multi-line content will flow across rows in rowSpan cells - (complex layout)
const table20 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table20.push(
[{ content: 'hello', colSpan: 2 }, { rowSpan: 2, colSpan: 2, content: 'sup\nman\nhey' }, { rowSpan: 3, content: 'hi\nyo' }],
[{ content: 'howdy', colSpan: 2 }],
['o', 'k', '', '']
);
// rowSpan cells can have a staggered layout
const table21 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table21.push(
[{ content: 'a', rowSpan: 2 }, 'b'],
[{ content: 'c', rowSpan: 2 }],
['d']
);
// the layout manager automatically create empty cells to fill in the table
const table22 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table22.push(
[{ content: 'a', rowSpan: 3, colSpan: 2 }, 'b'],
[],
[{ content: 'c', rowSpan: 2, colSpan: 2 }],
[]
);
// use table rowHeights option to fix row height. The truncation symbol will be shown on the last line.
const table23 = new Table({ rowHeights: [2], style: { head: [], border: [] } }) as Table.HorizontalTable;
table23.push(['hello\nhi\nsup']);
// if colWidths is not specified, the layout manager will automatically widen rows to fit the content
const table24 = new Table({ style: { head: [], border: [] } }) as Table.HorizontalTable;
table24.push(
[{ colSpan: 2, content: 'hello there' }],
['hi', 'hi']
);
// you can specify a column width for only the first row, other rows will be automatically widened to fit content
const table25 = new Table({ colWidths: [4], style: { head: [], border: [] } }) as Table.HorizontalTable;
table25.push(
[{ colSpan: 2, content: 'hello there' }],
['hi', { hAlign: 'center', content: 'hi' }]
);
// a column with a null column width will be automatically widened to fit content
const table26 = new Table({ colWidths: [null, 4], style: { head: [], border: [] } }) as Table.HorizontalTable;
table26.push(
[{ colSpan: 2, content: 'hello there' }],
[{ hAlign: 'right', content: 'hi' }, 'hi']
);
// feel free to use colors in your content strings, column widths will be calculated correctly
const table27 = new Table({ colWidths: [5], style: { head: [], border: [] } }) as Table.HorizontalTable;
table27.push([/*colors.red(*/'hello'/*)*/]);
+101
View File
@@ -0,0 +1,101 @@
// Type definitions for cli-table2 0.2
// Project: https://github.com/jamestalmage/cli-table2
// Definitions by: Melvin Groenhoff <https://github.com/mgroenhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace CliTable2 {
type CharName =
"top" |
"top-mid" |
"top-left" |
"top-right" |
"bottom" |
"bottom-mid" |
"bottom-left" |
"bottom-right" |
"left" |
"left-mid" |
"mid" |
"mid-mid" |
"right" |
"right-mid" |
"middle";
type HorizontalAlignment = "left" | "center" | "right";
type VerticalAlignment = "top" | "center" | "bottom";
interface TableOptions {
truncate: string;
colWidths: Array<number | null>;
rowHeights: Array<number | null>;
colAligns: HorizontalAlignment[];
rowAligns: VerticalAlignment[];
head: string[];
wordWrap: boolean;
}
interface TableInstanceOptions extends TableOptions {
chars: Record<CharName, string>;
style: {
"padding-left": number;
"padding-right": number;
head: string[];
border: string[];
compact: boolean;
};
}
interface TableConstructorOptions extends Partial<TableOptions> {
chars?: Partial<Record<CharName, string>>;
style?: Partial<TableInstanceOptions["style"]>;
}
type CellValue = boolean | number | string | null | undefined;
interface CellOptions {
content: CellValue;
chars?: Partial<Record<CharName, string>>;
truncate?: string;
colSpan?: number;
rowSpan?: number;
hAlign?: HorizontalAlignment;
vAlign?: VerticalAlignment;
style?: {
"padding-left"?: number;
"padding-right"?: number;
head?: string[];
border?: string[];
};
}
interface GenericTable<T> extends Array<T> {
options: CliTable2.TableInstanceOptions;
readonly width: number;
}
type Table = HorizontalTable | VerticalTable | CrossTable;
type Cell = CellValue | CellOptions;
type HorizontalTable = GenericTable<HorizontalTableRow>;
type HorizontalTableRow = Cell[];
type VerticalTable = GenericTable<VerticalTableRow>;
interface VerticalTableRow {
[name: string]: Cell;
}
type CrossTable = GenericTable<CrossTableRow>;
interface CrossTableRow {
[name: string]: Cell[];
}
}
interface CliTable2 {
new (options?: CliTable2.TableConstructorOptions): CliTable2.Table;
readonly prototype: CliTable2.Table;
}
declare const CliTable2: CliTable2;
export = CliTable2;
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -17,6 +17,6 @@
},
"files": [
"index.d.ts",
"big-integer-tests.ts"
"cli-table2-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1
View File
@@ -16,6 +16,7 @@ const cb5 = new Clipboard('.btn', {
});
cb1.destroy();
cb1.isSupported();
cb2.on('success', e => {
console.info('Action:', e.action);
+5
View File
@@ -18,6 +18,11 @@ declare class Clipboard {
* Clears all event bindings.
*/
destroy(): void;
/**
* Checks if clipboard.js is supported
*/
isSupported(): boolean;
}
declare namespace Clipboard {
+9
View File
@@ -0,0 +1,9 @@
import * as cloudEnv from 'cloud-env';
if (cloudEnv.get('IP', '0.0.0.0') !== '0.0.0.0') {
throw new Error(`cloudEnv.get: expected value 0.0.0.0, but actually received value ${cloudEnv.get('IP', '0.0.0.0')}`);
}
if (!(cloudEnv.defaults instanceof Object)) {
throw new Error(`cloudEnv.defaults: expected value of defaults be an instance of Object, but it was actually an instance of another class: ${typeof cloudEnv.defaults}`);
}
+51
View File
@@ -0,0 +1,51 @@
// Type definitions for cloud-env 0.2.2
// Project: https://github.com/ryanj/cloud-env
// Definitions by: Ben Davies <https://github.com/Morfent>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare interface DefaultSettings {
PORT?: number;
IP?: string;
HOSTNAME?: string;
APP_NAME?: string;
MONGODB_DB_URL?: string;
MONGODB_DB_HOST?: string;
MONGODB_DB_PORT?: number;
MONGODB_DB_USERNAME?: string;
MONGODB_DB_PASSWORD?: string;
POSTGRESQL_DB_URL?: string;
POSTGRESQL_DB_HOST?: string;
POSTGRESQL_DB_PORT?: number;
POSTGRESQL_DB_USERNAME?: string;
POSTGRESQL_DB_PASSWORD?: string;
MYSQL_DB_URL?: string;
MYSQL_DB_HOST?: string;
MYSQL_DB_PORT?: number;
MYSQL_DB_USERNAME?: string;
MYSQL_DB_PASSWORD?: string;
}
declare type MaybeNum = number | void;
declare type MaybeStr = string | void;
export const get: (key: string, default_key?: string) => MaybeStr;
export const defaults: { [key: string]: DefaultSettings; };
export const PORT: MaybeNum;
export const IP: MaybeStr;
export const HOSTNAME: MaybeStr;
export const APP_NAME: MaybeStr;
export const MONGODB_DB_URL: MaybeStr;
export const MONGODB_DB_HOST: MaybeStr;
export const MONGODB_DB_PORT: MaybeNum;
export const MONGODB_DB_USERNAME: MaybeStr;
export const MONGODB_DB_PASSWORD: MaybeStr;
export const POSTGRESQL_DB_URL: MaybeStr;
export const POSTGRESQL_DB_HOST: MaybeStr;
export const POSTGRESQL_DB_PORT: MaybeNum;
export const POSTGRESQL_DB_USERNAME: MaybeStr;
export const POSTGRESQL_DB_PASSWORD: MaybeStr;
export const MYSQL_DB_URL: MaybeStr;
export const MYSQL_DB_HOST: MaybeStr;
export const MYSQL_DB_PORT: MaybeNum;
export const MYSQL_DB_USERNAME: MaybeStr;
export const MYSQL_DB_PASSWORD: MaybeStr;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cloud-env-tests.ts"
]
}
@@ -0,0 +1,12 @@
import combine = require("combine-source-map");
const sourcemap = combine.create();
sourcemap.addFile({ sourceFile: "file.js", source: "return 123" })
.addFile({ sourceFile: "source.js", source: "return 'abc'" });
const res: string = sourcemap.base64();
const res2 = sourcemap.comment();
combine.removeComments("(123 | 'abc') // #sourceMappingURL=file.js.map");
+59
View File
@@ -0,0 +1,59 @@
// Type definitions for combine-source-map 0.8
// Project: https://github.com/thlorenz/combine-source-map
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** Add source maps of multiple files, offset them and then combine them into one source map.
* (documentation based on project's README file)
*/
declare class Combiner {
constructor(file?: string, sourceRoot?: string);
/** Adds map to underlying source map.
* If source contains a source map comment that has the source of the original file inlined it will offset these
* mappings and include them.
* If no source map comment is found or it has no source inlined, mappings for the file will be generated and included
* @param opts the 'sourceFile' path/name and the file's 'source' contents
* @param offset the source file 'line' number and 'column' number offsets
*/
addFile(opts: { sourceFile: string; source: string }, offset?: Combiner.Offset): Combiner;
/** output the combined source map in base64 format
* @return base64 encoded combined source map
*/
base64(): string;
/** generate a base64 encoded sourceMappingURL comment
* @return base64 encoded sourceMappingUrl comment of the combined source map
*/
comment(): string;
_addGeneratedMap(sourceFile: string, source: string, offset?: Combiner.Offset): Combiner;
_addExistingMap(sourceFile: string, source: string, existingMap: any, offset?: Combiner.Offset): Combiner;
}
declare namespace Combiner {
/** An offset line and column number */
interface Offset {
line?: number;
column?: number;
}
/** Create a source map combiner that accepts multiple files, offsets them and then combines them into one source map.
* @param file optional name of the generated file
* @param sourceRoot optional sourceRoot of the map to be generated
* @return Combiner instance to which source maps can be added and later combined
*/
function create(file?: string, sourceRoot?: string): Combiner;
/** removeComments
* @param src
* @return src with all sourceMappingUrl comments removed
*/
function removeComments(src: string): string;
}
export = Combiner;
export as namespace Combiner;

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